Skip to content

Renewal initialisation silently collapses a process via only(x), and the seeding window is not observable in I_t #263

Closed

Description

@seabbs-bot

Renewal's initialisation is a PriorLike slot, which suggests a latent process can be passed. In practice it is consumed as a single scalar:

init_incidence ~ as_turing_submodel(infection.initialisation, _n_strata(n); prefix = true)
I₀ = infection.transformation.(_seed(init_incidence, n))     # src/infection_models/Renewal.jl

with _n_strata(n::Int) = 1 (src/base/shapes.jl) and _seed(x, ::Int) = only(x) (src/infection_models/utils.jl). So a latent process passed here is drawn at length 1 and collapsed by only. The pre-window infections are then deterministic geometric decay at the rate implied by R₁:

renewal_init_window(::ConstantRenewalStep, I₀::Real, r, len_gen_int) =
    I₀ * [exp(-r * t) for t in (len_gen_int - 1):-1:0]        # src/steps/RenewalSteps.jl

and that window is not part of the returned I_t (get_state), so there is no estimated seeding path at all.

Passing a process to initialisation therefore silently does something other than what the slot's type suggests — worth either supporting it or rejecting it with an error, rather than drawing one value and discarding the rest.

Why it is wanted

We are porting the EpiSewer wastewater model (https://github.com/adrian-lison/EpiSewer). Its default seeding_estimate_rw estimates the whole seeding phase as a geometric random walk over the G + se days before the modelled window:

iota[1:(G+se)] = exp(random_walk([iota_log_seed_intercept]', iota_log_ar_noise, 0));
// iota_log_ar_noise ~ normal(0, iota_log_seed_sd), non-centred
// iota_log_seed_sd ~ truncated Normal(0.05, 0.025) on [0, Inf)

and then back-computes R_t over that window from the seeded infections. Deterministic geometric decay is a materially different assumption: it forces the pre-window shape to whatever R₁ implies, rather than letting the data inform the run-up. For a wastewater series where the shedding convolution reaches ~38 days back, the seeding phase is a large part of what the early data constrains.

The closest thing available is ImportedCases(<latent process>), which adds a sampled per-time importation rate inside the recursion — a different mechanism, not a seeding phase.

Possible shape

Either accept a length-len_gen_int process for initialisation and use it as the init window directly instead of renewal_init_window, or add a separate seeding slot so the two concerns (level at t₀ vs shape of the run-up) stay distinct. Including the seeding window in the returned I_t would also help, since at present it cannot be inspected or plotted.

Companion issue for the other unsupported EpiSewer default component (stochastic infection noise) filed separately.

This was opened by a bot. Please ping @seabbs for any questions.

Activity

  1. seabbs-bot commented on Aug 17, 2026

    @seabbs-bot
    CollaboratorAuthor

    Correction from the reporter, same as on #262: the "cannot be expressed" framing here is too strong. An estimated seeding phase does appear reachable today, without an upstream change.

    renewal_init_window dispatches on the step:

    function renewal_init_window(::ConstantRenewalStep, I₀::Real, r, len_gen_int)
        return I₀ * [exp(-r * t) for t in (len_gen_int - 1):-1:0]
    end

    AbstractConstantRenewalStep and renewal_init_window are both in the package's public list, and Renewal accepts a recurrent_step. The core is also resolved before the scan through as_turing_submodel(step.core, n; prefix = true), so a custom core can draw a seeding path, carry it as a field on the resolved core, and return it from its own renewal_init_window method. That is a downstream extension, not a missing capability, and we will do it that way in EpiSewer.jl rather than asking for it here.

    What I think genuinely stands

    Two smaller things, both about the interface rather than the capability:

    1. initialisation silently discards a process. It is typed as a PriorLike slot, so passing a latent model type-checks, but it is drawn at length 1 and collapsed by _seed(x, ::Int) = only(x). Passing RandomWalk() there does something other than what the slot's type advertises, with no error. Either reject a multi-valued prior with a message pointing at recurrent_step/renewal_init_window, or document that the slot means "the level at t₀" and nothing more. As it stands the type says more than the implementation honours.

    2. The seeding window is not observable. get_state returns only the scanned values, so the init window — whether the default geometric decay or a custom estimated path — never appears in I_t and cannot be inspected or plotted. For a wastewater model whose shedding convolution reaches ~38 days back, that window is a large part of what the early data constrains, so being unable to see it is a real limitation. Worth considering whether get_state should optionally include it, or whether a RecordExpectedLatent-style hook could expose it.

    Neither is a blocker for us. Retitling this to match what is actually being asked; close it if you consider both points working-as-intended.

    Apologies for the two over-stated issues in a row — I should have traced the public extension seams before concluding either was a gap.

    This was posted by a bot. Please ping @seabbs for any questions.

  2. changed the title [-]Renewal initialisation is collapsed by only(x), so an estimated seeding phase cannot be expressed[/-] [+]Renewal initialisation silently collapses a process via only(x), and the seeding window is not observable in I_t[/+] on Aug 17, 2026
  3. seabbs-bot commented on Sep 2, 2026

    @seabbs-bot
    CollaboratorAuthor

    A correction to the premise, worth recording separately from the fix.

    A process in initialisation is not always silently collapsed. The slot is drawn at _n_strata(n), so for a Dims{2} shape a process there means one seed per stratum, which is a working and intended use — initialisation = IID(Normal(log(20.0), 1.0)) with rt = Stratify(...) appears in test/unit/infection_models/strata_renewal.jl:43 and test/unit/inference/inference.jl:215. The collapse happens only on the Int shape, where _n_strata(n) = 1 and _seed(x, ::Int) = only(x) (src/infection_models/utils.jl:152).

    So the slot is a LEVEL — one value, or one per stratum — and it does that job correctly. What is unreachable is a seeding path: a process covering the whole pre-window run-up. Rejecting a process at construction, the second half of what this issue proposes, would therefore break real models, and it is not implementable anyway, because the shape is only known when as_turing_model is called, not when the Renewal is built.

    PR #347 takes the first half instead, with the two concerns kept distinct by the type in the slot rather than by a second slot: initialisation stays the level at t₀ and says so, and SeedingPath(process) draws the process at the seeding window's own shape (len_gen_int, or n_strata × len_gen_int for a stratified renewal) and uses it as the initial incidence window directly, with no geometric decay and no growth rate implied. The window is returned as I_seed in both cases, so the deterministic one is inspectable too.

    This was opened by a bot. Please ping @seabbs for any questions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions