Compartmental Models
Scenario-based simulation to compare estimated latent, subclinical, and incubation rates.
Under Construction
Work in progress!
SEIIR Model
Basic model
Hide code
<- function(times, state, parameters) {
seiir_model with(as.list(c(state, parameters)), {
<- -beta * S * (I_sub + I_clin) / N
dS <- beta * S * (I_sub + I_clin) / N - sigma * E
dE <- p_sub * sigma * E - lambda * I_sub
dI_sub <- (1 - p_sub) * sigma * E + lambda * I_sub - gamma_clin * I_clin
dI_clin <- gamma_clin * I_clin
dR
<- p_sub * sigma * E
sub_inc <- (1 - p_sub) * sigma * E + lambda * I_sub
clin_inc
list(c(dS, dE, dI_sub, dI_clin, dR), sub_inc = sub_inc, clin_inc = clin_inc)
})
}
# initial values
<- c(
initial_state S = 999,
E = 1,
I_sub = 0,
I_clin = 0,
R = 0
)
# sampling distributions
<- list(
param_distributions beta_meanlog = log(0.3), beta_sdlog = 0.1, # ??
sigma_meanlog = log(1/1.3290530), sigma_sdlog = 0.1, # study average per AFT
lambda_meanlog = log(1/2.4793733), lambda_sdlog = 0.1, # study average per AFT
gamma_clin_meanlog = log(1/10.8), gamma_clin_sdlog = 0.1, # Shankar's 2019
p_sub_shape1 = 10, p_sub_shape2 = 5, # prob of I_sub -> I_clin ~0.68-0.75
N = 1000 # herd size
)
Run Simulation
Hide code
<- simulate_SEIIR_intervention(seiir_model,
full_results
param_distributions,
initial_state,n_iterations = 1000,
timesteps = 200)
Plot dynamics
Hide code
plot_seiir_dynamics(full_results$summary, plot_title = "Burn Through")
Plot incidence
Hide code
<- calculate_ratio_subclinical(full_results$summary)
ratio_out $total[2]/ratio_out$total[1] ratio_out
[1] 0.6383648
Hide code
plot_incidence_bar(full_results$summary)
Simulation with Intervention
Hide code
<- simulate_SEIIR_intervention(seiir_model,
interv_results
param_distributions,
initial_state,n_iterations = 1000,
timesteps = 200,
detect = 3, # when clinical cases >= detect, 3 per Backer 2012
vacc_effect = 0.20, # effectiveness
immune_param = c(7, 1) # mean and sd for delay before immunity
)
Time of intervention
Hide code
<- interv_results$all_results %>%
interv_time filter(I_clin >= 3) %>%
slice_head(n = 1) %>%
pull(time)
interv_time
[1] 13
Plot intervention dynamics
Hide code
plot_seiir_dynamics(interv_results$summary, plot_title = "Intervention", vline=interv_time)
Plot incidence
Hide code
<- calculate_ratio_subclinical(interv_results$summary)
ratio_out $total[2]/ratio_out$total[1] ratio_out
[1] 0.6367239
Hide code
plot_incidence_bar(interv_results$summary)