Run Household Transmission Model
Usage
run_model(
inf_model,
obs_model,
data,
init_probs,
t_start = 1,
epsilon = 1e-10,
ih_cov = NULL,
eh_cov = NULL,
init = NULL,
save_llik = FALSE,
save_states = FALSE,
stan_opts = stan_options()
)Arguments
- inf_model
Infection process model object generated by make_infection_model
- obs_model
Observation process model object generated by make_observation_model
- data
data frame with columns the following columns:
"t", time of observation
"hh_id", numeric household ID which must be 1, 2, ..., N where N is the total number of household
"part_id", participant ID within the household which must be 1, 2, ... n where n is the number of observed household members
"hh_size", number of household members (whether observed or not)
At least one column with binary outcome information where the column name matches the outcome name provided to make_observation_model
- init_probs
vector of initial probabilities for each infection process model state
- t_start
integer value corresponding to the start of model time
- epsilon
very small number to use for zero probability transitions
- ih_cov
NULL for run without covariates, otherwise data frame with intra-household covariates for each participant
- eh_cov
NULL for run without covariates, otherwise data frame with extra-household covariates for each participant
- init
initial conditions for MCMC chains
- save_llik
whether to write the per-household log-likelihood (
llik_final) in the model's generated quantities, for use withloo/waic(defaultFALSE). WhenFALSE,llik_finalis length 0 and the extra per-household forward pass is skipped.- save_states
whether to write the per-participant log forward probabilities (
logalpha) in the model's generated quantities, for reconstructing latent state probabilities (defaultFALSE). WhenFALSE,logalphais a 0x0 matrix.- stan_opts
a named list of Stan sampler options, as produced by
stan_options()(for examplestan_options(iter = 1000)).
Examples
if (FALSE) { # interactive()
# Subset sir package data to 10 households (for speedy example)
sir_sub <- sir[sir$hh_id <= 10, ]
# Make infetion process model for SIR model
inf_mod <- make_infection_model(
transmit(from = "S", to = "I"),
progress(from = "I", to = "R", gamma = NA))
# Make observation process model
obs_mod <- make_observation_model(
pcr = c("S" = 0.05, "I" = 0.95, "R" = 0.05),
igg = c("S" = 0.01, "I" = 0.01, "R" = 0.8))
# Fitting the Stan model is slow, so it is not run on CRAN.
# \donttest{
run_model(inf_model = inf_mod,
obs_model = obs_mod,
data = sir_sub,
init_probs = c(1 - 2 * 1e-10, 1e-10, 1e-10))
# }
}