From cc605cd4a9de22a05e6cd160dfb773443e150e83 Mon Sep 17 00:00:00 2001 From: Kasper Schou Telkamp Date: Thu, 2 Nov 2023 12:18:03 +0100 Subject: [PATCH 01/11] Added CRAN install instructions --- README.Rmd | 7 +++++++ README.md | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/README.Rmd b/README.Rmd index 51aabe7..9d05811 100644 --- a/README.Rmd +++ b/README.Rmd @@ -28,6 +28,13 @@ The Automated and Early Detection of Seasonal Epidemic Onset (`aedseo`) Package ## Installation +``` r +# Install aedseo from CRAN +install.packages("aedseo") +``` + +### Development vestion + You can install the development version of `aedseo` from [GitHub](https://github.com/) with: ``` r diff --git a/README.md b/README.md index 7e185e0..f04349a 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,13 @@ fashion. ## Installation +``` r +# Install aedseo from CRAN +install.packages("aedseo") +``` + +### Development vestion + You can install the development version of `aedseo` from [GitHub](https://github.com/) with: From 41ad5995bca94f6c21bc90a7eda59b5816206ef2 Mon Sep 17 00:00:00 2001 From: Kasper Schou Telkamp Date: Thu, 2 Nov 2023 12:23:28 +0100 Subject: [PATCH 02/11] Inspecting the `@return` tags --- R/aedseo.R | 2 +- R/tsd.R | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/R/aedseo.R b/R/aedseo.R index 018a9de..add996b 100644 --- a/R/aedseo.R +++ b/R/aedseo.R @@ -17,7 +17,7 @@ #' @param family A character string specifying the family for modeling. #' Choose between "poisson," or "quasipoisson". #' -#' @return A tibble containing: +#' @return A `aedseo` object containing: #' - 'reference_time': The time point for which the growth rate is estimated. #' - 'observed': The observed value in the reference time point. #' - 'growth_rate': The estimated growth rate. diff --git a/R/tsd.R b/R/tsd.R index e7ebb3c..4638190 100644 --- a/R/tsd.R +++ b/R/tsd.R @@ -12,9 +12,10 @@ #' @param time A date vector containing the corresponding dates. #' @param time_interval A character vector specifying the time interval. #' Choose between "day," "week," or "month." -#' -#' @return A `aedseo_tsd` object containing time, the observations, -#' and the periodInYear. +#' +#' @return A `aedseo_tsd` object containing: +#' - 'time': The time point for for where the observations is observed. +#' - 'observed': The observed value at the time point. #' #' @export #' From f560f5907ae5130d8b2571b98cdc3903e9ef97e0 Mon Sep 17 00:00:00 2001 From: Kasper Schou Telkamp Date: Thu, 2 Nov 2023 13:34:05 +0100 Subject: [PATCH 03/11] Added SSI as cph and fnd --- DESCRIPTION | 6 ++++-- _pkgdown.yml | 7 ++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index f13ffa1..f4ee650 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,9 +1,11 @@ Package: aedseo Title: Automated and Early Detection of Seasonal Epidemic Onset Version: 0.0.0.9000 -Authors@R: +Authors@R: c( person("Kasper", "Schou Telkamp", ,"ksst@ssi.dk", role = c("aut", "cre"), - comment = c(ORCID = "0009-0001-5126-0190")) + comment = c(ORCID = "0009-0001-5126-0190")), + person("Statens Serum Institut, SSI", role = c("cph", "fnd")) + ) Description: A powerful tool for automating the early detection of seasonal epidemic onsets in time series data. It offers the ability to estimate growth rates for consecutive time intervals and calculate the Sum of Cases (SoC) within those intervals. It is particularly useful for epidemiologists, public health professionals, and researchers seeking to identify and respond to seasonal epidemics in a timely fashion. License: MIT + file LICENSE Encoding: UTF-8 diff --git a/_pkgdown.yml b/_pkgdown.yml index 56602f2..d1af786 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -1,4 +1,9 @@ -url: https://telkamp7.github.io/aedseo/ +url: https://ssi-dk.github.io/aedseo/ template: bootstrap: 5 +authors: + Statens Serum Institut, SSI: + href: https://www.ssi.dk/ + html: >- + Posit \ No newline at end of file From 9555737b121221a967803a8e729ea9cfde629014 Mon Sep 17 00:00:00 2001 From: Kasper Schou Telkamp Date: Thu, 2 Nov 2023 13:35:23 +0100 Subject: [PATCH 04/11] Removed superflous --- R/tsd.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/tsd.R b/R/tsd.R index 4638190..542cb73 100644 --- a/R/tsd.R +++ b/R/tsd.R @@ -12,7 +12,7 @@ #' @param time A date vector containing the corresponding dates. #' @param time_interval A character vector specifying the time interval. #' Choose between "day," "week," or "month." -#' +#' #' @return A `aedseo_tsd` object containing: #' - 'time': The time point for for where the observations is observed. #' - 'observed': The observed value at the time point. From f168ed07cba5775af6ef6961be0e0294da3c8749 Mon Sep 17 00:00:00 2001 From: Kasper Schou Telkamp Date: Thu, 2 Nov 2023 13:48:49 +0100 Subject: [PATCH 05/11] Added `stable` lifecycle tags --- R/aedseo.R | 2 +- R/autoplot.R | 2 +- R/fit_growth_rate.R | 2 +- R/plot.R | 2 +- R/predict.R | 2 +- R/summary.R | 2 +- R/tsd.R | 2 +- README.Rmd | 2 +- README.md | 2 +- man/aedseo-package.Rd | 7 ++++++- man/aedseo.Rd | 4 ++-- man/autoplot.Rd | 2 +- man/fit_growth_rate.Rd | 2 +- man/plot.Rd | 2 +- man/predict.aedseo.Rd | 2 +- man/summary.aedseo.Rd | 2 +- man/tsd.Rd | 9 ++++++--- 17 files changed, 28 insertions(+), 20 deletions(-) diff --git a/R/aedseo.R b/R/aedseo.R index add996b..6f7134b 100644 --- a/R/aedseo.R +++ b/R/aedseo.R @@ -1,7 +1,7 @@ #' Automated and Early Detection of Seasonal Epidemic Onset #' #' @description -#' `r lifecycle::badge("experimental")` +#' `r lifecycle::badge("stable")` #' #' This function performs automated and early detection of seasonal epidemic #' onsets (aedseo) on a time series dataset. It estimates growth rates for diff --git a/R/autoplot.R b/R/autoplot.R index 909dee2..baf8611 100644 --- a/R/autoplot.R +++ b/R/autoplot.R @@ -1,7 +1,7 @@ #' Create a complete ggplot appropriate to a particular data type #' #' @description -#' `r lifecycle::badge("experimental")` +#' `r lifecycle::badge("stable")` #' #' This function generates a complete ggplot object suitable for #' visualizing time series data in an `aedseo_tsd` object. It creates a line diff --git a/R/fit_growth_rate.R b/R/fit_growth_rate.R index 193a975..a358e5a 100644 --- a/R/fit_growth_rate.R +++ b/R/fit_growth_rate.R @@ -1,7 +1,7 @@ #' Fit a growth rate model to time series observations. #' #' @description -#' `r lifecycle::badge("experimental")` +#' `r lifecycle::badge("stable")` #' #' This function fits a growth rate model to time series observations and #' provides parameter estimates along with confidence intervals. diff --git a/R/plot.R b/R/plot.R index 5965f18..d973a1f 100644 --- a/R/plot.R +++ b/R/plot.R @@ -1,7 +1,7 @@ #' Create a complete ggplot appropriate to a particular data type #' #' @description -#' `r lifecycle::badge("experimental")` +#' `r lifecycle::badge("stable")` #' #' This function generates a complete ggplot object suitable for #' visualizing time series data in an `aedseo_tsd` object. It creates a line diff --git a/R/predict.R b/R/predict.R index 8b10da9..44a4828 100644 --- a/R/predict.R +++ b/R/predict.R @@ -1,7 +1,7 @@ #' Predict Growth Rates for Future Time Steps #' #' @description -#' `r lifecycle::badge("experimental")` +#' `r lifecycle::badge("stable")` #' #' This function is used to predict future growth rates based on a model object #' created using the AEDSEO package. It takes the model object and the number diff --git a/R/summary.R b/R/summary.R index ed3ff3a..2245be9 100644 --- a/R/summary.R +++ b/R/summary.R @@ -1,7 +1,7 @@ #' Summary method for aedseo objects #' #' @description -#' `r lifecycle::badge("experimental")` +#' `r lifecycle::badge("stable")` #' #' Summarize the results of an aedseo analysis, including the latest growth rate #' estimate, the confidence interval, and information about growth warnings. diff --git a/R/tsd.R b/R/tsd.R index 542cb73..b8309f4 100644 --- a/R/tsd.R +++ b/R/tsd.R @@ -2,7 +2,7 @@ #' and corresponding dates. #' #' @description -#' `r lifecycle::badge("experimental")` +#' `r lifecycle::badge("stable")` #' #' This function takes observed data and the corresponding date vector and #' converts it into a `aedseo_tsd` object, which is a time series diff --git a/README.Rmd b/README.Rmd index 9d05811..6603121 100644 --- a/README.Rmd +++ b/README.Rmd @@ -19,7 +19,7 @@ knitr::opts_chunk$set( [![R-CMD-check](https://github.com/telkamp7/aedseo/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/telkamp7/aedseo/actions/workflows/R-CMD-check.yaml) [![Codecov test coverage](https://codecov.io/gh/telkamp7/aedseo/branch/master/graph/badge.svg)](https://app.codecov.io/gh/telkamp7/aedseo?branch=master) -[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental) +[![Lifecycle: stable](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental) ## Description diff --git a/README.md b/README.md index f04349a..700ad93 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ [![Codecov test coverage](https://codecov.io/gh/telkamp7/aedseo/branch/master/graph/badge.svg)](https://app.codecov.io/gh/telkamp7/aedseo?branch=master) [![Lifecycle: -experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental) +stable](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental) ## Description diff --git a/man/aedseo-package.Rd b/man/aedseo-package.Rd index cffb6ae..1d32320 100644 --- a/man/aedseo-package.Rd +++ b/man/aedseo-package.Rd @@ -8,7 +8,7 @@ \description{ \if{html}{\figure{logo.png}{options: style='float: right' alt='logo' width='120'}} -The Automated and Early Detection of Seasonal Epidemic Onset (aedseo) Package provides a powerful tool for automating the early detection of seasonal epidemic onsets in time series data. It offers the ability to estimate growth rates for consecutive time intervals and calculate the Sum of Cases (SoC) within those intervals. This package is particularly useful for epidemiologists, public health professionals, and researchers seeking to identify and respond to seasonal epidemics in a timely fashion. +A powerful tool for automating the early detection of seasonal epidemic onsets in time series data. It offers the ability to estimate growth rates for consecutive time intervals and calculate the Sum of Cases (SoC) within those intervals. It is particularly useful for epidemiologists, public health professionals, and researchers seeking to identify and respond to seasonal epidemics in a timely fashion. } \seealso{ Useful links: @@ -22,5 +22,10 @@ Useful links: \author{ \strong{Maintainer}: Kasper Schou Telkamp \email{ksst@ssi.dk} (\href{https://orcid.org/0009-0001-5126-0190}{ORCID}) +Other contributors: +\itemize{ + \item Statens Serum Institut, SSI [copyright holder, funder] +} + } \keyword{internal} diff --git a/man/aedseo.Rd b/man/aedseo.Rd index 81686f5..6121b04 100644 --- a/man/aedseo.Rd +++ b/man/aedseo.Rd @@ -28,7 +28,7 @@ a disease outbreak.} Choose between "poisson," or "quasipoisson".} } \value{ -A tibble containing: +A \code{aedseo} object containing: \itemize{ \item 'reference_time': The time point for which the growth rate is estimated. \item 'observed': The observed value in the reference time point. @@ -47,7 +47,7 @@ disease threshold? } } \description{ -\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#experimental}{\figure{lifecycle-experimental.svg}{options: alt='[Experimental]'}}}{\strong{[Experimental]}} +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}} This function performs automated and early detection of seasonal epidemic onsets (aedseo) on a time series dataset. It estimates growth rates for diff --git a/man/autoplot.Rd b/man/autoplot.Rd index cf89ce8..b5ec6d8 100644 --- a/man/autoplot.Rd +++ b/man/autoplot.Rd @@ -24,7 +24,7 @@ ribbon} A ggplot object for visualizing the time series data. } \description{ -\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#experimental}{\figure{lifecycle-experimental.svg}{options: alt='[Experimental]'}}}{\strong{[Experimental]}} +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}} This function generates a complete ggplot object suitable for visualizing time series data in an \code{aedseo_tsd} object. It creates a line diff --git a/man/fit_growth_rate.Rd b/man/fit_growth_rate.Rd index ed9b1cb..237ea64 100644 --- a/man/fit_growth_rate.Rd +++ b/man/fit_growth_rate.Rd @@ -31,7 +31,7 @@ confidence intervals. } } \description{ -\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#experimental}{\figure{lifecycle-experimental.svg}{options: alt='[Experimental]'}}}{\strong{[Experimental]}} +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}} This function fits a growth rate model to time series observations and provides parameter estimates along with confidence intervals. diff --git a/man/plot.Rd b/man/plot.Rd index 28766a5..f9393ca 100644 --- a/man/plot.Rd +++ b/man/plot.Rd @@ -19,7 +19,7 @@ A ggplot object for visualizing the time series data. } \description{ -\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#experimental}{\figure{lifecycle-experimental.svg}{options: alt='[Experimental]'}}}{\strong{[Experimental]}} +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}} This function generates a complete ggplot object suitable for visualizing time series data in an \code{aedseo_tsd} object. It creates a line diff --git a/man/predict.aedseo.Rd b/man/predict.aedseo.Rd index 8da8673..f88e4a1 100644 --- a/man/predict.aedseo.Rd +++ b/man/predict.aedseo.Rd @@ -21,7 +21,7 @@ rates, including time, estimated growth rate, lower confidence interval, and upper confidence interval for the specified number of future time steps. } \description{ -\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#experimental}{\figure{lifecycle-experimental.svg}{options: alt='[Experimental]'}}}{\strong{[Experimental]}} +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}} This function is used to predict future growth rates based on a model object created using the AEDSEO package. It takes the model object and the number diff --git a/man/summary.aedseo.Rd b/man/summary.aedseo.Rd index c93c1ff..d74d4f1 100644 --- a/man/summary.aedseo.Rd +++ b/man/summary.aedseo.Rd @@ -17,7 +17,7 @@ This function is used for its side effect, which is printing a summary message to the console. } \description{ -\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#experimental}{\figure{lifecycle-experimental.svg}{options: alt='[Experimental]'}}}{\strong{[Experimental]}} +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}} Summarize the results of an aedseo analysis, including the latest growth rate estimate, the confidence interval, and information about growth warnings. diff --git a/man/tsd.Rd b/man/tsd.Rd index 9d24ae1..5e07eea 100644 --- a/man/tsd.Rd +++ b/man/tsd.Rd @@ -16,11 +16,14 @@ tsd(observed, time, time_interval = c("day", "week", "month")) Choose between "day," "week," or "month."} } \value{ -A \code{aedseo_tsd} object containing time, the observations, -and the periodInYear. +A \code{aedseo_tsd} object containing: +\itemize{ +\item 'time': The time point for for where the observations is observed. +\item 'observed': The observed value at the time point. +} } \description{ -\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#experimental}{\figure{lifecycle-experimental.svg}{options: alt='[Experimental]'}}}{\strong{[Experimental]}} +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}} This function takes observed data and the corresponding date vector and converts it into a \code{aedseo_tsd} object, which is a time series From b26dde83ba553779607ec9b453e6c05b6fce6aeb Mon Sep 17 00:00:00 2001 From: Kasper Schou Telkamp Date: Thu, 2 Nov 2023 13:59:14 +0100 Subject: [PATCH 06/11] Addeed new features to the NEWS.md --- NEWS.md | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index c657dce..cbad941 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,20 @@ # aedseo (development version) -* Initial CRAN submission. +# aedseo 0.1 + +## Features + +- Added the `aedseo` function, which automates the early detection of seasonal epidemic onsets by estimating growth rates for consecutive time intervals and calculating the Sum of Cases (sum_of_cases). + +- Introduced `autoplot` and `plot` methods for visualizing `aedseo` and `aedseo_tsd` objects. These functions allow you to create insightful ggplot2 plots for your data. + +- Included the `fit_growth_rate` function, enabling users to fit growth rate models to time series observations. + +- Introduced the `predict` method for `aedseo` objects, which allows you to predict observations for future time steps given +the growth rates. + +- Added the `summary` method for `aedseo` objects, providing a comprehensive summary of the results. + +- Introduced the `tsd` function, allowing users to create S3 `aedseo_tsd` (time-series data) objects from observed data and corresponding dates. + +Please note that this is the initial CRAN release of the aedseo package, and we look forward to adding more features and improvements in future updates. We appreciate your feedback and contributions to make this package even more useful for early detection of seasonal epidemics. \ No newline at end of file From e529040b6f61761450b817c5857df44078f27b30 Mon Sep 17 00:00:00 2001 From: Kasper Schou Telkamp Date: Thu, 2 Nov 2023 14:05:41 +0100 Subject: [PATCH 07/11] Updated URLs --- DESCRIPTION | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index f4ee650..9bd084d 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -11,8 +11,8 @@ License: MIT + file LICENSE Encoding: UTF-8 Roxygen: list(markdown = TRUE) RoxygenNote: 7.2.3 -URL: https://github.com/telkamp7/aedseo, https://telkamp7.github.io/aedseo/ -BugReports: https://github.com/telkamp7/aedseo/issues +URL: https://github.com/ssi-dk/aedseo, https://ssi-dk.github.io/aedseo/ +BugReports: https://github.com/ssi-dk/aedseo/issues Suggests: ISOweek, kableExtra, From d126705411bbda84a5bc7e36ded44e83f0786d46 Mon Sep 17 00:00:00 2001 From: Kasper Schou Telkamp Date: Thu, 2 Nov 2023 14:07:41 +0100 Subject: [PATCH 08/11] Fixed URLs --- man/aedseo-package.Rd | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/man/aedseo-package.Rd b/man/aedseo-package.Rd index 1d32320..06793e8 100644 --- a/man/aedseo-package.Rd +++ b/man/aedseo-package.Rd @@ -13,9 +13,9 @@ A powerful tool for automating the early detection of seasonal epidemic onsets i \seealso{ Useful links: \itemize{ - \item \url{https://github.com/telkamp7/aedseo} - \item \url{https://telkamp7.github.io/aedseo/} - \item Report bugs at \url{https://github.com/telkamp7/aedseo/issues} + \item \url{https://github.com/ssi-dk/aedseo} + \item \url{https://ssi-dk.github.io/aedseo/} + \item Report bugs at \url{https://github.com/ssi-dk/aedseo/issues} } } From a5ee83fcb17fc447fd1fa8b757b8c48ad366abee Mon Sep 17 00:00:00 2001 From: Kasper Schou Telkamp Date: Thu, 2 Nov 2023 14:25:07 +0100 Subject: [PATCH 09/11] fixed url --- README.Rmd | 4 ++-- README.md | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.Rmd b/README.Rmd index 6603121..30ae47d 100644 --- a/README.Rmd +++ b/README.Rmd @@ -13,11 +13,11 @@ knitr::opts_chunk$set( ) ``` -# aedseo aedseo website +# aedseo aedseo website -[![R-CMD-check](https://github.com/telkamp7/aedseo/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/telkamp7/aedseo/actions/workflows/R-CMD-check.yaml) +[![R-CMD-check](https://github.com/ssi-dk/aedseo/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/ssi-dk/aedseo/actions/workflows/R-CMD-check.yaml) [![Codecov test coverage](https://codecov.io/gh/telkamp7/aedseo/branch/master/graph/badge.svg)](https://app.codecov.io/gh/telkamp7/aedseo?branch=master) [![Lifecycle: stable](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental) diff --git a/README.md b/README.md index 700ad93..6551502 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ -# aedseo aedseo website +# aedseo aedseo website -[![R-CMD-check](https://github.com/telkamp7/aedseo/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/telkamp7/aedseo/actions/workflows/R-CMD-check.yaml) +[![R-CMD-check](https://github.com/ssi-dk/aedseo/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/ssi-dk/aedseo/actions/workflows/R-CMD-check.yaml) [![Codecov test coverage](https://codecov.io/gh/telkamp7/aedseo/branch/master/graph/badge.svg)](https://app.codecov.io/gh/telkamp7/aedseo?branch=master) [![Lifecycle: From 41a7e4102f176c0dfae0350bce29681c0623bdc9 Mon Sep 17 00:00:00 2001 From: Kasper Schou Telkamp Date: Thu, 2 Nov 2023 14:48:49 +0100 Subject: [PATCH 10/11] added mathrm{} --- vignettes/articles/aedseo.Rmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vignettes/articles/aedseo.Rmd b/vignettes/articles/aedseo.Rmd index dff0fbd..e052103 100644 --- a/vignettes/articles/aedseo.Rmd +++ b/vignettes/articles/aedseo.Rmd @@ -48,7 +48,7 @@ Inspired by [@Hara_2010, @Obadia_2012] The exponential growth rate, denoted as $r$, represents the per capita change in the number of new cases per unit of time. Given that incidence data are integer-valued, the proposed method relies on generalized linear models (GLM). For count data, the Poisson distribution is a suitable choice as a model. Hence, the count observations denoted as $Y$ are assumed to follow a Poisson distribution \begin{equation} - Y \sim \Pois(\lambda) + Y \sim \mathrm{Pois}(\lambda) \end{equation} Here, the link function, $\log()$, connects the linear predictor to the expected value of the data point, expressed as $\log(\lambda)=\mu$. Given a single continuous covariate $t$, the mean $\mu$ can be expressed as From f5ad48f32c3f0b3deb60b554c224b4cf82410109 Mon Sep 17 00:00:00 2001 From: Kasper Schou Telkamp Date: Thu, 2 Nov 2023 14:51:00 +0100 Subject: [PATCH 11/11] Removed article, will resubmit later --- vignettes/articles/aedseo.Rmd | 280 ------------------------------ vignettes/articles/preamble.tex | 2 - vignettes/articles/references.bib | 159 ----------------- 3 files changed, 441 deletions(-) delete mode 100644 vignettes/articles/aedseo.Rmd delete mode 100644 vignettes/articles/preamble.tex delete mode 100644 vignettes/articles/references.bib diff --git a/vignettes/articles/aedseo.Rmd b/vignettes/articles/aedseo.Rmd deleted file mode 100644 index e052103..0000000 --- a/vignettes/articles/aedseo.Rmd +++ /dev/null @@ -1,280 +0,0 @@ ---- -title: "Automated and Early Detection of Seasonal Epidemic Onset" -bibliography: "references.bib" -output: - html_document: - includes: - in_header: preamble.tex ---- - -```{r, include = FALSE} -knitr::opts_chunk$set( - collapse = TRUE, - comment = "#>" -) -``` - -```{r setup} -library(aedseo) -library(ISOweek) -library(ggplot2) -library(dplyr) -library(tidyr) -library(tibble) -library(kableExtra) -``` - -## Introduction - -Understanding the seasonality of respiratory virus infections is crucial for countries to make informed recommendations concerning the timing of monoclonal antibody provision, particularly for the treatment and prophylaxis of children exposed to respiratory syncytial virus (RSV) in their first year(s) of life, primarily premature infants [@Terletskaia_2005, @Teirlinck_2023]. Moreover, the timely detection of epidemic onset has the potential to guide empirical antiviral therapy for hospitalized patients with suspected influenza [@McGeer_2009]. This, in turn, contributes to the reduction of the health an economic burden caused by respiratory virus infections. Achieving accurate identification of the beginning of seasonal respiratory epidemics necessitates regular and prompt data collection, coupled with a standardized procedure for continuous data analysis. - -A wide range of statistical methods are at out disposal for defining influenza epidemics. Over the last two decades, techniques such as Serfling-based models and dynamic linear models, which rely on recent data [@Serfling_1963, @Stroup_1989, @West_1997, @Pelat_2007], have been extensively employed for this purpose. - -This package revolves around the timely detection of the onset of seasonal respiratory epidemics. - -## Methodology - -The methodology used to detect the onset of seasonal respiratory epidemics can be divided into two essential criteria: - -- The local estimate of the exponential growth rate, $r$, is significantly greater than zero. -- The sum of cases (SoC) over the past $k$ units of time exceeds a disease-specific threshold. - -Here, $k$ denotes the window size employed to obtain the local estimate of the exponential growth rate and the SoC. When both of these criteria are met, an alarm is triggered and the onset of the seasonal epidemic is detected. - -### Exponential growth rate - -Inspired by [@Hara_2010, @Obadia_2012] - -The exponential growth rate, denoted as $r$, represents the per capita change in the number of new cases per unit of time. Given that incidence data are integer-valued, the proposed method relies on generalized linear models (GLM). For count data, the Poisson distribution is a suitable choice as a model. Hence, the count observations denoted as $Y$ are assumed to follow a Poisson distribution - -\begin{equation} - Y \sim \mathrm{Pois}(\lambda) -\end{equation} - -Here, the link function, $\log()$, connects the linear predictor to the expected value of the data point, expressed as $\log(\lambda)=\mu$. Given a single continuous covariate $t$, the mean $\mu$ can be expressed as - -\begin{equation} - \mu = \alpha + r t -\end{equation} - -This is equivalent to a multiplicative model for $\lambda$, i.e. - -\begin{equation} - \lambda = \exp(\alpha + r t) = \exp(\alpha) \exp(r t) -\end{equation} - -Intuitively, negative values of $r$ result in a decline in the number of observed cases, while $r=0$ represents stability, and positive values of $r$ indicate an increase. The direct relationship between growth rates and reproductive numbers is further elaborated in the study by @Wallinga_2007. - -It is important to note that the Poisson distribution assumes that the mean and variance are equal. In reality, real data often deviate from this assumption, with the variance ($v$) being significantly larger than the mean. This biological phenomenon, known as overdispersion, can be addressed within a model in various ways. One approach is to employ quasi-Poisson regression, which assumes $v=\sigma\lambda$, or to use negative binomial regression, which assumes $v=\lambda+\lambda^2/\theta$, where both $\sigma$ and $\theta$ are overdispersion parameters. - -## Simulations - -To assess the effectiveness of the proposed algorithm, a simulation study is conducted. The simulated data is generated using a negative binomial model with a mean parameter $\mu$ and a variance parameter $\phi\mu$. In this context, $\phi$ denotes a dispersion parameter, which is assumed to be greater than or equal to 1. The mean, denoted as $\mu(t)$, is defined by a linear predictor that incorporates both a trend component and a seasonality components represented by Fourier terms. The equation for $\mu(t)$ is as follows: - -\begin{equation} - \mu(t) = \exp\Biggl( \theta + \beta t + \sum_{j=1}^m \biggl( \gamma_{\sin} \sin\Bigl( \frac{2 \pi t}{52}\Bigl) + \gamma_{\cos} \cos \Bigl( \frac{2 \pi t}{52} \Bigl) \biggl) \Biggl) -\end{equation} - -To accommodate a variety of scenarios encountered in practical applications, the simulations is generated using different combinations of parameters. These parameters include baseline frequencies of reports denoted as $\theta$, trends represented by $\beta$, seasonal patterns characterized by $\gamma_{\sin}$ and $\gamma_{\cos}$, as well as dispersions indicated by $\phi$. A list of the specific parameter combinations are provided in Table XX. - - -```{r parameter_combinations} -# TODO: #7 Conduct the simulation study and write the article on the `aedseo` -# package. @telkamp7 -parameter_combinations <- as_tibble(expand_grid( - theta = c(3, 4, 5, 6, 7), - beta = c(0.001), - gamma_sin = c(1, 2), - gamma_cos = c(1, 2), - phi = c(1, 2) -)) - -parameter_combinations %>% - mutate(Scenario = row_number()) %>% - select(Scenario, theta:phi) %>% - rename( - `$\\theta$` = theta, - `$\\beta$` = beta, - `$\\gamma_{\\sin}$` = gamma_sin, - `$\\gamma_{\\cos}$` = gamma_cos, - `$\\phi$` = phi - ) %>% - kbl( - booktabs = TRUE, - escape = FALSE, - align = "l", - caption = "Parameters and criteria to generate the 40 scenarios.", - linesep = c(rep("", 7), "\\addlinespace") - ) %>% - kable_paper(latex_options = c("HOLD_position")) -``` - - -```{r} -mu_t <- function( - t, - theta = 1, - exp_beta = 1.001, - gamma_sin = 1, - gamma_cos = 1, - trend = 1, - j = 1, - ...) { - # Start construction of linear predictor - linear_predictor <- theta - # ... add a trend if the scenario request it - if (trend == 1) { - linear_predictor <- linear_predictor + log(exp_beta) * t - } - # ... add a seasonal component - linear_predictor <- linear_predictor + - gamma_sin * sin(2 * pi * t * j / 52) + - gamma_cos * cos(2 * pi * t * j / 52) - - return(exp(linear_predictor)) -} - -simulate_from_nbinom <- function(...) { - # Set some default values for the simulation - default_pars <- list( - "t" = 1, - "theta" = 1, - "exp_beta" = 1.001, - "gamma_sin" = 1, - "gamma_cos" = 1, - "trend" = 1, - "j" = 1, - "phi" = 1, - "seed" = 42 - ) - - # Match call - mc <- as.list(match.call())[-1] - # ... and change parameters relative to the call - index_mc <- !names(default_pars) %in% names(mc) - mc <- append(mc, default_pars[index_mc])[names(default_pars)] - - # Set the seed - set.seed(mc$seed) - - # Calculate the number of time points - n <- length(eval(mc$t)) - # Calculate mu_t - mu_t_scenario <- do.call(what = "mu_t", args = mc) - # ... and compute the variance of the negative binomial distribution - variance <- mu_t_scenario * mc$phi - # ... and infer the size in the negative binomial distribution - size <- (mu_t_scenario + mu_t_scenario^2) / variance - # Plugin and simulate the data - simulation <- rnbinom(n = n, mu = mu_t_scenario, size = size) - - return(list("mu_t" = mu_t_scenario, "simulation" = simulation, "pars" = mc)) -} -``` - - -```{r} -# Define the number of years and the number of months within a year -years <- 3 -weeks <- 52 -# ... calculate the total number of observations -n <- years * weeks -# ... and a vector containing the overall time passed -time_overall <- 1:n -# Create arbitrary dates -dates <- as.POSIXct( - x = time_overall * 86400 * 7, - origin = "2010-01-01", - tz = "UTC", - format = "%F" -) - -# Simulate the data -simulation <- simulate_from_nbinom(t = time_overall) - -# Collect the data in a 'tibble' -sim_data <- tibble( - Date = dates, - mu_t = simulation$mu_t, - y = simulation$simulation -) - -# Have a glance at the time varying mean -sim_data %>% - pivot_longer(cols = mu_t:y, names_to = "type", values_to = "value") %>% - ggplot(mapping = aes(x = Date, y = value)) + - geom_line() + - geom_point() + - facet_wrap(facets = vars(type), ncol = 1) - -sim_data %>% - ggplot(mapping = aes(x = Date)) + - geom_line(mapping = aes(y = mu_t)) + - geom_point(mapping = aes(y = y)) - -# Construct a 'tsibble' object with the time series data -tsd_data <- tsd( - observed = simulation$simulation, - time = dates, - time_interval = "week" -) - -# Apply the 'aedseo' algorithm -aedseo_results <- aedseo( - tsd = tsd_data, - k = 5, - level = 0.95, - family = "quasipoisson" -) - -# Visualize the growth rate -aedseo_results %>% - ggplot(mapping = aes(x = reference_time, y = growth_rate)) + - geom_line() + - geom_ribbon( - mapping = aes( - ymin = lower_growth_rate, - ymax = upper_growth_rate - ), - alpha = 0.3 - ) + - geom_hline(yintercept = 0, linetype = "dashed") - -aedseo_results %>% - ggplot(mapping = aes(x = reference_time)) + - geom_point(mapping = aes(y = growth_rate, alpha = growth_warning)) + - geom_errorbar( - mapping = aes( - ymin = lower_growth_rate, - ymax = upper_growth_rate, - alpha = growth_warning - ) - ) + - geom_hline(yintercept = 0, linetype = "dashed") -``` - - - -```{r, eval=FALSE, include=FALSE} -# Define a vector containing the weeks within a year, replicated for each year -time_in_year <- rep(x = 1:weeks, times = years) - -# Define the mean number of cases -theta <- 5 -# ... and a trend -exp_beta <- 1.001 -# ... and seasonal parameters -gamma_sin <- gamma_cos <- 1 - -# Calculate the time varying mean -mu_t <- exp( - theta + - time_overall * log(exp_beta) + - gamma_sin * sin(2 * pi * time_in_year / 52) + - gamma_cos * cos(2 * pi * time_in_year / 52) -) - -# Draw a realization from the negative binomial distribution -sim_nbinom <- rnbinom(n = n, mu = mu_t, size = 10) -``` - diff --git a/vignettes/articles/preamble.tex b/vignettes/articles/preamble.tex deleted file mode 100644 index e6fdf97..0000000 --- a/vignettes/articles/preamble.tex +++ /dev/null @@ -1,2 +0,0 @@ -\usepackage{amsmath} % For aligning equations among other -\DeclareMathOperator{\Pois}{Pois} diff --git a/vignettes/articles/references.bib b/vignettes/articles/references.bib deleted file mode 100644 index f7dd0b1..0000000 --- a/vignettes/articles/references.bib +++ /dev/null @@ -1,159 +0,0 @@ -@article{McGeer_2009, - author = {McGeer, Allison J.}, - title = "{Diagnostic Testing or Empirical Therapy for Patients Hospitalized with Suspected Influenza: What to Do?}", - journal = {Clinical Infectious Diseases}, - volume = {48}, - number = {Supplement_1}, - pages = {S14-S19}, - year = {2009}, - month = {01}, - issn = {1058-4838}, - doi = {10.1086/591852}, - url = {https://doi.org/10.1086/591852}, - eprint = {https://academic.oup.com/cid/article-pdf/48/Supplement\_1/S14/20908185/48-Supplement\_1-S14.pdf}, -} - -@article{Serfling_1963, - ISSN = {00946214}, - URL = {http://www.jstor.org/stable/4591848}, - author = {Robert E. Serfling}, - journal = {Public Health Reports (1896-1970)}, - number = {6}, - pages = {494--506}, - publisher = {Association of Schools of Public Health}, - title = {Methods for Current Statistical Analysis of Excess Pneumonia-Influenza Deaths}, - urldate = {2023-10-18}, - volume = {78}, - year = {1963} -} - -@article{Stroup_1989, -author = {Stroup, Donna F. and Williamson, G. David and Herndon, Joy L. and Karon, John M.}, -title = {Detection of aberrations in the occurrence of notifiable diseases surveillance data}, -journal = {Statistics in Medicine}, -volume = {8}, -number = {3}, -pages = {323-329}, -keywords = {Surveillance, Aberrations, Clustering, Bootstrap, Scan}, -doi = {https://doi.org/10.1002/sim.4780080312}, -url = {https://onlinelibrary.wiley.com/doi/abs/10.1002/sim.4780080312}, -eprint = {https://onlinelibrary.wiley.com/doi/pdf/10.1002/sim.4780080312}, -year = {1989} -} - -@book{West_1997, -author = {West, Mike and Harrison, Jeff}, -title = {Bayesian Forecasting and Dynamic Models (2nd Ed.)}, -year = {1997}, -isbn = {0387947256}, -publisher = {Springer-Verlag}, -address = {Berlin, Heidelberg} -} - - -@article{Pelat_2007, -Author = {Pelat, Camille and Boëlle, Pierre-Yves and Cowling, Benjamin J. and - Carrat, Fabrice and Flahault, Antoine and Ansart, Séverine and Valleron, - Alain-Jacques}, -Title = {Online detection and quantification of epidemics}, -Journal = {BMC Medical Informatics and Decision Making}, -Year = {2007}, -Volume = {7}, -Month = {Oct 15}, -DOI = {10.1186/1472-6947-7-29}, -Article-Number = {29}, -EISSN = {1472-6947}, -} - - -@article{Terletskaia_2005, -Author = {Terletskaia-Ladwig, E and Enders, G and Schalasta, G and Enders, M}, -Title = {Defining the timing of respiratory syncytial virus (RSV) outbreaks: an - epidemiological study}, -Journal = {BMC infectious diseases}, -Year = {2005}, -Volume = {5}, -Month = {Mar 31}, -DOI = {10.1186/1471-2334-5-20}, -Article-Number = {20}, -EISSN = {1471-2334}, -Unique-ID = {WOS:000228535800001}, -} - -@article {Teirlinck_2021, - author = {Anne C. Teirlinck and Eeva K. Broberg and Are Stuwitz Berg and Harry Campbell and Rachel M. Reeves and AnnaSara Carnahan and Bruno Lina and Gatis Pakarna and H{\r a}kon B{\o}{\r a}s and Hanna Nohynek and Hanne-Dorthe Emborg and Harish Nair and Janine Reiche and Jesus Angel Oliva and Joanne O{\textquoteright}Gorman and John Paget and Karol Szymanski and Kostas Danis and Maja Socan and Manuel Gijon and Marie Rapp and Martina Havl{\'\i}{\v c}kov{\'a} and Ramona Trebbien and Raquel Guiomar and Siddhivinayak S. Hirve and Silke Buda and Sylvie van der Werf and Adam Meijer and Thea K. Fischer}, - title = {Recommendations for respiratory syncytial virus surveillance at the national level}, - volume = {58}, - number = {3}, - elocation-id = {2003766}, - year = {2021}, - doi = {10.1183/13993003.03766-2020}, - publisher = {European Respiratory Society}, - issn = {0903-1936}, - URL = {https://erj.ersjournals.com/content/58/3/2003766}, - eprint = {https://erj.ersjournals.com/content/58/3/2003766.full.pdf}, - journal = {European Respiratory Journal} -} - -@article {Teirlinck_2023, - author = {Anne C. Teirlinck and Caroline K. Johannesen and Eeva K. Broberg and Pasi Penttinen and Harry Campbell and Harish Nair and Rachel M. Reeves and H{\r a}kon B{\o}{\r a}s and Mia Brytting and Wei Cai and AnnaSara Carnahan and Jean-Sebastien Casalegno and Kostas Danis and Cillian De Gascun and Joanna Ellis and Hanne-Dorthe Emborg and Manuel Gijon and Raquel Guiomar and Siddhivinayak S. Hirve and Helena Ji{\v r}incov{\'a} and Hanna Nohynek and Jesus Angel Oliva and Richard Osei-Yeboah and John Paget and Gatis Pakarna and Richard Pebody and Lance Presser and Marie Rapp and Janine Reiche and Ana Paula Rodrigues and Elina Sepp{\"a}l{\"a} and Maja Socan and Karol Szymanski and Ramona Trebbien and Jarom{\'\i}ra Ve{\v c}e{\v r}ov{\'a} and Sylvie van der Werf and Maria Zambon and Adam Meijer and Thea K. Fischer}, - title = {New perspectives on respiratory syncytial virus surveillance at the national level: lessons from the COVID-19 pandemic}, - volume = {61}, - number = {4}, - elocation-id = {2201569}, - year = {2023}, - doi = {10.1183/13993003.01569-2022}, - publisher = {European Respiratory Society}, - issn = {0903-1936}, - URL = {https://erj.ersjournals.com/content/61/4/2201569}, - eprint = {https://erj.ersjournals.com/content/61/4/2201569.full.pdf}, - journal = {European Respiratory Journal} -} - -@article{Hara_2010, -author = {O’Hara, Robert B. and Kotze, D. Johan}, -title = {Do not log-transform count data}, -journal = {Methods in Ecology and Evolution}, -volume = {1}, -number = {2}, -pages = {118-122}, -keywords = {generalized linear models, linear models, overdispersion, Poisson, transformation}, -doi = {https://doi.org/10.1111/j.2041-210X.2010.00021.x}, -url = {https://besjournals.onlinelibrary.wiley.com/doi/abs/10.1111/j.2041-210X.2010.00021.x}, -eprint = {https://besjournals.onlinelibrary.wiley.com/doi/pdf/10.1111/j.2041-210X.2010.00021.x}, -year = {2010} -} - - -@article{Wallinga_2007, -author = {Wallinga, J and Lipsitch, M }, -title = {How generation intervals shape the relationship between growth rates and reproductive numbers}, -journal = {Proceedings of the Royal Society B: Biological Sciences}, -volume = {274}, -number = {1609}, -pages = {599-604}, -year = {2007}, -doi = {10.1098/rspb.2006.3754}, -URL = {https://royalsocietypublishing.org/doi/abs/10.1098/rspb.2006.3754}, -eprint = {https://royalsocietypublishing.org/doi/pdf/10.1098/rspb.2006.3754}, -} - - - -@article{Obadia_2012, -Author = {Obadia, Thomas and Haneef, Romana and Boelle, Pierre-Yves}, -Title = {The R0 package: a toolbox to estimate reproduction numbers for epidemic - outbreaks}, -Journal = {BMC Medical Informatics and Decision Making}, -Year = {2012}, -Volume = {12}, -Month = {Dec 18}, -DOI = {10.1186/1472-6947-12-147}, -Article-Number = {147}, -ISSN = {1472-6947}, -Unique-ID = {WOS:000315332700001}, -} - - - -