generate_stwa_draws: Create post-estimation predictive draws

Description Usage Arguments Value

Description

Given the outputs from a fitted TMB model object, create an object with posterior predictive draws for all groupings specified by a template data.table

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
generate_stwa_draws(
  tmb_sdreport,
  keep_params,
  num_draws,
  covariate_names,
  template_dt,
  rescale_covars = FALSE,
  covar_scaling_factors = NULL,
  fourier_harmonics_level = NULL,
  fourier_stationary = TRUE
)

Arguments

tmb_sdreport

output of 'TMB::sdreport()' on the fitted model object. Should include a joint precision matrix (by specifying 'getJointPrecision = TRUE' in the call to 'sdreport()'). This object will be parsed to check for fixed effects, random effects, and the Fourier time series terms.

keep_params

[char] Vector of parameter names to keep when generating draws from the precision matrix. Keep only parameters needed for prediction

num_draws

[int] How many posterior predictive samples to take?

covariate_names

[char] All covariate field names, including 'intercept'

template_dt

[data.table] table containing at least the following fields: - idx_age: Zero-indexed age grouping - idx_week: Zero-indexed week grouping (typically week - 1) - idx_year: Zero-indexed year grouping (typically year - min(year)) - idx_loc: Zero-indexed location grouping - idx_fourier: Indexer for fourier analysis

rescale_covars

[bool, default TRUE] Should covariates in the template data.table be rescaled based on a set of normalizing factors?

covar_scaling_factors

[default NULL] If 'rescale_covars' is TRUE, this argument should be set to a data.table with three fields: - 'cov_name': The name of each covariate in 'covariate_names' - 'cov_mean': The mean that will be subtracted for normalization - 'cov_sd': The standard deviation that will be divided for normalization

fourier_harmonics_level

[int, default NULL] Number of levels used to fit seasonality in the model. This parameter will be ignored if there are no 'Z_fourier' parameters in the fitted output

fourier_stationary

[bool, default TRUE] Are the fitted coefficients for each seasonality curve the same across years? If FALSE, assumes that the coefficients vary by year according to an autoregressive process of order 1

Value

A named list with three items: - 'param_names': Vector of parameter names in the order they have been extracted - 'param_draws': Matrix of parameter draws - 'pred_draws': Matrix of mortality predictive draws, taken at the observation points specified in the 'template_dt'


njhenry/covidemr documentation built on Feb. 2, 2022, 2:31 a.m.