-
Notifications
You must be signed in to change notification settings - Fork 4
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
Tutorial: Porting An Existing Model (Influenza-Epidemia) To MSR #162
Tutorial: Porting An Existing Model (Influenza-Epidemia) To MSR #162
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #162 +/- ##
=======================================
Coverage 93.43% 93.43%
=======================================
Files 38 38
Lines 1005 1005
=======================================
Hits 939 939
Misses 66 66
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
…to 135-UPX3-instantiate-cfas-epidemia-for-flu-model-via-msr
Would appreciate some Why thoughts on the following settings: day_of_week_effect_prior_modes = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
day_of_week_effect_prior_scales = [0.25, 0.25, 0.25, 0.25, 0.25, 0.25]
holiday_eff_prior_mode = -0.2
holiday_eff_prior_scale = 0.2
post_holiday_eff_prior_mode = 0.0
post_holiday_eff_prior_scale = 0.2
recency_eff_prior_mode = 0.0
recency_eff_prior_scale = 0.1
recency_effect_length = 0
generation_time_dist = [0.233, 0.359, 0.198, 0.103, 0.053, 0.027, 0.014, 0.007, 0.003, 0.002, 0.001]
ihr_intercept_prior_mode = -6.5
ihr_intercept_prior_scale = 0.5
inf_model_prior_infections_per_capita = 0.0001
inf_model_seeds = 8
inf_to_hosp_dist = [0.05, 0.1, 0.175, 0.225, 0.175, 0.125, 0.075, 0.05, 0.025]
max_rt = 3.0
n_pre_observation_days = 14
non_obs_effect_prior_mode = -50
non_obs_effect_prior_scale = 0.01
reciprocal_dispersion_prior_mode = 10
reciprocal_dispersion_prior_scale = 5
reference_day_of_week = 4
rt_intercept_prior_mode = -0.4054651
rt_intercept_prior_scale = 0.3
seed = 54321
susceptible_fraction_prior_mode = 0.9
susceptible_fraction_prior_scale = 0.1
weekly_rw_prior_scale = 0.25
first_fitting_date = "2023-09-15"
[mcmc]
adapt_delta = 0.9
max_treedepth = 12
n_chains = 1
n_warmup = 1000
n_iter = 2000 Apologies for not putting this question here sooner. I do not know why I bottled it in my markdown file. |
Transmission ComponentI would also appreciate some thoughts on my attempted description of the transmission component of In where The link function for with where Original R code for reference: build_light_rt <- function(rt_intercept_prior_mode,
rt_intercept_prior_scale,
max_rt,
rw_prior_scale) {
rt_model <- epidemia::epirt(
formula = as.formula(
sprintf(
paste0(
"R(location, date) ~ 1 + ",
"rw(time = week, gr = location, prior_scale = %f)"
),
rw_prior_scale
)
),
prior_intercept = rstanarm::normal(
location = rt_intercept_prior_mode,
scale = rt_intercept_prior_scale
),
link = epidemia::scaled_logit(K = max_rt)
)
return(rt_model)
} |
Observation ComponentSimilar to above, would appreciate some thoughts on the veracity of the following description: NOTE: As of 2024-07-09, the below is a "corrected" description. Proceeding, each US territory has is own time series of observed influenza hospitalizations This distribution is not fixed; rather, it is determined by the Since Note that since The expected value for the observed influenza hospitalizations on day with
Within
We have: where
Within given the selected value for The corresponding code in build_light_obs <- function(inf_to_hosp_dist,
ihr_intercept_prior_mode,
ihr_intercept_prior_scale,
day_of_week_eff_prior_modes,
day_of_week_eff_prior_scales,
holiday_eff_prior_mode,
holiday_eff_prior_scale,
post_holiday_eff_prior_mode,
post_holiday_eff_prior_scale,
non_obs_effect_prior_mode,
non_obs_effect_prior_scale,
inv_dispersion_prior_mode,
inv_dispersion_prior_scale,
link = "logit") {
return(epidemia::epiobs(
formula = as.formula(paste0(
"hosp ~ 1 + day_of_week + ",
"is_holiday + ",
"is_post_holiday + ",
"nonobservation_period"
)),
## Add a covariate for the
## nonobservation window to
## leave an initial evolution
## period with no observations
i2o = inf_to_hosp_dist,
link = link,
family = "neg_binom",
prior_intercept = rstanarm::normal(
location = ihr_intercept_prior_mode,
scale = ihr_intercept_prior_scale
),
prior = rstanarm::normal(
location = c(
day_of_week_eff_prior_modes,
holiday_eff_prior_mode,
post_holiday_eff_prior_mode,
non_obs_effect_prior_mode
),
## a large negative non_obs_effect
## effectively conditions on detection
## prob = 0 outside the observation period
scale = c(
day_of_week_eff_prior_scales,
holiday_eff_prior_scale,
post_holiday_eff_prior_scale,
non_obs_effect_prior_scale
## non-obs prior scale
## should be small to
## enforce non-obs effect
## close to (large negative) mode
)
),
prior_aux = rstanarm::normal(
location = inv_dispersion_prior_mode,
scale = inv_dispersion_prior_scale
)
))
} |
@AFg6K7h4fhy2 terminology edits only for the post on the |
Comments on the observation component description
Should state explicitly that
Suggest reported hospitalizations
Suggest modeled by a linear model with a logit link
linear prediction
Need to include the predictor variables, not just the coefficients:
## make sure day_of_week is properly
## set up as a factor
dow_levels <- levels(
lubridate::wday("2023-01-01",
label = TRUE,
week_start = params$reference_day_of_week
)
)
clean_data <- clean_data |>
dplyr::mutate(
day_of_week = factor(day_of_week,
ordered = FALSE,
levels = dow_levels
)
) |
…cfas-epidemia-for-flu-model-via-msr
…cfas-epidemia-for-flu-model-via-msr
…cfas-epidemia-for-flu-model-via-msr
…cfas-epidemia-for-flu-model-via-msr
…cfas-epidemia-for-flu-model-via-msr
NOTE: This is currently a work in progress. I've committed a skeleton of the Quarto tutorial but need to continuing finishing the implementation in Python before porting over more and then writing in detail. Consider this draft PR and its initial commit a placeholder.
Recall the goal from the corresponding issue:
And also recall the desired features: