Skip to content

1.3.2 CRAN release

Compare
Choose a tag to compare
@seabbs seabbs released this 13 Dec 22:18

In this release model run times have been reduced using a combination of code optimisation and testing to reduce the likelihood of long running edge cases. Model flexibility has also been increased, particularly for the back calculation approach which now supports an increased range of prior choices. A significant development in this release is the edition of the experimental estimate_secondary model (and supporting forecast and plot functions). This allows a downstream target to be forecast from an observation. Example use cases include forecasting deaths from test positive cases and hospital bed usage from hospital admissions. This approach is intended to provide an alternative to models in which multiple targets are estimated jointly.

New features

  • Added a new argument, prior, to backcalc_opts. This allows the use of different priors for the
    underlying latent infections when estimating using deconvolution/back-calculation rather than the package
    default of using a generated Rt model (enable this option by setting rt = NULL). The default prior
    remains smoothed mean delay shifted reported cases but optionally no prior can now also be used (for
    scenarios when the data is very untrustworthy but likely to perform extremely poorly in real time).In addition,
    the previously estimated infections can be used (i.e infections[t] = infections[t-1] * exp(GP)) with this being
    an approximate version of the generative Rt model that does not weight previous infections using the generation
    time.
  • Updates the smoothing applied to mean shifted reported cases used as a prior for back calculation when
    prior = "reports" to be a partial centred moving average rather than a right aligned moving average.
    This choice means that increasing the prior window does not alter the location of epidemic peaks as when using a right alighted moving average.
  • Updates the default smoothing applied to mean shifted reported cases to be 14 days rather than 7 as usage indicates this
    provided too much weight to small scale changes. This remains user set able.
  • Adds a new argument init_fit to stan_opts() that enables the user to pass in a stanfit to use to initialise a model fit in estimate_infections(). Optionally init_fit = "cumulative" can also be passed which first fits to cumulative data and then uses the result to initialise the full fit on incidence data. This approach is based on the approach used in epidemia authored by James Scott. Currently stan warnings from this initial fit are broadcast to the user and may cause concern as the short run time and approximate settings often lead to poor convergence.
  • Adds estimate_secondary and forecast_secondary along with a plot method and a new option function (secondary_opts). These functions implement a generic model for forecasting a secondary observation (such as hospital bed usage, deaths in hospital) that entirely depends on a primary observation (such as hospital admissions) via a combination of convolving over a delay and adding/subtracting current observations. They share the same observation model and optional features used by estimate_infections and so support data truncation, scaling (between primary and secondary observations), multiple log normal delays, a day of the week effect, and various error models. stationary_opts allows for easy specification of the most common use cases (incidence and prevalence variables). See the documentation and examples for model details.

Other changes

  • Updates discretised_gamma_pmf (discretised truncated Gamma PMF) and discretised_lognormal_pmf (discretised truncated lognormal PMF) to limit/clip the values of the parameters by prespecified lower and upper bounds.
  • Tightens the initialisation of fitting in estimate_infections by reducing all standard deviations used by a scaling factor of 0.1 in create_initial_conditions.
  • Adds boundary checking on gt_mean (the mean of the generation time) to reject samples with a mean greater than gt_max (the maximum allowed generation time). Adds boundary checking to reject standard deviations that are negative. Adds a boundary check on R values to reject them if 10 times greater than the mean of the initial prior. In some scenarios this will require users to supply a prior not is not completely misspecified (i.e if the prior has a mean of 1 and the posterior has a mean of 50).
  • Refactor of update_rt (an internal stan function found in inst/stan/functions/rt.stan) to be vectorised. This change reduces run times by approximately 1- ~ 20% (though only tested on a small subset of examples) and opens the way for future model extensions (such as additive rather than multiplicative random walks, and introducing covariates).
  • Switched to reporting two significant figures in all summary tables
  • Reduced minimum default Gaussian process length scale to 3 days from 7 based on experience running the model at scale.