-
Notifications
You must be signed in to change notification settings - Fork 0
/
ethiopia_recalibration.R
90 lines (62 loc) · 2.71 KB
/
ethiopia_recalibration.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# title ethiopia recalibration
# author Lydia Haile
# purpose recalibrate sites in Ethiopia to match MAP prevalence after turning IRS off
library(vimcmalaria)
library(cali)
library(malariasimulation)
library(dplyr)
library(data.table)
source('J:/malaria_no_more/src/model_country/MNM_functions.R')
# vimc inputs ----
site_data<- readRDS('J:/malaria_no_more/src/model_country/site_files/ETH_new_eir.rds')
coverage_data<- read.csv('J:/malaria_no_more/src/model_country/coverage_80.csv')
# turn IRS coverage off
site_data$interventions$irs_cov = 0
# write recalibration function for each site of ethiopia
recalibrate<- function(site){
model_input <- parameterise_mnm(
site_name = site,
ur = 'both',
iso3c = 'ETH',
site_data = site_data,
coverage_data,
scenario = 'vaccine_scaleup'
)
summary_mean_pfpr_2_10 <- function (x) {
message('calibrating')
x<- data.table(x)
# Calculate the PfPR2-10:
prev_2_10 <- mean(x[timestep %in% c((11*365):(12*365))]$n_detect_pcr_730_3649/x[timestep %in% c((11*365):(12* 365))]$n_730_3649) # average over a year
# Return the calculated PfPR2-10:
return(prev_2_10)
}
# pull target pfpr from 2010 for corresponding site
target_pfpr <- site_data$prevalence |> filter(year == 2011, name_1 == site) |> pull(pfpr)
print(paste0('target pfpr ', target_pfpr ))
# Add a parameter to the parameter list specifying the number of timesteps
simparams<- model_input$param_list
simparams$timesteps <- 15 * 365
# Establish a tolerance value:
pfpr_tolerance <- 0.01
# Set upper and lower EIR bounds for the calibrate function to check
lower_EIR <- 0.2
upper_EIR <- 1
# Run the calibrate() function:
cali_EIR <- cali::calibrate(target = target_pfpr,
summary_function = summary_mean_pfpr_2_10,
parameters = simparams,
tolerance = pfpr_tolerance,
low = lower_EIR, high = upper_EIR)
print(paste0('calibrated EIR for site ', site, ' :', cali_EIR))
simparams<- set_equilibrium(simparams, init_EIR = cali_EIR)
saveRDS(simparams, paste0('calibrated_site_', site, '.rds'))
}
simparams$progress_bar<- TRUE
output_calibrated<- run_simulation(timesteps = simparams$timesteps, parameters = simparams)
ggplot(data= output_calibrated, mapping = aes(x= timestep/365 + 2000, y= (n_detect_pcr_730_3649/ n_730_3649)))+
geom_point() +
geom_line(data= site_pfpr, mapping = aes(x= year, y= pfpr), color= 'blue')
# pull target pfpr from 2010 for corresponding site
site_pfpr <- site_data$prevalence |> filter(name_1 == site)
ggplot(data= site_pfpr, mapping = aes(x= year, y= pfpr))+
geom_line(data= site_pfpr, mapping = aes(x= year, y= pfpr), color= 'blue')