diff --git a/approaches/composable-turing-models.qmd b/approaches/composable-turing-models.qmd index 9b00abc..cc8285b 100644 --- a/approaches/composable-turing-models.qmd +++ b/approaches/composable-turing-models.qmd @@ -75,28 +75,28 @@ page-layout: full ::: ```{.julia .code-overflow-scroll} -using ComposableTuringIDModels, Distributions, Turing - -# Renewal infections with an inline prior model -data = IDData(gen_distribution = Gamma(1.4, 1 / 0.38)) - -model = IDModel( - Renewal(data; - rt = AR(; ϵ_t = HierarchicalNormal( - std_prior = HalfNormal(0.1))), - initialisation_prior = Normal(log(1.0), 1.0)), - - # Multiple observation layers: - # delay → ascertainment → negative-binomial noise - LatentDelay( - Ascertainment( - NegativeBinomialError(), - Intercept(Normal(log(0.4), 0.1))), - truncated(Normal(5.0, 2.0), 0.0, Inf))) - -# Fit to case data with Turing's NUTS +using ComposableTuringIDModels, Distributions, Turing, Mooncake +using ADTypes: AutoMooncake + +# Renewal infections with an autoregressive log-R_t prior +renewal = Renewal(; + generation_time = Gamma(1.4, 1 / 0.38), + rt = AR(; ϵ_t = HierarchicalNormal(std = HalfNormal(0.1))), + initialisation = Normal(log(1.0), 1.0)) + +# Observation layers: delay → ascertainment → negative-binomial noise +obs = LatentDelay( + Ascertainment( + NegativeBinomialError(), + Intercept(Normal(log(0.4), 0.1))), + truncated(Normal(5.0, 2.0), 0.0, Inf)) + +model = IDModel(renewal, obs) + +# Fit to case data with Turing's NUTS (Mooncake AD) chain = sample(as_turing_model(model, cases, length(cases)), - NUTS(), MCMCThreads(), 1_000, 2) + NUTS(0.95; adtype = AutoMooncake(; config = nothing)), + MCMCThreads(), 100, 2) ``` ::: diff --git a/approaches/composed-distributions.qmd b/approaches/composed-distributions.qmd index fb53133..6906687 100644 --- a/approaches/composed-distributions.qmd +++ b/approaches/composed-distributions.qmd @@ -150,7 +150,7 @@ The model does not change, only the delays each case supplies. ### Censoring and modifiers compose as leaves Real line-list delays are rarely clean, and the corrections are part of the model rather than a preprocessing step. -[CensoredDistributions.jl](https://censoreddistributions.epiaware.org/) supplies censoring leaves for primary-event censoring, interval censoring, and truncation. +[CensoredDistributions.jl](https://censoreddistributions.epiaware.org/dev/) supplies censoring leaves for primary-event censoring, interval censoring, and truncation. [ModifiedDistributions.jl](https://modifieddistributions.epiaware.org/dev/) supplies modifier leaves that rescale, weight, or transform a delay. Both are leaves like any other, so they slot into the tree and the composers peel through them to reach the free delay underneath. @@ -187,18 +187,14 @@ Nothing is recomputed in separate post-processing that could drift from the mode - [ModifiedDistributions.jl](https://modifieddistributions.epiaware.org/dev/) lets you rescale, weight, or otherwise transform individual leaves without changing the tree structure. -- [CensoredDistributions.jl](https://censoreddistributions.epiaware.org/) adds +- [CensoredDistributions.jl](https://censoreddistributions.epiaware.org/dev/) adds the censoring layer for real line-list data. - [LoweredDistributions.jl](https://lowereddistributions.epiaware.org/dev/) lowers the same tree onto a phase-type chain or a CTMC, the bridge to compartmental models. -- Fitting outside Turing, or fitting a plain struct alongside a tree? - [DistributionsInference.jl](https://github.com/EpiAware/DistributionsInference.jl) - hosts the PPL-neutral log-density and readback that `as_logdensity` and - `as_turing` build on: `distribution_priors` assembles priors the same way - `param_priors` does for a tree, and `distribution_params` reads a fitted - chain back to the estimated values by name, whatever fittable object it - came from. +- [DistributionsInference.jl](https://github.com/EpiAware/DistributionsInference.jl) + assembles PPL-neutral priors and reads a fitted chain back by name, for + fitting the tree (or any fittable struct) outside Turing. - Ready to fit a full model with infection dynamics? See the [composable Turing models approach](composable-turing-models.qmd). diff --git a/packages/index.qmd b/packages/index.qmd index cf16e30..867df1f 100644 --- a/packages/index.qmd +++ b/packages/index.qmd @@ -36,7 +36,7 @@ Status reflects where a package sits in its release cycle rather than a judgemen
convolve_series.