Wastewater and infection renewal
The data are CDC's public simulated example: wastewater RNA concentrations from a catchment of 400,000 people and daily hospital admissions in a state of 3,000,000 people. We use site 1 and the first 35 calendar days, from 1 September through 5 October 2023. Each wastewater record carries its sampling date, laboratory and detection limit; hospital records occupy a separate daily axis. The remaining state population has no wastewater observations. These are synthetic observations published by CDC's ww-inference-model, not measurements from a named community. The input tables and their exact source revision are linked under Reproduce.
Model
A shared weekly log reproduction number drives daily infection renewal. Each subpopulation follows that reference with its own stationary AR(1) deviation. Recent infections contribute infectiousness through a fixed generation-interval probability mass function. A feedback term attenuates the reproduction number as recent incidence increases:
Here incidence is a daily population fraction. The reference has zero subpopulation deviation; its trajectory therefore anchors the hierarchy. Fifty unobserved days provide an exponentially seeded history before the first observation. Seven further days allow the fitted process to continue into a forecast. Neither the unobserved history nor the forecast contributes an extra observation likelihood.
The renewal recurrence is an ordinary StanBlocks function. This is the code the model calls, read from its source during the build:
renewal_feedback(logRt::vector[nt], g::vector[ng], gamma::real, I0::real,
r::real, n_seed::int)::vector[nt] = begin
I::vector[nt]
for t in 1:nt
if t <= n_seed
I[t] = I0 * exp(r * (t - 1))
else
conv = 0.0
for s in 1:ng
prev = t - s >= 1 ? I[t - s] : 0.0
conv = conv + g[s] * prev
end
Rt = exp(logRt[t]) * exp(-gamma * conv)
I[t] = Rt * conv
end
end
I
endThe @brm declaration keeps the population hierarchy, priors and observation families together. Its plate produces the infection trajectory of each subpopulation. Separate indexing arrays then connect each observed sample to the appropriate day, catchment and laboratory. Repeated measurements can share one latent infection value without duplicating that state.
Wastewater and hospital admissions
panes: brm|stanblocks|rkppl|stan|jax:2function cdc_ww_brm_model(df = cdc_ww_brm_fixture())
@brm df begin
# Shared epidemic parameters. `dar` owns the zero-start differenced-AR
# innovations while the intercept remains the initial weekly log-Rᵘ level.
gamma ~ LogNormal(-4.0, 0.5)
phi_delta ~ Beta(2.0, 8.0)
sigma_delta ~ Exponential(4.0)
log10_g ~ Normal(12.0, 1.0)
t_peak ~ LogNormal(log(4.0), 0.25)
viral_peak ~ Normal(6.0, 1.0)
shed_tail ~ LogNormal(log(14.0), 0.3)
dur_shed = t_peak + shed_tail
shedding = viral_shedding_trajectory(t_peak, viral_peak, dur_shed, nsh)
log_ru_week ~ 1 + dar(week_grid; p = 1)
effect(log_ru_week, Intercept) ~ Normal(0.0, 0.5)
log_ru = weekly_expand(log_ru_week, week_idx)
# Hierarchical incidence and initial growth are defined over the latent
# subpopulation axis, including the uncovered reference population.
logit_I0 ~ 1 + (1 | initial | subpopulation)
initial_growth ~ 1 + (1 | growth | subpopulation)
effect(logit_I0, Intercept) ~ Normal(-9.0, 1.0)
effect(initial_growth, Intercept) ~ Normal(0.0, 0.05)
sd(:, initial) ~ Normal(0.0, 0.75)
sd(:, growth) ~ Normal(0.0, 0.05)
# The plate produces latent trajectories only, one per subpopulation.
# Observation frames are mapped onto this matrix after the plate.
@plate for k in eachindex(logit_I0)
eps_d ~ Normal(zeros(n_total), 1.0) # this subpopulation's daily innovations
delta_k = ar1_dev(eps_d, phi_delta, sigma_delta)
log_rt_k = log_ru .+ (1.0 - is_reference[k]) .* delta_k
I_mat[k] = renewal_from_first_observed(log_rt_k, g, gamma,
logistic(logit_I0[k]), initial_growth[k], uot)
end
# Sparse wastewater records have independent time, subpopulation, lab
# and record-specific LOD mappings. Multiple labs may observe the same
# catchment/time pair; the reference population may have no records.
log_lab_mod ~ 0 + (1 | ww_scale | ww_lab)
log_sigma_ww ~ 1 + (1 | ww_noise | ww_lab)
effect(log_sigma_ww, Intercept) ~ Normal(log(0.35), 0.5)
sd(:, ww_scale) ~ Normal(0.0, 0.5)
sd(:, ww_noise) ~ Normal(0.0, 0.35)
ww_mu = ww_expected_log(I_mat, shedding, ww_time, ww_subpop, ww_obs_lab,
log_lab_mod, log10_g, mwpd)
ww_sigma = gather_exp(log_sigma_ww, ww_obs_lab)
ww_log_conc ~ censored(Normal(ww_mu, ww_sigma); lower = ww_lod)
# jurisdiction aggregate infections (population-weighted across subpops)
I_agg = wsum(I_mat, w)
# Count-stream module. Each stream gets a hierarchical rate center and a
# stationary weekly AR deviation. Observation rows can be daily or span
# arbitrary inclusive intervals and can map different latent catchments.
phi_count ~ Beta(2.0, 8.0)
sigma_count ~ Exponential(20.0)
count_rate_center ~ 1 + (1 | count_rate | count_stream)
effect(count_rate_center, Intercept) ~ Normal(-4.6, 0.3)
sd(:, count_rate) ~ Normal(0.0, 0.5)
@plate for s in eachindex(count_rate_center)
eps_count ~ Normal(zeros(n_weeks), 1.0) # this stream's weekly innovations
count_rate_week[s] = count_rate_center[s] .+ ar1_dev(eps_count, phi_count, sigma_count)
end
count_rate_daily = weekly_expand_columns(count_rate_week, week_idx)
dow_share ~ Dirichlet(7, 5.0)
dow_effect = scale_simplex(dow_share, 7.0)
log_phi_count ~ 1 + (1 | count_dispersion | count_stream)
effect(log_phi_count, Intercept) ~ Normal(log(15.0), 0.5)
sd(:, count_dispersion) ~ Normal(0.0, 0.5)
count_mu = count_interval_mean(I_mat, count_subpop_weights, count_delay,
count_rate_daily, count_start, count_stop,
count_obs_stream, dow, dow_effect,
count_population)
count_phi = gather_exp(log_phi_count, count_obs_stream)
count ~ NegativeBinomial2(count_mu, count_phi)
# Forecast contract: named deterministic carriers use the same fitted
# latent state and observation mappings but are not calibration outcomes.
forecast_infections = take_window(I_agg, uot + nt + 1, ht)
forecast_count_mean = count_interval_mean(
I_mat, count_subpop_weights, count_delay, count_rate_daily,
forecast_count_start, forecast_count_stop,
forecast_count_obs_stream, dow, dow_effect, count_population)
forecast_ww_log_mean = ww_expected_log(
I_mat, shedding, forecast_ww_time, forecast_ww_subpop,
forecast_ww_obs_lab, log_lab_mod, log10_g, mwpd)
end
end
function wastewater_public_model(data=wastewater_public_data())
cdc_ww_brm_model(data)
endSBBRMI with data keys = [:count, :count_delay, :count_obs_stream, :count_population, :count_start, :count_stop, :count_stream_idx, :count_subpop_weights, :dow, :dow_share_alpha, :forecast_count_obs_stream, :forecast_count_start, :forecast_count_stop, :forecast_ww_obs_lab, :forecast_ww_subpop, :forecast_ww_time, :g, :ht, :is_reference, :kernel_nsub_I_mat, :kernel_nsub_count_rate_week, :mwpd, :n_count_stream, :n_subpopulation, :n_terms_count_dispersion_count_stream, :n_terms_count_rate_count_stream, :n_terms_growth_subpopulation, :n_terms_initial_subpopulation, :n_terms_ww_noise_ww_lab, :n_terms_ww_scale_ww_lab, :n_total, :n_weeks, :n_ww_lab, :nsh, :nt, :subpopulation_idx, :uot, :w, :week_grid, :week_idx, :ww_lab_idx, :ww_lod, :ww_log_conc, :ww_obs_lab, :ww_subpop, :ww_time]
configured submodels:
ranef_correlated_draws_single_margin_1 = Base.merge(BayesianRegressionModels._sb_single_margin_ranef(BayesianRegressionModels.ranef_correlated_draws), quote
tau ~ (StanBlocks.builtin.restricted)(normal, 0.0, 0.75; n = n_terms, lower = 0.0)
end)
ranef_correlated_draws_single_margin_2 = Base.merge(BayesianRegressionModels._sb_single_margin_ranef(BayesianRegressionModels.ranef_correlated_draws), quote
tau ~ (StanBlocks.builtin.restricted)(normal, 0.0, 0.05; n = n_terms, lower = 0.0)
end)
ranef_correlated_draws_single_margin_3 = Base.merge(BayesianRegressionModels._sb_single_margin_ranef(BayesianRegressionModels.ranef_correlated_draws), quote
tau ~ (StanBlocks.builtin.restricted)(normal, 0.0, 0.5; n = n_terms, lower = 0.0)
end)
ranef_correlated_draws_single_margin_4 = Base.merge(BayesianRegressionModels._sb_single_margin_ranef(BayesianRegressionModels.ranef_correlated_draws), quote
tau ~ (StanBlocks.builtin.restricted)(normal, 0.0, 0.35; n = n_terms, lower = 0.0)
end)
emitted @slic body:
begin
b_initial_subpopulation ~ ranef_correlated_draws_single_margin_1(; group_idx = subpopulation_idx, n_groups = n_subpopulation, n_terms = n_terms_initial_subpopulation)
b_growth_subpopulation ~ ranef_correlated_draws_single_margin_2(; group_idx = subpopulation_idx, n_groups = n_subpopulation, n_terms = n_terms_growth_subpopulation)
b_ww_scale_ww_lab ~ ranef_correlated_draws_single_margin_3(; group_idx = ww_lab_idx, n_groups = n_ww_lab, n_terms = n_terms_ww_scale_ww_lab)
b_ww_noise_ww_lab ~ ranef_correlated_draws_single_margin_4(; group_idx = ww_lab_idx, n_groups = n_ww_lab, n_terms = n_terms_ww_noise_ww_lab)
b_count_rate_count_stream ~ ranef_correlated_draws_single_margin_3(; group_idx = count_stream_idx, n_groups = n_count_stream, n_terms = n_terms_count_rate_count_stream)
b_count_dispersion_count_stream ~ ranef_correlated_draws_single_margin_3(; group_idx = count_stream_idx, n_groups = n_count_stream, n_terms = n_terms_count_dispersion_count_stream)
gamma ~ lognormal(-4.0, 0.5)
phi_delta ~ beta(2.0, 8.0)
sigma_delta ~ exponential(1.0 ./ 4.0)
log10_g ~ normal(12.0, 1.0)
t_peak ~ lognormal(1.3862943611198906, 0.25)
viral_peak ~ normal(6.0, 1.0)
shed_tail ~ lognormal(2.6390573296152584, 0.3)
dur_shed = (+)(t_peak, shed_tail)
shedding = (Main.wastewater.viral_shedding_trajectory)(t_peak, viral_peak, dur_shed, nsh)
X_log_ru_week = hcat(rep_vector(1.0, num_elements(week_grid)))
pop_log_ru_week ~ _popefs_normal(; X = X_log_ru_week, beta_loc = [0.0], beta_scale = [0.5])
dar_log_ru_week_week_grid ~ _sb_dar1(; time = week_grid)
log_ru_week = pop_log_ru_week + dar_log_ru_week_week_grid
log_ru = (Main.wastewater.weekly_expand)(log_ru_week, week_idx)
X_logit_I0 = hcat(rep_vector(1.0, num_elements(subpopulation_idx)))
pop_logit_I0 ~ _popefs_normal(; X = X_logit_I0, beta_loc = [-9.0], beta_scale = [1.0])
r_logit_I0_initial_subpopulation = b_initial_subpopulation[subpopulation_idx, 1]
logit_I0 = pop_logit_I0 + r_logit_I0_initial_subpopulation
X_initial_growth = hcat(rep_vector(1.0, num_elements(subpopulation_idx)))
pop_initial_growth ~ _popefs_normal(; X = X_initial_growth, beta_loc = [0.0], beta_scale = [0.05])
r_initial_growth_growth_subpopulation = b_growth_subpopulation[subpopulation_idx, 1]
initial_growth = pop_initial_growth + r_initial_growth_growth_subpopulation
r_log_lab_mod_ww_scale_ww_lab = b_ww_scale_ww_lab[ww_lab_idx, 1]
log_lab_mod = r_log_lab_mod_ww_scale_ww_lab
X_log_sigma_ww = hcat(rep_vector(1.0, num_elements(ww_lab_idx)))
pop_log_sigma_ww ~ _popefs_normal(; X = X_log_sigma_ww, beta_loc = [-1.0498221244986778], beta_scale = [0.5])
r_log_sigma_ww_ww_noise_ww_lab = b_ww_noise_ww_lab[ww_lab_idx, 1]
log_sigma_ww = pop_log_sigma_ww + r_log_sigma_ww_ww_noise_ww_lab
ww_sigma = (Main.wastewater.gather_exp)(log_sigma_ww, ww_obs_lab)
phi_count ~ beta(2.0, 8.0)
sigma_count ~ exponential(1.0 ./ 20.0)
X_count_rate_center = hcat(rep_vector(1.0, num_elements(count_stream_idx)))
pop_count_rate_center ~ _popefs_normal(; X = X_count_rate_center, beta_loc = [-4.6], beta_scale = [0.3])
r_count_rate_center_count_rate_count_stream = b_count_rate_count_stream[count_stream_idx, 1]
count_rate_center = pop_count_rate_center + r_count_rate_center_count_rate_count_stream
dow_share ~ dirichlet(dow_share_alpha)
dow_effect = (Main.wastewater.scale_simplex)(dow_share, 7.0)
X_log_phi_count = hcat(rep_vector(1.0, num_elements(count_stream_idx)))
pop_log_phi_count ~ _popefs_normal(; X = X_log_phi_count, beta_loc = [2.70805020110221], beta_scale = [0.5])
r_log_phi_count_count_dispersion_count_stream = b_count_dispersion_count_stream[count_stream_idx, 1]
log_phi_count = pop_log_phi_count + r_log_phi_count_count_dispersion_count_stream
count_phi = (Main.wastewater.gather_exp)(log_phi_count, count_obs_stream)
I_mat ~ plate(logit_I0, is_reference, initial_growth; outer = (kernel_nsub_I_mat,)) do logit_I0, is_reference, initial_growth
#= brm-docs-example.jl:31 =#
eps_d ~ normal(rep_vector(0.0, n_total), 1.0)
#= brm-docs-example.jl:32 =#
delta_k = ar1_dev(eps_d, phi_delta, sigma_delta)
#= brm-docs-example.jl:33 =#
log_rt_k = log_ru .+ (1.0 - is_reference) .* delta_k
#= brm-docs-example.jl:34 =#
renewal_from_first_observed(log_rt_k, g, gamma, inv_logit(logit_I0), initial_growth, uot)
#= brm-docs-example.jl:36 =#
end
ww_mu = (Main.wastewater.ww_expected_log)(I_mat, shedding, ww_time, ww_subpop, ww_obs_lab, log_lab_mod, log10_g, mwpd)
ww_log_conc ~ censored(normal, ww_mu, ww_sigma; lower = ww_lod)
I_agg = (Main.wastewater.wsum)(I_mat, w)
forecast_infections = (Main.wastewater.take_window)(I_agg, (+)(uot, nt, 1), ht)
forecast_ww_log_mean = (Main.wastewater.ww_expected_log)(I_mat, shedding, forecast_ww_time, forecast_ww_subpop, forecast_ww_obs_lab, log_lab_mod, log10_g, mwpd)
count_rate_week ~ plate(count_rate_center; outer = (kernel_nsub_count_rate_week,)) do count_rate_center
#= brm-docs-example.jl:63 =#
eps_count ~ normal(rep_vector(0.0, n_weeks), 1.0)
#= brm-docs-example.jl:64 =#
count_rate_center .+ ar1_dev(eps_count, phi_count, sigma_count)
#= brm-docs-example.jl:65 =#
end
count_rate_daily = (Main.wastewater.weekly_expand_columns)(count_rate_week, week_idx)
count_mu = (Main.wastewater.count_interval_mean)(I_mat, count_subpop_weights, count_delay, count_rate_daily, count_start, count_stop, count_obs_stream, dow, dow_effect, count_population)
count ~ neg_binomial_2(count_mu, count_phi)
forecast_count_mean = (Main.wastewater.count_interval_mean)(I_mat, count_subpop_weights, count_delay, count_rate_daily, forecast_count_start, forecast_count_stop, forecast_count_obs_stream, dow, dow_effect, count_population)
end"""
Group-level (varying) effects of grouping `g`.
Non-centered, from the scale `tau[1]` (drawn from its prior) and standardized effects
`z[1:length(levels(g)), 1:1] ~ Normal(0, 1)`. Returns the
level-by-margin matrix `z .* tau[1]`, one row per level of `g` in order.
"""
brm_group_effects(g) = begin
tau[1:1] .~ restricted.(Normal(0.0, 0.75), 0.0, Inf)
z[1:length(levels(g)), 1:1] .~ Normal.(0, 1)
return z .* tau[1]
end
"""
Group-level (varying) effects of grouping `g`.
Non-centered, from the scale `tau[1]` (drawn from its prior) and standardized effects
`z[1:length(levels(g)), 1:1] ~ Normal(0, 1)`. Returns the
level-by-margin matrix `z .* tau[1]`, one row per level of `g` in order.
"""
brm_group_effects_(g) = begin
tau[1:1] .~ restricted.(Normal(0.0, 0.05), 0.0, Inf)
z[1:length(levels(g)), 1:1] .~ Normal.(0, 1)
return z .* tau[1]
end
"""
Group-level (varying) effects of grouping `g`.
Non-centered, from the scale `tau[1]` (drawn from its prior) and standardized effects
`z[1:length(levels(g)), 1:1] ~ Normal(0, 1)`. Returns the
level-by-margin matrix `z .* tau[1]`, one row per level of `g` in order.
"""
brm_group_effects__(g) = begin
tau[1:1] .~ restricted.(Normal(0.0, 0.5), 0.0, Inf)
z[1:length(levels(g)), 1:1] .~ Normal.(0, 1)
return z .* tau[1]
end
"""
Group-level (varying) effects of grouping `g`.
Non-centered, from the scale `tau[1]` (drawn from its prior) and standardized effects
`z[1:length(levels(g)), 1:1] ~ Normal(0, 1)`. Returns the
level-by-margin matrix `z .* tau[1]`, one row per level of `g` in order.
"""
brm_group_effects___(g) = begin
tau[1:1] .~ restricted.(Normal(0.0, 0.35), 0.0, Inf)
z[1:length(levels(g)), 1:1] .~ Normal.(0, 1)
return z .* tau[1]
end
"""
A differenced AR(1) level path over `T` steps (`dar`).
Draws the persistence `beta` and innovation scale `sigma` from their priors.
The path starts at `level[1] = increment[1] = 0`; then
`increment[t] = beta * increment[t - 1] + sigma * innovation` with
`innovation ~ Normal(0, 1)`, and `level[t] = level[t - 1] + increment[t]`.
Returns the level path `level`.
"""
brm_differenced_ar1(T) = begin
beta ~ truncated(Normal(0.5, 0.2), 0, 1)
sigma ~ HalfNormal(0.2)
@scan begin
level[1] = 0.0
increment[1] = 0.0
for t = 2:T
innovation ~ Normal(0, 1)
increment[t] = beta * increment[t - 1] + sigma * innovation
level[t] = level[t - 1] + increment[t]
end
end
return level
end
"""
A plate's cell values, concatenated in cell order.
Scalar cells are returned as they are; vector cells are joined with
`reduce(vcat, cells)` (an empty vector when there are no cells).
"""
ReactiveKernels.@kernel(flatten_cells(cells) = begin
values = if eltype(cells) <: Number
cells
else
if eltype(cells) <: AbstractVector
if isempty(cells)
(eltype(eltype(cells)))[]
else
reduce(vcat, cells)
end
else
brm_flatten_cells(cells)
end
end
return values
end)
begin
subpopulation_fit_levels = brm_fit_levels(subpopulation_fit)
ww_lab_fit_levels = brm_fit_levels(ww_lab_fit)
count_stream_fit_levels = brm_fit_levels(count_stream_fit)
b_initial_subpopulation ~ brm_group_effects(subpopulation_fit_levels)
subpopulation_level = brm_level_indices(subpopulation, subpopulation_fit_levels)
ranef_logit_I0_initial_subpopulation = b_initial_subpopulation[subpopulation_level, 1]
b_growth_subpopulation ~ brm_group_effects_(subpopulation_fit_levels)
ranef_initial_growth_growth_subpopulation = b_growth_subpopulation[subpopulation_level, 1]
b_ww_scale_ww_lab ~ brm_group_effects__(ww_lab_fit_levels)
ww_lab_level = brm_level_indices(ww_lab, ww_lab_fit_levels)
ranef_log_lab_mod_ww_scale_ww_lab = b_ww_scale_ww_lab[ww_lab_level, 1]
b_ww_noise_ww_lab ~ brm_group_effects___(ww_lab_fit_levels)
ranef_log_sigma_ww_ww_noise_ww_lab = b_ww_noise_ww_lab[ww_lab_level, 1]
b_count_rate_count_stream ~ brm_group_effects__(count_stream_fit_levels)
count_stream_level = brm_level_indices(count_stream, count_stream_fit_levels)
ranef_count_rate_center_count_rate_count_stream = b_count_rate_count_stream[count_stream_level, 1]
b_count_dispersion_count_stream ~ brm_group_effects__(count_stream_fit_levels)
ranef_log_phi_count_count_dispersion_count_stream = b_count_dispersion_count_stream[count_stream_level, 1]
dar_log_ru_week_week_grid_level ~ brm_differenced_ar1(14)
log_ru_week_Intercept ~ Normal(0.0, 0.5)
log_ru_week = log_ru_week_Intercept .+ dar_log_ru_week_week_grid_level
logit_I0_Intercept ~ Normal(-9.0, 1.0)
logit_I0 = logit_I0_Intercept .+ ranef_logit_I0_initial_subpopulation
initial_growth_Intercept ~ Normal(0.0, 0.05)
initial_growth = initial_growth_Intercept .+ ranef_initial_growth_growth_subpopulation
log_lab_mod = ranef_log_lab_mod_ww_scale_ww_lab
log_sigma_ww_Intercept ~ Normal(-1.0498221244986778, 0.5)
log_sigma_ww = log_sigma_ww_Intercept .+ ranef_log_sigma_ww_ww_noise_ww_lab
count_rate_center_Intercept ~ Normal(-4.6, 0.3)
count_rate_center = count_rate_center_Intercept .+ ranef_count_rate_center_count_rate_count_stream
log_phi_count_Intercept ~ Normal(2.70805020110221, 0.5)
log_phi_count = log_phi_count_Intercept .+ ranef_log_phi_count_count_dispersion_count_stream
gamma ~ LogNormal(-4.0, 0.5)
phi_delta ~ Beta(2.0, 8.0)
sigma_delta ~ Exponential(4.0)
log10_g ~ Normal(12.0, 1.0)
t_peak ~ LogNormal(1.3862943611198906, 0.25)
viral_peak ~ Normal(6.0, 1.0)
shed_tail ~ LogNormal(2.6390573296152584, 0.3)
phi_count ~ Beta(2.0, 8.0)
sigma_count ~ Exponential(20.0)
dow_share ~ Dirichlet([5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0])
dur_shed = t_peak .+ shed_tail
shedding = viral_shedding_trajectory(t_peak, viral_peak, dur_shed, nsh)
log_ru = weekly_expand(log_ru_week, week_idx)
ww_sigma = gather_exp(log_sigma_ww, ww_obs_lab)
dow_effect = scale_simplex(dow_share, 7.0)
count_phi = gather_exp(log_phi_count, count_obs_stream)
@plate for i = eachindex(is_reference)
eps_d[i] .~ Normal.(zeros(n_total), 1.0)
eps_d_cell = eps_d[i]
delta_k = ar1_dev(eps_d_cell, phi_delta, sigma_delta)
log_rt_k = log_ru .+ _rk_kernel_stan_sub(1.0, is_reference[i]) .* delta_k
I_mat_cells[i] = renewal_from_first_observed(log_rt_k, g, gamma, logistic(logit_I0[i]), initial_growth[i], uot)
end
I_mat = flatten_cells(I_mat_cells)
ww_mu = ww_expected_log(I_mat_cells, shedding, ww_time, ww_subpop, ww_obs_lab, log_lab_mod, log10_g, mwpd)
I_agg = wsum(I_mat_cells, w)
forecast_infections = take_window(I_agg, .+(uot, nt, 1), ht)
forecast_ww_log_mean = ww_expected_log(I_mat_cells, shedding, forecast_ww_time, forecast_ww_subpop, forecast_ww_obs_lab, log_lab_mod, log10_g, mwpd)
@plate for i_ = eachindex(count_rate_center)
eps_count[i_] .~ Normal.(zeros(n_weeks), 1.0)
eps_count_cell = eps_count[i_]
count_rate_week_cells[i_] = count_rate_center[i_] .+ ar1_dev(eps_count_cell, phi_count, sigma_count)
end
count_rate_week = flatten_cells(count_rate_week_cells)
count_rate_daily = weekly_expand_columns(count_rate_week_cells, week_idx)
count_mu = count_interval_mean(I_mat_cells, count_subpop_weights, count_delay, count_rate_daily, count_start, count_stop, count_obs_stream, dow, dow_effect, count_population)
forecast_count_mean = count_interval_mean(I_mat_cells, count_subpop_weights, count_delay, count_rate_daily, forecast_count_start, forecast_count_stop, forecast_count_obs_stream, dow, dow_effect, count_population)
ww_log_conc .~ censored.(Normal.(ww_mu, ww_sigma), ww_lod, Inf)
count .~ NegativeBinomial2.(count_mu, count_phi)
endfunctions {
vector viral_shedding_trajectory(
real t_peak,
real viral_peak,
real duration_shedding,
int n
) {
vector[n] s;
real growth = (viral_peak / t_peak);
real wane = (viral_peak / (duration_shedding - t_peak));
for(t in 1:n) {
if((t <= t_peak)) {
s[t] = exp((log(10.0) * growth * t));
} else {
real log10_load = ((viral_peak + (wane * t_peak)) - (wane * t));
s[t] = exp((log(10.0) * ((log10_load < 0.0) ? 0.0 : log10_load)));
}
}
return (s / sum(s));
}
matrix hcat(vector x) {
int n = dims(x)[1];
return to_matrix(x, n, 1);
}
vector differenced_ar1_path(
real beta,
real sigma,
vector z
) {
int n = dims(z)[1];
vector[(n + 1)] x = rep_vector(0.0, (n + 1));
real increment = 0.0;
if((n > 0)) {
for(t in 1:n) {
increment = ((beta * increment) + (sigma * z[t]));
x[(t + 1)] = (x[t] + increment);
}
}
return x;
}
vector weekly_expand(
vector x,
array[] int week_idx
) {
int nt = dims(week_idx)[1];
return x[week_idx];
}
vector gather_exp(vector x, array[] int idx) {
int n = dims(idx)[1];
return exp(x[idx]);
}
vector scale_simplex(vector x, real scale) {
int K = dims(x)[1];
return (scale * x);
}
vector normal_lpdfs(
vector obs,
vector loc,
real scale
) {
return jbroadcasted_normal_lpdfs(obs, loc, scale);
}
vector jbroadcasted_normal_lpdfs(
vector x1,
vector x2,
real x3
) {
int n = dims(x1)[1];
vector[n] rv;
for(i in 1:n) {
rv[i] = normal_lpdfs(broadcasted_getindex(x1, i), broadcasted_getindex(x2, i), x3);
}
return rv;
}
real normal_lpdfs(
real args1,
real args2,
real args3
) {
return normal_lpdf(args1 | args2, args3);
}
real broadcasted_getindex(vector x, int i) {
return x[i];
}
vector normal_vector_rng(
int anontok__1,
vector a,
real b
) {
int n = anontok__1;
if((n == 0)) {
vector[n] rv;
return rv;
} else {
return to_vector(normal_rng(a, b));
}
}
vector ar1_dev(
vector eps,
real phi,
real sigma
) {
int nt = dims(eps)[1];
vector[nt] d;
d[1] = ((sigma * eps[1]) / sqrt((1.0 - square(phi))));
for(t in 2:nt) {
d[t] = ((phi * d[(t - 1)]) + (sigma * eps[t]));
}
return d;
}
vector renewal_from_first_observed(
vector logRt,
vector g,
real gamma,
real i_first_obs,
real growth,
int uot
) {
int nt = dims(logRt)[1];
return renewal_feedback(logRt, g, gamma, exp((log(i_first_obs) - (uot * growth))), growth, uot);
}
vector renewal_feedback(
vector logRt,
vector g,
real gamma,
real I0,
real r,
int n_seed
) {
int nt = dims(logRt)[1];
int ng = dims(g)[1];
vector[nt] I;
for(t in 1:nt) {
if((t <= n_seed)) {
I[t] = (I0 * exp((r * (t - 1))));
} else {
real conv = 0.0;
for(s in 1:ng) {
real prev = (((t - s) >= 1) ? I[(t - s)] : 0.0);
conv = (conv + (g[s] * prev));
}
real Rt = (exp(logRt[t]) * exp(((-gamma) * conv)));
I[t] = (Rt * conv);
}
}
return I;
}
vector ww_expected_log(
matrix I_mat,
vector sh,
array[] int sample_time,
array[] int sample_subpop,
array[] int sample_lab,
vector log_lab_mod,
real log10_g,
real mwpd
) {
int nsh = dims(sh)[1];
int n = dims(sample_time)[1];
if (dims(sample_subpop)[1] != n) reject("ww_expected_log: dim mismatch — `sample_subpop` dim 1 (= ", dims(sample_subpop)[1], ") does not match `n` (= ", n, "), inferred from `sample_time` dim 1. `n` sizes: `sample_time` dim 1 (= ", dims(sample_time)[1], "), `sample_subpop` dim 1 (= ", dims(sample_subpop)[1], "), `sample_lab` dim 1 (= ", dims(sample_lab)[1], ").");
if (dims(sample_lab)[1] != n) reject("ww_expected_log: dim mismatch — `sample_lab` dim 1 (= ", dims(sample_lab)[1], ") does not match `n` (= ", n, "), inferred from `sample_time` dim 1. `n` sizes: `sample_time` dim 1 (= ", dims(sample_time)[1], "), `sample_subpop` dim 1 (= ", dims(sample_subpop)[1], "), `sample_lab` dim 1 (= ", dims(sample_lab)[1], ").");
vector[n] out;
for(i in 1:n) {
real shed = 0.0;
for(lag in 1:nsh) {
int t = ((sample_time[i] - lag) + 1);
shed = (shed + ((t >= 1) ? (sh[lag] * I_mat[t, sample_subpop[i]]) : 0.0));
}
out[i] = ((((log(10.0) * log10_g) + log((shed + 1.0e-8))) - log(mwpd)) + log_lab_mod[sample_lab[i]]);
}
return out;
}
real lower_clamping_normal_lpdf(
vector y,
vector lo,
vector args1,
vector args2
) {
return sum(lower_clamping_normal_lpdfs(y, lo, args1, args2));
}
vector lower_clamping_normal_lpdfs(
vector y,
vector lo,
vector args1,
vector args2
) {
int n = dims(y)[1];
return jbroadcasted_lower_clamping_lpdf_normal(y, lo, args1, args2);
}
vector jbroadcasted_lower_clamping_lpdf_normal(
vector x1,
vector x3,
vector x4,
vector x5
) {
int n = dims(x1)[1];
vector[n] rv;
for(i in 1:n) {
rv[i] = lower_clamping_normal_lpdf(broadcasted_getindex(x1, i) |
broadcasted_getindex(x3, i),
broadcasted_getindex(x4, i),
broadcasted_getindex(x5, i)
);
}
return rv;
}
real lower_clamping_normal_lpdf(
real y,
real lo,
real args1,
real args2
) {
array[1] real rv;
rv[1] = negative_infinity();
if((y == lo)) {
rv[1] = normal_lcdf_stable(lo, args1, args2);
} else {
if((y > lo)) {
rv[1] = normal_lpdf(y | args1, args2);
}
}
return rv[1];
}
real normal_lcdf_stable(
real x,
real loc,
real scale
) {
return (is_inf(x) ? ((x < 0) ? negative_infinity() : 0.0) : ((((x - loc) / scale) < -35) ? std_normal_lcdf_tail(((x - loc) / scale)) : ((((x - loc) / scale) <= 0) ? (log(erfc(((-(x - loc)) / (scale * sqrt(2.0))))) - log(2.0)) : log1m((0.5 * erfc(((x - loc) / (scale * sqrt(2.0)))))))));
}
real std_normal_lcdf_tail(
real z
) {
return ((-0.5 * square(z)) + std_normal_scaled_lcdf_tail(z));
}
real std_normal_scaled_lcdf_tail(
real z
) {
real w = inv(square(z));
return (
((-log((-z))) - 0.9189385332046728) +
log1p((w * (-1 + (w * (3 + (w * (-15 + (w * (105 + (w * (-945 + (w * 10395))))))))))))
);
}
vector lower_clamping_vector_normal_rng(
int anontok__1,
vector lo,
vector args1,
vector args2
) {
int n = anontok__1;
return jbroadcasted_lower_clamping_cell_rng_normal_rng(rep_vector(0.0, n), lo, args1, args2);
}
vector jbroadcasted_lower_clamping_cell_rng_normal_rng(
vector x1,
vector x3,
vector x4,
vector x5
) {
int n = dims(x1)[1];
vector[n] rv;
for(i in 1:n) {
rv[i] = lower_clamping_cell_normal_rng(
broadcasted_getindex(x1, i),
broadcasted_getindex(x3, i),
broadcasted_getindex(x4, i),
broadcasted_getindex(x5, i)
);
}
return rv;
}
real lower_clamping_cell_normal_rng(
real dummy,
real lo,
real args1,
real args2
) {
return lower_clamping_normal_rng(lo, args1, args2);
}
real lower_clamping_normal_rng(
real lo,
real args1,
real args2
) {
vector[1] draw;
draw[1] = normal_rng(args1, args2);
if((draw[1] < lo)) {
draw[1] = lo;
}
return draw[1];
}
vector wsum(
matrix I_mat,
vector w
) {
int m = dims(I_mat)[1];
int K = dims(I_mat)[2];
if (dims(w)[1] != K) reject("wsum: dim mismatch — `w` dim 1 (= ", dims(w)[1], ") does not match `K` (= ", K, "), inferred from `I_mat` dim 2. `K` sizes: `I_mat` dim 2 (= ", dims(I_mat)[2], "), `w` dim 1 (= ", dims(w)[1], ").");
return (I_mat * w);
}
vector take_window(
vector x,
int start_idx,
int width
) {
return x[start_idx:((start_idx + width) - 1)];
}
matrix weekly_expand_columns(
matrix x,
array[] int week_idx
) {
int S = dims(x)[2];
int nt = dims(week_idx)[1];
matrix[nt, S] out;
for(t in 1:nt) {
for(stream in 1:S) {
out[t, stream] = x[week_idx[t], stream];
}
}
return out;
}
vector count_interval_mean(
matrix I_mat,
matrix subpop_weights,
matrix delay,
matrix logit_rate,
array[] int interval_start,
array[] int interval_stop,
array[] int stream_idx,
array[] int dow,
vector dow_effect,
vector population
) {
int nt = dims(I_mat)[1];
int K = dims(I_mat)[2];
int S = dims(subpop_weights)[2];
int nd = dims(delay)[1];
int n = dims(interval_start)[1];
if (dims(logit_rate)[1] != nt) reject("count_interval_mean: dim mismatch — `logit_rate` dim 1 (= ", dims(logit_rate)[1], ") does not match `nt` (= ", nt, "), inferred from `I_mat` dim 1. `nt` sizes: `I_mat` dim 1 (= ", dims(I_mat)[1], "), `logit_rate` dim 1 (= ", dims(logit_rate)[1], "), `dow` dim 1 (= ", dims(dow)[1], ").");
if (dims(dow)[1] != nt) reject("count_interval_mean: dim mismatch — `dow` dim 1 (= ", dims(dow)[1], ") does not match `nt` (= ", nt, "), inferred from `I_mat` dim 1. `nt` sizes: `I_mat` dim 1 (= ", dims(I_mat)[1], "), `logit_rate` dim 1 (= ", dims(logit_rate)[1], "), `dow` dim 1 (= ", dims(dow)[1], ").");
if (dims(subpop_weights)[1] != K) reject("count_interval_mean: dim mismatch — `subpop_weights` dim 1 (= ", dims(subpop_weights)[1], ") does not match `K` (= ", K, "), inferred from `I_mat` dim 2. `K` sizes: `I_mat` dim 2 (= ", dims(I_mat)[2], "), `subpop_weights` dim 1 (= ", dims(subpop_weights)[1], ").");
if (dims(delay)[2] != S) reject("count_interval_mean: dim mismatch — `delay` dim 2 (= ", dims(delay)[2], ") does not match `S` (= ", S, "), inferred from `subpop_weights` dim 2. `S` sizes: `subpop_weights` dim 2 (= ", dims(subpop_weights)[2], "), `delay` dim 2 (= ", dims(delay)[2], "), `logit_rate` dim 2 (= ", dims(logit_rate)[2], "), `population` dim 1 (= ", dims(population)[1], ").");
if (dims(logit_rate)[2] != S) reject("count_interval_mean: dim mismatch — `logit_rate` dim 2 (= ", dims(logit_rate)[2], ") does not match `S` (= ", S, "), inferred from `subpop_weights` dim 2. `S` sizes: `subpop_weights` dim 2 (= ", dims(subpop_weights)[2], "), `delay` dim 2 (= ", dims(delay)[2], "), `logit_rate` dim 2 (= ", dims(logit_rate)[2], "), `population` dim 1 (= ", dims(population)[1], ").");
if (dims(population)[1] != S) reject("count_interval_mean: dim mismatch — `population` dim 1 (= ", dims(population)[1], ") does not match `S` (= ", S, "), inferred from `subpop_weights` dim 2. `S` sizes: `subpop_weights` dim 2 (= ", dims(subpop_weights)[2], "), `delay` dim 2 (= ", dims(delay)[2], "), `logit_rate` dim 2 (= ", dims(logit_rate)[2], "), `population` dim 1 (= ", dims(population)[1], ").");
if (dims(interval_stop)[1] != n) reject("count_interval_mean: dim mismatch — `interval_stop` dim 1 (= ", dims(interval_stop)[1], ") does not match `n` (= ", n, "), inferred from `interval_start` dim 1. `n` sizes: `interval_start` dim 1 (= ", dims(interval_start)[1], "), `interval_stop` dim 1 (= ", dims(interval_stop)[1], "), `stream_idx` dim 1 (= ", dims(stream_idx)[1], ").");
if (dims(stream_idx)[1] != n) reject("count_interval_mean: dim mismatch — `stream_idx` dim 1 (= ", dims(stream_idx)[1], ") does not match `n` (= ", n, "), inferred from `interval_start` dim 1. `n` sizes: `interval_start` dim 1 (= ", dims(interval_start)[1], "), `interval_stop` dim 1 (= ", dims(interval_stop)[1], "), `stream_idx` dim 1 (= ", dims(stream_idx)[1], ").");
vector[n] out;
for(record in 1:n) {
int stream = stream_idx[record];
real expected = 0.0;
for(outcome_time in interval_start[record]:interval_stop[record]) {
real delayed = 0.0;
for(lag in 1:nd) {
int infection_time = ((outcome_time - lag) + 1);
if((infection_time >= 1)) {
real stream_incidence = 0.0;
for(subpop in 1:K) {
stream_incidence = (stream_incidence + (I_mat[infection_time, subpop] * subpop_weights[subpop, stream]));
}
delayed = (delayed + (delay[lag, stream] * inv_logit(logit_rate[infection_time, stream]) * stream_incidence));
}
}
expected = (expected + (population[stream] * dow_effect[dow[outcome_time]] * delayed));
}
out[record] = (expected + 1.0e-8);
}
return out;
}
vector neg_binomial_2_lpmfs(
array[] int obs,
vector mu,
vector phi
) {
return jbroadcasted_neg_binomial_2_lpmfs(obs, mu, phi);
}
vector jbroadcasted_neg_binomial_2_lpmfs(
array[] int x1,
vector x2,
vector x3
) {
int n = dims(x1)[1];
vector[n] rv;
for(i in 1:n) {
rv[i] = neg_binomial_2_lpmfs(
broadcasted_getindex(x1, i),
broadcasted_getindex(x2, i),
broadcasted_getindex(x3, i)
);
}
return rv;
}
real neg_binomial_2_lpmfs(
int args1,
real args2,
real args3
) {
return neg_binomial_2_lpmf(args1 | args2, args3);
}
int broadcasted_getindex(array[] int x, int i) {
return x[i];
}
array[] int neg_binomial_2_int_rng(
int anontok__1,
vector a,
vector b
) {
int n = anontok__1;
if((n == 0)) {
array[n] int rv;
return rv;
} else {
return neg_binomial_2_rng(a, b);
}
}
}
data {
int n_terms_initial_subpopulation;
int n_subpopulation;
int n_terms_growth_subpopulation;
int n_terms_ww_scale_ww_lab;
int n_ww_lab;
int n_terms_ww_noise_ww_lab;
int n_terms_count_rate_count_stream;
int n_count_stream;
int n_terms_count_dispersion_count_stream;
int nsh;
int week_grid_n;
vector[week_grid_n] week_grid;
int week_idx_n;
array[week_idx_n] int week_idx;
int subpopulation_idx_n;
array[subpopulation_idx_n] int subpopulation_idx;
int ww_lab_idx_n;
array[ww_lab_idx_n] int ww_lab_idx;
int ww_obs_lab_n;
array[ww_obs_lab_n] int ww_obs_lab;
int count_stream_idx_n;
array[count_stream_idx_n] int count_stream_idx;
int dow_share_alpha_n;
vector[dow_share_alpha_n] dow_share_alpha;
int count_obs_stream_n;
array[count_obs_stream_n] int count_obs_stream;
int n_total;
int kernel_nsub_I_mat;
int is_reference_n;
vector[is_reference_n] is_reference;
int g_n;
vector[g_n] g;
int uot;
int ww_time_n;
array[ww_time_n] int ww_time;
int ww_subpop_n;
array[ww_subpop_n] int ww_subpop;
real mwpd;
int ww_log_conc_n;
vector[ww_log_conc_n] ww_log_conc;
int ww_lod_n;
vector[ww_lod_n] ww_lod;
int w_n;
vector[w_n] w;
int ht;
int nt;
int forecast_ww_obs_lab_n;
int forecast_ww_time_n;
array[forecast_ww_time_n] int forecast_ww_time;
int forecast_ww_subpop_n;
array[forecast_ww_subpop_n] int forecast_ww_subpop;
array[forecast_ww_obs_lab_n] int forecast_ww_obs_lab;
int n_weeks;
int kernel_nsub_count_rate_week;
int count_subpop_weights_m;
int count_subpop_weights_n;
matrix[count_subpop_weights_m, count_subpop_weights_n] count_subpop_weights;
int count_delay_m;
int count_delay_n;
matrix[count_delay_m, count_delay_n] count_delay;
int count_start_n;
array[count_start_n] int count_start;
int count_stop_n;
array[count_stop_n] int count_stop;
int dow_n;
array[dow_n] int dow;
int count_population_n;
vector[count_population_n] count_population;
int count_n;
array[count_n] int count;
int forecast_count_obs_stream_n;
int forecast_count_start_n;
array[forecast_count_start_n] int forecast_count_start;
int forecast_count_stop_n;
array[forecast_count_stop_n] int forecast_count_stop;
array[forecast_count_obs_stream_n] int forecast_count_obs_stream;
}
transformed data {
matrix[num_elements(week_grid), 1] X_log_ru_week = hcat(rep_vector(1.0, num_elements(week_grid)));
int pop_log_ru_week_n_covariates = 1;
int dar_log_ru_week_week_grid_n_innov = (num_elements(week_grid) - 1);
matrix[num_elements(subpopulation_idx), 1] X_logit_I0 = hcat(rep_vector(1.0, num_elements(subpopulation_idx)));
int pop_logit_I0_n_covariates = 1;
matrix[num_elements(subpopulation_idx), 1] X_initial_growth = hcat(rep_vector(1.0, num_elements(subpopulation_idx)));
int pop_initial_growth_n_covariates = 1;
matrix[num_elements(ww_lab_idx), 1] X_log_sigma_ww = hcat(rep_vector(1.0, num_elements(ww_lab_idx)));
int pop_log_sigma_ww_n_covariates = 1;
matrix[num_elements(count_stream_idx), 1] X_count_rate_center = hcat(rep_vector(1.0, num_elements(count_stream_idx)));
int pop_count_rate_center_n_covariates = 1;
matrix[num_elements(count_stream_idx), 1] X_log_phi_count = hcat(rep_vector(1.0, num_elements(count_stream_idx)));
int pop_log_phi_count_n_covariates = 1;
vector[n_total] I_mat__pl_inv1 = rep_vector(0.0, n_total);
vector[n_weeks] count_rate_week__pl_inv1 = rep_vector(0.0, n_weeks);
}
parameters {
vector<lower=0.0>[n_terms_initial_subpopulation] b_initial_subpopulation_tau;
vector[(n_terms_initial_subpopulation * n_subpopulation)] b_initial_subpopulation_z_flat;
vector<lower=0.0>[n_terms_growth_subpopulation] b_growth_subpopulation_tau;
vector[(n_terms_growth_subpopulation * n_subpopulation)] b_growth_subpopulation_z_flat;
vector<lower=0.0>[n_terms_ww_scale_ww_lab] b_ww_scale_ww_lab_tau;
vector[(n_terms_ww_scale_ww_lab * n_ww_lab)] b_ww_scale_ww_lab_z_flat;
vector<lower=0.0>[n_terms_ww_noise_ww_lab] b_ww_noise_ww_lab_tau;
vector[(n_terms_ww_noise_ww_lab * n_ww_lab)] b_ww_noise_ww_lab_z_flat;
vector<lower=0.0>[n_terms_count_rate_count_stream] b_count_rate_count_stream_tau;
vector[(n_terms_count_rate_count_stream * n_count_stream)] b_count_rate_count_stream_z_flat;
vector<lower=0.0>[n_terms_count_dispersion_count_stream] b_count_dispersion_count_stream_tau;
vector[(n_terms_count_dispersion_count_stream * n_count_stream)] b_count_dispersion_count_stream_z_flat;
real<lower=0.0> gamma;
real<lower=0, upper=1> phi_delta;
real<lower=0.0> sigma_delta;
real log10_g;
real<lower=0.0> t_peak;
real viral_peak;
real<lower=0.0> shed_tail;
vector[pop_log_ru_week_n_covariates] pop_log_ru_week_beta_pop;
real<lower=0.0, upper=1.0> dar_log_ru_week_week_grid_beta;
real<lower=0.0> dar_log_ru_week_week_grid_sigma;
vector[dar_log_ru_week_week_grid_n_innov] dar_log_ru_week_week_grid_z;
vector[pop_logit_I0_n_covariates] pop_logit_I0_beta_pop;
vector[pop_initial_growth_n_covariates] pop_initial_growth_beta_pop;
vector[pop_log_sigma_ww_n_covariates] pop_log_sigma_ww_beta_pop;
real<lower=0, upper=1> phi_count;
real<lower=0.0> sigma_count;
vector[pop_count_rate_center_n_covariates] pop_count_rate_center_beta_pop;
simplex[dow_share_alpha_n] dow_share;
vector[pop_log_phi_count_n_covariates] pop_log_phi_count_beta_pop;
matrix[n_total, kernel_nsub_I_mat] I_mat_eps_d;
matrix[n_weeks, kernel_nsub_count_rate_week] count_rate_week_eps_count;
}
transformed parameters {
matrix[n_terms_initial_subpopulation, n_subpopulation] b_initial_subpopulation_z = to_matrix(b_initial_subpopulation_z_flat, n_terms_initial_subpopulation, n_subpopulation);
matrix[n_subpopulation, n_terms_initial_subpopulation] b_initial_subpopulation = ((diag_matrix(b_initial_subpopulation_tau) * b_initial_subpopulation_z)');
matrix[n_terms_growth_subpopulation, n_subpopulation] b_growth_subpopulation_z = to_matrix(b_growth_subpopulation_z_flat, n_terms_growth_subpopulation, n_subpopulation);
matrix[n_subpopulation, n_terms_growth_subpopulation] b_growth_subpopulation = ((diag_matrix(b_growth_subpopulation_tau) * b_growth_subpopulation_z)');
matrix[n_terms_ww_scale_ww_lab, n_ww_lab] b_ww_scale_ww_lab_z = to_matrix(b_ww_scale_ww_lab_z_flat, n_terms_ww_scale_ww_lab, n_ww_lab);
matrix[n_ww_lab, n_terms_ww_scale_ww_lab] b_ww_scale_ww_lab = ((diag_matrix(b_ww_scale_ww_lab_tau) * b_ww_scale_ww_lab_z)');
matrix[n_terms_ww_noise_ww_lab, n_ww_lab] b_ww_noise_ww_lab_z = to_matrix(b_ww_noise_ww_lab_z_flat, n_terms_ww_noise_ww_lab, n_ww_lab);
matrix[n_ww_lab, n_terms_ww_noise_ww_lab] b_ww_noise_ww_lab = ((diag_matrix(b_ww_noise_ww_lab_tau) * b_ww_noise_ww_lab_z)');
matrix[n_terms_count_rate_count_stream, n_count_stream] b_count_rate_count_stream_z = to_matrix(b_count_rate_count_stream_z_flat, n_terms_count_rate_count_stream, n_count_stream);
matrix[n_count_stream, n_terms_count_rate_count_stream] b_count_rate_count_stream = ((diag_matrix(b_count_rate_count_stream_tau) * b_count_rate_count_stream_z)');
matrix[n_terms_count_dispersion_count_stream, n_count_stream] b_count_dispersion_count_stream_z = to_matrix(
b_count_dispersion_count_stream_z_flat,
n_terms_count_dispersion_count_stream,
n_count_stream
);
matrix[n_count_stream, n_terms_count_dispersion_count_stream] b_count_dispersion_count_stream = ((diag_matrix(b_count_dispersion_count_stream_tau) * b_count_dispersion_count_stream_z)');
real dur_shed = (t_peak + shed_tail);
vector[nsh] shedding = viral_shedding_trajectory(t_peak, viral_peak, dur_shed, nsh);
vector[num_elements(week_grid)] pop_log_ru_week = (X_log_ru_week * pop_log_ru_week_beta_pop);
vector[(dar_log_ru_week_week_grid_n_innov + 1)] dar_log_ru_week_week_grid = differenced_ar1_path(
dar_log_ru_week_week_grid_beta,
dar_log_ru_week_week_grid_sigma,
dar_log_ru_week_week_grid_z
);
vector[num_elements(week_grid)] log_ru_week = (pop_log_ru_week + dar_log_ru_week_week_grid);
vector[week_idx_n] log_ru = weekly_expand(log_ru_week, week_idx);
vector[num_elements(subpopulation_idx)] pop_logit_I0 = (X_logit_I0 * pop_logit_I0_beta_pop);
vector[subpopulation_idx_n] r_logit_I0_initial_subpopulation = b_initial_subpopulation[subpopulation_idx, 1];
vector[num_elements(subpopulation_idx)] logit_I0 = (pop_logit_I0 + r_logit_I0_initial_subpopulation);
vector[num_elements(subpopulation_idx)] pop_initial_growth = (X_initial_growth * pop_initial_growth_beta_pop);
vector[subpopulation_idx_n] r_initial_growth_growth_subpopulation = b_growth_subpopulation[subpopulation_idx, 1];
vector[num_elements(subpopulation_idx)] initial_growth = (pop_initial_growth + r_initial_growth_growth_subpopulation);
vector[ww_lab_idx_n] r_log_lab_mod_ww_scale_ww_lab = b_ww_scale_ww_lab[ww_lab_idx, 1];
vector[ww_lab_idx_n] log_lab_mod = r_log_lab_mod_ww_scale_ww_lab;
vector[num_elements(ww_lab_idx)] pop_log_sigma_ww = (X_log_sigma_ww * pop_log_sigma_ww_beta_pop);
vector[ww_lab_idx_n] r_log_sigma_ww_ww_noise_ww_lab = b_ww_noise_ww_lab[ww_lab_idx, 1];
vector[num_elements(ww_lab_idx)] log_sigma_ww = (pop_log_sigma_ww + r_log_sigma_ww_ww_noise_ww_lab);
vector[ww_obs_lab_n] ww_sigma = gather_exp(log_sigma_ww, ww_obs_lab);
vector[num_elements(count_stream_idx)] pop_count_rate_center = (X_count_rate_center * pop_count_rate_center_beta_pop);
vector[count_stream_idx_n] r_count_rate_center_count_rate_count_stream = b_count_rate_count_stream[count_stream_idx, 1];
vector[num_elements(count_stream_idx)] count_rate_center = (pop_count_rate_center + r_count_rate_center_count_rate_count_stream);
vector[dow_share_alpha_n] dow_effect = scale_simplex(dow_share, 7.0);
vector[num_elements(count_stream_idx)] pop_log_phi_count = (X_log_phi_count * pop_log_phi_count_beta_pop);
vector[count_stream_idx_n] r_log_phi_count_count_dispersion_count_stream = b_count_dispersion_count_stream[count_stream_idx, 1];
vector[num_elements(count_stream_idx)] log_phi_count = (pop_log_phi_count + r_log_phi_count_count_dispersion_count_stream);
vector[count_obs_stream_n] count_phi = gather_exp(log_phi_count, count_obs_stream);
matrix[n_total, kernel_nsub_I_mat] I_mat_delta_k;
matrix[week_idx_n, kernel_nsub_I_mat] I_mat_log_rt_k;
matrix[week_idx_n, kernel_nsub_I_mat] I_mat;
for(plate_i__pl_1 in 1:kernel_nsub_I_mat) {
I_mat_delta_k[:, plate_i__pl_1] = ar1_dev(I_mat_eps_d[:, plate_i__pl_1], phi_delta, sigma_delta);
I_mat_log_rt_k[:, plate_i__pl_1] = (log_ru + ((1.0 - is_reference[plate_i__pl_1]) .* I_mat_delta_k[:, plate_i__pl_1]));
I_mat[:, plate_i__pl_1] = renewal_from_first_observed(
I_mat_log_rt_k[:, plate_i__pl_1],
g,
gamma,
inv_logit(logit_I0[plate_i__pl_1]),
initial_growth[plate_i__pl_1],
uot
);
}
vector[ww_obs_lab_n] ww_mu = ww_expected_log(I_mat, shedding, ww_time, ww_subpop, ww_obs_lab, log_lab_mod, log10_g, mwpd);
matrix[n_weeks, kernel_nsub_count_rate_week] count_rate_week;
for(plate_i__pl_2 in 1:kernel_nsub_count_rate_week) {
count_rate_week[:, plate_i__pl_2] = (
count_rate_center[plate_i__pl_2] +
ar1_dev(count_rate_week_eps_count[:, plate_i__pl_2], phi_count, sigma_count)
);
}
matrix[week_idx_n, kernel_nsub_count_rate_week] count_rate_daily = weekly_expand_columns(count_rate_week, week_idx);
vector[count_obs_stream_n] count_mu = count_interval_mean(
I_mat,
count_subpop_weights,
count_delay,
count_rate_daily,
count_start,
count_stop,
count_obs_stream,
dow,
dow_effect,
count_population
);
}
model {
b_initial_subpopulation_tau ~ normal(0.0, 0.75);
b_initial_subpopulation_z_flat ~ std_normal();
b_growth_subpopulation_tau ~ normal(0.0, 0.05);
b_growth_subpopulation_z_flat ~ std_normal();
b_ww_scale_ww_lab_tau ~ normal(0.0, 0.5);
b_ww_scale_ww_lab_z_flat ~ std_normal();
b_ww_noise_ww_lab_tau ~ normal(0.0, 0.35);
b_ww_noise_ww_lab_z_flat ~ std_normal();
b_count_rate_count_stream_tau ~ normal(0.0, 0.5);
b_count_rate_count_stream_z_flat ~ std_normal();
b_count_dispersion_count_stream_tau ~ normal(0.0, 0.5);
b_count_dispersion_count_stream_z_flat ~ std_normal();
gamma ~ lognormal(-4.0, 0.5);
phi_delta ~ beta(2.0, 8.0);
sigma_delta ~ exponential((1.0 ./ 4.0));
log10_g ~ normal(12.0, 1.0);
t_peak ~ lognormal(1.3862943611198906, 0.25);
viral_peak ~ normal(6.0, 1.0);
shed_tail ~ lognormal(2.6390573296152584, 0.3);
pop_log_ru_week_beta_pop ~ normal([0.0]', [0.5]');
dar_log_ru_week_week_grid_beta ~ normal(0.5, 0.2);
dar_log_ru_week_week_grid_sigma ~ normal(0.0, 0.2);
dar_log_ru_week_week_grid_z ~ std_normal();
pop_logit_I0_beta_pop ~ normal([-9.0]', [1.0]');
pop_initial_growth_beta_pop ~ normal([0.0]', [0.05]');
pop_log_sigma_ww_beta_pop ~ normal([-1.0498221244986778]', [0.5]');
phi_count ~ beta(2.0, 8.0);
sigma_count ~ exponential((1.0 ./ 20.0));
pop_count_rate_center_beta_pop ~ normal([-4.6]', [0.3]');
dow_share ~ dirichlet(dow_share_alpha);
pop_log_phi_count_beta_pop ~ normal([2.70805020110221]', [0.5]');
for(plate_i__pl_1 in 1:kernel_nsub_I_mat) {
I_mat_eps_d[:, plate_i__pl_1] ~ normal(I_mat__pl_inv1, 1.0);
}
ww_log_conc ~ lower_clamping_normal(ww_lod, ww_mu, ww_sigma);
for(plate_i__pl_2 in 1:kernel_nsub_count_rate_week) {
count_rate_week_eps_count[:, plate_i__pl_2] ~ normal(count_rate_week__pl_inv1, 1.0);
}
count ~ neg_binomial_2(count_mu, count_phi);
}
generated quantities {
vector[ww_log_conc_n] ww_log_conc_likelihood = lower_clamping_normal_lpdfs(ww_log_conc, ww_lod, ww_mu, ww_sigma);
vector[ww_log_conc_n] ww_log_conc_gen = lower_clamping_vector_normal_rng(ww_log_conc_n, ww_lod, ww_mu, ww_sigma);
vector[week_idx_n] I_agg = wsum(I_mat, w);
vector[ht] forecast_infections = take_window(I_agg, (uot + nt + 1), ht);
vector[forecast_ww_obs_lab_n] forecast_ww_log_mean = ww_expected_log(
I_mat,
shedding,
forecast_ww_time,
forecast_ww_subpop,
forecast_ww_obs_lab,
log_lab_mod,
log10_g,
mwpd
);
vector[count_n] count_likelihood = neg_binomial_2_lpmfs(count, count_mu, count_phi);
array[count_n] int count_gen = neg_binomial_2_int_rng(count_n, count_mu, count_phi);
vector[forecast_count_obs_stream_n] forecast_count_mean = count_interval_mean(
I_mat,
count_subpop_weights,
count_delay,
count_rate_daily,
forecast_count_start,
forecast_count_stop,
forecast_count_obs_stream,
dow,
dow_effect,
count_population
);
}using ReactiveKernels, ReactiveKernelsPPL
rk = RKBRMI(model)
source = jax_source(rk.model, rk_bound_plan(rk))
write("model.py", source)
inputs = rk_bound_data(rk, source) # exactly the inputs prepare_data readsThis model has no JAX module yet.
JAXEmissionError: the function `viral_shedding_trajectory` has loops or branches, so its lowered code is not translated in recipe `shedding = (t_peak, viral_peak, dur_shed, nsh) -> Main.var"##RKEmittedModels#23814".viral_shedding_trajectory(t_peak, viral_peak, dur_shed, nsh)`. Define it with `@traceable` (its authored body is translated), author it as a kernel, or give it a `ReactiveKernels._jax_function_call` method; for a method a package generates, the package supplies its source with `ReactiveKernels.register_source_provider!`Wastewater concentration is proportional to infection incidence convolved with the shedding profile. The profile has an inferred peak and duration and is normalized before convolution. A laboratory multiplier changes the concentration scale, and a laboratory noise scale controls log-concentration error. Values at their detection limits contribute a left-censoring probability. Concentrations retain their source units, genome copies per mL; the dilution constant uses mL per person per day.
Hospital admissions constrain a different view of the same infections. The model averages incidence with population weights, convolves it with the infection-to-hospital delay distribution, and applies a varying admission probability and a mean-one weekday effect. A negative-binomial likelihood accounts for count variation beyond the Poisson variance. The wastewater and admission frames remain separate throughout this calculation; there is no interpolation of sparse samples into invented daily measurements.
With one measured catchment, the state admissions series supplies information about infections outside that catchment. The shared reference and deviation priors determine how those signals are pooled. Changing the population weights therefore changes the scientific model, not merely the labels on its output.
Fit and diagnostics
Four independent WarmupHMC chains start from different random seeds, each requesting 1,000 retained draws. The completion sampler requires three chains to finish and then lets the remaining chain finish its current warmup round. The table records how many chains contributed, which were omitted, the total retained draws, divergences and sampling time. These are results of the cached run; rebuilding this page reads its tables without sampling again.
| started | retained | omitted | draws | divergences | % | seconds |
|---|---|---|---|---|---|---|
| 4 | 3 | 1 | 3000 | 20 | 0.6667 | 517.4 |
Population summaries use the retained chains on the quantities' natural scales. The intervals contain the central 95 % of their pooled draws. Split R-hat compares chains; bulk and tail effective sample sizes describe the information in the centre and tails. A small divergence count alone is insufficient evidence that the chains agree. The completion rule can also select chains by speed, so the omitted-chain record belongs with the result.
| quantity | unit | median | 2.5 % | 97.5 % | R-hat | bulk ESS | tail ESS |
|---|---|---|---|---|---|---|---|
| initial reference R | 1.133 | 0.6734 | 1.929 | 1.084 | 49 | 60 | |
| feedback | 0.01827 | 0.006996 | 0.04819 | 1.001 | 7304 | 2304 | |
| subpopulation SD | log R | 0.09803 | 0.005665 | 0.3958 | 1.003 | 324 | 380 |
| shedding peak | days | 3.981 | 2.401 | 6.439 | 1.001 | 1380 | 1634 |
This run retained three chains and recorded 20 divergences. The initial reference reproduction number has R-hat 1.084 and bulk ESS 49, so agreement on the other reported quantities does not establish convergence of the whole fit. The initial level belongs to the unobserved seeding history, but its uncertainty is coupled to the later trajectory. Treat the bands below as provisional Monte Carlo summaries, not validated transmission estimates.
Reproduction number
{"spec":"{\"$schema\":\"https://vega.github.io/schema/vega-lite/v5.json\",\"_aovSummary\":{\"bands\":[[\"q025\",\"q975\",\"q025/q975\"],[\"q25\",\"q75\",\"q25/q75\"]],\"point_col\":\"q50\",\"value_label\":\"q50\"},\"config\":{\"axis\":{\"labelLimit\":0},\"header\":{\"labelLimit\":0},\"legend\":{\"labelLimit\":0}},\"data\":{\"values\":[{\"q025\":1.012,\"q25\":1.103,\"q50\":1.138,\"q75\":1.186,\"q975\":1.323,\"time\":1.0},{\"q025\":1.012,\"q25\":1.103,\"q50\":1.138,\"q75\":1.186,\"q975\":1.323,\"time\":2.0},{\"q025\":1.012,\"q25\":1.103,\"q50\":1.138,\"q75\":1.186,\"q975\":1.323,\"time\":3.0},{\"q025\":1.012,\"q25\":1.103,\"q50\":1.138,\"q75\":1.186,\"q975\":1.323,\"time\":4.0},{\"q025\":1.012,\"q25\":1.103,\"q50\":1.138,\"q75\":1.186,\"q975\":1.323,\"time\":5.0},{\"q025\":1.012,\"q25\":1.103,\"q50\":1.138,\"q75\":1.186,\"q975\":1.323,\"time\":6.0},{\"q025\":1.022,\"q25\":1.099,\"q50\":1.125,\"q75\":1.153,\"q975\":1.22,\"time\":7.0},{\"q025\":1.022,\"q25\":1.099,\"q50\":1.125,\"q75\":1.153,\"q975\":1.22,\"time\":8.0},{\"q025\":1.022,\"q25\":1.099,\"q50\":1.125,\"q75\":1.153,\"q975\":1.22,\"time\":9.0},{\"q025\":1.022,\"q25\":1.099,\"q50\":1.125,\"q75\":1.153,\"q975\":1.22,\"time\":10.0},{\"q025\":1.022,\"q25\":1.099,\"q50\":1.125,\"q75\":1.153,\"q975\":1.22,\"time\":11.0},{\"q025\":1.022,\"q25\":1.099,\"q50\":1.125,\"q75\":1.153,\"q975\":1.22,\"time\":12.0},{\"q025\":1.022,\"q25\":1.099,\"q50\":1.125,\"q75\":1.153,\"q975\":1.22,\"time\":13.0},{\"q025\":1.021,\"q25\":1.09,\"q50\":1.116,\"q75\":1.139,\"q975\":1.203,\"time\":14.0},{\"q025\":1.021,\"q25\":1.09,\"q50\":1.116,\"q75\":1.139,\"q975\":1.203,\"time\":15.0},{\"q025\":1.021,\"q25\":1.09,\"q50\":1.116,\"q75\":1.139,\"q975\":1.203,\"time\":16.0},{\"q025\":1.021,\"q25\":1.09,\"q50\":1.116,\"q75\":1.139,\"q975\":1.203,\"time\":17.0},{\"q025\":1.021,\"q25\":1.09,\"q50\":1.116,\"q75\":1.139,\"q975\":1.203,\"time\":18.0},{\"q025\":1.021,\"q25\":1.09,\"q50\":1.116,\"q75\":1.139,\"q975\":1.203,\"time\":19.0},{\"q025\":1.021,\"q25\":1.09,\"q50\":1.116,\"q75\":1.139,\"q975\":1.203,\"time\":20.0},{\"q025\":1.004,\"q25\":1.083,\"q50\":1.111,\"q75\":1.139,\"q975\":1.218,\"time\":21.0},{\"q025\":1.004,\"q25\":1.083,\"q50\":1.111,\"q75\":1.139,\"q975\":1.218,\"time\":22.0},{\"q025\":1.004,\"q25\":1.083,\"q50\":1.111,\"q75\":1.139,\"q975\":1.218,\"time\":23.0},{\"q025\":1.004,\"q25\":1.083,\"q50\":1.111,\"q75\":1.139,\"q975\":1.218,\"time\":24.0},{\"q025\":1.004,\"q25\":1.083,\"q50\":1.111,\"q75\":1.139,\"q975\":1.218,\"time\":25.0},{\"q025\":1.004,\"q25\":1.083,\"q50\":1.111,\"q75\":1.139,\"q975\":1.218,\"time\":26.0},{\"q025\":1.004,\"q25\":1.083,\"q50\":1.111,\"q75\":1.139,\"q975\":1.218,\"time\":27.0},{\"q025\":0.9439,\"q25\":1.069,\"q50\":1.113,\"q75\":1.158,\"q975\":1.344,\"time\":28.0},{\"q025\":0.9439,\"q25\":1.069,\"q50\":1.113,\"q75\":1.158,\"q975\":1.344,\"time\":29.0},{\"q025\":0.9439,\"q25\":1.069,\"q50\":1.113,\"q75\":1.158,\"q975\":1.344,\"time\":30.0},{\"q025\":0.9439,\"q25\":1.069,\"q50\":1.113,\"q75\":1.158,\"q975\":1.344,\"time\":31.0},{\"q025\":0.9439,\"q25\":1.069,\"q50\":1.113,\"q75\":1.158,\"q975\":1.344,\"time\":32.0},{\"q025\":0.9439,\"q25\":1.069,\"q50\":1.113,\"q75\":1.158,\"q975\":1.344,\"time\":33.0},{\"q025\":0.9439,\"q25\":1.069,\"q50\":1.113,\"q75\":1.158,\"q975\":1.344,\"time\":34.0},{\"q025\":0.8455,\"q25\":1.054,\"q50\":1.112,\"q75\":1.172,\"q975\":1.489,\"time\":35.0}]},\"height\":300,\"layer\":[{\"_lr_layer\":true,\"encoding\":{\"tooltip\":[{\"field\":\"time\",\"title\":\"Day (1 = 1 September 2023)\",\"type\":\"quantitative\"},{\"field\":\"q50\",\"title\":\"median\",\"type\":\"quantitative\"},{\"field\":\"q025\",\"title\":\"q025\",\"type\":\"quantitative\"},{\"field\":\"q975\",\"title\":\"q975\",\"type\":\"quantitative\"}],\"x\":{\"field\":\"time\",\"scale\":{\"zero\":false},\"title\":\"Day (1 = 1 September 2023)\",\"type\":\"quantitative\"},\"y\":{\"field\":\"q025\",\"scale\":{\"zero\":false},\"title\":\"Reference reproduction number\",\"type\":\"quantitative\"},\"y2\":{\"field\":\"q975\"}},\"mark\":{\"color\":\"#2a78d6\",\"line\":false,\"opacity\":0.2,\"type\":\"area\"},\"params\":[{\"bind\":\"scales\",\"name\":\"grid\",\"select\":{\"encodings\":[\"x\",\"y\"],\"type\":\"interval\"}}]},{\"_lr_layer\":true,\"encoding\":{\"tooltip\":[{\"field\":\"time\",\"title\":\"Day (1 = 1 September 2023)\",\"type\":\"quantitative\"},{\"field\":\"q50\",\"title\":\"median\",\"type\":\"quantitative\"},{\"field\":\"q025\",\"title\":\"q025\",\"type\":\"quantitative\"},{\"field\":\"q975\",\"title\":\"q975\",\"type\":\"quantitative\"}],\"x\":{\"field\":\"time\",\"scale\":{\"zero\":false},\"title\":\"Day (1 = 1 September 2023)\",\"type\":\"quantitative\"},\"y\":{\"field\":\"q25\",\"scale\":{\"zero\":false},\"title\":\"Reference reproduction number\",\"type\":\"quantitative\"},\"y2\":{\"field\":\"q75\"}},\"mark\":{\"color\":\"#2a78d6\",\"line\":false,\"opacity\":0.6,\"type\":\"area\"}},{\"_lr_layer\":true,\"encoding\":{\"tooltip\":[{\"field\":\"time\",\"title\":\"Day (1 = 1 September 2023)\",\"type\":\"quantitative\"},{\"field\":\"q50\",\"title\":\"median\",\"type\":\"quantitative\"},{\"field\":\"q025\",\"title\":\"q025\",\"type\":\"quantitative\"},{\"field\":\"q975\",\"title\":\"q975\",\"type\":\"quantitative\"}],\"x\":{\"field\":\"time\",\"scale\":{\"zero\":false},\"title\":\"Day (1 = 1 September 2023)\",\"type\":\"quantitative\"},\"y\":{\"field\":\"q50\",\"scale\":{\"zero\":false},\"title\":\"Reference reproduction number\",\"type\":\"quantitative\"}},\"mark\":{\"color\":\"#2a78d6\",\"strokeWidth\":2,\"type\":\"line\"}}],\"width\":640,\"description\":\"Unadjusted reference reproduction number over the observed window: posterior median, 50 % and 95 % bands.\"}","caption":"Unadjusted reference reproduction number over the observed window: posterior median, 50 % and 95 % bands.","alt":"Unadjusted reference reproduction number over the observed window: posterior median, 50 % and 95 % bands."}The plotted quantity is the exponentiated shared reference process, before infection feedback and catchment-specific deviations. It is not the realized reproduction number of the measured catchment. Its bands describe uncertainty in that latent reference, rather than a prediction interval for a future concentration. Convolution and sparse sampling mean that a short change in wastewater need not imply an equally sharp change in transmission.
This example uses BRM's structural port of the CDC model. The recurrence, subpopulation hierarchy, shedding and count streams follow the same causal order; the priors and hospitalization-rate parameterization are those of the checked-in BRM declaration. This fit is not a reproduction of CDC's posterior estimates. The research notes give the differences and retain the smaller EpiSewer-style model for comparison.
Reproduce
Commands and fit receipt
The repository's test environment supplies the pinned BRM, StanBlocks, BridgeStan, WarmupHMC and TreeArrays dependencies. These shell commands are manual: the docs build executes the model declarations and figures but reads the completed fit's summaries. Run the fit deliberately when its model, data or settings change; routine documentation edits reuse the cache.
julia --startup-file=no --project=test test/setup_env.jl
julia -t 4 --startup-file=no --project=test research/wastewater/fit.jlThe script writes its receipt before sampling and saves the draws outside the repository. Its key includes the emitted program, data, settings, seed and sampling harness. TreeArrays reduces the named chain and draw axes to small summary tables. A second invocation with the same key rebuilds those tables from the saved draws. The receipt identifies the program behind these numbers.
On a fresh checkout the draws may be absent. An existing receipt guards against repeating a recent fit; set BRM_DOCS_FIT_FORCE=1 for a deliberate rerun. BRM_DOCS_CACHE selects a persistent draw-cache directory; its default is under the system temporary directory. Only the small summary tables belong in git.
| field | value |
|---|---|
| commit | b22a2a360174d9f2cf5c135d1836bc5076390124 |
| uncommitted_changes | yes |
| started | 2026-11-11 00:23 local time |
| host | a Linux fleet host, 4 Julia threads |
| julia | 1.10.12 |
| BayesianRegressionModels | 0.2.270 |
| sampler | WarmupHMC completion_warmup_mcmc, adaptive_centering_problem over the BridgeStan problem, AutoEnzyme |
| chains | 4 per fit, quorum 3, 1000 draws each |
| model | wastewater |
| sources | CDCgov/ww-inference-model 3e92fea29a0b96212e1690dbdcaeb8abfe19cc4f; public simulated site 1 and state admissions; 2023-09-01 to 2023-10-05 |
| seed | 20261111 |
| content_sha256 | 433c0b668a77a77b414dabec0c706ce86ff6341bb3ab2a478f0ea081cd79e53f |
| harness_sha256 | d8a510d69ccc7b671466acce09471ba544a121efed260fb0bb761ddb8ef1d5f5 |
| settings | (1000, 4, nothing, Base.Pairs(:target_acceptance_rate => 0.95)) |
| WarmupHMC | 0.2.11 |
| StanBlocks | 0.2.31 |
| TreeArrays | 0.2.0 |
| BridgeStan | 2.9.0 |
| seconds | 517.376364277 |
| divergent | 20 |
| omitted_chains | 1 |
| dimension | 248 |
| status | complete |
| completed | 2026-11-11T02:23:59 |
| summary | TreeArrays quantiles pooled over chain and draw; split R-hat, bulk and tail ESS |