From 14f259ad21be07b72e72ab1ebfaf4a052052cd1c Mon Sep 17 00:00:00 2001 From: Sam Abbott Date: Fri, 4 Oct 2024 19:01:07 +0100 Subject: [PATCH] Issue 109: Add explicit dist and primary arg usage to getting started (#122) * add explicit dist and primary arg usage to getting started * Update primarycensoreddist.Rmd --- NEWS.md | 1 + vignettes/primarycensoreddist.Rmd | 26 ++++++++++++++------------ 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/NEWS.md b/NEWS.md index d1bbfbb..0c93319 100644 --- a/NEWS.md +++ b/NEWS.md @@ -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 diff --git a/vignettes/primarycensoreddist.Rmd b/vignettes/primarycensoreddist.Rmd index bced166..a2ca97a 100644 --- a/vignettes/primarycensoreddist.Rmd +++ b/vignettes/primarycensoreddist.Rmd @@ -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( @@ -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 @@ -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(