From 1c8a9cdf413d71fe760f3259038fdabc93032cc1 Mon Sep 17 00:00:00 2001 From: Joshua Lambert Date: Wed, 19 Feb 2025 13:52:39 +0000 Subject: [PATCH] right truncation (noun), right-truncation (adjective) --- R/truncate_linelist.R | 10 +++++----- man/truncate_linelist.Rd | 10 +++++----- vignettes/reporting-delays-truncation.Rmd | 8 ++++---- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/R/truncate_linelist.R b/R/truncate_linelist.R index 2e03026..5559845 100644 --- a/R/truncate_linelist.R +++ b/R/truncate_linelist.R @@ -1,4 +1,4 @@ -#' Adjust or subset a line list to account for right-truncation +#' Adjust or subset a line list to account for right truncation #' #' @description #' Adjust or subset the line list `` by either changing dates that @@ -33,8 +33,8 @@ #' calculated as the date at the end of the outbreak (i.e. date of the last #' outcome). #' @param truncation_event A `character` string with which event in the line -#' list the right-truncation should apply to. The default is `"reporting"` for -#' the reporting delay, which is likely the most common form of right-truncation +#' list the right truncation should apply to. The default is `"reporting"` for +#' the reporting delay, which is likely the most common form of right truncation #' in real-time outbreak data. When `truncation_event = "reporting"` if a date #' of reporting (`$date_reporting`) is more recent than the sampled truncation #' time then the individual (row) is removed from the line list. If the date of @@ -69,13 +69,13 @@ #' truncation_event = "admission" #' ) #' -#' # variable right-truncation with mean 2 and sd 1 (default behaviour) +#' # variable right truncation with mean 2 and sd 1 (default behaviour) #' linelist_trunc <- truncate_linelist( #' linelist, #' delay = function(x) rlnorm(n = x, meanlog = 0.58, sdlog = 0.47) #' ) #' -#' # fixed right-truncation of 5 days +#' # fixed right truncation of 5 days #' linelist_trunc <- truncate_linelist( #' linelist, #' delay = function(x) rep(5, n = x) diff --git a/man/truncate_linelist.Rd b/man/truncate_linelist.Rd index 9b059af..1594acd 100644 --- a/man/truncate_linelist.Rd +++ b/man/truncate_linelist.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/truncate_linelist.R \name{truncate_linelist} \alias{truncate_linelist} -\title{Adjust or subset a line list to account for right-truncation} +\title{Adjust or subset a line list to account for right truncation} \usage{ truncate_linelist( linelist, @@ -31,8 +31,8 @@ calculated as the date at the end of the outbreak (i.e. date of the last outcome).} \item{truncation_event}{A \code{character} string with which event in the line -list the right-truncation should apply to. The default is \code{"reporting"} for -the reporting delay, which is likely the most common form of right-truncation +list the right truncation should apply to. The default is \code{"reporting"} for +the reporting delay, which is likely the most common form of right truncation in real-time outbreak data. When \code{truncation_event = "reporting"} if a date of reporting (\verb{$date_reporting}) is more recent than the sampled truncation time then the individual (row) is removed from the line list. If the date of @@ -84,13 +84,13 @@ linelist_trunc <- truncate_linelist( truncation_event = "admission" ) -# variable right-truncation with mean 2 and sd 1 (default behaviour) +# variable right truncation with mean 2 and sd 1 (default behaviour) linelist_trunc <- truncate_linelist( linelist, delay = function(x) rlnorm(n = x, meanlog = 0.58, sdlog = 0.47) ) -# fixed right-truncation of 5 days +# fixed right truncation of 5 days linelist_trunc <- truncate_linelist( linelist, delay = function(x) rep(5, n = x) diff --git a/vignettes/reporting-delays-truncation.Rmd b/vignettes/reporting-delays-truncation.Rmd index ee96686..7cac229 100644 --- a/vignettes/reporting-delays-truncation.Rmd +++ b/vignettes/reporting-delays-truncation.Rmd @@ -18,7 +18,7 @@ knitr::opts_chunk$set( If you are unfamiliar with the {simulist} package or the `sim_linelist()` function [Get Started vignette](simulist.html) is a great place to start. ::: -This vignette covers reporting delays in line list data, how to use {simulist} to produce line list data with a delay between symptom onset and reporting, explains right-truncation in outbreak data sets and shows how to use the `truncate_linelist()` function in {simulist} to augment a simulated line list to resemble real-time outbreak data. +This vignette covers reporting delays in line list data, how to use {simulist} to produce line list data with a delay between symptom onset and reporting, explains right truncation in outbreak data sets and shows how to use the `truncate_linelist()` function in {simulist} to augment a simulated line list to resemble real-time outbreak data. ## Reporting delays @@ -312,7 +312,7 @@ linelist_trunc <- truncate_linelist( The `delay` argument in `truncate_linelist()` is flexible to allow the use of a variety of random number generators, such as different parametric probability distributions or different distribution parameters. This enables variability in the truncation. However, it may be warranted that the truncation point is the same for all cases. This could be the case if the reporting of cases during an outbreak stopped on a given date. -To adjust the line list for right-truncation using a fixed truncation point we can use the same setup as specifying a fixed `reporting_delay` as outlined above. This will remove all events more recent than this time slice. +To adjust the line list for right truncation using a fixed truncation point we can use the same setup as specifying a fixed `reporting_delay` as outlined above. This will remove all events more recent than this time slice. ```{r, rlnorm-zero-sd} delay <- function(x) rep(6, times = x) @@ -359,7 +359,7 @@ plot(weekly_inci) By looking at the outbreak, we can pick three points to truncate: 1) early in the outbreak when the epicurve is growing (1st February 2023, epiweek 5), 2) in the middle of the outbreak (15th March 2023, epiweek 11), and 3) late in the outbreak when the number of cases is declining and the end of the outbreak is near (1st May 2023, epiweek 18). -We use the `max_date` argument in `truncate_linelist()` to specify the date we want to apply the right-truncation to, i.e. the sample truncation times are applied to `max_date` and not the day the outbreak is considered over (day of last event, the default setting). For this example we will set the right-truncation delay distribution to zero so it does not remove any cases before the `max_date`, and use the default truncation event (reporting date). +We use the `max_date` argument in `truncate_linelist()` to specify the date we want to apply the right truncation to, i.e. the sample truncation times are applied to `max_date` and not the day the outbreak is considered over (day of last event, the default setting). For this example we will set the right-truncation delay distribution to zero so it does not remove any cases before the `max_date`, and use the default truncation event (reporting date). ```{r trunc-stages, fig.width = 8, fig.height = 5, fig.show="hold", out.width="30%"} linelist_early <- truncate_linelist( @@ -449,7 +449,7 @@ plot(inci_late) + theme(plot.title = element_text(size = 25, hjust = 0.5)) ``` -Comparing the two sets of the three plots you can see how in the latter applying right-truncation gives the impression that cases are declining. +Comparing the two sets of the three plots you can see how in the latter applying right truncation gives the impression that cases are declining. These truncated line lists can be used to test methods that estimate the real-time reproduction number such as [{EpiNow2}](https://epiforecasts.io/EpiNow2/) or [{epinowcast}](https://package.epinowcast.org/).