Open ben18785 opened 5 months ago
to develop this idea
"Final" structure to the wrapper functions
prepare_sero_data <- function(raw_data) {
stan_sero_data <- data.frame(n_tested, n_seropositive, year_survey, age_min, age_max) return(stan_sero_data)
}
my_data <- prepare_sero_data(my_raw_data)
set_sero_model <- function(model = "time", seroreversion = TRUE, sf_data = my_data, foi_windows = my_foi_windows) {
check_set_foi_windows <- function (sf_data, foi_windows){
# - check the foi_windows and corrects it when possible
# otherwise returns an error
return(final_foi_windows)
}
if (!exists(foi_windows)) {
# use sf_data and build a vector with consecutive birth_cohort
final_foi_windows <- data.frame (year = birth_cohort, window: 1:length(birth_cohort))
# we need to add also if model == "age" and if model == "age-time"
} else (check_set_foi_windows(foi_windows))
return(list(model = model, is_foi_log = is_foi_log, seroreversion = seroreversion, sf_data = sf_data, foi_windows = final_foi_windows))
}
my_model <- set_sero_model(model = "time", is_foi_log = TRUE, seroreversion = TRUE, sf_data = my_data, foi_windows = my_foi_windows)
set_sero_priors <- function(my_model, is_foi_log = TRUE, foi, foi_1, foi_i, seroreversion_rate, sigma_cauchy_rw, type = "RW_forward") {
return(list_of_priors_to_go_to_stan) }
my_priors <- set_sero_priors(my_model, is_foi_log = TRUE, foi, foi_1, foi_i, seroreversion_rate, sigma_cauchy_rw, type = "RW_forward")
fit_sero_model <- function(sf_model = my_model, sf_data = my_data, sf_priors = my_priors, ...) {
}
my_fit <- fit_sero_model(sf_model = my_model, sf_data = my_data, sf_priors = my_priors)
First, we set up the data:
Then we currently fit the model to the data:
Our proposed changes are:
Time-varying:
Age-varying:
Time- and age-varying: