Multiple observation streams: cases, deaths, and strata
Real-time surveillance rarely watches an epidemic through a single lens. The same infections surface as reported cases, hospital admissions, deaths, and often each of these split by age, region, or variant. These streams share one underlying infection process but differ in their reporting delay, ascertainment, and noise [ DocumenterCitations.CitationSiteNode("sherratt2021surveillance-cite-2")
]. Fitting them jointly — one infection trajectory, several observation streams — propagates uncertainty correctly and lets a sparse stream (deaths) borrow strength from a dense one (cases).
This tutorial uses one construct, Split, for every multi-stream shape. Split observes the expected series arriving at the point where it sits in the pipeline through several named streams, so where you place it chooses the composition:
parallel — placed high, on infections: every stream observes the same
(cases and deaths each a delayed, ascertained fraction of ); cascade — placed low, after a shared layer: a later stream is observed downstream of an earlier one (deaths as a delayed fraction of the expected reported cases);
strata — one stream per data-defined group (an age band).
How Split threads streams
Every observation model in the package returns the uniform pair (; y_t, expected): the sampled observations y_t and the pre-error expected series the error was scored against. Exposing expected is what lets Split do all three shapes with one mechanism. Split feeds each stream the expected series reaching it, and — because Split is itself an observation model — a shared modifier can run before it. Split((cases = …, deaths = …)) on its own splits infections (parallel), while LatentDelay(Split((cases = …, deaths = …)), pmf) applies a common delay first and then splits, so a stream nested inside another stream's pipeline sits downstream of it (cascade).
The threaded quantity is the expected, not the realised, series
A downstream stream reads its upstream stream's expected (pre-error) series, never its realised, sampled counts. So a cascade threads the mean reported cases into deaths, not a noisy draw. The case where an observation depends on another stream's realised (error-corrupted) observation — feeding sampled cases, not expected cases, into deaths — is not covered here and is out of scope for now.
Split also prefixes each stream's sampled variables with the stream name automatically, so the streams stay distinct without any manual prefix layer.
Parallel: cases and deaths from shared infections
We drive the streams with a renewal infection process, exactly as in the renewal tutorial, and observe it through two pipelines. Cases are a short-delay, high-ascertainment negative-binomial stream. Deaths are a long-delay stream whose ascertainment — the infection-fatality ratio — is itself estimated: each stream is a full observation model, so its ascertainment can be a fixed fraction or, as here, a latent Intercept model with a prior.
using ComposableTuringIDModels, Distributions, Random, Turing, Mooncake
using ADTypes: AutoMooncake
Random.seed!(1234)
latent = AR(
damp = [truncated(Normal(0.8, 0.05), 0, 1),
truncated(Normal(0.1, 0.05), 0, 1)],
init = [Normal(0.0, 0.2), Normal(0.0, 0.2)],
ϵ_t = HierarchicalNormal(std = HalfNormal(0.1)))
renewal = Renewal(; generation_time = Gamma(6.5, 0.62),
rt = latent, initialisation = Normal(log(100.0), 0.1))
cases = LatentDelay(
Ascertainment(NegativeBinomialError(cluster_factor = HalfNormal(0.1)),
FixedIntercept(log(0.6))), # ~60% case ascertainment
LogNormal(1.6, 0.5)) # short infection→report delay
deaths = LatentDelay(
Ascertainment(NegativeBinomialError(cluster_factor = HalfNormal(0.1)),
Intercept(Normal(log(0.015), 0.25))), # estimated ~1.5% IFR
LogNormal(2.8, 0.4)) # long infection→death delay
parallel = Split((cases = cases, deaths = deaths))Split
├─ cases: LatentDelay
│ └─ model: Ascertainment
│ ├─ model: NegativeBinomialError
│ └─ latent: PrefixLatentModel
│ └─ model: FixedIntercept
└─ deaths: LatentDelay
└─ model: Ascertainment
├─ model: NegativeBinomialError
└─ latent: PrefixLatentModel
└─ model: InterceptThe composed model assembles the renewal infection process and the two-stream observation model exactly like a single-stream study.
model = IDModel(renewal, parallel)IDModel
├─ infection: Renewal
│ └─ rt: AR
│ └─ ϵ_t: HierarchicalNormal
└─ observation: Split
├─ cases: LatentDelay
│ └─ model: Ascertainment
│ ├─ model: NegativeBinomialError
│ └─ latent: PrefixLatentModel
│ └─ model: FixedIntercept
└─ deaths: LatentDelay
└─ model: Ascertainment
├─ model: NegativeBinomialError
└─ latent: PrefixLatentModel
└─ model: InterceptPassing missing data simulates a synthetic outbreak. The per-stream data contract is a NamedTuple keyed by stream name, and the returned generated_y_t is a NamedTuple of the two simulated series.
n = 70
sim = as_turing_model(model, (cases = missing, deaths = missing), n)()
y = sim.generated_y_t
(total_cases = sum(skipmissing(y.cases)), total_deaths = sum(skipmissing(y.deaths)))(total_cases = 6576, total_deaths = 82)Fitting conditions on both streams at once. We draw a full chain with NUTS, matching the other tutorials, and differentiate with Mooncake, the recommended backend for this package (see Automatic differentiation backend).
ydata = (cases = y.cases, deaths = y.deaths)
posterior = as_turing_model(model, ydata, n)
chain = sample(
posterior, NUTS(0.95; adtype = AutoMooncake(; config = nothing)),
MCMCThreads(), 250, 4; progress = false)┌ Info: Found initial step size
└ ϵ = 0.025
┌ Info: Found initial step size
└ ϵ = 0.00625
┌ Info: Found initial step size
└ ϵ = 0.0125
┌ Info: Found initial step size
└ ϵ = 0.025
┌ Warning: There were 5 divergent transitions. Consider reparameterising your model or using a smaller step size. For adaptive samplers such as NUTS and HMCDA, consider increasing `target_accept`.
└ @ Turing.Inference ~/.julia/packages/Turing/4sXd9/src/mcmc/hmc.jl:483
┌ Warning: There were 7 divergent transitions. Consider reparameterising your model or using a smaller step size. For adaptive samplers such as NUTS and HMCDA, consider increasing `target_accept`.
└ @ Turing.Inference ~/.julia/packages/Turing/4sXd9/src/mcmc/hmc.jl:483
┌ Warning: There were 4 divergent transitions. Consider reparameterising your model or using a smaller step size. For adaptive samplers such as NUTS and HMCDA, consider increasing `target_accept`.
└ @ Turing.Inference ~/.julia/packages/Turing/4sXd9/src/mcmc/hmc.jl:483
┌ Warning: There were 4 divergent transitions. Consider reparameterising your model or using a smaller step size. For adaptive samplers such as NUTS and HMCDA, consider increasing `target_accept`.
└ @ Turing.Inference ~/.julia/packages/Turing/4sXd9/src/mcmc/hmc.jl:483
┌ Warning: There were 20 divergent transitions. Consider reparameterising your model or using a smaller step size. For adaptive samplers such as NUTS and HMCDA, consider increasing `target_accept`.
└ @ Turing.Inference ~/.julia/packages/Turing/4sXd9/src/mcmc/hmc.jl:483The two streams keep their own overdispersion parameters — Split prefixes them cases.cluster_factor and deaths.cluster_factor — while sharing the one infection trajectory, and the deaths stream's estimated IFR intercept (deaths.Ascertainment.intercept) is recovered alongside them. The dense case stream pins the shared
using MCMCChains
summarystats(chain)╭─FlexiSummary (9 statistics) ─────────────────────────────────────────────────╮
│ iter collapsed │
│ chain collapsed │
│ ↓ stat = [mean, std, mcse, ess_bulk, ess_tail, rhat, q5, q50, q95] │
│ │
│ Parameters (147) ── AbstractPPL.VarName │
│ Float64 init[1], init[2], damp[1], damp[2], std, ϵ_t[1], ϵ_t[2], ϵ_t[3], │
│ ϵ_t[4], ϵ_t[5], ϵ_t[6], ϵ_t[7], ϵ_t[8], ϵ_t[9], ϵ_t[10], ϵ_t[11], │
│ ϵ_t[12], ϵ_t[13], ϵ_t[14], ϵ_t[15], ϵ_t[16], ϵ_t[17], ϵ_t[18], │
│ ϵ_t[19], ϵ_t[20], ϵ_t[21], ϵ_t[22], ϵ_t[23], ϵ_t[24], ϵ_t[25], │
│ ϵ_t[26], ϵ_t[27], ϵ_t[28], ϵ_t[29], ϵ_t[30], ϵ_t[31], ϵ_t[32], │
│ ϵ_t[33], ϵ_t[34], ϵ_t[35], ϵ_t[36], ϵ_t[37], ϵ_t[38], ϵ_t[39], │
│ ϵ_t[40], ϵ_t[41], ϵ_t[42], ϵ_t[43], ϵ_t[44], ϵ_t[45], ϵ_t[46], │
│ ϵ_t[47], ϵ_t[48], ϵ_t[49], ϵ_t[50], ϵ_t[51], ϵ_t[52], ϵ_t[53], │
│ ϵ_t[54], ϵ_t[55], ϵ_t[56], ϵ_t[57], ϵ_t[58], ϵ_t[59], ϵ_t[60], │
│ ϵ_t[61], ϵ_t[62], ϵ_t[63], ϵ_t[64], ϵ_t[65], ϵ_t[66], ϵ_t[67], │
│ ϵ_t[68], init_incidence, exp_I_t[1], exp_I_t[2], exp_I_t[3], │
│ exp_I_t[4], exp_I_t[5], exp_I_t[6], exp_I_t[7], exp_I_t[8], │
│ exp_I_t[9], exp_I_t[10], exp_I_t[11], exp_I_t[12], exp_I_t[13], │
│ exp_I_t[14], exp_I_t[15], exp_I_t[16], exp_I_t[17], exp_I_t[18], │
│ exp_I_t[19], exp_I_t[20], exp_I_t[21], exp_I_t[22], exp_I_t[23], │
│ exp_I_t[24], exp_I_t[25], exp_I_t[26], exp_I_t[27], exp_I_t[28], │
│ exp_I_t[29], exp_I_t[30], exp_I_t[31], exp_I_t[32], exp_I_t[33], │
│ exp_I_t[34], exp_I_t[35], exp_I_t[36], exp_I_t[37], exp_I_t[38], │
│ exp_I_t[39], exp_I_t[40], exp_I_t[41], exp_I_t[42], exp_I_t[43], │
│ exp_I_t[44], exp_I_t[45], exp_I_t[46], exp_I_t[47], exp_I_t[48], │
│ exp_I_t[49], exp_I_t[50], exp_I_t[51], exp_I_t[52], exp_I_t[53], │
│ exp_I_t[54], exp_I_t[55], exp_I_t[56], exp_I_t[57], exp_I_t[58], │
│ exp_I_t[59], exp_I_t[60], exp_I_t[61], exp_I_t[62], exp_I_t[63], │
│ exp_I_t[64], exp_I_t[65], exp_I_t[66], exp_I_t[67], exp_I_t[68], │
│ exp_I_t[69], exp_I_t[70], cases.cluster_factor, │
│ deaths.Ascertainment.intercept, deaths.cluster_factor │
│ │
│ Extras (14) │
│ Float64 n_steps, is_accept, acceptance_rate, log_density, │
│ hamiltonian_energy, hamiltonian_energy_error, │
│ max_hamiltonian_energy_error, tree_depth, numerical_error, │
│ step_size, nom_step_size, logprior, loglikelihood, logjoint │
│ │
│ Summary │
│ param mean std mcse ess_bulk ess_tail rhat … │
│ init[1] -0.0312 0.1976 0.0059 1127.2130 577.8214 1.0018 … │
│ init[2] 0.2941 0.1357 0.0045 889.8416 963.9832 1.0039 … │
│ damp[1] 0.7897 0.0428 0.0015 801.4896 773.1527 1.0022 … │
│ damp[2] 0.0891 0.0390 0.0012 911.3080 490.5608 1.0004 … │
│ std 0.0703 0.0298 0.0013 545.0376 744.6797 1.0015 … │
│ ϵ_t[1] 0.4169 0.9560 0.0292 1068.7674 657.6783 1.0026 … │
│ ϵ_t[2] 0.3802 0.9381 0.0261 1290.9751 878.5280 1.0015 … │
│ ϵ_t[3] 0.4385 0.9679 0.0278 1230.5764 670.8929 1.0010 … │
│ ϵ_t[4] 0.3549 0.9959 0.0269 1350.7626 784.9236 0.9995 … │
│ ϵ_t[5] 0.2715 0.9854 0.0283 1226.3736 755.5872 1.0020 … │
│ ϵ_t[6] 0.1953 0.9779 0.0260 1436.2952 710.7882 0.9991 … │
│ ϵ_t[7] 0.1666 0.9990 0.0258 1495.4679 835.4673 1.0070 … │
│ ϵ_t[8] 0.1494 1.0271 0.0308 1117.5526 767.6360 1.0035 … │
│ ϵ_t[9] 0.1088 1.0038 0.0257 1521.7526 563.6450 0.9994 … │
│ ϵ_t[10] 0.0011 0.9755 0.0281 1200.7520 634.0382 1.0080 … │
│ ϵ_t[11] -0.1238 0.9770 0.0275 1269.8430 677.9194 0.9997 … │
│ ϵ_t[12] -0.1410 0.9332 0.0281 1093.6777 695.6964 1.0019 … │
│ ϵ_t[13] -0.1724 0.9968 0.0240 1709.5595 600.7115 0.9995 … │
│ ϵ_t[14] -0.1671 0.9517 0.0255 1399.9846 646.8239 1.0007 … │
│ ϵ_t[15] -0.1404 0.9411 0.0261 1308.7754 569.3061 1.0021 … │
│ ϵ_t[16] -0.1706 0.9753 0.0248 1557.5368 738.9525 0.9992 … │
│ ϵ_t[17] -0.1206 0.9411 0.0255 1382.2962 597.9713 0.9994 … │
│ ϵ_t[18] -0.1427 0.9515 0.0285 1117.7639 570.5559 1.0013 … │
│ ϵ_t[19] -0.1603 0.9385 0.0257 1338.3461 785.8980 1.0015 … │
│ ϵ_t[20] -0.0632 0.9536 0.0263 1345.7687 579.5341 0.9998 … │
│ ϵ_t[21] -0.1790 1.0007 0.0264 1418.7807 628.1641 1.0067 … │
│ ϵ_t[22] -0.2307 0.9804 0.0239 1690.7036 629.6763 0.9998 … │
│ ϵ_t[23] -0.2668 0.9114 0.0253 1296.9434 843.5736 1.0021 … │
│ ϵ_t[24] -0.3124 0.9590 0.0271 1286.9799 679.4965 1.0031 … │
│ ϵ_t[25] -0.2689 0.9616 0.0250 1481.2779 898.2763 1.0006 … │
│ ϵ_t[26] -0.2083 1.0115 0.0281 1298.7021 697.0083 1.0013 … │
│ ϵ_t[27] -0.2408 0.9606 0.0274 1225.2250 688.9930 0.9993 … │
│ ϵ_t[28] -0.3025 0.9679 0.0288 1152.1084 617.7654 0.9999 … │
│ ϵ_t[29] -0.3346 0.9662 0.0233 1571.6879 705.9028 0.9990 … │
│ ϵ_t[30] -0.3575 0.9423 0.0245 1476.6402 767.7336 1.0002 … │
│ ϵ_t[31] -0.2802 1.0255 0.0311 1262.6374 556.6010 0.9991 … │
│ ϵ_t[32] -0.3341 0.9556 0.0256 1366.5011 736.5419 1.0067 … │
│ ϵ_t[33] -0.3868 0.9387 0.0262 1292.2572 651.4141 1.0023 … │
│ ϵ_t[34] -0.4517 0.9250 0.0238 1528.2559 844.5899 0.9993 … │
│ ϵ_t[35] -0.4282 0.9073 0.0252 1299.8254 793.0973 0.9993 … │
│ ϵ_t[36] -0.4150 0.9251 0.0277 1101.9173 654.4549 1.0012 … │
│ ϵ_t[37] -0.2317 0.9598 0.0250 1461.2540 907.7013 1.0006 … │
│ ϵ_t[38] -0.1349 0.9707 0.0253 1475.3243 570.5176 1.0023 … │
│ ϵ_t[39] -0.0543 0.9890 0.0252 1538.6770 809.1238 0.9993 … │
│ ϵ_t[40] 0.0922 0.9488 0.0250 1441.1376 709.5762 0.9998 … │
│ ϵ_t[41] 0.2228 0.9104 0.0239 1431.4232 905.5232 0.9995 … │
│ ϵ_t[42] 0.3279 0.9552 0.0277 1166.6558 683.1035 1.0032 … │
│ ϵ_t[43] 0.4247 0.9454 0.0276 1194.9183 756.6521 1.0001 … │
│ ϵ_t[44] 0.4737 0.9284 0.0248 1421.8246 456.5060 1.0001 … │
│ ϵ_t[45] 0.3472 0.9173 0.0267 1180.2258 743.4487 1.0017 … │
│ ϵ_t[46] 0.2795 0.9942 0.0253 1564.8734 660.0767 1.0054 … │
│ ϵ_t[47] 0.2002 0.9626 0.0252 1494.8119 718.8779 0.9994 … │
│ ϵ_t[48] 0.2867 1.0299 0.0270 1469.8045 679.3456 0.9993 … │
│ ϵ_t[49] 0.3146 0.9534 0.0281 1154.9638 785.8980 1.0006 … │
│ ϵ_t[50] 0.3605 0.9715 0.0293 1094.4896 679.1482 1.0006 … │
│ ϵ_t[51] 0.3981 0.9016 0.0241 1405.0840 872.8882 1.0012 … │
│ ϵ_t[52] 0.2927 0.9583 0.0277 1213.3493 678.5899 1.0014 … │
│ ϵ_t[53] 0.1375 0.9458 0.0248 1433.9268 790.8805 0.9993 … │
│ ϵ_t[54] -0.0235 0.9989 0.0269 1371.4853 618.2343 1.0017 … │
│ ϵ_t[55] -0.0852 1.0072 0.0260 1482.2072 689.2627 0.9995 … │
│ ϵ_t[56] -0.0757 0.9229 0.0276 1120.2503 661.0658 1.0021 … │
│ ϵ_t[57] -0.1213 0.9171 0.0263 1215.4784 740.6951 1.0000 … │
│ ϵ_t[58] -0.0023 0.9543 0.0270 1232.4542 819.5146 0.9995 … │
│ ϵ_t[59] 0.1648 0.9440 0.0245 1492.5497 745.5694 1.0002 … │
│ ϵ_t[60] 0.2286 0.9610 0.0264 1341.7978 604.8106 1.0006 … │
│ ϵ_t[61] 0.2170 0.9670 0.0259 1390.4680 534.0687 1.0033 … │
│ ϵ_t[62] 0.2179 0.9483 0.0239 1578.6915 645.4776 1.0016 … │
│ ϵ_t[63] 0.1125 0.9947 0.0274 1321.5486 720.5976 1.0008 … │
│ ϵ_t[64] 0.0952 1.0317 0.0288 1257.1241 738.0266 1.0028 … │
│ ϵ_t[65] -0.0101 1.0230 0.0269 1443.3472 768.4978 0.9991 … │
│ ϵ_t[66] -0.0020 0.9919 0.0263 1423.6353 561.4009 0.9998 … │
│ ϵ_t[67] 0.0040 1.0131 0.0284 1245.4663 726.3208 1.0026 … │
│ ϵ_t[68] 0.0413 1.0209 0.0285 1283.2441 534.3843 0.9990 … │
│ init_incide… 4.6617 0.1002 0.0035 818.4278 532.2620 0.9995 … │
│ exp_I_t[1] 105.7388 11.9856 0.4274 783.8796 715.6716 0.9994 … │
│ exp_I_t[2] 146.5625 25.0810 0.8659 861.5167 674.4684 1.0002 … │
│ exp_I_t[3] 141.3916 17.6205 0.5832 894.9558 789.1016 0.9993 … │
│ exp_I_t[4] 147.7299 17.9177 0.6054 877.0832 653.6760 1.0005 … │
│ exp_I_t[5] 159.7226 20.5648 0.6570 988.0309 702.6069 0.9992 … │
│ exp_I_t[6] 171.4057 20.8730 0.6490 1056.5588 871.5642 1.0002 … │
│ exp_I_t[7] 181.5480 22.2756 0.6339 1184.6242 994.9245 1.0013 … │
│ exp_I_t[8] 190.7460 20.8668 0.5576 1387.1384 881.3880 0.9994 … │
│ exp_I_t[9] 200.4140 20.6402 0.5516 1389.9864 942.2477 1.0002 … │
│ exp_I_t[10] 209.7587 20.6187 0.5774 1269.9531 894.4686 0.9993 … │
│ exp_I_t[11] 218.2648 19.1285 0.5026 1445.8166 810.5245 1.0019 … │
│ exp_I_t[12] 225.6589 18.1981 0.4866 1442.6049 810.7459 1.0000 … │
│ exp_I_t[13] 230.5510 16.9405 0.5512 939.2690 844.6288 1.0030 … │
│ exp_I_t[14] 235.1448 15.9772 0.4419 1250.2332 990.3156 0.9991 … │
│ exp_I_t[15] 238.6131 18.6714 0.5147 1339.3007 733.9352 1.0010 … │
│ exp_I_t[16] 241.0731 17.3894 0.4995 1300.8819 856.4395 0.9999 … │
│ exp_I_t[17] 243.1728 16.4739 0.4395 1406.8351 746.1896 1.0050 … │
│ exp_I_t[18] 244.2440 17.8941 0.4450 1671.4977 742.3869 0.9991 … │
│ exp_I_t[19] 245.8900 17.8266 0.4770 1413.6056 915.3549 0.9994 … │
│ exp_I_t[20] 245.8701 17.0252 0.4618 1373.1387 773.6396 0.9999 … │
│ exp_I_t[21] 245.3501 16.4630 0.4602 1292.9206 868.2807 0.9998 … │
│ exp_I_t[22] 246.5527 18.6406 0.5095 1437.0067 849.8517 0.9994 … │
│ exp_I_t[23] 245.0310 17.7194 0.4567 1507.4811 943.0320 0.9997 … │
│ exp_I_t[24] 242.1461 17.0381 0.4532 1398.6365 885.5151 0.9993 … │
│ exp_I_t[25] 238.7711 16.3906 0.4630 1253.4076 880.6356 1.0000 … │
│ exp_I_t[26] 234.2212 16.4343 0.4353 1430.3392 800.1835 0.9998 … │
│ exp_I_t[27] 231.1680 16.4262 0.4313 1491.4297 934.0132 0.9996 … │
│ exp_I_t[28] 228.2763 17.0973 0.5555 971.2081 734.6082 1.0038 … │
│ exp_I_t[29] 224.0347 16.0869 0.5210 1010.7467 596.4737 1.0028 … │
│ exp_I_t[30] 218.6166 15.5046 0.4325 1279.3159 804.6567 1.0042 … │
│ exp_I_t[31] 213.1599 15.5765 0.4319 1301.4052 736.4902 1.0022 … │
│ exp_I_t[32] 207.2770 15.0981 0.4083 1335.2504 823.2405 0.9997 … │
│ exp_I_t[33] 202.3472 15.6271 0.4657 1145.6669 732.9620 1.0002 … │
│ exp_I_t[34] 196.2093 14.8709 0.3957 1488.0340 908.5485 0.9991 … │
│ exp_I_t[35] 189.5169 14.1796 0.3878 1308.7771 1024.3146 1.0006 … │
│ exp_I_t[36] 181.5843 12.4064 0.3523 1238.8006 975.4709 0.9998 … │
│ exp_I_t[37] 174.2607 12.6521 0.3448 1328.2154 973.3333 0.9990 … │
│ exp_I_t[38] 167.0007 12.3392 0.3490 1242.5092 880.2411 0.9997 … │
│ exp_I_t[39] 161.8599 12.7080 0.3417 1407.5634 703.7570 1.0040 … │
│ exp_I_t[40] 156.9577 12.0305 0.3255 1357.7780 799.2115 1.0018 … │
│ exp_I_t[41] 152.9770 12.6351 0.3798 1127.3989 676.8982 1.0015 … │
│ exp_I_t[42] 150.4215 11.4896 0.3374 1095.1080 1021.4676 1.0040 … │
│ exp_I_t[43] 149.1282 11.7858 0.3957 881.6908 775.3063 1.0023 … │
│ exp_I_t[44] 149.4955 11.3558 0.3218 1223.0251 968.6727 1.0019 … │
│ exp_I_t[45] 150.9643 11.4683 0.3433 1199.1969 831.3565 1.0033 … │
│ exp_I_t[46] 153.7607 11.0454 0.3055 1306.1130 780.3280 1.0039 … │
│ exp_I_t[47] 155.6917 11.9439 0.3283 1301.9893 762.5789 0.9996 … │
│ exp_I_t[48] 157.4077 12.0085 0.3236 1373.9880 782.7594 0.9993 … │
│ exp_I_t[49] 159.0057 12.1191 0.3805 995.3686 789.8608 1.0003 … │
│ exp_I_t[50] 162.3984 12.7457 0.3538 1297.5916 882.9393 0.9997 … │
│ exp_I_t[51] 166.3368 11.9311 0.3911 962.3546 795.3131 0.9996 … │
│ exp_I_t[52] 171.5696 12.6320 0.3450 1350.3778 948.6378 0.9991 … │
│ exp_I_t[53] 177.0396 13.1764 0.3836 1174.4458 906.3856 1.0017 … │
│ exp_I_t[54] 181.5956 13.7029 0.4374 983.6324 908.0965 0.9997 … │
│ exp_I_t[55] 185.4579 14.3958 0.4224 1245.7157 876.7427 1.0004 … │
│ exp_I_t[56] 187.5416 14.6362 0.3714 1600.9468 943.1262 1.0078 … │
│ exp_I_t[57] 188.9590 13.9237 0.3922 1242.9672 793.0973 1.0019 … │
│ exp_I_t[58] 190.2440 13.5632 0.3645 1384.9029 871.0345 0.9990 … │
│ exp_I_t[59] 190.5880 13.4707 0.3966 1167.1084 690.1402 1.0006 … │
│ exp_I_t[60] 192.6344 14.0280 0.4336 1083.2752 674.3759 1.0013 … │
│ exp_I_t[61] 195.7197 14.7610 0.4345 1203.3049 921.2935 0.9992 … │
│ exp_I_t[62] 199.9770 15.0338 0.4535 1075.9412 734.6116 1.0008 … │
│ exp_I_t[63] 203.9789 15.4944 0.4703 1111.5736 751.3976 1.0009 … │
│ exp_I_t[64] 208.3366 17.5676 0.5399 1079.2619 626.6145 1.0012 … │
│ exp_I_t[65] 211.4538 19.2260 0.5620 1188.1456 948.4357 1.0005 … │
│ exp_I_t[66] 215.1357 22.6648 0.6614 1159.8935 1004.5510 1.0027 … │
│ exp_I_t[67] 217.7363 27.5976 0.7679 1324.2945 876.3151 0.9999 … │
│ exp_I_t[68] 221.1375 33.4510 0.9630 1273.1192 837.7206 0.9994 … │
│ exp_I_t[69] 224.3814 39.6362 1.1665 1226.9957 842.1481 1.0003 … │
│ exp_I_t[70] 228.4868 46.7752 1.4229 1169.5174 767.8486 0.9996 … │
│ cases.clust… 0.0935 0.0198 0.0007 846.8558 690.6421 1.0002 … │
│ deaths.Asce… -4.1861 0.1027 0.0033 1002.9586 667.6912 1.0018 … │
│ deaths.clus… 0.1046 0.0806 0.0024 614.6377 273.3758 1.0007 … │
╰──────────────────────────────────────────────────────────────────────────────╯Summary statistics confirm the parameters converged, but they do not show whether the fit actually tracks the two simulated series. Posterior-predictive draws from the same fitted chain, plotted against the simulated counts, close that loop. The helpers below turn a time × draws matrix into 50% and 95% credible bands and draw a median line with ribbons. predictive_bands walks a named stream's per-index sampled y_t, filling any index a stream's delay leaves unscored with missing.
Split prefixes each stream's y_t, so predictive_bands reads cases.y_t[i] and deaths.y_t[i] off the predict chain, the prefixed equivalent of the bare y_t[i] the renewal tutorial reads from a single-stream model:
missmodel = as_turing_model(model, (cases = missing, deaths = missing), n)
pred = predict(missmodel, chain)
cases_bands = predictive_bands(pred, n, i -> @varname(cases.y_t[i]))
deaths_bands = predictive_bands(pred, n, i -> @varname(deaths.y_t[i]))
fig = Figure(; size = (760, 620))
ax1 = Axis(fig[1, 1]; ylabel = "Cases")
ci_ribbon!(ax1, 1:n, cases_bands; color = :teal,
label = "posterior predictive")
scatter!(ax1, 1:n, y.cases; color = :black, markersize = 6,
label = "simulated")
axislegend(ax1; position = :lt)
ax2 = Axis(fig[2, 1]; xlabel = "Day", ylabel = "Deaths")
ci_ribbon!(ax2, 1:n, deaths_bands; color = :firebrick,
label = "posterior predictive")
scatter!(ax2, 1:n, y.deaths; color = :black, markersize = 6,
label = "simulated")
axislegend(ax2; position = :lt)
fig
The band covers the simulated series on almost every day for both streams, and both medians track the outbreak's rise and fall rather than sitting flat at the mean. The sparser death series (82 simulated deaths against 6576 cases over the same 70 days) still recovers: its band is visibly wider, but it moves with the same underlying trajectory rather than needing its own signal to do so.
Cascade: deaths downstream of reported cases
In the parallel model, cases and deaths both branch off infections, so a reporting artefact in the case series (a weekend dip, an ascertainment change) does not touch deaths. Sometimes we want the opposite: deaths modelled as a delayed fraction of the reported cases, so whatever is reflected in cases propagates into deaths. That is a cascade Split placed lower in the stack. Share the infection→case-report delay, then split: the cases stream applies its error to the delayed expectation, and the deaths stream sits downstream, delayed again by the case-report→death interval and scaled by the fatality fraction.
cascade = LatentDelay( # infection→case delay
Split((
cases = NegativeBinomialError(cluster_factor = HalfNormal(0.1)),
deaths = LatentDelay( # case→death delay
Ascertainment(NegativeBinomialError(cluster_factor = HalfNormal(0.1)),
FixedIntercept(log(0.02))),
LogNormal(2.2, 0.3)))),
LogNormal(1.6, 0.5))
cascade_model = IDModel(renewal, cascade)
cas = as_turing_model(cascade_model, (cases = missing, deaths = missing), n)()(generated_y_t = (cases = Union{Missing, Int64}[76, 72, 60, 69, 66, 71, 62, 46, 46, 50 … 61, 82, 63, 61, 76, 68, 84, 90, 86, 86], deaths = Union{Missing, Int64}[missing, missing, missing, missing, missing, missing, missing, missing, missing, missing … 1, 3, 0, 2, 0, 1, 3, 1, 1, 1]), expected_y_t = (cases = [75.53059845577076, 72.44929725908295, 69.92288327324468, 67.95719680096136, 66.23523286089522, 64.42851736453831, 62.49544408093108, 60.47576001981976, 58.18250975128724, 55.980231209181426 … 64.63232837947915, 66.88221842964651, 69.59856713167973, 72.4695311197853, 75.39665393344198, 78.68832044145, 82.8346591507756, 88.88308678615209, 96.72087893974384, 104.97289041883072], deaths = [1.178497060321164, 1.1407977091182842, 1.1053536824055297, 1.071938289122182, 1.0404586455237261, 1.0116915367183719, 0.9874223037358283, 0.9697770693161261, 0.960226697324335, 0.9589120767728494 … 1.089858873114468, 1.0983089769499856, 1.1109245375189378, 1.1278410634210507, 1.148525252384327, 1.1723448357899462, 1.1991294408795437, 1.2292772287703064, 1.2634772367736475, 1.3023457786428807]), I_t = [113.30421443691378, 106.82968869917647, 106.18237385570397, 112.15670832320137, 92.94825873829538, 92.57431980561839, 82.7041194465945, 87.80794116051, 71.9785627876843, 85.39007765551665 … 81.807600552076, 81.17677723596945, 85.86204133897627, 92.89058733268088, 98.58007449113917, 125.76289301812933, 127.23451353757879, 131.68647258400281, 138.83188030260231, 146.43831325605967], Z_t = [0.17259244977107174, 0.06970139686157353, 0.022542067915055593, 0.04971034951598992, -0.1490756066790227, -0.15443781883360352, -0.2510687657770778, -0.15220429564275473, -0.29738249331586714, -0.07166464912115547 … 0.19879069380148912, 0.15019044422228722, 0.1588521599312567, 0.19279721594984672, 0.21178553278647555, 0.4095317467611087, 0.362061148891969, 0.3090814741046563, 0.26077230897298154, 0.22655433567418015])The Split sits after the shared case delay and before the error leaves, so the deaths stream's expected input is the delayed-and-ascertained expected cases, not the raw infections: it is both scaled by the fatality fraction and shortened by the case delay.
(cases_expected_length = length(cas.expected_y_t.cases),
deaths_expected_length = length(cas.expected_y_t.deaths),
deaths_are_a_fraction_of_cases =
sum(cas.expected_y_t.deaths) < sum(cas.expected_y_t.cases))(cases_expected_length = 55, deaths_expected_length = 38, deaths_are_a_fraction_of_cases = true)Strata: one stream per age band
A stratified stream — one observation series per age band, region, or variant — is again the same construct, here composed with the renewal infection process and observed through one named stream per band. Each band is a full observation model, so its delay and ascertainment can differ, and its parameters are namespaced by the band name.
strata_obs = Split((
young = LatentDelay(
Ascertainment(NegativeBinomialError(cluster_factor = HalfNormal(0.1)),
FixedIntercept(log(0.7))), LogNormal(1.5, 0.4)),
old = LatentDelay(
Ascertainment(NegativeBinomialError(cluster_factor = HalfNormal(0.1)),
FixedIntercept(log(0.4))), LogNormal(1.8, 0.4))))
strata_model = IDModel(renewal, strata_obs)
strata_sim = as_turing_model(
strata_model, (young = missing, old = missing), n)().generated_y_t
map(s -> sum(skipmissing(s)), strata_sim) # totals per band(young = 3818, old = 2089)The streams above each observe the same infections. When the streams instead draw on a weighted mix of infections — one band, another band, and a summed total — the same Split carries an observation-strata × infection-strata weight matrix, and a single template model is replicated once per data stream. Split(template, W) projects the infection series reaching it through W, so it composes inside an IDModel like any other observation model: the infections come from the modelled process, not a hand-built series. One weight matrix covers the one-to-one (an identity map), many-to-one (an aggregation row summing infection strata into one stream), and many-to-many (a general matrix) infection → observation cases.
Here the renewal process supplies one infection stratum, and W maps it onto a young band, an old band, and their total:
W = reshape([0.7, 0.3, 1.0], 3, 1) # young, old, and their total
weighted = Split(LatentDelay(PoissonError(), LogNormal(1.6, 0.5)), W)
weighted_model = IDModel(renewal, weighted)
age = as_turing_model(
weighted_model, (young = missing, old = missing, total = missing), n)()
map(s -> sum(skipmissing(s)), age.generated_y_t) # simulated total per band(young = 2595, old = 1172, total = 3853)The aggregate total stream sees the summed expected infections of both bands — its expected series is exactly young .+ old.
Simulating checks that the forward map runs. It does not check that a many-to-one W is actually recoverable from data. Fitting weighted_model to its own simulated streams answers that: the fit conditions on young, old, and the aggregate total together, exactly as Split conditions on any other named streams.
weighted_data = (young = age.generated_y_t.young, old = age.generated_y_t.old,
total = age.generated_y_t.total)
weighted_posterior = as_turing_model(weighted_model, weighted_data, n)
weighted_chain = sample(
weighted_posterior, NUTS(0.95; adtype = AutoMooncake(; config = nothing)),
MCMCThreads(), 250, 2; progress = false)┌ Info: Found initial step size
└ ϵ = 0.0015625
┌ Info: Found initial step size
└ ϵ = 4.8828125e-5
┌ Warning: There were 115 divergent transitions. Consider reparameterising your model or using a smaller step size. For adaptive samplers such as NUTS and HMCDA, consider increasing `target_accept`.
└ @ Turing.Inference ~/.julia/packages/Turing/4sXd9/src/mcmc/hmc.jl:483
┌ Warning: There were 13 divergent transitions. Consider reparameterising your model or using a smaller step size. For adaptive samplers such as NUTS and HMCDA, consider increasing `target_accept`.
└ @ Turing.Inference ~/.julia/packages/Turing/4sXd9/src/mcmc/hmc.jl:483
┌ Warning: There were 128 divergent transitions. Consider reparameterising your model or using a smaller step size. For adaptive samplers such as NUTS and HMCDA, consider increasing `target_accept`.
└ @ Turing.Inference ~/.julia/packages/Turing/4sXd9/src/mcmc/hmc.jl:483young, old, and total are not three independent counts: total is exactly young + old, so all three read the same one-stratum
summarystats(weighted_chain)╭─FlexiSummary (9 statistics) ─────────────────────────────────────────────────╮
│ iter collapsed │
│ chain collapsed │
│ ↓ stat = [mean, std, mcse, ess_bulk, ess_tail, rhat, q5, q50, q95] │
│ │
│ Parameters (144) ── AbstractPPL.VarName │
│ Float64 init[1], init[2], damp[1], damp[2], std, ϵ_t[1], ϵ_t[2], ϵ_t[3], │
│ ϵ_t[4], ϵ_t[5], ϵ_t[6], ϵ_t[7], ϵ_t[8], ϵ_t[9], ϵ_t[10], ϵ_t[11], │
│ ϵ_t[12], ϵ_t[13], ϵ_t[14], ϵ_t[15], ϵ_t[16], ϵ_t[17], ϵ_t[18], │
│ ϵ_t[19], ϵ_t[20], ϵ_t[21], ϵ_t[22], ϵ_t[23], ϵ_t[24], ϵ_t[25], │
│ ϵ_t[26], ϵ_t[27], ϵ_t[28], ϵ_t[29], ϵ_t[30], ϵ_t[31], ϵ_t[32], │
│ ϵ_t[33], ϵ_t[34], ϵ_t[35], ϵ_t[36], ϵ_t[37], ϵ_t[38], ϵ_t[39], │
│ ϵ_t[40], ϵ_t[41], ϵ_t[42], ϵ_t[43], ϵ_t[44], ϵ_t[45], ϵ_t[46], │
│ ϵ_t[47], ϵ_t[48], ϵ_t[49], ϵ_t[50], ϵ_t[51], ϵ_t[52], ϵ_t[53], │
│ ϵ_t[54], ϵ_t[55], ϵ_t[56], ϵ_t[57], ϵ_t[58], ϵ_t[59], ϵ_t[60], │
│ ϵ_t[61], ϵ_t[62], ϵ_t[63], ϵ_t[64], ϵ_t[65], ϵ_t[66], ϵ_t[67], │
│ ϵ_t[68], init_incidence, exp_I_t[1], exp_I_t[2], exp_I_t[3], │
│ exp_I_t[4], exp_I_t[5], exp_I_t[6], exp_I_t[7], exp_I_t[8], │
│ exp_I_t[9], exp_I_t[10], exp_I_t[11], exp_I_t[12], exp_I_t[13], │
│ exp_I_t[14], exp_I_t[15], exp_I_t[16], exp_I_t[17], exp_I_t[18], │
│ exp_I_t[19], exp_I_t[20], exp_I_t[21], exp_I_t[22], exp_I_t[23], │
│ exp_I_t[24], exp_I_t[25], exp_I_t[26], exp_I_t[27], exp_I_t[28], │
│ exp_I_t[29], exp_I_t[30], exp_I_t[31], exp_I_t[32], exp_I_t[33], │
│ exp_I_t[34], exp_I_t[35], exp_I_t[36], exp_I_t[37], exp_I_t[38], │
│ exp_I_t[39], exp_I_t[40], exp_I_t[41], exp_I_t[42], exp_I_t[43], │
│ exp_I_t[44], exp_I_t[45], exp_I_t[46], exp_I_t[47], exp_I_t[48], │
│ exp_I_t[49], exp_I_t[50], exp_I_t[51], exp_I_t[52], exp_I_t[53], │
│ exp_I_t[54], exp_I_t[55], exp_I_t[56], exp_I_t[57], exp_I_t[58], │
│ exp_I_t[59], exp_I_t[60], exp_I_t[61], exp_I_t[62], exp_I_t[63], │
│ exp_I_t[64], exp_I_t[65], exp_I_t[66], exp_I_t[67], exp_I_t[68], │
│ exp_I_t[69], exp_I_t[70] │
│ │
│ Extras (14) │
│ Float64 n_steps, is_accept, acceptance_rate, log_density, │
│ hamiltonian_energy, hamiltonian_energy_error, │
│ max_hamiltonian_energy_error, tree_depth, numerical_error, │
│ step_size, nom_step_size, logprior, loglikelihood, logjoint │
│ │
│ Summary │
│ param mean std mcse ess_bulk ess_tail rhat … │
│ init[1] 0.0533 0.1341 0.0278 334.4891 26.4487 2.4620 … │
│ init[2] -0.1271 0.0590 0.0346 3.4581 28.6452 2.2916 … │
│ damp[1] 0.7829 0.0298 0.0040 120.8181 40.2327 2.4620 … │
│ damp[2] 0.4353 0.3410 0.3375 1.2314 NaN 2.4620 … │
│ std 0.0742 0.0662 0.0656 1.2678 NaN 2.4328 … │
│ ϵ_t[1] 0.7910 1.0237 0.8433 1.8519 24.0768 2.2916 … │
│ ϵ_t[2] -0.6684 1.0417 0.7620 2.0331 42.3223 2.2916 … │
│ ϵ_t[3] 0.4355 0.8738 0.5553 3.2756 35.7641 2.2916 … │
│ ϵ_t[4] -0.7113 0.9383 0.7609 1.6608 11.7031 2.4620 … │
│ ϵ_t[5] 0.0871 0.6826 0.0345 346.4496 37.3388 2.4620 … │
│ ϵ_t[6] -0.8072 1.0441 0.8303 1.7674 1.4546 2.2916 … │
│ ϵ_t[7] -0.2318 0.7983 0.1394 219.3628 27.3336 2.4620 … │
│ ϵ_t[8] 0.6349 0.9047 0.6414 2.6824 34.7500 2.2916 … │
│ ϵ_t[9] 0.6315 0.8950 0.6917 1.9459 28.0057 2.2916 … │
│ ϵ_t[10] -0.2365 0.7353 0.1685 331.4545 23.8562 2.4620 … │
│ ϵ_t[11] -0.3251 0.7208 0.3740 13.8161 52.5757 2.4620 … │
│ ϵ_t[12] 0.8004 1.0454 0.8338 1.9329 30.1022 2.2916 … │
│ ϵ_t[13] 0.8720 1.1916 1.0303 1.4366 33.9533 2.2916 … │
│ ϵ_t[14] 0.0426 0.7252 0.0341 362.2749 25.6309 2.4620 … │
│ ϵ_t[15] 0.2839 0.7901 0.4373 4.7197 26.8222 2.4620 … │
│ ϵ_t[16] 0.6623 1.1761 0.9987 1.4611 25.3163 2.2916 … │
│ ϵ_t[17] -0.3302 0.7334 0.2111 48.4169 22.0563 2.4620 … │
│ ϵ_t[18] -0.9174 0.9215 0.7466 1.7056 1.4311 2.2916 … │
│ ϵ_t[19] -0.2458 0.6884 0.0311 280.8451 28.1511 2.4620 … │
│ ϵ_t[20] -0.2534 0.7253 0.0292 450.2633 35.5182 2.4620 … │
│ ϵ_t[21] 0.2725 0.7911 0.4319 5.7766 28.0198 2.4620 … │
│ ϵ_t[22] -0.9366 1.1180 0.9408 1.6595 1.4085 2.2916 … │
│ ϵ_t[23] -0.0822 0.7153 0.0276 491.3797 24.7931 2.4620 … │
│ ϵ_t[24] -0.0853 0.7426 0.0344 400.0443 20.2648 2.4620 … │
│ ϵ_t[25] 0.4186 0.8546 0.5709 2.6788 21.9694 2.4620 … │
│ ϵ_t[26] 0.9478 1.2036 1.0741 1.3463 25.6498 2.2916 … │
│ ϵ_t[27] -0.3629 0.7199 0.3696 4.1774 27.3252 2.4620 … │
│ ϵ_t[28] -0.9231 1.1798 0.9935 1.5362 1.3764 2.2916 … │
│ ϵ_t[29] -0.4443 0.9028 0.4156 7.4860 27.3539 2.4620 … │
│ ϵ_t[30] -0.2816 0.7994 0.3924 6.9880 24.7333 2.4620 … │
│ ϵ_t[31] 0.9555 1.1476 1.0231 1.3506 41.9024 2.2916 … │
│ ϵ_t[32] 0.4918 0.9257 0.6269 2.8427 41.1899 2.2916 … │
│ ϵ_t[33] 0.0276 0.6155 0.0250 457.4934 31.4550 2.4620 … │
│ ϵ_t[34] 0.0440 0.7386 0.0377 219.9130 22.8347 2.4620 … │
│ ϵ_t[35] 0.3049 0.6823 0.2733 17.4012 35.8544 2.4620 … │
│ ϵ_t[36] 0.5698 0.8952 0.6938 1.9827 27.1211 2.4620 … │
│ ϵ_t[37] 0.0386 0.7036 0.0302 451.6206 34.7152 2.4620 … │
│ ϵ_t[38] -0.9317 1.0594 0.9185 1.3820 7.1742 2.4620 … │
│ ϵ_t[39] -0.0245 0.6725 0.0336 379.9781 23.7321 2.4620 … │
│ ϵ_t[40] -0.4966 0.8583 0.5866 2.8976 23.3143 2.4620 … │
│ ϵ_t[41] -0.3273 0.7859 0.3719 6.7663 48.6509 2.4620 … │
│ ϵ_t[42] -0.7094 1.0396 0.8314 2.0205 28.5576 2.4620 … │
│ ϵ_t[43] 0.6000 0.9018 0.5687 2.9778 22.5676 2.4620 … │
│ ϵ_t[44] -0.3112 0.7400 0.3937 6.5334 37.4754 2.4620 … │
│ ϵ_t[45] 0.5698 0.8732 0.5618 2.2451 42.9092 2.4620 … │
│ ϵ_t[46] -0.7188 1.1291 0.9830 1.4557 1.3455 2.2916 … │
│ ϵ_t[47] 1.0408 1.1384 0.9358 1.5588 34.8877 2.4620 … │
│ ϵ_t[48] 0.2814 0.6124 0.0306 308.1362 28.7718 2.4620 … │
│ ϵ_t[49] 0.6118 0.8277 0.5435 2.8457 34.4132 2.4620 … │
│ ϵ_t[50] 0.2147 0.6958 0.0952 148.3108 27.8624 2.4620 … │
│ ϵ_t[51] -0.6931 0.9400 0.7727 1.6900 12.1316 2.4620 … │
│ ϵ_t[52] -0.6434 0.9048 0.6945 1.9033 14.3231 2.4620 … │
│ ϵ_t[53] -0.3911 0.6992 0.3584 5.7891 32.7163 2.4620 … │
│ ϵ_t[54] 0.5582 0.8046 0.4532 5.5923 20.5028 2.4620 … │
│ ϵ_t[55] -0.4594 0.8516 0.6465 1.8980 1.4900 2.2916 … │
│ ϵ_t[56] -0.5848 0.8934 0.7246 1.8388 1.4663 2.2916 … │
│ ϵ_t[57] 0.6137 0.8618 0.5514 2.9887 28.0136 2.2916 … │
│ ϵ_t[58] -0.8736 1.1572 0.9907 1.4035 1.3258 2.2916 … │
│ ϵ_t[59] -0.9698 1.2441 1.1032 1.2586 1.2791 2.3201 … │
│ ϵ_t[60] 0.4297 0.8293 0.5624 2.9256 19.1204 2.4620 … │
│ ϵ_t[61] 0.1087 0.7233 0.0646 225.5944 32.2354 2.4620 … │
│ ϵ_t[62] -0.3598 0.7125 0.4261 4.5775 43.3768 2.4620 … │
│ ϵ_t[63] -0.0894 0.7012 0.0324 401.9320 31.1354 2.4620 … │
│ ϵ_t[64] 0.5280 0.8422 0.6103 2.1336 28.0399 2.2916 … │
│ ϵ_t[65] 0.7775 1.1545 0.9771 1.4836 22.4896 2.2916 … │
│ ϵ_t[66] 0.2816 0.7458 0.3275 9.6922 29.4872 2.4620 … │
│ ϵ_t[67] -0.4567 0.8062 0.5478 2.8833 25.8418 2.2916 … │
│ ϵ_t[68] 0.7771 1.1124 0.9318 1.4989 41.0708 2.2916 … │
│ init_incide… 1.6945 2.8920 2.8684 1.2632 5.6456 2.4328 … │
│ exp_I_t[1] 49.5708 49.7862 49.1272 1.2638 5.6456 2.4328 … │
│ exp_I_t[2] 41.8320 42.0758 41.4849 1.2661 5.6456 2.4328 … │
│ exp_I_t[3] 43.2596 43.1146 42.6758 1.2645 5.6456 2.4524 … │
│ exp_I_t[4] 42.9505 42.8439 42.4371 1.2623 5.6456 2.4328 … │
│ exp_I_t[5] 42.1208 41.8922 41.5022 1.2619 5.6456 2.4328 … │
│ exp_I_t[6] 41.0747 40.9260 40.5519 1.2620 5.6456 2.4524 … │
│ exp_I_t[7] 40.4397 40.2038 39.8432 1.2632 5.6456 2.4524 … │
│ exp_I_t[8] 39.8247 39.6698 39.3195 1.2638 5.6456 2.4328 … │
│ exp_I_t[9] 39.3702 39.1814 38.8420 1.2642 5.6456 2.4328 … │
│ exp_I_t[10] 38.9059 38.7115 38.3774 1.2632 5.6456 2.4524 … │
│ exp_I_t[11] 38.5464 38.3287 38.0024 1.2637 5.6456 2.3201 … │
│ exp_I_t[12] 38.1112 37.9359 37.6153 1.2653 5.6456 2.4328 … │
│ exp_I_t[13] 37.7652 37.6077 37.2912 1.2665 5.6456 2.4328 … │
│ exp_I_t[14] 37.5238 37.3372 37.0238 1.2684 5.6456 2.4328 … │
│ exp_I_t[15] 37.2391 37.0382 36.7277 1.2673 5.6456 2.4524 … │
│ exp_I_t[16] 37.0090 36.8329 36.5247 1.2660 5.6456 2.3201 … │
│ exp_I_t[17] 36.7589 36.5603 36.2546 1.2659 5.6456 2.4328 … │
│ exp_I_t[18] 36.4675 36.2225 35.9202 1.2676 5.6456 2.4328 … │
│ exp_I_t[19] 36.2538 36.0302 35.7308 1.2680 5.6456 2.4524 … │
│ exp_I_t[20] 35.9855 35.7751 35.4799 1.2665 5.6456 2.4524 … │
│ exp_I_t[21] 35.7646 35.5349 35.2409 1.2651 5.6456 2.3201 … │
│ exp_I_t[22] 35.5328 35.3091 35.0173 1.2641 5.6456 2.4328 … │
│ exp_I_t[23] 35.3668 35.1030 34.8132 1.2634 5.6456 2.4524 … │
│ exp_I_t[24] 35.1434 34.9529 34.6650 1.2638 5.6456 2.3201 … │
│ exp_I_t[25] 34.9681 34.7399 34.4536 1.2628 5.6456 2.4524 … │
│ exp_I_t[26] 34.8380 34.6413 34.3564 1.2626 5.6456 2.4524 … │
│ exp_I_t[27] 34.7240 34.4919 34.2084 1.2620 5.6456 2.4524 … │
│ exp_I_t[28] 34.6328 34.3582 34.0755 1.2631 5.6456 2.3201 … │
│ exp_I_t[29] 34.4997 34.2651 33.9828 1.2647 5.6456 2.3201 … │
│ exp_I_t[30] 34.3876 34.1828 33.9002 1.2625 5.6456 2.3201 … │
│ exp_I_t[31] 34.2663 34.0677 33.7855 1.2634 5.6456 2.3201 … │
│ exp_I_t[32] 34.2029 34.0322 33.7498 1.2638 5.6456 2.4328 … │
│ exp_I_t[33] 34.1594 33.9386 33.6584 1.2632 5.6456 2.4328 … │
│ exp_I_t[34] 34.1048 33.9043 33.6251 1.2617 5.6456 2.3201 … │
│ exp_I_t[35] 34.0106 33.8157 33.5360 1.2635 5.6456 2.3201 … │
│ exp_I_t[36] 33.9366 33.7496 33.4700 1.2640 5.6456 2.4328 … │
│ exp_I_t[37] 33.9412 33.7381 33.4600 1.2636 5.6456 2.4328 … │
│ exp_I_t[38] 33.8921 33.6599 33.3820 1.2622 5.6456 2.4524 … │
│ exp_I_t[39] 33.8880 33.6588 33.3818 1.2635 5.6456 2.4328 … │
│ exp_I_t[40] 33.8197 33.6318 33.3544 1.2650 5.6456 2.4328 … │
│ exp_I_t[41] 33.8399 33.6211 33.3438 1.2663 5.6456 2.3201 … │
│ exp_I_t[42] 33.7608 33.5871 33.3103 1.2637 5.6456 2.4328 … │
│ exp_I_t[43] 33.6976 33.5318 33.2557 1.2644 5.6456 2.3201 … │
│ exp_I_t[44] 33.6326 33.5261 33.2487 1.2624 5.6456 2.4328 … │
│ exp_I_t[45] 33.6658 33.5511 33.2732 1.2622 5.6456 2.4524 … │
│ exp_I_t[46] 33.5989 33.5454 33.2675 1.2630 5.6456 2.4524 … │
│ exp_I_t[47] 33.5770 33.5322 33.2544 1.2631 5.6456 2.4328 … │
│ exp_I_t[48] 33.5806 33.5875 33.3094 1.2637 5.6456 2.4524 … │
│ exp_I_t[49] 33.6159 33.6290 33.3508 1.2648 5.6456 2.4328 … │
│ exp_I_t[50] 33.6415 33.6743 33.3969 1.2649 5.6456 2.4524 … │
│ exp_I_t[51] 33.6837 33.7236 33.4460 1.2622 5.6456 2.4328 … │
│ exp_I_t[52] 33.6825 33.7268 33.4494 1.2632 5.6456 2.4524 … │
│ exp_I_t[53] 33.6704 33.7164 33.4389 1.2638 5.6456 2.4524 … │
│ exp_I_t[54] 33.7013 33.7472 33.4697 1.2626 5.6456 2.4524 … │
│ exp_I_t[55] 33.6902 33.7356 33.4585 1.2625 5.6456 2.3201 … │
│ exp_I_t[56] 33.7899 33.8354 33.5574 1.2626 5.6456 2.4328 … │
│ exp_I_t[57] 33.8080 33.8549 33.5760 1.2633 5.6456 2.4524 … │
│ exp_I_t[58] 33.8154 33.8637 33.5841 1.2623 5.6456 2.3201 … │
│ exp_I_t[59] 33.9145 33.9641 33.6829 1.2624 5.6456 2.6190 … │
│ exp_I_t[60] 33.9220 33.9713 33.6902 1.2626 5.6456 2.6190 … │
│ exp_I_t[61] 33.9749 34.0268 33.7441 1.2639 5.6456 2.6190 … │
│ exp_I_t[62] 34.0038 34.0605 33.7749 1.2634 5.6456 2.6190 … │
│ exp_I_t[63] 34.0394 34.1001 33.8121 1.2638 5.6456 2.6190 … │
│ exp_I_t[64] 34.0564 34.1214 33.8311 1.2625 5.6456 2.6190 … │
│ exp_I_t[65] 34.0573 34.1252 33.8335 1.2617 5.6456 2.6190 … │
│ exp_I_t[66] 34.0703 34.1449 33.8495 1.2621 5.6456 2.6190 … │
│ exp_I_t[67] 34.0364 34.1155 33.8181 1.2617 5.6456 2.6190 … │
│ exp_I_t[68] 34.0398 34.1249 33.8242 1.2616 5.6456 2.6190 … │
│ exp_I_t[69] 34.0547 34.1486 33.8429 1.2631 5.6456 2.6190 … │
│ exp_I_t[70] 34.0395 34.1437 33.8324 1.1978 1.0163 2.6469 … │
╰──────────────────────────────────────────────────────────────────────────────╯Posterior-predictive bands per stream, plotted against the simulated counts, show whether the shared infection process and the W weights together recover each stratum — including total, which is nowhere in the infection process itself, only assembled from it by W:
weighted_pred = predict(as_turing_model(
weighted_model, (young = missing, old = missing, total = missing), n),
weighted_chain)
young_bands = predictive_bands(weighted_pred, n, i -> @varname(young.y_t[i]))
old_bands = predictive_bands(weighted_pred, n, i -> @varname(old.y_t[i]))
total_bands = predictive_bands(weighted_pred, n, i -> @varname(total.y_t[i]))
fig2 = Figure(; size = (760, 780))
ax_young = Axis(fig2[1, 1]; ylabel = "Young")
ax_old = Axis(fig2[2, 1]; ylabel = "Old")
ax_total = Axis(fig2[3, 1]; ylabel = "Total (young + old)", xlabel = "Day")
for (ax, bands, obs, color) in (
(ax_young, young_bands, age.generated_y_t.young, :teal),
(ax_old, old_bands, age.generated_y_t.old, :firebrick),
(ax_total, total_bands, age.generated_y_t.total, :purple))
ci_ribbon!(ax, 1:n, bands; color = color, label = "posterior predictive")
scatter!(ax, 1:n, obs; color = :black, markersize = 6, label = "simulated")
end
axislegend(ax_young; position = :lt)
fig2
Despite the slower mixing, the 95% band covers the simulated counts on almost every day for all three streams, so the many-to-one map is recovered, not merely simulated. A single shared young and old need no independent signal of their own, and total — a stream the infection process never draws directly — still lands on its simulated series because W ties it to the same shared path. Split(template, W) many-to-one aggregation is not just forward-simulated here, it is fit and recovered.
Here the single renewal process supplied one infection stratum, broadcast through W. When the strata are genuinely separate infection processes — several distinct regions, say, each with its own latent — swap the single infection model for CombineInfections: it draws each process independently and stacks the results into the same infection-strata × time matrix Split/StrataMap already expect, so IDModel(CombineInfections([...]), Split(template, W)) maps several distinct infection processes onto streams end-to-end. For one process carried across a strata axis instead, with partially pooled per-stratum deviations, see Stratify and Partial pooling across groups. It also composes with Renewal's mixing slot, see Coupled patch models.
References
- K. Sherratt, S. Abbott, S. R. Meakin, J. Hellewell, J. D. Munday, N. Bosse, M. Jit and S. Funk. Exploring surveillance data biases when estimating the reproduction number: with insights into subpopulation transmission of COVID-19 in England. Philosophical Transactions of the Royal Society B 376, 20200283 (2021).