Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add seasonal/perennial vector mix example to set_carrying_capacity vignette #329

Open
pwinskill opened this issue Jul 29, 2024 · 0 comments
Assignees
Labels
documentation Improvements or additions to documentation

Comments

@pwinskill
Copy link
Member

The set carrying capacity help should inform the user

  1. How to recreate the internal seasonality dynamics with set_carrying_capacity()
  2. How to model a mix of seaonal and perennial vectors.

Sandbox example:

library(malariasimulation)

# Some seasonal pars
g0 <- 0.284596
g <- c(-0.317878, -0.0017527, 0.116455)
h <- c(-0.331361, 0.293128, -0.0617547)

# Setting seasonality the standard way
p_seasonal <- get_parameters(
  list(
    human_population = 10000,
    model_seasonality = TRUE,
    g0 = g0,
    g = g,
    h = h
  )
) |>
  set_equilibrium(init_EIR = 20)
p_seasonal$clinical_incidence_rendering_min_ages = 0
p_seasonal$clinical_incidence_rendering_max_ages = 100 * 365

s_seasonal <- run_simulation(365 * 5, p_seasonal)

# Setting seasonality via carrying capacity (dev branch version)
r <- rep(NA, 365 * 5)
for(t in 1:(365 * 5)){
  r[t] <- malariasimulation:::rainfall(
    t,
    g0,
    g,
    h,
    0.001
  )
}
r_bar <- mean(r)

p_cc <- get_parameters(
  list(
    human_population = 10000
  )
) |>
  set_carrying_capacity(
    timesteps = 1:(365 * 5),
    carrying_capacity_scalers <- 
      matrix(r / r_bar, ncol = 1)
  )  |>
  set_equilibrium(init_EIR = 20)
p_cc$clinical_incidence_rendering_min_ages = 0
p_cc$clinical_incidence_rendering_max_ages = 100 * 365

s_cc <- run_simulation(365 * 5, p_cc)

# With perennial sp alongside seasonal

sea <- malariasimulation::gamb_params
sea$species <- "seasonal"

per <- malariasimulation::gamb_params
per$species <- "perennial"

p_cc2 <- get_parameters(
  list(
    human_population = 10000
  )
) |>
  set_species(list(
    sea = sea,
    per = per
  ),
  proportions = c(0.5, 0.5)
  ) |>
  set_carrying_capacity(
    timesteps = 1:(365 * 5),
    carrying_capacity_scalers <- 
      matrix(c(r / r_bar, rep(1, length(r))), ncol = 2)
  )  |>
  set_equilibrium(init_EIR = 20)
p_cc2$clinical_incidence_rendering_min_ages = 0
p_cc2$clinical_incidence_rendering_max_ages = 100 * 365

s_cc2 <- run_simulation(365 * 5, p_cc2)


# Compare incidence
par(mfrow = c(1, 2))
# Standard seasonal
plot(s_seasonal$n_inc_clinical_0_36500, t = "l", ylab = "inc")
# Recreating seasonal with carrying capacity changes
lines(s_cc$n_inc_clinical_0_36500, col = "red")
# One seasonal and one perennial vector
lines(s_cc2$n_inc_clinical_0_36500, col = "green")

# Compare EIR
plot(s_cc2$EIR_seasonal, t = "l", ylab = "EIR")
lines(s_cc2$EIR_perennial, col = "green")

image

@pwinskill pwinskill added the documentation Improvements or additions to documentation label Jul 29, 2024
@pwinskill pwinskill self-assigned this Jul 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

1 participant