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

Example correlation diagnostics: #302

Closed
wants to merge 5 commits into from
Closed

Conversation

giovannic
Copy link
Member

I've made a test script which outputs some diagnostics for the cases you mentioned. Feel free to copy and paste/adapt to diagnose what you need.

Once you have something that might be generally useful, we could turn this into a PR to merge into dev :)

Here's an example of use:

library(malariasimulation)

month <- 30
year <- 365

# =========================================================
# testing that pev targets different people for inter round
# =========================================================

params <- get_parameters(list(
  human_population = 10000
))

params <- set_mass_pev(
  params,
  profile = rtss_profile,
  timesteps = c(5, 10),
  coverages = c(.5, .5),
  min_wait = 0,
  min_ages = 5 * month,
  max_ages = 10 * year,
  booster_spacing = c(1),
  booster_coverage = matrix(0., nrow=2), 
  booster_profile = list(rtss_booster_profile)
)

set.seed(123)

correlations <- get_correlation_parameters(params)

correlations$inter_round_rho('pev', 0)

output <- run_simulation(
  timesteps = 100,
  parameters = params,
  correlations = correlations
)

set.seed(123)

correlations <- get_correlation_parameters(params)

correlations$inter_round_rho('pev', 1)

output_2 <- run_simulation(
  timesteps = 100,
  parameters = params,
  correlations = correlations
)

print(output$n_new_vaccinations)
print(output_2$n_new_vaccinations)

# ===========================================
# testing that bednets and pev can be negatively correlated
# ===========================================

params <- get_parameters(list(
  human_population = 10000
))

params <- set_bednets(
  params,
  c(5, 10),
  coverages = c(.5, .5),
  retention = 5 * 365,
  dn0 = matrix(c(.533, .533), nrow = 2, ncol = 1),
  rn = matrix(c(.56, .56), nrow = 2, ncol = 1),
  rnm = matrix(c(.24, .24), nrow = 2, ncol = 1),
  gamman = rep(2.64 * 365, 2)
)

params <- set_mass_pev(
  params,
  profile = rtss_profile,
  timesteps = c(5, 10),
  coverages = c(.5, .5),
  min_wait = 0,
  min_ages = 5 * month,
  max_ages = 10 * year,
  booster_spacing = c(1),
  booster_coverage = matrix(0., nrow=2), 
  booster_profile = list(rtss_booster_profile)
)

set.seed(123)

correlations <- get_correlation_parameters(params)

correlations$inter_round_rho('pev', 1)
correlations$inter_round_rho('bednets', 1)
correlations$inter_intervention_rho('pev', 'bednets', 1.)

output <- run_simulation(
  timesteps = 100,
  parameters = params,
  correlations = correlations
)

set.seed(123)

correlations <- get_correlation_parameters(params)

correlations$inter_round_rho('pev', 1)
correlations$inter_round_rho('bednets', 1)
correlations$inter_intervention_rho('pev', 'bednets', -1.)

output_2 <- run_simulation(
  timesteps = 100,
  parameters = params,
  correlations = correlations
)

print(output$n_combined_pev_bednets)
print(output_2$n_combined_pev_bednets)

The outputs all look good!

  [1]   0   0   0   0   0   0   0   0   0 926   0   0   0   0   0   0   0   0
 [19]   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0
 [37]   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0
 [55]   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0
 [73]   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0
 [91]   0   0   0   0   0   0   0   0   0   0
  [1]    0    0    0    0    0    0    0    0    0 1789    0    0    0    0    0
 [16]    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
 [31]    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
 [46]    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
 [61]    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
 [76]    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
 [91]    0    0    0    0    0    0    0    0    0    0
  [1]    0    0    0    0    0 1830 1830 1830 1830 1827 1833 1833 1832 1832 1830
 [16] 1826 1824 1823 1823 1820 1820 1820 1819 1817 1815 1814 1812 1811 1811 1811
 [31] 1808 1806 1804 1802 1800 1798 1798 1796 1796 1794 1793 1792 1790 1788 1786
 [46] 1783 1782 1781 1778 1778 1778 1776 1775 1772 1772 1770 1769 1768 1767 1766
 [61] 1765 1765 1764 1762 1762 1762 1761 1760 1758 1758 1756 1755 1754 1753 1751
 [76] 1751 1749 1747 1746 1745 1742 1742 1741 1740 1740 1739 1739 1737 1737 1736
 [91] 1734 1734 1732 1730 1730 1729 1726 1725 1724 1722
  [1] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
 [38] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
 [75] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

Changes to malariasimulation:

  • Some utility functions for outputting combined intervention counts
  • Some outputs for diagnosing inter round correlation issues

 * Some utility functions for outputting combined intervention counts
 * Some outputs for diagnosing inter round correlation issues
@giovannic giovannic requested a review from htopazian May 8, 2024 16:06
htopazian added 4 commits May 9, 2024 20:07
- separated drug_time, smc_time, mda_time
- the n_spray at the current timestep
- spray_last_year the number with spraying over the last 365 timesteps
@giovannic
Copy link
Member Author

Closing due to inactivity

@giovannic giovannic closed this Jul 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants