Title: | Nowcasting by Bayesian Smoothing |
---|---|
Description: | A Bayesian approach to estimate the number of occurred-but-not-yet-reported cases from incomplete, time-stamped reporting data for disease outbreaks. 'NobBS' learns the reporting delay distribution and the time evolution of the epidemic curve to produce smoothed nowcasts in both stable and time-varying case reporting settings, as described in McGough et al. (2020) <doi:10.1371/journal.pcbi.1007735>. |
Authors: | Sarah McGough [aut, cre], Nicolas Menzies [aut], Marc Lipsitch [aut], Michael Johansson [aut] |
Maintainer: | Sarah McGough <[email protected]> |
License: | MIT + file LICENSE |
Version: | 1.0.0 |
Built: | 2024-11-04 03:32:54 UTC |
Source: | https://github.com/sarahhbellum/nobbs |
Surveillance data from CDC Division of Vector-Borne Diseases.
1990-2010 case reporting data included.
The first column, onset_week
, indicates the week of symptom onset.
The second column, report_week
, indicates the week of case report.
The third column, gender
, indicates the gender of the infected individual (randomly assigned with 0.5:0.5 probability of "Male"/"Female"). This column may be used to produce stratified nowcasts using the function NobBS.strat
.
data(denguedat)
data(denguedat)
A data frame.
data(denguedat) nowcast <- NobBS(denguedat, as.Date("1990-04-09"),units="1 week",onset_date="onset_week", report_date="report_week") nowcast$estimates
data(denguedat) nowcast <- NobBS(denguedat, as.Date("1990-04-09"),units="1 week",onset_date="onset_week", report_date="report_week") nowcast$estimates
Nowcasting is useful to estimate the true number of cases when they are unknown or incomplete in the present because of reporting delays. 'NobBS' is a Bayesian nowcasting approach that learns from the reporting delay distribution as well as the temporal evolution of the epidemic curve to estimate the number of occurred but not yet reported cases for a given date.
NobBS( data, now, units, onset_date, report_date, moving_window = NULL, max_D = NULL, cutoff_D = NULL, proportion_reported = 1, quiet = TRUE, specs = list(dist = c("Poisson", "NB"), alpha1.mean.prior = 0, alpha1.prec.prior = 0.001, alphat.shape.prior = 0.001, alphat.rate.prior = 0.001, beta.priors = NULL, param_names = NULL, conf = 0.95, dispersion.prior = NULL, nAdapt = 1000, nChains = 1, nBurnin = 1000, nThin = 1, nSamp = 10000) )
NobBS( data, now, units, onset_date, report_date, moving_window = NULL, max_D = NULL, cutoff_D = NULL, proportion_reported = 1, quiet = TRUE, specs = list(dist = c("Poisson", "NB"), alpha1.mean.prior = 0, alpha1.prec.prior = 0.001, alphat.shape.prior = 0.001, alphat.rate.prior = 0.001, beta.priors = NULL, param_names = NULL, conf = 0.95, dispersion.prior = NULL, nAdapt = 1000, nChains = 1, nBurnin = 1000, nThin = 1, nSamp = 10000) )
data |
A time series of reporting data in line list format (one row per case), with a column |
now |
An object of datatype |
units |
Time scale of reporting. Options: "1 day", "1 week". |
onset_date |
In quotations, the name of the column of datatype |
report_date |
In quotations, the name of the column of datatype |
moving_window |
Size of moving window for estimation of cases (numeric). The moving window size should be specified in the same date units as the reporting data (i.e. specify 7 to indicate 7 days, 7 weeks, etc). Default: NULL, i.e. takes all historical dates into consideration. |
max_D |
Maximum possible delay observed or considered for estimation of the delay distribution (numeric). Default: (length of unique dates in time series)-1 ; or, if a moving window is specified, (size of moving window)-1 |
cutoff_D |
Consider only delays d<= |
proportion_reported |
A decimal greater than 0 and less than or equal to 1 representing the proportion of all cases expected to be reported. Default: 1, e.g. 100 percent of all cases will eventually be reported. For asymptomatic diseases where not all cases will ever be reported, or for outbreaks in which severe under-reporting is expected, change this to less than 1. |
quiet |
Suppress all output and progress bars from the JAGS process. Default: TRUE. |
specs |
A list with arguments specifying the Bayesian model used: |
The function returns a list with the following elements: estimates
, a 5-column data frame containing estimates for each date in the window of predictions (up to "now") with corresponding date of case onset, lower and upper bounds of the prediction interval, and the number of cases for that onset date reported up to 'now'; estimates.inflated
, a Tx4 data frame containing estimates inflated by the proportion_reported for each date in the time series (up to "now") with corresponding date of case onset, lower and upper bounds of the prediction interval, and the number of cases for that onset date reported up to 'now'; nowcast.post.samples
, vector of 10,000 samples from the posterior predictive distribution of the nowcast, and params.post
, a 10,000xN dataframe containing 10,000 posterior samples for the "N" parameters specified in specs[["param_names"]]. See McGough et al. 2019 (https://www.biorxiv.org/content/10.1101/663823v1) for detailed explanation of parameters.
'NobBS' requires that JAGS (Just Another Gibbs Sampler) is downloaded to the system. JAGS can be downloaded at <http://mcmc-jags.sourceforge.net/>.
# Load the data data(denguedat) # Perform default 'NobBS' assuming Poisson distribution, vague priors, and default specifications. nowcast <- NobBS(denguedat, as.Date("1990-04-09"),units="1 week",onset_date="onset_week", report_date="report_week") nowcast$estimates
# Load the data data(denguedat) # Perform default 'NobBS' assuming Poisson distribution, vague priors, and default specifications. nowcast <- NobBS(denguedat, as.Date("1990-04-09"),units="1 week",onset_date="onset_week", report_date="report_week") nowcast$estimates
Produces nowcasts stratified by a single variable of interest, e.g. by geographic unit (province/state/region) or by age group.
NobBS.strat( data, now, units, onset_date, report_date, strata, moving_window = NULL, max_D = NULL, cutoff_D = NULL, quiet = TRUE, proportion_reported = 1, specs = list(dist = c("Poisson", "NB"), alpha1.mean.prior = 0, alpha1.prec.prior = 0.001, alphat.shape.prior = 0.001, alphat.rate.prior = 0.001, beta.priors = NULL, param_names = NULL, conf = 0.95, dispersion.prior = NULL, nAdapt = 1000, nChains = 1, nBurnin = 1000, nThin = 1, nSamp = 10000) )
NobBS.strat( data, now, units, onset_date, report_date, strata, moving_window = NULL, max_D = NULL, cutoff_D = NULL, quiet = TRUE, proportion_reported = 1, specs = list(dist = c("Poisson", "NB"), alpha1.mean.prior = 0, alpha1.prec.prior = 0.001, alphat.shape.prior = 0.001, alphat.rate.prior = 0.001, beta.priors = NULL, param_names = NULL, conf = 0.95, dispersion.prior = NULL, nAdapt = 1000, nChains = 1, nBurnin = 1000, nThin = 1, nSamp = 10000) )
data |
A time series of reporting data in line list format (one row per case), with a column |
now |
An object of datatype |
units |
Time scale of reporting. Options: "1 day", "1 week". |
onset_date |
In quotations, the name of the column of datatype |
report_date |
In quotations, the name of the column of datatype |
strata |
In quotations, the name of the column indicating the stratifying variable. |
moving_window |
Size of moving window for estimation of cases (numeric). The moving window size should be specified in the same date units as the reporting data (i.e. specify 7 to indicate 7 days, 7 weeks, etc). Default: NULL, i.e. takes all historical dates into consideration. |
max_D |
Maximum possible delay observed or considered for estimation of the delay distribution (numeric). Default: (length of unique dates in time series)-1 ; or, if a moving window is specified, (size of moving window)-1 |
cutoff_D |
Consider only delays d<= |
quiet |
Suppress all output and progress bars from the JAGS process. Default: TRUE. |
proportion_reported |
A decimal greater than 0 and less than or equal to 1 representing the proportion of all cases expected to be reported. Default: 1, e.g. 100 percent of all cases will eventually be reported. For asymptomatic diseases where not all cases will ever be reported, or for outbreaks in which severe under-reporting is expected, change this to less than 1. |
specs |
A list with arguments specifying the Bayesian model used: |
The function returns a list with the following elements: estimates
, a 5-column data frame containing estimates for each date in the window of predictions (up to "now") with corresponding date of case onset, lower and upper bounds of the prediction interval, and the number of cases for that onset date reported up to 'now'; estimates.inflated
, a Tx4 data frame containing estimates inflated by the proportion_reported for each date in the time series (up to "now") with corresponding date of case onset, lower and upper bounds of the prediction interval, and the number of cases for that onset date reported up to 'now'; nowcast.post.samples
, vector of 10,000 samples from the posterior predictive distribution of the nowcast, and params.post
, a 10,000xN dataframe containing 10,000 posterior samples for the "N" parameters specified in specs[["param_names"]]. See McGough et al. 2019 (https://www.biorxiv.org/content/10.1101/663823v1) for detailed explanation of parameters.
'NobBS' requires that JAGS (Just Another Gibbs Sampler) is downloaded to the system. JAGS can be downloaded at <http://mcmc-jags.sourceforge.net/>.
# Load the data data(denguedat) # Perform stratified 'NobBS' assuming Poisson distribution, vague priors, and default # specifications. nowcast <- NobBS.strat(denguedat, as.Date("1990-02-05"),units="1 week",onset_date="onset_week", report_date="report_week",strata="gender") nowcast$estimates
# Load the data data(denguedat) # Perform stratified 'NobBS' assuming Poisson distribution, vague priors, and default # specifications. nowcast <- NobBS.strat(denguedat, as.Date("1990-02-05"),units="1 week",onset_date="onset_week", report_date="report_week",strata="gender") nowcast$estimates