Skip to content

LatentDelay flattens a stratified expected series #376

Open

Description

@seabbs-bot

LatentDelay convolves a strata × time expected series as though it were one long vector, so the strata are lost and the streams bleed into each other across the boundary.

ld = LatentDelay(PoissonError(), [0.5, 0.3, 0.2])
as_turing_model(ld, missing, fill(10.0, 3, 12))()

input expected series : (3, 12)
returned y_t          : (34,)

34 = 3*12 - 2, which is the convolution shortening a length-36 vector by length(pmf) - 1. So it is treating the matrix as flat, and the tail of stratum 1 convolves into the head of stratum 2.

Why it matters

It makes LatentDelay(Split(...)) unusable on a stratified model. Building that end-to-end fails downstream with

AssertionError: The strata map has 3 columns but the expected series has 1 infection strata (rows)

because the flattened series no longer has the strata the map expects. That is the failure a user sees; the flattening above is the cause.

The two are worth separating because the shape inference is being fixed independently in #363, which correctly derives (3, 12) for that model. After #363 the stratum count is right and this is the remaining blocker, so the assertion will still fire.

Scope

This is pre-existing and not a regression from #363 — verified identically on main and on 246-shape. Found while verifying that PR.

Worth checking whether the other length-changing observation modifiers share it. Aggregate and ReportTriangle also reshape the series they are handed, and neither is exercised on a stratified model in the tests.

The fix presumably convolves along the time axis per stratum rather than over the flattened array, but the right shape depends on what a stratified delay should mean when the pmf itself is shared across strata versus per stratum, which is a decision rather than a mechanical fix.

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

Activity

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