Skip to contents

Wrapper function to take a location's training data and fit to the site-level model

Usage

fit_site_level_model(
  train_data,
  params,
  model_file,
  forecast_date,
  forecast_time,
  generation_interval,
  inf_to_hosp,
  infection_feedback_pmf,
  model_type,
  output_dir,
  adapt_delta,
  max_treedepth,
  seed,
  include_hosp = 1,
  compute_likelihood = 1,
  n_draws = 100,
  n_chains = 4,
  iter_sampling = 500,
  iter_warmup = 250,
  n_parallel_chains = 4,
  write_files = TRUE,
  output_full_df = FALSE,
  ...
)

Arguments

train_data

dataframe containing the hospital admissions on each day, the wastewater concentrations in each site and lab, and other metadata needed to pass to stan to run the model

params

disease-specific parameters, including hyperparameters for priors.

model_file

the compiled stan model

forecast_date

date of the forecast

forecast_time

duration of the forecast period

generation_interval

a discretized (in days) normalized pmf indexed starting at 1 of the probability of each time from initial infection to secondary transmission

inf_to_hosp

a discretized (in days) normalized pmf indexed starting at 0 of the probability of time from initial infection to hospital admissions

infection_feedback_pmf

a discretized (in days) normalized pmf that dictates the distribution of delays from incident infection to incidence feedback

model_type

name of the model being fit. Options are "site-level infection dynamics", "site-level observation error", "site-level time-varying concentration"

output_dir

location to save the model outputs

adapt_delta

dapt_delta target proposal acceptance probability for the No-U-Turn Sampler.

max_treedepth

max value in exponents of 2 of what the binary tree size in the NUTS algorithm should have

seed

random seed for the sampler

include_hosp

whether or not to include hospital admissions data in the likelihood (default = 1) to include

compute_likelihood

whether or not to include any data in the likelihood (default = 1), if set to 0 returns prior predictions

n_draws

number of draws to save in the draws.parquet, default = 100

n_chains

number of independent MCMC chains to run, default = 4

iter_sampling

number of iterations to save in MCMC sampling, default = 500

iter_warmup

number of iterations to discard in MCMC sampling, default = 250

n_parallel_chains

number of chains to run in parallel, default = 4

write_files

whether or not to save the outputs, default = 1 to save

output_full_df

whether or not to have targets return the full dataframe of draws, default = FALSE to just return a dataframe of filepaths

...

Additional named arguments (ignored) to allow do.call() on lists with additional entries

Value

a dataframe with model draws for all time points for WW concentraiton, hospitalizaitons, hosp per 100k, and the matched data