Skip to content

Commit

Permalink
Minor adjustments for worked example D
Browse files Browse the repository at this point in the history
  • Loading branch information
KeithJF82 committed Jun 20, 2024
1 parent 01953ac commit 9e1b447
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 12 deletions.
4 changes: 2 additions & 2 deletions R/main.R
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,8 @@ Model_Run_Many_Reps <- function(FOI_spillover = 0.0, R0 = 1.0, vacc_data = list(
parameter_setup <- function(FOI_spillover = 0.0, R0 = 1.0, vacc_data = list(), pop_data = list(), year0 = 1940,
years_data = c(1941:1942), mode_start = 0, vaccine_efficacy = 1.0, start_SEIRV = list(), dt = 1.0){

assert_that(FOI_spillover>0.0)
assert_that(R0>0.0)
assert_that(FOI_spillover>=0.0)
assert_that(R0>=0.0)
assert_that(length(pop_data[, 1])>1, msg = "Need population data for multiple years")
assert_that(length(pop_data[1, ])>1, msg = "Need population data for multiple age groups")
n_years = length(pop_data[, 1])-1
Expand Down
Binary file modified src/YEP.dll
Binary file not shown.
Binary file modified src/cpp11.o
Binary file not shown.
14 changes: 4 additions & 10 deletions vignettes/BWorkedExampleDMCMC.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,6 @@ log_params_ini <- c(log(enviro_coeffs_ini), log(c(0.1,0.2)))
filename_prefix <- "Chain"
#Number of iterations to run
Niter <- 1
# Type of parameter set used to calculate spillover FOI and R0 (here both
# calculated from environmental covariates)
type <- "FOI+R0 enviro"
# Flag indicating how to set initial population immunity level
mode_start <- 1
# Type of prior likelihood calculation to use
Expand All @@ -71,26 +68,23 @@ n_reps <- 5
p_severe_inf = 0.12
# Probability of an infection with severe symptoms causing death
p_death_severe_inf = 0.39
# Fixed R0 values (here set to NULL because R0 is variable)
R0_fixed_values = NULL
# Additional values: severe and fatal case reporting probability are set to NULL due to being estimated
# as variables; vaccine efficacy and Brazil spillover FOI multiplier set to 1.0 as constants.
add_values=list(p_rep_severe = NULL, p_rep_death = NULL, vaccine_efficacy = 1.0, m_FOI_Brazil = 1.0)
add_values=list(p_rep_severe = NA, p_rep_death = NA, vaccine_efficacy = 1.0, m_FOI_Brazil = 1.0)
# True/false flag indicating whether or not to run model in deterministic mode
# (so that binomial calculations give average instead of randomized output)
deterministic = FALSE
# Variable to set different modes for running on multiple processors simultaneously;
# here set to "none" so that parallel processing is not used
mode_parallel="none"
mode_parallel=FALSE
```

We then run the MCMC() function. Output data recorded at each iteration is saved to an output file every 10 iterations. Likelihood is calculated as described in Guide 4 [Link TBA].

```{r,eval=FALSE}
MCMC(log_params_ini, input_data, obs_sero_data, obs_case_data, filename_prefix,
Niter, type, mode_start, prior_settings, dt,
n_reps, enviro_data, R0_fixed_values, p_severe_inf, p_death_severe_inf,
add_values, deterministic,mode_parallel,NULL)
Niter, mode_start, prior_settings, dt, n_reps, enviro_data, p_severe_inf,
p_death_severe_inf, add_values, deterministic,mode_parallel,NULL)
```

The saved output of MCMC() takes the form of a data frame of values of the current likelihood (posterior_current), likelihood calculated from proposed parameter values (posterior_prop), current and proposed parameter values, a flag indicating whether the proposed parameter values were accepted (set to 1 if they were accepted, 0 if they were not), and the chain covariance.
Expand Down

0 comments on commit 9e1b447

Please sign in to comment.