Skip to content

R_mean gets no initial value, so chains start far from the prior #1476

Description

@sbfnk-bot

R_mean gets no initial value, so chains start far from the prior

R_mean, the mean reproduction number, is never given a starting value in create_initial_conditions(). Each chain therefore starts from Stan's default, exp(uniform(-2, 2)), which runs from 0.135 to 7.39. For the example data the typical set sits around 1.2, so a chain can start several-fold off.

Where it comes from

Before #1396, R0 was a variable parameter, registered with make_param("R0", rt$prior, lower_bound = 0). That put it in the params vector, and create_initial_conditions() (R/create.R) initialised it from the user's Rt prior along with the delay parameters and GP terms.

#1396 swapped R0 for R_mean and gave it a virtual parameter id past the end of the params vector (param_id_R0 <- n_params_variable + 1L) for the init-prior dispatch. It left R/create.R untouched, so the new parameter never got an init. grep -rn "R_mean" R/ returns nothing on current main.

Impact

On the example data sampling still recovers, so on its own this does not cause fitting failures. But starting far from the typical set wastes warmup, and it is the one parameter left uninitialised while every other one is seeded from its prior.

Fix

Seed R_mean from the Rt prior in create_initial_conditions(), the way R0 was seeded before #1396 and the way the delay parameters already are. No runtime cost.

Activity

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

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions