Skip to content

Commit

Permalink
Issue 109: Add explicit dist and primary arg usage to getting started (
Browse files Browse the repository at this point in the history
…#122)

* add explicit dist and primary arg usage to getting started

* Update primarycensoreddist.Rmd
  • Loading branch information
seabbs authored Oct 4, 2024
1 parent 5ac1c87 commit 14f259a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ This is the development version of `primarycensoreddist` and is not yet ready fo

* Simplified the "Analytic solutions" vignette by removing verbose derivation details.
* Added links between vignettes to make it easier to navigate the documentation.
* Added explicit usage of `pdist`, `dprimary`, `rdist`, and `rprimary` arguments in the getting started vignette to make it easier to link to mathematical details.

# primarycensoreddist 0.5.0

Expand Down
26 changes: 14 additions & 12 deletions vignettes/primarycensoreddist.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,17 @@ pwindow <- 1
# Random samples without secondary censoring
samples <- rprimarycensoreddist(
n, rlnorm,
meanlog = meanlog, sdlog = sdlog,
pwindow = pwindow, swindow = 0, D = obs_time
n,
rdist = rlnorm, rprimary = runif,
pwindow = pwindow, swindow = 0, D = obs_time,
meanlog = meanlog, sdlog = sdlog
)
# Random samples with secondary censoring
samples_sc <- rprimarycensoreddist(
n, rlnorm,
meanlog = meanlog, sdlog = sdlog,
pwindow = pwindow, swindow = 1, D = obs_time
n,
rdist = rlnorm, rprimary = runif,
pwindow = pwindow, swindow = 1, D = obs_time,
meanlog = meanlog, sdlog = sdlog
)
# Calculate the PMF for the samples with secondary censoring
samples_sc_pmf <- data.frame(
Expand Down Expand Up @@ -172,9 +174,9 @@ Let's compare the empirical CDF of our samples without secondary censoring to th
empirical_cdf <- ecdf(samples)
theoretical_cdf <- pprimarycensoreddist(
seq(0, obs_time, length.out = 100),
plnorm,
meanlog = meanlog, sdlog = sdlog,
pwindow = pwindow, D = obs_time
pdist = plnorm, dprimary = dunif,
pwindow = pwindow, D = obs_time,
meanlog = meanlog, sdlog = sdlog
)
# Create a data frame for plotting
Expand Down Expand Up @@ -226,9 +228,9 @@ Let's compare the empirical PMF of our samples with secondary censoring to the t
# Calculate the theoretical PMF using dprimarycensoreddist
theoretical_pmf <- dprimarycensoreddist(
0:(obs_time - 1),
plnorm,
meanlog = meanlog, sdlog = sdlog,
pwindow = pwindow, swindow = 1, D = obs_time
pdist = plnorm, dprimary = dunif,
pwindow = pwindow, swindow = 1, D = obs_time,
meanlog = meanlog, sdlog = sdlog
)
pmf_df <- data.frame(
Expand Down

0 comments on commit 14f259a

Please sign in to comment.