Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initialisation for epidemic inference #42

Merged
merged 6 commits into from
Feb 19, 2024

Conversation

SamuelBrand1
Copy link
Collaborator

@SamuelBrand1 SamuelBrand1 commented Feb 16, 2024

This PR is for creating an appropriate initialisation for inference. In practice, this applies to the renewal model approach encapsulated by the Renewal model.

Major changes

  • An new expectation is that any latent process model should pass an init kw value and this can have its own priors e.g. here:
    init ~ latent_process_priors.init_rw_value_dist
    σ_RW = sqrt(σ²_RW)
    rw[1] = σ_RW * ϵ_t[1]
    for t = 2:n
    rw[t] = rw[t-1] + σ_RW * ϵ_t[t]
    end
    return rw, (; σ_RW, init)
  • The callable function associated with an object which is a subtype of AbstractEpiModel is now fixed as defining the latent process -> infections transformation. Before it defined an updating function to be used by scan; however that was not the natural approach in (say) direct infection modelling. Instances of Renewal model now use scan under the hood. eg here:
    @submodel latent_process, latent_process_aux =
    latent_process(time_steps; latent_process_priors = latent_process_priors)
    #Transform into infections
    I_t = epimodel(latent_process, latent_process_aux)
  • This change means that initialisation is also dealt with by the callable function. The only complex one is for Renewal here.
  • For Renewal initialisation is done by treating init as defining a time zero incidence. The pre-time zero incidence is backwards exponential with the exponential growth rate implied by R_t[1] from the latent process and the GI. Note that this matches @dylanhmorris here. The difference is I use a quick Newton method with an informed guess to do the $\mathcal{R}_0$ to $r$ transformation; this is faster than using a generic root finder because you can solve the structure of the problem here and gets to high accuracy in a couple of steps: evidence here.

Minor change

  • I've changed an Aqua kwarg to persistent_tasks = false because locally a Turing extension was precompiling out of sequence (TBD to burrow into that).

Closes #40

@SamuelBrand1 SamuelBrand1 linked an issue Feb 16, 2024 that may be closed by this pull request
@seabbs seabbs enabled auto-merge February 19, 2024 10:53
@seabbs seabbs self-requested a review February 19, 2024 10:53
Copy link
Collaborator

@seabbs seabbs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really nice. I like the reorg. Some general comments about naming, docs etc which feel a little messy here.

I really like the use of $R_0$ here to define the initial growth rate and the approximation approach makes sense and seems correct. From a reviewer side though this really feels like another PR and would have been easier to review if that were the case. I can see why you included it here though.

In terms of the renaming etc I think I would again suggest we move many of these comments to issues so we can keep up the velocity. The only change I would really like to see here is an explicit test of the approximation approach.

EpiAware/src/EpiAware.jl Show resolved Hide resolved
EpiAware/src/epimodel.jl Show resolved Hide resolved
EpiAware/src/epimodel.jl Outdated Show resolved Hide resolved
EpiAware/src/latent-processes.jl Show resolved Hide resolved
EpiAware/src/models.jl Show resolved Hide resolved
EpiAware/test/test_models.jl Show resolved Hide resolved
EpiAware/test/test_utilities.jl Outdated Show resolved Hide resolved
EpiAware/test/test_utilities.jl Show resolved Hide resolved
EpiAware/test/test_utilities.jl Show resolved Hide resolved
@SamuelBrand1 SamuelBrand1 self-assigned this Feb 19, 2024
@seabbs seabbs self-requested a review February 19, 2024 16:15
Copy link
Collaborator

@seabbs seabbs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Making an issue for internal functions now.

EpiAware/src/EpiAware.jl Show resolved Hide resolved
@seabbs seabbs merged commit 399c766 into main Feb 19, 2024
2 checks passed
@seabbs seabbs deleted the 40-initialisation-infection-generation-processes branch February 19, 2024 16:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Initialisation infection generation processes
2 participants