diff --git a/dev/.documenter-siteinfo.json b/dev/.documenter-siteinfo.json index feff9cca2..3731fefb2 100644 --- a/dev/.documenter-siteinfo.json +++ b/dev/.documenter-siteinfo.json @@ -1 +1 @@ -{"documenter":{"julia_version":"1.10.4","generation_timestamp":"2024-07-10T16:54:59","documenter_version":"1.5.0"}} \ No newline at end of file +{"documenter":{"julia_version":"1.10.4","generation_timestamp":"2024-07-10T21:25:11","documenter_version":"1.5.0"}} \ No newline at end of file diff --git a/dev/developer/checklist/index.html b/dev/developer/checklist/index.html index 45a716b04..e85e587ac 100644 --- a/dev/developer/checklist/index.html +++ b/dev/developer/checklist/index.html @@ -20,4 +20,4 @@ Either of those should automatically publish a new version to the Julia registry. - Once registered, the `TagBot.yml` workflow should create a tag, and rebuild the documentation for this tag. - - These steps can take quite a bit of time (1 hour or more), so don't be surprised if the new documentation takes a while to appear. + - These steps can take quite a bit of time (1 hour or more), so don't be surprised if the new documentation takes a while to appear. diff --git a/dev/developer/contributing/index.html b/dev/developer/contributing/index.html index 3c6fa1549..23f5a2b10 100644 --- a/dev/developer/contributing/index.html +++ b/dev/developer/contributing/index.html @@ -1,2 +1,2 @@ -Contributing · EpiAware.jl

Contributing

This page details the some of the guidelines that should be followed when contributing to this package. It is adapted from Documenter.jl.

Branches

release-* branches are used for tagged minor versions of this package. This follows the same approach used in the main Julia repository, albeit on a much more modest scale.

Please open pull requests against the master branch rather than any of the release-* branches whenever possible.

Backports

Bug fixes are backported to the release-* branches using git cherry-pick -x by a EpiAware member and will become available in point releases of that particular minor version of the package.

Feel free to nominate commits that should be backported by opening an issue. Requests for new point releases to be tagged in METADATA.jl can also be made in the same way.

release-* branches

  • Each new minor version x.y.0 gets a branch called release-x.y (a protected branch).
  • New versions are usually tagged only from the release-x.y branches.
  • For patch releases, changes get backported to the release-x.y branch via a single PR with the standard name "Backports for x.y.z" and label "Type: Backport". The PR message links to all the PRs that are providing commits to the backport. The PR gets merged as a merge commit (i.e. not squashed).
  • The old release-* branches may be removed once they have outlived their usefulness.
  • Patch version milestones are used to keep track of which PRs get backported etc.

Style Guide

Follow the style of the surrounding text when making changes. When adding new features please try to stick to the following points whenever applicable. This project follows the SciML style guide.

Tests

Unit tests

As is conventional for Julia packages, unit tests are located at test/*.jl with the entrypoint test/runtests.jl.

End to end testing

Tests that build example package docs from source and inspect the results (end to end tests) are located in /test/examples. The main entry points are test/examples/make.jl for building and test/examples/test.jl for doing some basic checks on the generated outputs.

+Contributing · EpiAware.jl

Contributing

This page details the some of the guidelines that should be followed when contributing to this package. It is adapted from Documenter.jl.

Branches

release-* branches are used for tagged minor versions of this package. This follows the same approach used in the main Julia repository, albeit on a much more modest scale.

Please open pull requests against the master branch rather than any of the release-* branches whenever possible.

Backports

Bug fixes are backported to the release-* branches using git cherry-pick -x by a EpiAware member and will become available in point releases of that particular minor version of the package.

Feel free to nominate commits that should be backported by opening an issue. Requests for new point releases to be tagged in METADATA.jl can also be made in the same way.

release-* branches

  • Each new minor version x.y.0 gets a branch called release-x.y (a protected branch).
  • New versions are usually tagged only from the release-x.y branches.
  • For patch releases, changes get backported to the release-x.y branch via a single PR with the standard name "Backports for x.y.z" and label "Type: Backport". The PR message links to all the PRs that are providing commits to the backport. The PR gets merged as a merge commit (i.e. not squashed).
  • The old release-* branches may be removed once they have outlived their usefulness.
  • Patch version milestones are used to keep track of which PRs get backported etc.

Style Guide

Follow the style of the surrounding text when making changes. When adding new features please try to stick to the following points whenever applicable. This project follows the SciML style guide.

Tests

Unit tests

As is conventional for Julia packages, unit tests are located at test/*.jl with the entrypoint test/runtests.jl.

End to end testing

Tests that build example package docs from source and inspect the results (end to end tests) are located in /test/examples. The main entry points are test/examples/make.jl for building and test/examples/test.jl for doing some basic checks on the generated outputs.

diff --git a/dev/developer/index.html b/dev/developer/index.html index beb929e4e..1d685121f 100644 --- a/dev/developer/index.html +++ b/dev/developer/index.html @@ -1,2 +1,2 @@ -Overview · EpiAware.jl

Developer documentation

Welcome to the EpiAware developer documentation! This section is designed to help you get started with developing the package.

+Overview · EpiAware.jl

Developer documentation

Welcome to the EpiAware developer documentation! This section is designed to help you get started with developing the package.

diff --git a/dev/getting-started/explainers/index.html b/dev/getting-started/explainers/index.html index 8452d1701..f7238f649 100644 --- a/dev/getting-started/explainers/index.html +++ b/dev/getting-started/explainers/index.html @@ -1,2 +1,2 @@ -Overview · EpiAware.jl

Explainers

This section contains a series of explainers that provide a detailed overview of the EpiAware platform and its features. These explainers are designed to help you understand the platform and its capabilities, and to provide you with the information you need to get started using EpiAware. See the sidebar for the list of explainers.

+Overview · EpiAware.jl

Explainers

This section contains a series of explainers that provide a detailed overview of the EpiAware platform and its features. These explainers are designed to help you understand the platform and its capabilities, and to provide you with the information you need to get started using EpiAware. See the sidebar for the list of explainers.

diff --git a/dev/getting-started/explainers/inference/index.html b/dev/getting-started/explainers/inference/index.html index da19d9e62..0771692f1 100644 --- a/dev/getting-started/explainers/inference/index.html +++ b/dev/getting-started/explainers/inference/index.html @@ -1,2 +1,2 @@ -Inference · EpiAware.jl
+Inference · EpiAware.jl
diff --git a/dev/getting-started/explainers/interfaces/index.html b/dev/getting-started/explainers/interfaces/index.html index 30fddf8c5..c8873c3d9 100644 --- a/dev/getting-started/explainers/interfaces/index.html +++ b/dev/getting-started/explainers/interfaces/index.html @@ -1,2 +1,2 @@ -Interfaces · EpiAware.jl

Interfaces

We support two primary workflows for using the package:

  • EpiProblem: A high-level interface for defining and fitting models to data. This is the recommended way to use the package.
  • Turing interface: A lower-level interface for defining and fitting models to data. This is the more flexible way to use the package and may also be more familiar to users of Turing.jl.

See the getting started section for tutorials on each of these workflows.

EpiProblem

Each module of the overall epidemiological model we are interested in is a Turing Model in its own right. In this section, we compose the individual models into the full epidemiological model using the EpiProblem struct.

The constructor for an EpiProblem requires:

  • An epi_model.
  • A latent_model.
  • An observation_model.
  • A tspan.

The tspan set the range of the time index for the models.

Turing interface

The Turing interface is a lower-level interface for defining and fitting models to data. This is the more flexible way to use the package and may also be more familiar to users of Turing.jl.

+Interfaces · EpiAware.jl

Interfaces

We support two primary workflows for using the package:

  • EpiProblem: A high-level interface for defining and fitting models to data. This is the recommended way to use the package.
  • Turing interface: A lower-level interface for defining and fitting models to data. This is the more flexible way to use the package and may also be more familiar to users of Turing.jl.

See the getting started section for tutorials on each of these workflows.

EpiProblem

Each module of the overall epidemiological model we are interested in is a Turing Model in its own right. In this section, we compose the individual models into the full epidemiological model using the EpiProblem struct.

The constructor for an EpiProblem requires:

  • An epi_model.
  • A latent_model.
  • An observation_model.
  • A tspan.

The tspan set the range of the time index for the models.

Turing interface

The Turing interface is a lower-level interface for defining and fitting models to data. This is the more flexible way to use the package and may also be more familiar to users of Turing.jl.

diff --git a/dev/getting-started/explainers/intro/index.html b/dev/getting-started/explainers/intro/index.html index 5ec242429..e18ba3d0b 100644 --- a/dev/getting-started/explainers/intro/index.html +++ b/dev/getting-started/explainers/intro/index.html @@ -60,4 +60,4 @@ E-->|sample...NUTS...| G G-->H -H-->I +H-->I diff --git a/dev/getting-started/explainers/julia/index.html b/dev/getting-started/explainers/julia/index.html index 0f07ba8a0..e6849dcc1 100644 --- a/dev/getting-started/explainers/julia/index.html +++ b/dev/getting-started/explainers/julia/index.html @@ -36,4 +36,4 @@ }, "julia.liveTestFile": "path/to/runtests.jl", "julia.environmentPath": "path/to/project/directory", -}

These settings set basic code formatting and whitespace settings for Julia files, as well as setting the path to the test file for the project and the path to the project directory for the environment.

The VS-Code command Julia: Start REPL will start a REPL in TERMINAL tab in the editor with the environment set to the project directory and the Testing tab will detect the defined tests for the project.

Literate programming with Julia in EpiAware

Its common to develop technical computing projects using a literate programming style, where code and documentation are interwoven. Julia supports this style of programming through a number of packages. In EpiAware we recommend the following:

We use Pluto for interactive development and Quarto for generating reports and academic articles. Both tools are useful for developing reproducible workflows.

+}

These settings set basic code formatting and whitespace settings for Julia files, as well as setting the path to the test file for the project and the path to the project directory for the environment.

The VS-Code command Julia: Start REPL will start a REPL in TERMINAL tab in the editor with the environment set to the project directory and the Testing tab will detect the defined tests for the project.

Literate programming with Julia in EpiAware

Its common to develop technical computing projects using a literate programming style, where code and documentation are interwoven. Julia supports this style of programming through a number of packages. In EpiAware we recommend the following:

We use Pluto for interactive development and Quarto for generating reports and academic articles. Both tools are useful for developing reproducible workflows.

diff --git a/dev/getting-started/explainers/latent-models/index.html b/dev/getting-started/explainers/latent-models/index.html index 3c90dd9a8..2b0b9adc6 100644 --- a/dev/getting-started/explainers/latent-models/index.html +++ b/dev/getting-started/explainers/latent-models/index.html @@ -1,2 +1,2 @@ -Latent models · EpiAware.jl
+Latent models · EpiAware.jl
diff --git a/dev/getting-started/explainers/modelling-infections/index.html b/dev/getting-started/explainers/modelling-infections/index.html index 88241eb69..7987ffbdc 100644 --- a/dev/getting-started/explainers/modelling-infections/index.html +++ b/dev/getting-started/explainers/modelling-infections/index.html @@ -1,2 +1,2 @@ -Modelling infections · EpiAware.jl
+Modelling infections · EpiAware.jl
diff --git a/dev/getting-started/explainers/observation-models/index.html b/dev/getting-started/explainers/observation-models/index.html index 82d4f5026..dff2e50a9 100644 --- a/dev/getting-started/explainers/observation-models/index.html +++ b/dev/getting-started/explainers/observation-models/index.html @@ -1,2 +1,2 @@ -Observation models · EpiAware.jl
+Observation models · EpiAware.jl
diff --git a/dev/getting-started/faq/index.html b/dev/getting-started/faq/index.html index bd7e62ba9..3e6e72fe1 100644 --- a/dev/getting-started/faq/index.html +++ b/dev/getting-started/faq/index.html @@ -1,2 +1,2 @@ -Frequently asked questions · EpiAware.jl

Frequently asked questions

This page contains a list of frequently asked questions about the EpiAware package. If you have a question that is not answered here, please open a discussion on the GitHub repository.

    Pluto scripts

    We use Pluto.jl scripts as part of our documentation and testing. The scripts are located in docs/src/examples and can be run using the Pluto.jl package. We recommend using the version of Pluto that is pinned in the Project.toml file defining the documentation environment. An entry point to running or developing this documentation is the docs/pluto-scripts.sh bash shell script. Run this from the root directory of this repository.

    +Frequently asked questions · EpiAware.jl

    Frequently asked questions

    This page contains a list of frequently asked questions about the EpiAware package. If you have a question that is not answered here, please open a discussion on the GitHub repository.

      Pluto scripts

      We use Pluto.jl scripts as part of our documentation and testing. The scripts are located in docs/src/examples and can be run using the Pluto.jl package. We recommend using the version of Pluto that is pinned in the Project.toml file defining the documentation environment. An entry point to running or developing this documentation is the docs/pluto-scripts.sh bash shell script. Run this from the root directory of this repository.

      diff --git a/dev/getting-started/index.html b/dev/getting-started/index.html index 833f80404..461c57005 100644 --- a/dev/getting-started/index.html +++ b/dev/getting-started/index.html @@ -1,2 +1,2 @@ -Overview · EpiAware.jl

      Getting started

      Note that this section of the documentation is still under construction. Please see replications for the most up-to-date information. Please feel free to contribute to the documentation by submitting a pull request.

      Welcome to the EpiAware documentation! This section is designed to help you get started with the package. It includes a frequently asked questions (FAQ) section, a series of explainers that provide a detailed overview of the platform and its features, and tutorials that will help you get started with EpiAware for specific tasks. See the sidebar for the list of topics.

      +Overview · EpiAware.jl

      Getting started

      Note that this section of the documentation is still under construction. Please see replications for the most up-to-date information. Please feel free to contribute to the documentation by submitting a pull request.

      Welcome to the EpiAware documentation! This section is designed to help you get started with the package. It includes a frequently asked questions (FAQ) section, a series of explainers that provide a detailed overview of the platform and its features, and tutorials that will help you get started with EpiAware for specific tasks. See the sidebar for the list of topics.

      diff --git a/dev/getting-started/installation/index.html b/dev/getting-started/installation/index.html index 10c93cc08..45d50397d 100644 --- a/dev/getting-started/installation/index.html +++ b/dev/getting-started/installation/index.html @@ -1,2 +1,2 @@ -Installation · EpiAware.jl

      Installation

      Eventually, EpiAware is likely to be added to the Julia registry. Until then, you can install it from the /EpiAware sub-directory of this repository by running the following command in the Julia REPL:

      using Pkg; Pkg.add(url="https://github.com/CDCgov/Rt-without-renewal", subdir="EpiAware")
      +Installation · EpiAware.jl

      Installation

      Eventually, EpiAware is likely to be added to the Julia registry. Until then, you can install it from the /EpiAware sub-directory of this repository by running the following command in the Julia REPL:

      using Pkg; Pkg.add(url="https://github.com/CDCgov/Rt-without-renewal", subdir="EpiAware")
      diff --git a/dev/getting-started/quickstart/index.html b/dev/getting-started/quickstart/index.html index eb310ba1c..d4de70efc 100644 --- a/dev/getting-started/quickstart/index.html +++ b/dev/getting-started/quickstart/index.html @@ -1,2 +1,2 @@ -Quickstart · EpiAware.jl

      Quickstart

      Get up and running with EpiAware in just a few minutes using this quickstart guide.

      +Quickstart · EpiAware.jl

      Quickstart

      Get up and running with EpiAware in just a few minutes using this quickstart guide.

      diff --git a/dev/getting-started/tutorials/index.html b/dev/getting-started/tutorials/index.html index eb381137f..776beef29 100644 --- a/dev/getting-started/tutorials/index.html +++ b/dev/getting-started/tutorials/index.html @@ -1,2 +1,2 @@ -Overview · EpiAware.jl

      Tutorials

      This section contains tutorials that will help you get started with EpiAware for specific tasks. See the sidebar for the list of tutorials.

      +Overview · EpiAware.jl

      Tutorials

      This section contains tutorials that will help you get started with EpiAware for specific tasks. See the sidebar for the list of tutorials.

      diff --git a/dev/getting-started/tutorials/multiple-infection-processes/index.html b/dev/getting-started/tutorials/multiple-infection-processes/index.html index b69919770..c650c4f16 100644 --- a/dev/getting-started/tutorials/multiple-infection-processes/index.html +++ b/dev/getting-started/tutorials/multiple-infection-processes/index.html @@ -1,2 +1,2 @@ -Multiple infection processes · EpiAware.jl
      +Multiple infection processes · EpiAware.jl
      diff --git a/dev/getting-started/tutorials/multiple-observation-models/index.html b/dev/getting-started/tutorials/multiple-observation-models/index.html index 01a668457..bf0764ed3 100644 --- a/dev/getting-started/tutorials/multiple-observation-models/index.html +++ b/dev/getting-started/tutorials/multiple-observation-models/index.html @@ -1,2 +1,2 @@ -Multiple observation models · EpiAware.jl
      +Multiple observation models · EpiAware.jl
      diff --git a/dev/getting-started/tutorials/nowcasting/index.html b/dev/getting-started/tutorials/nowcasting/index.html index 30159889a..cddd19343 100644 --- a/dev/getting-started/tutorials/nowcasting/index.html +++ b/dev/getting-started/tutorials/nowcasting/index.html @@ -1,2 +1,2 @@ -Nowcasting · EpiAware.jl
      +Nowcasting · EpiAware.jl
      diff --git a/dev/getting-started/tutorials/partial-pooling/index.html b/dev/getting-started/tutorials/partial-pooling/index.html index 683b7ecf2..11f693b1a 100644 --- a/dev/getting-started/tutorials/partial-pooling/index.html +++ b/dev/getting-started/tutorials/partial-pooling/index.html @@ -1,2 +1,2 @@ -Partial pooling · EpiAware.jl
      +Partial pooling · EpiAware.jl
      diff --git a/dev/getting-started/tutorials/simple-renewal-with-delays/index.html b/dev/getting-started/tutorials/simple-renewal-with-delays/index.html index 48278ef24..b4f309b81 100644 --- a/dev/getting-started/tutorials/simple-renewal-with-delays/index.html +++ b/dev/getting-started/tutorials/simple-renewal-with-delays/index.html @@ -1,2 +1,2 @@ -Simple renewal with delays · EpiAware.jl
      +Simple renewal with delays · EpiAware.jl
      diff --git a/dev/index.html b/dev/index.html index dde377ab5..0d1800cd4 100644 --- a/dev/index.html +++ b/dev/index.html @@ -1,2 +1,2 @@ -EpiAware.jl: Real-time infectious disease monitoring · EpiAware.jl

      EpiAware.jl

      Infectious disease situational awareness modelling toolkit for Julia.

      Where to start

      +EpiAware.jl: Real-time infectious disease monitoring · EpiAware.jl

      EpiAware.jl

      Infectious disease situational awareness modelling toolkit for Julia.

      Where to start

      diff --git a/dev/lib/EpiAwareBase/index.html b/dev/lib/EpiAwareBase/index.html index 6d140471a..0023b0050 100644 --- a/dev/lib/EpiAwareBase/index.html +++ b/dev/lib/EpiAwareBase/index.html @@ -1,2 +1,2 @@ -Overview · EpiAware.jl

      EpiAwareBase.jl

      This package provides the core functionality for the EpiAware ecosystem. It is a dependency of all other EpiAware packages.

      API

        +Overview · EpiAware.jl

        EpiAwareBase.jl

        This package provides the core functionality for the EpiAware ecosystem. It is a dependency of all other EpiAware packages.

        API

          diff --git a/dev/lib/EpiAwareBase/internals/index.html b/dev/lib/EpiAwareBase/internals/index.html index 33e0470fb..2a9ce72a3 100644 --- a/dev/lib/EpiAwareBase/internals/index.html +++ b/dev/lib/EpiAwareBase/internals/index.html @@ -1,2 +1,2 @@ -Internal API · EpiAware.jl
          +Internal API · EpiAware.jl
          diff --git a/dev/lib/EpiAwareBase/public/index.html b/dev/lib/EpiAwareBase/public/index.html index ee72c6369..10df98915 100644 --- a/dev/lib/EpiAwareBase/public/index.html +++ b/dev/lib/EpiAwareBase/public/index.html @@ -1,5 +1,5 @@ -Public API · EpiAware.jl

          Public Documentation

          Documentation for EpiAwareBae.jl's public interface.

          See the Internals section of the manual for internal package docs covering all submodules.

          Contents

          Index

          Public API

          EpiAware.EpiAwareBase.AbstractEpiOptMethodType
          abstract type AbstractEpiOptMethod <: AbstractEpiMethod

          Abstract supertype for infence/generative methods that are based on optimization, e.g. MAP estimation or variational inference.


          Fields

          source
          EpiAware.EpiAwareBase.EpiAwareObservablesType
          struct EpiAwareObservables

          The EpiAwareObservables struct represents the observables used in the EpiAware model.

          Fields

          • model: The model used for the observables.
          • data: The data used for the observables.
          • samples: Samples from the posterior distribution.
          • generated: The generated observables.

          Fields

          • model::Any

          • data::Any

          • samples::Any

          • generated::Any

          source
          EpiAware.EpiAwareBase.EpiMethodType
          struct EpiMethod{O<:AbstractEpiOptMethod, S<:AbstractEpiSamplingMethod} <: AbstractEpiMethod

          EpiMethod represents a method for performing EpiAware inference and/or generative modelling, which combines a sequence of optimization steps to pass initialisation information to a sampler method.


          Fields

          • pre_sampler_steps::Vector{O} where O<:AbstractEpiOptMethod: Pre-sampler optimization steps.

          • sampler::AbstractEpiSamplingMethod: Sampler method.

          source
          EpiAware.EpiAwareBase.EpiProblemType
          struct EpiProblem{E<:AbstractEpiModel, L<:AbstractLatentModel, O<:AbstractObservationModel} <: AbstractEpiProblem

          Defines an inference/generative modelling problem for case data.

          EpiProblem wraps the underlying components of an epidemiological model:

          • epi_model: An epidemiological model for unobserved infections.
          • latent_model: A latent model for underlying latent process.
          • observation_model: An observation model for observed cases.

          Along with a tspan tuple for the time span of the case data.


          Fields

          • epi_model::AbstractEpiModel: Epidemiological model for unobserved infections.

          • latent_model::AbstractLatentModel: Latent model for underlying latent process.

          • observation_model::AbstractObservationModel: Observation model for observed cases.

          • tspan::Tuple{Int64, Int64}: Time span for either inference or generative modelling of case time series.

          source
          EpiAware.EpiAwareBase._apply_methodFunction
          _apply_method(
          +Public API · EpiAware.jl

          Public Documentation

          Documentation for EpiAwareBae.jl's public interface.

          See the Internals section of the manual for internal package docs covering all submodules.

          Contents

          Index

          Public API

          EpiAware.EpiAwareBase.AbstractEpiOptMethodType
          abstract type AbstractEpiOptMethod <: AbstractEpiMethod

          Abstract supertype for infence/generative methods that are based on optimization, e.g. MAP estimation or variational inference.


          Fields

          source
          EpiAware.EpiAwareBase.EpiAwareObservablesType
          struct EpiAwareObservables

          The EpiAwareObservables struct represents the observables used in the EpiAware model.

          Fields

          • model: The model used for the observables.
          • data: The data used for the observables.
          • samples: Samples from the posterior distribution.
          • generated: The generated observables.

          Fields

          • model::Any

          • data::Any

          • samples::Any

          • generated::Any

          source
          EpiAware.EpiAwareBase.EpiMethodType
          struct EpiMethod{O<:AbstractEpiOptMethod, S<:AbstractEpiSamplingMethod} <: AbstractEpiMethod

          EpiMethod represents a method for performing EpiAware inference and/or generative modelling, which combines a sequence of optimization steps to pass initialisation information to a sampler method.


          Fields

          • pre_sampler_steps::Vector{O} where O<:AbstractEpiOptMethod: Pre-sampler optimization steps.

          • sampler::AbstractEpiSamplingMethod: Sampler method.

          source
          EpiAware.EpiAwareBase.EpiProblemType
          struct EpiProblem{E<:AbstractEpiModel, L<:AbstractLatentModel, O<:AbstractObservationModel} <: AbstractEpiProblem

          Defines an inference/generative modelling problem for case data.

          EpiProblem wraps the underlying components of an epidemiological model:

          • epi_model: An epidemiological model for unobserved infections.
          • latent_model: A latent model for underlying latent process.
          • observation_model: An observation model for observed cases.

          Along with a tspan tuple for the time span of the case data.


          Fields

          • epi_model::AbstractEpiModel: Epidemiological model for unobserved infections.

          • latent_model::AbstractLatentModel: Latent model for underlying latent process.

          • observation_model::AbstractObservationModel: Observation model for observed cases.

          • tspan::Tuple{Int64, Int64}: Time span for either inference or generative modelling of case time series.

          source
          EpiAware.EpiAwareBase._apply_methodFunction
          _apply_method(
               model::AbstractEpiModel,
               method::AbstractEpiMethod;
               ...
          @@ -10,18 +10,18 @@
               prev_result;
               kwargs...
           )
          -

          Apply the inference/generative method method to the AbstractEpiModel object mdl.

          Arguments

          • model::AbstractEpiModel: The model to apply the method to.
          • method::AbstractEpiMethod: The epidemiological method to apply.
          • prev_result: The previous result of the method.
          • kwargs: Additional keyword arguments passed to the method.

          Returns

          • nothing: If no concrete implementation is defined for the given method.
          source
          EpiAware.EpiAwareBase.apply_methodMethod
          apply_method(
          +

          Apply the inference/generative method method to the AbstractEpiModel object mdl.

          Arguments

          • model::AbstractEpiModel: The model to apply the method to.
          • method::AbstractEpiMethod: The epidemiological method to apply.
          • prev_result: The previous result of the method.
          • kwargs: Additional keyword arguments passed to the method.

          Returns

          • nothing: If no concrete implementation is defined for the given method.
          source
          EpiAware.EpiAwareBase.apply_methodMethod
          apply_method(
               model,
               method,
               data;
               kwargs...
           ) -> EpiAwareObservables
          -

          Wrap the _apply_method function by calling it with the given model, method, data, and optional keyword arguments (kwargs). The resulting solution is then passed to the generated_observables function, along with the model and input data, to compute the generated observables.

          Arguments

          • model: The model to apply the method to.
          • method: The method to apply to the model.
          • data: The data to pass to the apply_method function.
          • kwargs: Optional keyword arguments to pass to the apply_method function.

          Returns

          The generated observables computed from the solution.

          source
          EpiAware.EpiAwareBase.apply_methodMethod
          apply_method(
          +

          Wrap the _apply_method function by calling it with the given model, method, data, and optional keyword arguments (kwargs). The resulting solution is then passed to the generated_observables function, along with the model and input data, to compute the generated observables.

          Arguments

          • model: The model to apply the method to.
          • method: The method to apply to the model.
          • data: The data to pass to the apply_method function.
          • kwargs: Optional keyword arguments to pass to the apply_method function.

          Returns

          The generated observables computed from the solution.

          source
          EpiAware.EpiAwareBase.apply_methodMethod
          apply_method(
               epiproblem::EpiProblem,
               method::AbstractEpiMethod,
               data;
          @@ -29,43 +29,43 @@
               condition_parameters,
               kwargs...
           ) -> EpiAwareObservables
          -

          Run the EpiAware algorithm to estimate the parameters of an epidemiological model.

          Arguments

          • epiproblem::EpiProblem: An EpiProblem object specifying the epidemiological problem.
          • method::EpiMethod: An EpiMethod object specifying the inference method.
          • data: The observed data used for inference.

          Keyword Arguments

          • fix_parameters::NamedTuple: A NamedTuple of fixed parameters for the model.
          • condition_parameters::NamedTuple: A NamedTuple of conditioned parameters for the model.
          • kwargs...: Additional keyword arguments passed to the inference methods.

          Returns

          • A NamedTuple with a samples field which is the output of applying methods and a model field with the model used. Optionally, a gens field with the generated quantities from the model if that makes sense with the inference method.
          source
          EpiAware.EpiAwareBase.broadcast_nMethod
          broadcast_n(
          +

          Run the EpiAware algorithm to estimate the parameters of an epidemiological model.

          Arguments

          • epiproblem::EpiProblem: An EpiProblem object specifying the epidemiological problem.
          • method::EpiMethod: An EpiMethod object specifying the inference method.
          • data: The observed data used for inference.

          Keyword Arguments

          • fix_parameters::NamedTuple: A NamedTuple of fixed parameters for the model.
          • condition_parameters::NamedTuple: A NamedTuple of conditioned parameters for the model.
          • kwargs...: Additional keyword arguments passed to the inference methods.

          Returns

          • A NamedTuple with a samples field which is the output of applying methods and a model field with the model used. Optionally, a gens field with the generated quantities from the model if that makes sense with the inference method.
          source
          EpiAware.EpiAwareBase.broadcast_nMethod
          broadcast_n(
               broadcast_rule::AbstractBroadcastRule,
               latent,
               n,
               period
           )
          -

          This function is used to define the behavior of broadcasting for a specific type of AbstractBroadcastRule.

          The broadcast_n function returns the length of the latent periods to generate using the given broadcast_rule. Which model of broadcasting to be implemented is set by the type of broadcast_rule. If no implemention is defined for the given broadcast_rule, then EpiAware will return a warning and return nothing.

          source
          EpiAware.EpiAwareBase.broadcast_ruleMethod
          broadcast_rule(
          +

          This function is used to define the behavior of broadcasting for a specific type of AbstractBroadcastRule.

          The broadcast_n function returns the length of the latent periods to generate using the given broadcast_rule. Which model of broadcasting to be implemented is set by the type of broadcast_rule. If no implemention is defined for the given broadcast_rule, then EpiAware will return a warning and return nothing.

          source
          EpiAware.EpiAwareBase.broadcast_ruleMethod
          broadcast_rule(
               broadcast_rule::AbstractBroadcastRule,
               n,
               period
           )
          -

          This function is used to define the behavior of broadcasting for a specific type of AbstractBroadcastRule.

          The broadcast_rule function implements a model of broadcasting a latent process. Which model of broadcasting to be implemented is set by the type of broadcast_rule. If no implemention is defined for the given broadcast_rule, then EpiAware will return a warning and return nothing.

          source
          EpiAware.EpiAwareBase.condition_modelMethod
          condition_model(
          +

          This function is used to define the behavior of broadcasting for a specific type of AbstractBroadcastRule.

          The broadcast_rule function implements a model of broadcasting a latent process. Which model of broadcasting to be implemented is set by the type of broadcast_rule. If no implemention is defined for the given broadcast_rule, then EpiAware will return a warning and return nothing.

          source
          EpiAware.EpiAwareBase.condition_modelMethod
          condition_model(
               model,
               fix_parameters,
               condition_parameters
           ) -> Any
          -

          Condition a model on fixed (i.e to a value) and conditioned (i.e to data) parameters.

          Returns

          • model: The conditioned model.
          source
          EpiAware.EpiAwareBase.generate_epiawareMethod
          generate_epiaware(
               y_t,
               time_step,
               epi_model::AbstractEpiModel,
               latent_model::AbstractLatentModel,
               observation_model::AbstractObservationModel
           )
          -

          Create an epi-aware model using the specified epimodel, latentmodel, and observation_model.

          Arguments

          • y_t: The observed data.
          • time_steps: The time steps.
          • epi_model: An abstract epi model.
          • latent_model: An abstract latent model.
          • observation_model: An abstract observation model.

          Returns

          • nothing
          source
          EpiAware.EpiAwareBase.generate_epiawareMethod
          generate_epiaware(epiproblem::EpiProblem, data) -> Any
          -

          Generate an epi-aware model given an EpiProblem and data.

          Arguments

          • epiproblem: Epi problem specification.
          • data: Observed data.

          Returns

          A tuple containing the generated quantities of the epi-aware model.

          source
          EpiAware.EpiAwareBase.generate_latentMethod
          generate_latent(latent_model::AbstractLatentModel, n) -> Any
          -

          Constructor function for a latent process path $Z_t$ of length n.

          The generate_latent function implements a model of generating a latent process. Which model for generating the latent process infections is implemented is set by the type of latent_model. If no implemention is defined for the type of latent_model, then EpiAware will pass a warning and return nothing.

          Interface to Turing.jl probablilistic programming language (PPL)

          Apart from the no implementation fallback method, the generate_latent implementation function should return a constructor function for a DynamicPPL.Model object. Sample paths of $Z_t$ are generated quantities of the constructed model. Priors for model parameters are fields of epi_model.

          source
          EpiAware.EpiAwareBase.generate_latent_infsMethod
          generate_latent_infs(
          +

          Create an epi-aware model using the specified epimodel, latentmodel, and observation_model.

          Arguments

          • y_t: The observed data.
          • time_steps: The time steps.
          • epi_model: An abstract epi model.
          • latent_model: An abstract latent model.
          • observation_model: An abstract observation model.

          Returns

          • nothing
          source
          EpiAware.EpiAwareBase.generate_epiawareMethod
          generate_epiaware(epiproblem::EpiProblem, data) -> Any
          +

          Generate an epi-aware model given an EpiProblem and data.

          Arguments

          • epiproblem: Epi problem specification.
          • data: Observed data.

          Returns

          A tuple containing the generated quantities of the epi-aware model.

          source
          EpiAware.EpiAwareBase.generate_latentMethod
          generate_latent(latent_model::AbstractLatentModel, n) -> Any
          +

          Constructor function for a latent process path $Z_t$ of length n.

          The generate_latent function implements a model of generating a latent process. Which model for generating the latent process infections is implemented is set by the type of latent_model. If no implemention is defined for the type of latent_model, then EpiAware will pass a warning and return nothing.

          Interface to Turing.jl probablilistic programming language (PPL)

          Apart from the no implementation fallback method, the generate_latent implementation function should return a constructor function for a DynamicPPL.Model object. Sample paths of $Z_t$ are generated quantities of the constructed model. Priors for model parameters are fields of epi_model.

          source
          EpiAware.EpiAwareBase.generate_latent_infsMethod
          generate_latent_infs(
               epi_model::AbstractEpiModel,
               Z_t
           ) -> Any
          -

          Constructor function for unobserved/latent infections based on the type of epi_model <: AbstractEpimodel and a latent process path $Z_t$.

          The generate_latent_infs function implements a model of generating unobserved/latent infections conditional on a latent process. Which model of generating unobserved/latent infections to be implemented is set by the type of epi_model. If no implemention is defined for the given epi_model, then EpiAware will return a warning and return nothing.

          Interface to Turing.jl probablilistic programming language (PPL)

          Apart from the no implementation fallback method, the generate_latent_infs implementation function returns a constructor function for a DynamicPPL.Model object where the unobserved/latent infections are a generated quantity. Priors for model parameters are fields of epi_model.

          source
          EpiAware.EpiAwareBase.generate_observationsMethod
          generate_observations(
          +

          Constructor function for unobserved/latent infections based on the type of epi_model <: AbstractEpimodel and a latent process path $Z_t$.

          The generate_latent_infs function implements a model of generating unobserved/latent infections conditional on a latent process. Which model of generating unobserved/latent infections to be implemented is set by the type of epi_model. If no implemention is defined for the given epi_model, then EpiAware will return a warning and return nothing.

          Interface to Turing.jl probablilistic programming language (PPL)

          Apart from the no implementation fallback method, the generate_latent_infs implementation function returns a constructor function for a DynamicPPL.Model object where the unobserved/latent infections are a generated quantity. Priors for model parameters are fields of epi_model.

          source
          EpiAware.EpiAwareBase.generate_observationsMethod
          generate_observations(
               obs_model::AbstractObservationModel,
               y_t,
               Y_t
           ) -> Any
          -

          Constructor function for generating observations based on the given observation model.

          The generate_observations function implements a model of generating observations based on the given observation model. Which model of generating observations to be implemented is set by the type of obs_model. If no implemention is defined for the given obs_model, then EpiAware will return a warning and return nothing.

          source
          EpiAware.EpiAwareBase.generated_observablesMethod
          generated_observables(
          +

          Constructor function for generating observations based on the given observation model.

          The generate_observations function implements a model of generating observations based on the given observation model. Which model of generating observations to be implemented is set by the type of obs_model. If no implemention is defined for the given obs_model, then EpiAware will return a warning and return nothing.

          source
          EpiAware.EpiAwareBase.generated_observablesMethod
          generated_observables(
               model,
               data,
               solution
           ) -> EpiAwareObservables
          -

          Generate observables from a given model and solution and return them as a EpiAwareObservables struct.

          Arguments

          • model: The model used for generating observables.
          • data: The data used for generating observables.
          • solution: The solution used for generating observables.

          Returns

          An instance of EpiAwareObservables struct with the provided model, data, solution, and the generated observables if specified

          source
          +

          Generate observables from a given model and solution and return them as a EpiAwareObservables struct.

          Arguments

          • model: The model used for generating observables.
          • data: The data used for generating observables.
          • solution: The solution used for generating observables.

          Returns

          An instance of EpiAwareObservables struct with the provided model, data, solution, and the generated observables if specified

          source
          diff --git a/dev/lib/EpiAwareUtils/index.html b/dev/lib/EpiAwareUtils/index.html index ebc47c95e..bfa1fdf7d 100644 --- a/dev/lib/EpiAwareUtils/index.html +++ b/dev/lib/EpiAwareUtils/index.html @@ -1,2 +1,2 @@ -Overview · EpiAware.jl
          +Overview · EpiAware.jl
          diff --git a/dev/lib/EpiAwareUtils/internals/index.html b/dev/lib/EpiAwareUtils/internals/index.html index ba65cac35..22cd54eeb 100644 --- a/dev/lib/EpiAwareUtils/internals/index.html +++ b/dev/lib/EpiAwareUtils/internals/index.html @@ -1,5 +1,5 @@ -Internal API · EpiAware.jl

          Internal Documentation

          Documentation for EpiAwareUtils.jl's internal interface.

          Contents

          Index

          Internal API

          EpiAware.EpiAwareBase._apply_methodFunction
          _apply_method(
          +Internal API · EpiAware.jl

          Internal Documentation

          Documentation for EpiAwareUtils.jl's internal interface.

          Contents

          Index

          Internal API

          EpiAware.EpiAwareBase._apply_methodFunction
          _apply_method(
               model::DynamicPPL.Model,
               method::DirectSample;
               ...
          @@ -10,7 +10,7 @@
               prev_result;
               kwargs...
           ) -> Any
          -

          Implements direct sampling from a Turing model.

          source
          EpiAware.EpiAwareBase._apply_methodFunction
          _apply_method(
               model::DynamicPPL.Model,
               method::AbstractEpiMethod;
               ...
          @@ -21,43 +21,43 @@
               prev_result;
               kwargs...
           ) -> Any
          -

          Apply the inference/generative method method to the Model object mdl.

          Arguments

          • model::AbstractEpiModel: The model to apply the method to.
          • method::AbstractEpiMethod: The epidemiological method to apply.
          • prev_result: The previous result of the method.
          • kwargs: Additional keyword arguments passed to the method.

          Returns

          • nothing: If no concrete implementation is defined for the given method.
          source
          EpiAware.EpiAwareBase._apply_methodMethod
          _apply_method(
          +

          Apply the inference/generative method method to the Model object mdl.

          Arguments

          • model::AbstractEpiModel: The model to apply the method to.
          • method::AbstractEpiMethod: The epidemiological method to apply.
          • prev_result: The previous result of the method.
          • kwargs: Additional keyword arguments passed to the method.

          Returns

          • nothing: If no concrete implementation is defined for the given method.
          source
          EpiAware.EpiAwareBase._apply_methodMethod
          _apply_method(
               model::DynamicPPL.Model,
               method::EpiMethod,
               prev_result;
               kwargs...
           ) -> Any
          -

          Apply steps defined by an EpiMethod to a model object.

          This function applies the steps defined by an EpiMethod object to a Model object. It iterates over the pre-sampler steps defined in the EpiMethod object and recursively applies them to the model. Finally, it applies the sampler step defined in the EpiMethod object to the model. The prev_result argument is used to pass the result obtained from applying the previous steps, if any.

          Arguments

          • method::EpiMethod: The EpiMethod object containing the steps to be applied.
          • model::Model: The model object to which the steps will be applied.
          • prev_result: The previous result obtained from applying the steps. Defaults to nothing.
          • kwargs...: Additional keyword arguments that can be passed to the steps.

          Returns

          • prev_result: The result obtained after applying the steps.
          source
          EpiAware.EpiAwareBase._apply_methodMethod
          _apply_method(
          +

          Apply steps defined by an EpiMethod to a model object.

          This function applies the steps defined by an EpiMethod object to a Model object. It iterates over the pre-sampler steps defined in the EpiMethod object and recursively applies them to the model. Finally, it applies the sampler step defined in the EpiMethod object to the model. The prev_result argument is used to pass the result obtained from applying the previous steps, if any.

          Arguments

          • method::EpiMethod: The EpiMethod object containing the steps to be applied.
          • model::Model: The model object to which the steps will be applied.
          • prev_result: The previous result obtained from applying the steps. Defaults to nothing.
          • kwargs...: Additional keyword arguments that can be passed to the steps.

          Returns

          • prev_result: The result obtained after applying the steps.
          source
          EpiAware.EpiAwareBase._apply_methodMethod
          _apply_method(
               model::DynamicPPL.Model,
               method::EpiMethod;
               kwargs...
           ) -> Any
          -

          Apply a method to a mode without previous results

          Arguments

          • model::Model: The model to apply the method to.
          • method::EpiMethod: The method to apply.
          • kwargs...: Additional keyword arguments.

          Returns

          • The result of applying the method to the model.
          source
          EpiAware.EpiAwareBase.condition_modelMethod
          condition_model(
          +

          Apply a method to a mode without previous results

          Arguments

          • model::Model: The model to apply the method to.
          • method::EpiMethod: The method to apply.
          • kwargs...: Additional keyword arguments.

          Returns

          • The result of applying the method to the model.
          source
          EpiAware.EpiAwareBase.condition_modelMethod
          condition_model(
               model::DynamicPPL.Model,
               fix_parameters::NamedTuple,
               condition_parameters::NamedTuple
           ) -> Any
          -

          Apply the condition to the model by fixing the specified parameters and conditioning on the others.

          Arguments

          • model::Model: The model to be conditioned.
          • fix_parameters::NamedTuple: The parameters to be fixed.
          • condition_parameters::NamedTuple: The parameters to be conditioned on.

          Returns

          • _model: The conditioned model.
          source
          EpiAware.EpiAwareBase.generate_epiawareMethod
          generate_epiaware(
          +

          Apply the condition to the model by fixing the specified parameters and conditioning on the others.

          Arguments

          • model::Model: The model to be conditioned.
          • fix_parameters::NamedTuple: The parameters to be fixed.
          • condition_parameters::NamedTuple: The parameters to be conditioned on.

          Returns

          • _model: The conditioned model.
          source
          EpiAware.EpiAwareBase.generate_epiawareMethod
          generate_epiaware(
               y_t,
               time_steps,
               epi_model::AbstractTuringEpiModel;
               latent_model,
               observation_model
           )
          -

          Generate an epi-aware model given the observed data and model specifications.

          Arguments

          • y_t: Observed data.
          • time_steps: Number of time steps.
          • epi_model: A Turing Epi model specification.
          • latent_model: A Turing Latent model specification.
          • observation_model: A Turing Observation model specification.

          Returns

          A DynamicPPPL.Model object.

          source
          EpiAware.EpiAwareBase.generated_observablesMethod
          generated_observables(
          +

          Generate an epi-aware model given the observed data and model specifications.

          Arguments

          • y_t: Observed data.
          • time_steps: Number of time steps.
          • epi_model: A Turing Epi model specification.
          • latent_model: A Turing Latent model specification.
          • observation_model: A Turing Observation model specification.

          Returns

          A DynamicPPPL.Model object.

          source
          EpiAware.EpiAwareBase.generated_observablesMethod
          generated_observables(
               model::DynamicPPL.Model,
               data,
               solution::Union{NamedTuple, MCMCChains.Chains}
           ) -> EpiAwareObservables
          -

          Generate observables from a given model and solution including generated quantities.

          source
          EpiAware.EpiAwareUtils._apply_direct_sampleMethod
          _apply_direct_sample(
               model,
               method,
               n_samples::Int64;
               kwargs...
           ) -> Any
          -

          Sample the model directly using Turing.Prior() and a NamedTuple of the sampled random variables along with generated quantities.

          source
          +

          Sample the model directly using rand and return a single set of sampled random variables.

          source
          diff --git a/dev/lib/EpiAwareUtils/public/index.html b/dev/lib/EpiAwareUtils/public/index.html index bd3c0c113..4fcbe8ef9 100644 --- a/dev/lib/EpiAwareUtils/public/index.html +++ b/dev/lib/EpiAwareUtils/public/index.html @@ -1,5 +1,5 @@ -Public API · EpiAware.jl

          Public Documentation

          Documentation for EpiAwareBae.jl's public interface.

          See the Internals section of the manual for internal package docs covering all submodules.

          Contents

          Index

          Public API

          EpiAware.EpiAwareUtils.DirectSampleType
          struct DirectSample <: AbstractEpiSamplingMethod

          Sample directly from a Turing model.


          Fields

          • n_samples::Union{Nothing, Int64}: Number of samples from a model. If an integer is provided, the model is sampled n_samples times using Turing.Prior() returning an MCMChains. Chain object. If nothing, the model is sampled once returning a NamedTuple object of the sampled random variables along with generated quantities
          source
          EpiAware.EpiAwareUtils.HalfNormalType
          struct HalfNormal{T<:Real} <: Distributions.Distribution{Distributions.Univariate, Distributions.Continuous}

          Create a half-normal prior distribution with the specified mean.

          Arguments:

          • μ: The mean of the half-normal distribution.

          Returns:

          • A HalfNormal distribution with the specified mean.

          Examples:

          using EpiAware, Distributions
          +Public API · EpiAware.jl

          Public Documentation

          Documentation for EpiAwareBae.jl's public interface.

          See the Internals section of the manual for internal package docs covering all submodules.

          Contents

          Index

          Public API

          EpiAware.EpiAwareUtils.DirectSampleType
          struct DirectSample <: AbstractEpiSamplingMethod

          Sample directly from a Turing model.


          Fields

          • n_samples::Union{Nothing, Int64}: Number of samples from a model. If an integer is provided, the model is sampled n_samples times using Turing.Prior() returning an MCMChains. Chain object. If nothing, the model is sampled once returning a NamedTuple object of the sampled random variables along with generated quantities
          source
          EpiAware.EpiAwareUtils.HalfNormalType
          struct HalfNormal{T<:Real} <: Distributions.Distribution{Distributions.Univariate, Distributions.Continuous}

          Create a half-normal prior distribution with the specified mean.

          Arguments:

          • μ: The mean of the half-normal distribution.

          Returns:

          • A HalfNormal distribution with the specified mean.

          Examples:

          using EpiAware, Distributions
           
           hn = HalfNormal(1.0)
           # output
          @@ -15,7 +15,7 @@
           # output
           1.0
          var(hn)
           # output
          -0.5707963267948966

          Fields

          • μ::Real
          source
          EpiAware.EpiAwareUtils.censored_pmfMethod
          censored_pmf(dist::Distributions.Distribution; Δd, D) -> Any
           

          Create a discrete probability mass function (PMF) from a given distribution, assuming a uniform distribution over primary event times with censoring intervals of width Δd for both primary and secondary events. The CDF for the time from the left edge of the interval containing the primary event to the secondary event is created by direct numerical integration of the convolution of the CDF of dist with the uniform density on [0,Δd), the discrete PMF for double censored delays is then found using simple differencing on the CDF.

          Arguments

          • dist: The distribution from which to create the PMF.
          • Δd: The step size for discretizing the domain. Default is 1.0.
          • D: The upper bound of the domain. Must be greater than Δd. Default D = nothing

          indicates that the distribution should be truncated at its 99th percentile rounded to nearest multiple of Δd.

          Returns

          • A vector representing the PMF.

          Raises

          • AssertionError if the minimum value of dist is negative.
          • AssertionError if Δd is not positive.
          • AssertionError if D is shorter than Δd.
          • AssertionError if D is not a multiple of Δd.

          Examples

          using Distributions
           using EpiAware.EpiAwareUtils
           
          @@ -61,7 +61,7 @@
            0.003
            0.001
            0.0
          - 0.0
          source
          EpiAware.EpiAwareUtils.get_param_arrayMethod
          get_param_array(chn::MCMCChains.Chains) -> Any
           

          Extract a parameter array from a Chains object chn that matches the shape of number of sample and chain pairs in chn.

          Arguments

          • chn::Chains: The Chains object containing the MCMC samples.

          Returns

          • param_array: An array of parameter samples, where each element corresponds to a single

          MCMC sample as a NamedTuple.

          Example

          Sampling from a simple model which has both scalar and vector quantity random variables across 4 chains.

          using Turing, MCMCChains, EpiAware
           
           @model function testmodel()
          @@ -70,7 +70,7 @@
           mdl = testmodel()
           chn = sample(mdl, Prior(), MCMCSerial(), 2, 1, progress=false)
           
          -A = get_param_array(chn)
          source
          EpiAware.EpiAwareUtils.prefix_submodelMethod
          prefix_submodel(
               model::AbstractModel,
               fn::Function,
               prefix::String,
          @@ -81,6 +81,6 @@
           submodel = prefix_submodel(FixedIntercept(0.1), generate_latent, string(1), 2)
           submodel
           # output
          -Model{typeof(prefix_submodel), (:model, :fn, :prefix, Symbol("#splat#kwargs")), (), (), Tuple{FixedIntercept{Float64}, typeof(generate_latent), String, Tuple{Int64}}, Tuple{}, DefaultContext}(EpiAware.EpiAwareUtils.prefix_submodel, (model = FixedIntercept{Float64}(0.1), fn = EpiAware.EpiAwareBase.generate_latent, prefix = "1", var"#splat#kwargs" = (2,)), NamedTuple(), DefaultContext())

          We can now draw a sample from the submodel.

          rand(submodel)
          source
          EpiAware.EpiAwareUtils.scanMethod
          scan(f::AbstractModel, init, xs) -> Tuple{Any, Any}
          -

          Apply f to each element of xs and accumulate the results.

          f must be a callable on a sub-type of AbstractModel.

          Design note

          scan is being restricted to AbstractModel sub-types to ensure: 1. That compiler specialization is activated 2. Also avoids potential compiler overhead from specialisation on f<: Function.

          Arguments

          • f: A callable/functor that takes two arguments, carry and x, and returns a new carry and a result y.
          • init: The initial value for the carry variable.
          • xs: An iterable collection of elements.

          Returns

          • ys: An array containing the results of applying f to each element of xs.
          • carry: The final value of the carry variable after processing all elements of xs.

          Examples

          ```jldoctest using EpiAware

          struct Adder <: EpiAwareBase.AbstractModel end function (a::Adder)(carry, x) carry + x, carry + x end

          scan(Adder(), 0, 1:5) #output ([1, 3, 6, 10, 15], 15)

          source
          EpiAware.EpiAwareUtils.spread_drawsMethod
          spread_draws(chn::MCMCChains.Chains) -> DataFrames.DataFrame
          -
          spread_draws(chn::Chains)

          Converts a Chains object into a DataFrame in tidybayes format.

          Arguments

          • chn::Chains: The Chains object to be converted.

          Returns

          • df::DataFrame: The converted DataFrame.
          source
          +Model{typeof(prefix_submodel), (:model, :fn, :prefix, Symbol("#splat#kwargs")), (), (), Tuple{FixedIntercept{Float64}, typeof(generate_latent), String, Tuple{Int64}}, Tuple{}, DefaultContext}(EpiAware.EpiAwareUtils.prefix_submodel, (model = FixedIntercept{Float64}(0.1), fn = EpiAware.EpiAwareBase.generate_latent, prefix = "1", var"#splat#kwargs" = (2,)), NamedTuple(), DefaultContext())

          We can now draw a sample from the submodel.

          rand(submodel)
          source
          EpiAware.EpiAwareUtils.scanMethod
          scan(f::AbstractModel, init, xs) -> Tuple{Any, Any}
          +

          Apply f to each element of xs and accumulate the results.

          f must be a callable on a sub-type of AbstractModel.

          Design note

          scan is being restricted to AbstractModel sub-types to ensure: 1. That compiler specialization is activated 2. Also avoids potential compiler overhead from specialisation on f<: Function.

          Arguments

          • f: A callable/functor that takes two arguments, carry and x, and returns a new carry and a result y.
          • init: The initial value for the carry variable.
          • xs: An iterable collection of elements.

          Returns

          • ys: An array containing the results of applying f to each element of xs.
          • carry: The final value of the carry variable after processing all elements of xs.

          Examples

          ```jldoctest using EpiAware

          struct Adder <: EpiAwareBase.AbstractModel end function (a::Adder)(carry, x) carry + x, carry + x end

          scan(Adder(), 0, 1:5) #output ([1, 3, 6, 10, 15], 15)

          source
          EpiAware.EpiAwareUtils.spread_drawsMethod
          spread_draws(chn::MCMCChains.Chains) -> DataFrames.DataFrame
          +
          spread_draws(chn::Chains)

          Converts a Chains object into a DataFrame in tidybayes format.

          Arguments

          • chn::Chains: The Chains object to be converted.

          Returns

          • df::DataFrame: The converted DataFrame.
          source
          diff --git a/dev/lib/EpiInfModels/index.html b/dev/lib/EpiInfModels/index.html index 97a83fabf..6e8e042f5 100644 --- a/dev/lib/EpiInfModels/index.html +++ b/dev/lib/EpiInfModels/index.html @@ -1,2 +1,2 @@ -Overview · EpiAware.jl

          EpiInfModels.jl

          This package provides infectious disease transmission models for the EpiAware ecosystem.

          API

            +Overview · EpiAware.jl

            EpiInfModels.jl

            This package provides infectious disease transmission models for the EpiAware ecosystem.

            API

              diff --git a/dev/lib/EpiInfModels/internals/index.html b/dev/lib/EpiInfModels/internals/index.html index 4aee5ec99..fcdd8e58c 100644 --- a/dev/lib/EpiInfModels/internals/index.html +++ b/dev/lib/EpiInfModels/internals/index.html @@ -1,5 +1,5 @@ -Internal API · EpiAware.jl

              Internal Documentation

              Documentation for EpiInfModels.jl's internal interface.

              Contents

              Index

              Internal API

              EpiAware.EpiAwareBase.generate_latent_infsMethod
              generate_latent_infs(
              +Internal API · EpiAware.jl

              Internal Documentation

              Documentation for EpiInfModels.jl's internal interface.

              Contents

              Index

              Internal API

              EpiAware.EpiAwareBase.generate_latent_infsMethod
              generate_latent_infs(
                   epi_model::AbstractTuringRenewal,
                   _Rt
               ) -> Any
              @@ -18,7 +18,7 @@
               #Sample random parameters from prior
               θ = rand(latent_inf)
               #Get unobserved infections as a generated quantities from the model
              -I_t = generated_quantities(latent_inf, θ)
              source
              EpiAware.EpiAwareBase.generate_latent_infsMethod
              generate_latent_infs(
                   epi_model::DirectInfections,
                   Z_t
               ) -> Any
              @@ -37,7 +37,7 @@
               #Sample random parameters from prior
               θ = rand(latent_inf)
               #Get unobserved infections as a generated quantities from the model
              -I_t = generated_quantities(latent_inf, θ)
              source
              EpiAware.EpiAwareBase.generate_latent_infsMethod
              generate_latent_infs(epi_model::ExpGrowthRate, rt) -> Any
               

              Implement the generate_latent_infs function for the ExpGrowthRate model.

              Example usage with ExpGrowthRate type of model for unobserved infection process

              generate_latent_infs can be used to construct a Turing model for the latent infections conditional on the sample path of a latent process. In this example, we generate a sample of a white noise latent process.

              First, we construct an ExpGrowthRate struct with an EpiData object, an initialisation prior and a transformation function.

              using Distributions, Turing, EpiAware
               gen_int = [0.2, 0.3, 0.5]
               g = exp
              @@ -53,11 +53,11 @@
               #Sample random parameters from prior
               θ = rand(latent_inf)
               #Get unobserved infections as a generated quantities from the model
              -I_t = generated_quantities(latent_inf, θ)
              source
              EpiAware.EpiInfModels.make_renewal_initMethod
              make_renewal_init(epi_model::Renewal, I₀, Rt) -> Any
              -

              Create the initial vector of infected individuals for a renewal model.

              Arguments

              • epi_model::Renewal: The renewal model.
              • I₀: The initial number of infected individuals.
              • Rt: The time-varying reproduction number.

              Returns

              The initial vector of infected individuals.

              source
              EpiAware.EpiInfModels.make_renewal_initMethod
              make_renewal_init(epi_model::Renewal, I₀, Rt) -> Any
              +

              Create the initial vector of infected individuals for a renewal model.

              Arguments

              • epi_model::Renewal: The renewal model.
              • I₀: The initial number of infected individuals.
              • Rt: The time-varying reproduction number.

              Returns

              The initial vector of infected individuals.

              source
              EpiAware.EpiInfModels.make_renewal_initMethod
              make_renewal_init(
                   epi_model::RenewalWithPopulation,
                   I₀,
                   Rt
               ) -> Tuple{Any, Float64}
              -

              Constructs the initial conditions for a renewal model with population.

              Arguments

              • epi_model::RenewalWithPopulation: The renewal model with population.
              • I₀: The initial number of infected individuals.
              • Rt: The time-varying reproduction number.

              Returns

              • A tuple containing the initial number of infected individuals at each generation

              interval and the population size of susceptible/available people.

              source
              EpiAware.EpiInfModels.neg_MGFMethod
              neg_MGF(r, w::AbstractVector) -> Any
              -

              Compute the negative moment generating function (MGF) for a given rate r and weights w.

              Arguments

              • r: The rate parameter.
              • w: An abstract vector of weights.

              Returns

              The value of the negative MGF.

              source
              +

              Constructs the initial conditions for a renewal model with population.

              Arguments

              • epi_model::RenewalWithPopulation: The renewal model with population.
              • I₀: The initial number of infected individuals.
              • Rt: The time-varying reproduction number.

              Returns

              • A tuple containing the initial number of infected individuals at each generation

              interval and the population size of susceptible/available people.

              source
              EpiAware.EpiInfModels.neg_MGFMethod
              neg_MGF(r, w::AbstractVector) -> Any
              +

              Compute the negative moment generating function (MGF) for a given rate r and weights w.

              Arguments

              • r: The rate parameter.
              • w: An abstract vector of weights.

              Returns

              The value of the negative MGF.

              source
              diff --git a/dev/lib/EpiInfModels/public/index.html b/dev/lib/EpiInfModels/public/index.html index 5d6e7c4d0..7ffef113b 100644 --- a/dev/lib/EpiInfModels/public/index.html +++ b/dev/lib/EpiInfModels/public/index.html @@ -1,5 +1,5 @@ -Public API · EpiAware.jl

              Public Documentation

              Documentation for EpiInfModels.jl's public interface.

              See the Internals section of the manual for internal package docs covering all submodules.

              Contents

              Index

              Public API

              EpiAware.EpiInfModels.DirectInfectionsType
              struct DirectInfections{S<:Distributions.Sampleable} <: AbstractTuringEpiModel

              Model unobserved/latent infections as a transformation on a sampled latent process.

              Mathematical specification

              If $Z_t$ is a realisation of the latent model, then the unobserved/latent infections are given by

              \[I_t = g(\hat{I}_0 + Z_t).\]

              where $g$ is a transformation function and the unconstrained initial infections $\hat{I}_0$ are sampled from a prior distribution.

              DirectInfections are constructed by passing an EpiData object data and an initialisation_prior for the prior distribution of $\hat{I}_0$. The default initialisation_prior is Normal().

              Constructors

              • DirectInfections(; data, initialisation_prior)

              Example usage with generate_latent_infs

              generate_latent_infs can be used to construct a Turing model for the latent infections conditional on the sample path of a latent process. In this example, we generate a sample of a white noise latent process.

              First, we construct a DirectInfections struct with an EpiData object, an initialisation prior and a transformation function.

              using Distributions, Turing, EpiAware
              +Public API · EpiAware.jl

              Public Documentation

              Documentation for EpiInfModels.jl's public interface.

              See the Internals section of the manual for internal package docs covering all submodules.

              Contents

              Index

              Public API

              EpiAware.EpiInfModels.DirectInfectionsType
              struct DirectInfections{S<:Distributions.Sampleable} <: AbstractTuringEpiModel

              Model unobserved/latent infections as a transformation on a sampled latent process.

              Mathematical specification

              If $Z_t$ is a realisation of the latent model, then the unobserved/latent infections are given by

              \[I_t = g(\hat{I}_0 + Z_t).\]

              where $g$ is a transformation function and the unconstrained initial infections $\hat{I}_0$ are sampled from a prior distribution.

              DirectInfections are constructed by passing an EpiData object data and an initialisation_prior for the prior distribution of $\hat{I}_0$. The default initialisation_prior is Normal().

              Constructors

              • DirectInfections(; data, initialisation_prior)

              Example usage with generate_latent_infs

              generate_latent_infs can be used to construct a Turing model for the latent infections conditional on the sample path of a latent process. In this example, we generate a sample of a white noise latent process.

              First, we construct a DirectInfections struct with an EpiData object, an initialisation prior and a transformation function.

              using Distributions, Turing, EpiAware
               gen_int = [0.2, 0.3, 0.5]
               g = exp
               
              @@ -14,7 +14,7 @@
               #Sample random parameters from prior
               θ = rand(latent_inf)
               #Get unobserved infections as a generated quantities from the model
              -I_t = generated_quantities(latent_inf, θ)

              Fields

              • data::EpiData: Epidata object.

              • initialisation_prior::Distributions.Sampleable: Prior distribution for the initialisation of the infections. Default is Normal().

              source
              EpiAware.EpiInfModels.EpiDataType
              struct EpiData{T<:Real, F<:Function}

              The EpiData struct represents epidemiological data used in infectious disease modeling.

              Constructors

              • EpiData(gen_int, transformation::Function). Constructs an EpiData object with discrete

              generation interval gen_int and transformation function transformation.

              • EpiData(;gen_distribution::ContinuousDistribution, D_gen, Δd = 1.0, transformation::Function = exp).

              Constructs an EpiData object with double interval censoring discretisation of the continuous next generation interval distribution gen_distribution with additional right truncation at D_gen. Δd sets the interval width (default = 1.0). transformation sets the transformation function

              Examples

              Construction direct from discrete generation interval and transformation function:

              using EpiAware
              +I_t = generated_quantities(latent_inf, θ)

              Fields

              • data::EpiData: Epidata object.

              • initialisation_prior::Distributions.Sampleable: Prior distribution for the initialisation of the infections. Default is Normal().

              source
              EpiAware.EpiInfModels.EpiDataType
              struct EpiData{T<:Real, F<:Function}

              The EpiData struct represents epidemiological data used in infectious disease modeling.

              Constructors

              • EpiData(gen_int, transformation::Function). Constructs an EpiData object with discrete

              generation interval gen_int and transformation function transformation.

              • EpiData(;gen_distribution::ContinuousDistribution, D_gen, Δd = 1.0, transformation::Function = exp).

              Constructs an EpiData object with double interval censoring discretisation of the continuous next generation interval distribution gen_distribution with additional right truncation at D_gen. Δd sets the interval width (default = 1.0). transformation sets the transformation function

              Examples

              Construction direct from discrete generation interval and transformation function:

              using EpiAware
               gen_int = [0.2, 0.3, 0.5]
               g = exp
               data = EpiData(gen_int, g)

              Construction from continuous distribution for generation interval.

              using Distributions
              @@ -22,7 +22,7 @@
               gen_distribution = Uniform(0.0, 10.0)
               
               data = EpiData(;gen_distribution
              -    D_gen = 10.0)

              Fields

              • gen_int::Vector{T} where T<:Real: Discrete generation interval.

              • len_gen_int::Integer: Length of the discrete generation interval.

              • transformation::Function: Transformation function defining constrained and unconstrained domain bijections.

              source
              EpiAware.EpiInfModels.ExpGrowthRateType
              struct ExpGrowthRate{S<:Distributions.Sampleable} <: AbstractTuringEpiModel

              Model unobserved/latent infections as due to time-varying exponential growth rate $r_t$ which is generated by a latent process.

              Mathematical specification

              If $Z_t$ is a realisation of the latent model, then the unobserved/latent infections are given by

              \[I_t = g(\hat{I}_0) \exp(Z_t).\]

              where $g$ is a transformation function and the unconstrained initial infections $\hat{I}_0$ are sampled from a prior distribution.

              ExpGrowthRate are constructed by passing an EpiData object data and an initialisation_prior for the prior distribution of $\hat{I}_0$. The default initialisation_prior is Normal().

              Constructor

              • ExpGrowthRate(; data, initialisation_prior).

              Example usage with generate_latent_infs

              generate_latent_infs can be used to construct a Turing model for the latent infections conditional on the sample path of a latent process. In this example, we generate a sample of a white noise latent process.

              First, we construct an ExpGrowthRate struct with an EpiData object, an initialisation prior and a transformation function.

              using Distributions, Turing, EpiAware
              +    D_gen = 10.0)

              Fields

              • gen_int::Vector{T} where T<:Real: Discrete generation interval.

              • len_gen_int::Integer: Length of the discrete generation interval.

              • transformation::Function: Transformation function defining constrained and unconstrained domain bijections.

              source
              EpiAware.EpiInfModels.ExpGrowthRateType
              struct ExpGrowthRate{S<:Distributions.Sampleable} <: AbstractTuringEpiModel

              Model unobserved/latent infections as due to time-varying exponential growth rate $r_t$ which is generated by a latent process.

              Mathematical specification

              If $Z_t$ is a realisation of the latent model, then the unobserved/latent infections are given by

              \[I_t = g(\hat{I}_0) \exp(Z_t).\]

              where $g$ is a transformation function and the unconstrained initial infections $\hat{I}_0$ are sampled from a prior distribution.

              ExpGrowthRate are constructed by passing an EpiData object data and an initialisation_prior for the prior distribution of $\hat{I}_0$. The default initialisation_prior is Normal().

              Constructor

              • ExpGrowthRate(; data, initialisation_prior).

              Example usage with generate_latent_infs

              generate_latent_infs can be used to construct a Turing model for the latent infections conditional on the sample path of a latent process. In this example, we generate a sample of a white noise latent process.

              First, we construct an ExpGrowthRate struct with an EpiData object, an initialisation prior and a transformation function.

              using Distributions, Turing, EpiAware
               gen_int = [0.2, 0.3, 0.5]
               g = exp
               
              @@ -37,7 +37,7 @@
               #Sample random parameters from prior
               θ = rand(latent_inf)
               #Get unobserved infections as a generated quantities from the model
              -I_t = generated_quantities(latent_inf, θ)

              Fields

              • data::EpiData

              • initialisation_prior::Distributions.Sampleable

              source
              EpiAware.EpiInfModels.RenewalType
              struct Renewal{S<:Distributions.Sampleable} <: AbstractTuringRenewal

              Model unobserved/latent infections as due to time-varying Renewal model with reproduction number $\mathcal{R}_t$ which is generated by a latent process.

              Mathematical specification

              If $Z_t$ is a realisation of the latent model, then the unobserved/latent infections are given by

              \[\begin{align} +I_t = generated_quantities(latent_inf, θ)


              Fields

              • data::EpiData

              • initialisation_prior::Distributions.Sampleable

              source
              EpiAware.EpiInfModels.RenewalType
              struct Renewal{S<:Distributions.Sampleable} <: AbstractTuringRenewal

              Model unobserved/latent infections as due to time-varying Renewal model with reproduction number $\mathcal{R}_t$ which is generated by a latent process.

              Mathematical specification

              If $Z_t$ is a realisation of the latent model, then the unobserved/latent infections are given by

              \[\begin{align} \mathcal{R}_t &= g(Z_t),\\ I_t &= \mathcal{R}_t \sum_{i=1}^{n-1} I_{t-i} g_i, \qquad t \geq 1, \\ I_t &= g(\hat{I}_0) \exp(r(\mathcal{R}_1) t), \qquad t \leq 0. @@ -56,7 +56,7 @@ #Sample random parameters from prior θ = rand(latent_inf) #Get unobserved infections as a generated quantities from the model -I_t = generated_quantities(latent_inf, θ)


              Fields

              • data::EpiData

              • initialisation_prior::Distributions.Sampleable

              source
              EpiAware.EpiInfModels.RenewalMethod
              function (epi_model::Renewal)(recent_incidence, Rt)

              Callable on a Renewal struct for compute new incidence based on recent incidence and Rt.

              Mathematical specification

              The new incidence is given by

              \[I_t = R_t \sum_{i=1}^{n-1} I_{t-i} g_i\]

              where I_t is the new incidence, R_t is the reproduction number, I_{t-i} is the recent incidence and g_i is the generation interval.

              Arguments

              • recent_incidence: Array of recent incidence values.
              • Rt: Reproduction number.

              Returns

              • Tuple containing the updated incidence array and the new incidence value.
              source
              EpiAware.EpiInfModels.RenewalWithPopulationType
              struct RenewalWithPopulation{S<:Distributions.Sampleable} <: AbstractTuringRenewal

              Model unobserved/latent infections as due to time-varying Renewal model with reproduction number $\mathcal{R}_t$ which is generated by a latent process and a population size of available people who can be infected N.

              Mathematical specification

              If $Z_t$ is a realisation of the latent model, then the unobserved/latent infections are given by

              \[\begin{align} +I_t = generated_quantities(latent_inf, θ)


              Fields

              • data::EpiData

              • initialisation_prior::Distributions.Sampleable

              source
              EpiAware.EpiInfModels.RenewalMethod
              function (epi_model::Renewal)(recent_incidence, Rt)

              Callable on a Renewal struct for compute new incidence based on recent incidence and Rt.

              Mathematical specification

              The new incidence is given by

              \[I_t = R_t \sum_{i=1}^{n-1} I_{t-i} g_i\]

              where I_t is the new incidence, R_t is the reproduction number, I_{t-i} is the recent incidence and g_i is the generation interval.

              Arguments

              • recent_incidence: Array of recent incidence values.
              • Rt: Reproduction number.

              Returns

              • Tuple containing the updated incidence array and the new incidence value.
              source
              EpiAware.EpiInfModels.RenewalWithPopulationType
              struct RenewalWithPopulation{S<:Distributions.Sampleable} <: AbstractTuringRenewal

              Model unobserved/latent infections as due to time-varying Renewal model with reproduction number $\mathcal{R}_t$ which is generated by a latent process and a population size of available people who can be infected N.

              Mathematical specification

              If $Z_t$ is a realisation of the latent model, then the unobserved/latent infections are given by

              \[\begin{align} \mathcal{R}_t &= g(Z_t),\\ S_t &= S_{t-1} - I_t,\\ I_t &= {S_{t-1} \over N}\mathcal{R}_t \sum_{i=1}^{n-1} I_{t-i} g_i, \qquad t \geq 1, \\ @@ -76,13 +76,13 @@ #Sample random parameters from prior θ = rand(latent_inf) #Get unobserved infections as a generated quantities from the model -I_t = generated_quantities(latent_inf, θ)


              Fields

              • data::EpiData

              • initialisation_prior::Distributions.Sampleable

              • pop_size::Float64

              source
              EpiAware.EpiInfModels.RenewalWithPopulationMethod
              function (epi_model::RenewalWithPopulation)(recent_incidence_and_available_sus, Rt)

              Callable on a RenewalWithPopulation struct for compute new incidence based on recent incidence, Rt and depletion of susceptibles.

              Mathematical specification

              The new incidence is given by

              \[I_t = {S_{t-1} / N} R_t \sum_{i=1}^{n-1} I_{t-i} g_i\]

              where I_t is the new incidence, R_t is the reproduction number, I_{t-i} is the recent incidence and g_i is the generation interval.

              Arguments

              • recent_incidence_and_available_sus: A tuple with an array of recent incidence

              values and the remaining susceptible/available individuals.

              • Rt: Reproduction number.

              Returns

              • Tuple containing the updated incidence array and the new recent_incidence_and_available_sus

              value.

              source
              EpiAware.EpiInfModels.R_to_rMethod
              R_to_r(
              +I_t = generated_quantities(latent_inf, θ)

              Fields

              • data::EpiData

              • initialisation_prior::Distributions.Sampleable

              • pop_size::Float64

              source
              EpiAware.EpiInfModels.RenewalWithPopulationMethod
              function (epi_model::RenewalWithPopulation)(recent_incidence_and_available_sus, Rt)

              Callable on a RenewalWithPopulation struct for compute new incidence based on recent incidence, Rt and depletion of susceptibles.

              Mathematical specification

              The new incidence is given by

              \[I_t = {S_{t-1} / N} R_t \sum_{i=1}^{n-1} I_{t-i} g_i\]

              where I_t is the new incidence, R_t is the reproduction number, I_{t-i} is the recent incidence and g_i is the generation interval.

              Arguments

              • recent_incidence_and_available_sus: A tuple with an array of recent incidence

              values and the remaining susceptible/available individuals.

              • Rt: Reproduction number.

              Returns

              • Tuple containing the updated incidence array and the new recent_incidence_and_available_sus

              value.

              source
              EpiAware.EpiInfModels.R_to_rMethod
              R_to_r(
                   R₀,
                   w::Array{T<:AbstractFloat, 1};
                   newton_steps,
                   Δd
               ) -> Any
              -

              This function computes an approximation to the exponential growth rate r given the reproductive ratio R₀ and the discretized generation interval w with discretized interval width Δd. This is based on the implicit solution of

              \[G(r) - {1 \over R_0} = 0.\]

              where

              \[G(r) = \sum_{i=1}^n w_i e^{-r i}.\]

              is the negative moment generating function (MGF) of the generation interval distribution.

              The two step approximation is based on: 1. Direct solution of implicit equation for a small r approximation. 2. Improving the approximation using Newton's method for a fixed number of steps newton_steps.

              Returns:

              • The approximate value of r.
              source
              EpiAware.EpiInfModels.expected_RtMethod
              expected_Rt(
              +

              This function computes an approximation to the exponential growth rate r given the reproductive ratio R₀ and the discretized generation interval w with discretized interval width Δd. This is based on the implicit solution of

              \[G(r) - {1 \over R_0} = 0.\]

              where

              \[G(r) = \sum_{i=1}^n w_i e^{-r i}.\]

              is the negative moment generating function (MGF) of the generation interval distribution.

              The two step approximation is based on: 1. Direct solution of implicit equation for a small r approximation. 2. Improving the approximation using Newton's method for a fixed number of steps newton_steps.

              Returns:

              • The approximate value of r.
              source
              EpiAware.EpiInfModels.expected_RtMethod
              expected_Rt(
                   data::EpiData,
                   infections::Vector{<:Real}
               ) -> Any
              @@ -90,5 +90,5 @@
               
               data = EpiData([0.2, 0.3, 0.5], exp)
               infections = [100, 200, 300, 400, 500]
              -expected_Rt(data, infections)
              source
              EpiAware.EpiInfModels.r_to_RMethod
              r_to_R(r, w::AbstractVector) -> Any
              -
              r_to_R(r, w)

              Compute the reproductive ratio given exponential growth rate r and discretized generation interval w.

              Arguments

              • r: The exponential growth rate.
              • w: discretized generation interval.

              Returns

              • The reproductive ratio.
              source
              +expected_Rt(data, infections)source
              EpiAware.EpiInfModels.r_to_RMethod
              r_to_R(r, w::AbstractVector) -> Any
              +
              r_to_R(r, w)

              Compute the reproductive ratio given exponential growth rate r and discretized generation interval w.

              Arguments

              • r: The exponential growth rate.
              • w: discretized generation interval.

              Returns

              • The reproductive ratio.
              source
              diff --git a/dev/lib/EpiInference/index.html b/dev/lib/EpiInference/index.html index 1d6dd6465..0d58609d6 100644 --- a/dev/lib/EpiInference/index.html +++ b/dev/lib/EpiInference/index.html @@ -1,2 +1,2 @@ -Overview · EpiAware.jl
              +Overview · EpiAware.jl
              diff --git a/dev/lib/EpiInference/internals/index.html b/dev/lib/EpiInference/internals/index.html index 6a017c14c..733e28424 100644 --- a/dev/lib/EpiInference/internals/index.html +++ b/dev/lib/EpiInference/internals/index.html @@ -1,40 +1,40 @@ Internal API · EpiAware.jl

              Internal Documentation

              Documentation for EpInference.jl's internal interface.

              Contents

              Index

              Internal API

              EpiAware.EpiAwareBase._apply_methodFunction
              _apply_method(
                   model::DynamicPPL.Model,
              -    method::ManyPathfinder;
              +    method::NUTSampler;
                   ...
               ) -> Any
               _apply_method(
                   model::DynamicPPL.Model,
              -    method::ManyPathfinder,
              +    method::NUTSampler,
                   prev_result;
                   kwargs...
               ) -> Any
              -

              Apply a ManyPathfinder method to a DynamicPPL.Model object.

              If prev_result is a vector of real numbers, then the ManyPathfinder method is applied with the initial values set to prev_result. Otherwise, the ManyPathfinder method is run with default initial values generated.

              source
              EpiAware.EpiAwareBase._apply_methodFunction
              _apply_method(
                   model::DynamicPPL.Model,
              -    method::NUTSampler;
              +    method::ManyPathfinder;
                   ...
               ) -> Any
               _apply_method(
                   model::DynamicPPL.Model,
              -    method::NUTSampler,
              +    method::ManyPathfinder,
                   prev_result;
                   kwargs...
               ) -> Any
              -

              Apply NUTS sampling to a DynamicPPL.Model object with prev_result representing any initial results to use for sampler initialisation.

              source
              EpiAware.EpiInference._apply_nutsMethod
              _apply_nuts(
              +

              Apply a ManyPathfinder method to a DynamicPPL.Model object.

              If prev_result is a vector of real numbers, then the ManyPathfinder method is applied with the initial values set to prev_result. Otherwise, the ManyPathfinder method is run with default initial values generated.

              source
              EpiAware.EpiInference._apply_nutsMethod
              _apply_nuts(
                   model,
                   method,
                   prev_result::Pathfinder.PathfinderResult;
                   kwargs...
               ) -> Any
              -

              Initialise NUTS with initial parameters from a Pathfinder result.

              source
              EpiAware.EpiInference._continue_manypathfinder!Method
              _continue_manypathfinder!(
                   pfs,
                   mdl::DynamicPPL.Model;
                   max_tries,
                   nruns,
                   kwargs...
               )
              -

              Continue running the pathfinder algorithm until a pathfinder succeeds or the maximum number of tries is reached.

              Arguments

              • pfs: An array of pathfinder objects.
              • mdl::DynamicPPL.Model: The model to perform inference on.
              • max_tries: The maximum number of tries to run the pathfinder algorithm. Default is Inf.
              • nruns: The number of times to run the pathfinder function.
              • kwargs...: Additional keyword arguments passed to pathfinder.

              Returns

              • pfs: The updated array of pathfinder objects.
              source
              EpiAware.EpiInference._get_best_elbo_pathfinderMethod
              _get_best_elbo_pathfinder(pfs) -> Any
              -

              Selects the pathfinder with the highest ELBO estimate from a list of pathfinders.

              Arguments

              • pfs: A list of pathfinders results or Symbol values indicating failure.

              Returns

              The pathfinder with the highest ELBO estimate.

              source
              EpiAware.EpiInference._run_manypathfinderMethod
              _run_manypathfinder(mdl::DynamicPPL.Model; nruns, kwargs...)
              -

              Run pathfinder multiple times and store the results in an array. Fails safely.

              Arguments

              • mdl::DynamicPPL.Model: The Turing model to be used for inference.
              • nruns: The number of times to run the pathfinder function.
              • kwargs...: Additional keyword arguments passed to pathfinder.

              Returns

              An array of PathfinderResult objects or Symbol values indicating success or failure.

              source
              +

              Continue running the pathfinder algorithm until a pathfinder succeeds or the maximum number of tries is reached.

              Arguments

              Returns

              source
              EpiAware.EpiInference._get_best_elbo_pathfinderMethod
              _get_best_elbo_pathfinder(pfs) -> Any
              +

              Selects the pathfinder with the highest ELBO estimate from a list of pathfinders.

              Arguments

              • pfs: A list of pathfinders results or Symbol values indicating failure.

              Returns

              The pathfinder with the highest ELBO estimate.

              source
              EpiAware.EpiInference._run_manypathfinderMethod
              _run_manypathfinder(mdl::DynamicPPL.Model; nruns, kwargs...)
              +

              Run pathfinder multiple times and store the results in an array. Fails safely.

              Arguments

              • mdl::DynamicPPL.Model: The Turing model to be used for inference.
              • nruns: The number of times to run the pathfinder function.
              • kwargs...: Additional keyword arguments passed to pathfinder.

              Returns

              An array of PathfinderResult objects or Symbol values indicating success or failure.

              source
              diff --git a/dev/lib/EpiInference/public/index.html b/dev/lib/EpiInference/public/index.html index 3c9a2df62..ef2d412bc 100644 --- a/dev/lib/EpiInference/public/index.html +++ b/dev/lib/EpiInference/public/index.html @@ -1,5 +1,5 @@ -Public API · EpiAware.jl

              Public Documentation

              Documentation for EpiInference.jl's public interface.

              See the Internals section of the manual for internal package docs covering all submodules.

              Contents

              Index

              Public API

              EpiAware.EpiInference.ManyPathfinderType
              struct ManyPathfinder <: AbstractEpiOptMethod

              A variational inference method that runs manypathfinder.


              Fields

              • ndraws::Int64: Number of draws per pathfinder run.

              • nruns::Int64: Number of many pathfinder runs.

              • maxiters::Int64: Maximum number of optimization iterations for each run.

              • max_tries::Int64: Maximum number of tries if all runs fail.

              source
              EpiAware.EpiInference.NUTSamplerType
              struct NUTSampler{A<:ADTypes.AbstractADType, E<:AbstractMCMC.AbstractMCMCEnsemble, M} <: AbstractEpiSamplingMethod

              A NUTS method for sampling from a DynamicPPL.Model object.

              The NUTSampler struct represents using the No-U-Turn Sampler (NUTS) to sample from the distribution defined by a DynamicPPL.Model.


              Fields

              • target_acceptance::Float64: The target acceptance rate for the sampler.

              • adtype::ADTypes.AbstractADType: The automatic differentiation type used for computing gradients.

              • mcmc_parallel::AbstractMCMC.AbstractMCMCEnsemble: The parallelization strategy for the MCMC sampler.

              • nchains::Int64: The number of MCMC chains to run.

              • max_depth::Int64: Tree depth limit for the NUTS sampler.

              • Δ_max::Float64: Divergence threshold for the NUTS sampler.

              • init_ϵ::Float64: The initial step size for the NUTS sampler.

              • ndraws::Int64: The number of samples to draw from each chain.

              • metricT::Any: The metric type to use for the HMC sampler.

              source
              EpiAware.EpiInference.manypathfinderMethod
              manypathfinder(
              +Public API · EpiAware.jl

              Public Documentation

              Documentation for EpiInference.jl's public interface.

              See the Internals section of the manual for internal package docs covering all submodules.

              Contents

              Index

              Public API

              EpiAware.EpiInference.ManyPathfinderType
              struct ManyPathfinder <: AbstractEpiOptMethod

              A variational inference method that runs manypathfinder.


              Fields

              • ndraws::Int64: Number of draws per pathfinder run.

              • nruns::Int64: Number of many pathfinder runs.

              • maxiters::Int64: Maximum number of optimization iterations for each run.

              • max_tries::Int64: Maximum number of tries if all runs fail.

              source
              EpiAware.EpiInference.NUTSamplerType
              struct NUTSampler{A<:ADTypes.AbstractADType, E<:AbstractMCMC.AbstractMCMCEnsemble, M} <: AbstractEpiSamplingMethod

              A NUTS method for sampling from a DynamicPPL.Model object.

              The NUTSampler struct represents using the No-U-Turn Sampler (NUTS) to sample from the distribution defined by a DynamicPPL.Model.


              Fields

              • target_acceptance::Float64: The target acceptance rate for the sampler.

              • adtype::ADTypes.AbstractADType: The automatic differentiation type used for computing gradients.

              • mcmc_parallel::AbstractMCMC.AbstractMCMCEnsemble: The parallelization strategy for the MCMC sampler.

              • nchains::Int64: The number of MCMC chains to run.

              • max_depth::Int64: Tree depth limit for the NUTS sampler.

              • Δ_max::Float64: Divergence threshold for the NUTS sampler.

              • init_ϵ::Float64: The initial step size for the NUTS sampler.

              • ndraws::Int64: The number of samples to draw from each chain.

              • metricT::Any: The metric type to use for the HMC sampler.

              source
              EpiAware.EpiInference.manypathfinderMethod
              manypathfinder(
                   mdl::DynamicPPL.Model,
                   ndraws;
                   nruns,
              @@ -7,4 +7,4 @@
                   max_tries,
                   kwargs...
               ) -> Any
              -

              Run multiple instances of the pathfinder algorithm and returns the pathfinder run with the largest ELBO estimate.

              Arguments

              • mdl::DynamicPPL.Model: The model to perform inference on.
              • nruns::Int: The number of pathfinder runs to perform.
              • ndraws::Int: The number of draws per pathfinder run, readjusted to be at least as large as the number of chains.
              • nchains::Int: The number of chains that will be initialised by pathfinder draws.
              • maxiters::Int: The maximum number of optimizer iterations per pathfinder run.
              • max_tries::Int: The maximum number of extra tries to find a valid pathfinder result.
              • kwargs...: Additional keyword arguments passed to pathfinder.

              Returns

              • best_pfs::PathfinderResult: Best pathfinder result by estimated ELBO.
              source
              +

              Run multiple instances of the pathfinder algorithm and returns the pathfinder run with the largest ELBO estimate.

              Arguments

              • mdl::DynamicPPL.Model: The model to perform inference on.
              • nruns::Int: The number of pathfinder runs to perform.
              • ndraws::Int: The number of draws per pathfinder run, readjusted to be at least as large as the number of chains.
              • nchains::Int: The number of chains that will be initialised by pathfinder draws.
              • maxiters::Int: The maximum number of optimizer iterations per pathfinder run.
              • max_tries::Int: The maximum number of extra tries to find a valid pathfinder result.
              • kwargs...: Additional keyword arguments passed to pathfinder.

              Returns

              • best_pfs::PathfinderResult: Best pathfinder result by estimated ELBO.
              source
              diff --git a/dev/lib/EpiLatentModels/index.html b/dev/lib/EpiLatentModels/index.html index ea3d70dfe..7deaa4eca 100644 --- a/dev/lib/EpiLatentModels/index.html +++ b/dev/lib/EpiLatentModels/index.html @@ -1,2 +1,2 @@ -Overview · EpiAware.jl
              +Overview · EpiAware.jl
              diff --git a/dev/lib/EpiLatentModels/internals/index.html b/dev/lib/EpiLatentModels/internals/index.html index 44a804ba0..c9e199d46 100644 --- a/dev/lib/EpiLatentModels/internals/index.html +++ b/dev/lib/EpiLatentModels/internals/index.html @@ -1,16 +1,16 @@ -Internal API · EpiAware.jl

              Internal Documentation

              Documentation for EpiLatentModels.jl's internal interface.

              Contents

              Index

              Internal API

              EpiAware.EpiAwareBase.broadcast_nMethod
              broadcast_n(_::RepeatBlock, n, period) -> Any
              -

              A function that returns the length of the latent periods to generate using the RepeatBlock rule which is equal n divided by the period and rounded up to the nearest integer.

              Arguments

              • rule::RepeatBlock: The broadcasting rule.
              • n: The number of samples to generate.
              • period: The period of the broadcast.
              source
              EpiAware.EpiAwareBase.broadcast_nMethod
              broadcast_n(_::RepeatEach, n, period) -> Any
              -

              A function that returns the length of the latent periods to generate using the RepeatEach rule which is equal to the period.

              Arguments

              • rule::RepeatEach: The broadcasting rule.
              • n: The number of samples to generate.
              • period: The period of the broadcast.

              Returns

              • m: The length of the latent periods to generate.
              source
              EpiAware.EpiAwareBase.broadcast_ruleMethod
              broadcast_rule(_::RepeatBlock, latent, n, period) -> Any
              -

              broadcast_rule is a function that applies the RepeatBlock rule to the latent process latent to generate n samples.

              Arguments

              • rule::RepeatBlock: The broadcasting rule.
              • latent::Vector: The latent process.
              • n: The number of samples to generate.
              • period: The period of the broadcast.

              Returns

              • latent: The generated broadcasted latent periods.
              source
              EpiAware.EpiAwareBase.broadcast_ruleMethod
              broadcast_rule(_::RepeatEach, latent, n, period) -> Any
              -

              broadcast_rule is a function that applies the RepeatEach rule to the latent process latent to generate n samples.

              Arguments

              • rule::RepeatEach: The broadcasting rule.
              • latent::Vector: The latent process.
              • n: The number of samples to generate.
              • period: The period of the broadcast.

              Returns

              • latent: The generated broadcasted latent periods.
              source
              EpiAware.EpiAwareBase.generate_latentMethod
              generate_latent(latent_model::AR, n) -> Any
              -

              Generate a latent AR series.

              Arguments

              • latent_model::AR: The AR model.
              • n::Int: The length of the AR series.

              Returns

              • ar::Vector{Float64}: The generated AR series.
              • params::NamedTuple: A named tuple containing the generated parameters (σ_AR, ar_init, damp_AR).

              Notes

              • The length of damp_prior and init_prior must be the same.
              • n must be longer than the order of the autoregressive process.
              source
              EpiAware.EpiAwareBase.generate_latentMethod
              generate_latent(model::BroadcastLatentModel, n) -> Any
              -

              Generates latent periods using the specified model and n number of samples.

              Arguments

              • model::BroadcastLatentModel: The broadcast latent model.
              • n::Any: The number of samples to generate.

              Returns

              • broadcasted_latent: The generated broadcasted latent periods.
              • latent_period_aux...: Additional auxiliary information about the latent periods.
              source
              EpiAware.EpiAwareBase.generate_latentMethod
              generate_latent(
              +Internal API · EpiAware.jl

              Internal Documentation

              Documentation for EpiLatentModels.jl's internal interface.

              Contents

              Index

              Internal API

              EpiAware.EpiAwareBase.broadcast_nMethod
              broadcast_n(_::RepeatBlock, n, period) -> Any
              +

              A function that returns the length of the latent periods to generate using the RepeatBlock rule which is equal n divided by the period and rounded up to the nearest integer.

              Arguments

              • rule::RepeatBlock: The broadcasting rule.
              • n: The number of samples to generate.
              • period: The period of the broadcast.
              source
              EpiAware.EpiAwareBase.broadcast_nMethod
              broadcast_n(_::RepeatEach, n, period) -> Any
              +

              A function that returns the length of the latent periods to generate using the RepeatEach rule which is equal to the period.

              Arguments

              • rule::RepeatEach: The broadcasting rule.
              • n: The number of samples to generate.
              • period: The period of the broadcast.

              Returns

              • m: The length of the latent periods to generate.
              source
              EpiAware.EpiAwareBase.broadcast_ruleMethod
              broadcast_rule(_::RepeatBlock, latent, n, period) -> Any
              +

              broadcast_rule is a function that applies the RepeatBlock rule to the latent process latent to generate n samples.

              Arguments

              • rule::RepeatBlock: The broadcasting rule.
              • latent::Vector: The latent process.
              • n: The number of samples to generate.
              • period: The period of the broadcast.

              Returns

              • latent: The generated broadcasted latent periods.
              source
              EpiAware.EpiAwareBase.broadcast_ruleMethod
              broadcast_rule(_::RepeatEach, latent, n, period) -> Any
              +

              broadcast_rule is a function that applies the RepeatEach rule to the latent process latent to generate n samples.

              Arguments

              • rule::RepeatEach: The broadcasting rule.
              • latent::Vector: The latent process.
              • n: The number of samples to generate.
              • period: The period of the broadcast.

              Returns

              • latent: The generated broadcasted latent periods.
              source
              EpiAware.EpiAwareBase.generate_latentMethod
              generate_latent(latent_model::AR, n) -> Any
              +

              Generate a latent AR series.

              Arguments

              • latent_model::AR: The AR model.
              • n::Int: The length of the AR series.

              Returns

              • ar::Vector{Float64}: The generated AR series.
              • params::NamedTuple: A named tuple containing the generated parameters (σ_AR, ar_init, damp_AR).

              Notes

              • The length of damp_prior and init_prior must be the same.
              • n must be longer than the order of the autoregressive process.
              source
              EpiAware.EpiAwareBase.generate_latentMethod
              generate_latent(model::BroadcastLatentModel, n) -> Any
              +

              Generates latent periods using the specified model and n number of samples.

              Arguments

              • model::BroadcastLatentModel: The broadcast latent model.
              • n::Any: The number of samples to generate.

              Returns

              • broadcasted_latent: The generated broadcasted latent periods.
              • latent_period_aux...: Additional auxiliary information about the latent periods.
              source
              EpiAware.EpiAwareBase.generate_latentMethod
              generate_latent(
                   latent_models::CombineLatentModels,
                   n
               ) -> Any
              -

              Generate latent variables using a combination of multiple latent models.

              Arguments

              • latent_models::CombineLatentModels: An instance of the CombineLatentModels type representing the collection of latent models.
              • n: The number of latent variables to generate.

              Returns

              • combined_latents: The combined latent variables generated from all the models.
              • latent_aux: A tuple containing the auxiliary latent variables generated from each individual model.

              Example

              source
              EpiAware.EpiAwareBase.generate_latentMethod
              generate_latent(latent_models::ConcatLatentModels, n) -> Any
              -

              Generate latent variables by concatenating multiple latent models.

              Arguments

              • latent_models::ConcatLatentModels: An instance of the ConcatLatentModels type representing the collection of latent models.
              • n: The number of latent variables to generate.

              Returns

              • concatenated_latents: The combined latent variables generated from all the models.
              • latent_aux: A tuple containing the auxiliary latent variables generated from each individual model.
              source
              EpiAware.EpiAwareBase.generate_latentMethod
              generate_latent(latent_model::DiffLatentModel, n) -> Any
              +

              Generate latent variables using a combination of multiple latent models.

              Arguments

              • latent_models::CombineLatentModels: An instance of the CombineLatentModels type representing the collection of latent models.
              • n: The number of latent variables to generate.

              Returns

              • combined_latents: The combined latent variables generated from all the models.
              • latent_aux: A tuple containing the auxiliary latent variables generated from each individual model.

              Example

              source
              EpiAware.EpiAwareBase.generate_latentMethod
              generate_latent(latent_models::ConcatLatentModels, n) -> Any
              +

              Generate latent variables by concatenating multiple latent models.

              Arguments

              • latent_models::ConcatLatentModels: An instance of the ConcatLatentModels type representing the collection of latent models.
              • n: The number of latent variables to generate.

              Returns

              • concatenated_latents: The combined latent variables generated from all the models.
              • latent_aux: A tuple containing the auxiliary latent variables generated from each individual model.
              source
              EpiAware.EpiAwareBase.generate_latentMethod
              generate_latent(latent_model::DiffLatentModel, n) -> Any
               

              Generate a Turing model for n-step latent process $Z_t$ using a differenced latent model defined by latent_model.

              Arguments

              • latent_model::DiffLatentModel: The differential latent model.
              • n: The length of the latent variables.

              Turing model specifications

              Sampled random variables

              • latent_init: The initial latent process variables.
              • Other random variables defined by model<:AbstractTuringLatentModel field of the undifferenced model.

              Generated quantities

              • A tuple containing the generated latent process as its first argument and a NamedTuple of sampled auxiliary variables as second argument.

              Example usage with DiffLatentModel model constructor

              generate_latent can be used to construct a Turing model for the differenced latent process. In this example, the underlying undifferenced process is a RandomWalk model.

              First, we construct a RandomWalk struct with an initial value prior and a step size standard deviation prior.

              using Distributions, EpiAware
               rw = RandomWalk(Normal(0.0, 1.0), truncated(Normal(0.0, 0.05), 0.0, Inf))

              Then, we can use DiffLatentModel to construct a DiffLatentModel for d-fold differenced process with rw as the undifferenced latent process.

              We have two constructor options for DiffLatentModel. The first option is to supply a common prior distribution for the initial terms and specify d as follows:

              diff_model = DiffLatentModel(rw, Normal(); d = 2)

              Or we can supply a vector of priors for the initial terms and d is inferred as follows:

              diff_model2 = DiffLatentModel(;undiffmodel = rw, init_priors = [Normal(), Normal()])

              Then, we can use generate_latent to construct a Turing model for the differenced latent process generating a length n process,

              # Construct a Turing model
               n = 100
              @@ -18,10 +18,10 @@
               θ = rand(difference_mdl)
               #Get a sampled latent process as a generated quantity from the model
               (Z_t, _) = generated_quantities(difference_mdl, θ)
              -Z_t
              source
              EpiAware.EpiAwareBase.generate_latentMethod
              generate_latent(latent_model::FixedIntercept, n) -> Any
              -

              Generate a latent intercept series with a fixed intercept value.

              Arguments

              • latent_model::FixedIntercept: The fixed intercept latent model.
              • n: The number of latent variables to generate.

              Returns

              • latent_vars: An array of length n filled with the fixed intercept value.
              • metadata: A named tuple containing the intercept value.
              source
              EpiAware.EpiAwareBase.generate_latentMethod
              generate_latent(obs_model::HierarchicalNormal, n) -> Any
              -
              function EpiAwareBase.generate_latent(obs_model::HierarchicalNormal, n)

              Generate latent variables from the hierarchical normal distribution.

              Arguments

              • obs_model::HierarchicalNormal: The hierarchical normal distribution model.
              • n: Number of latent variables to generate.

              Returns

              • η_t: Generated latent variables.
              • std: Standard deviation used in the generation.
              source
              EpiAware.EpiAwareBase.generate_latentMethod
              generate_latent(latent_model::Intercept, n) -> Any
              -

              Generate a latent intercept series.

              Arguments

              • latent_model::Intercept: The intercept model.
              • n::Int: The length of the intercept series.

              Returns

              • intercept::Vector{Float64}: The generated intercept series.
              • metadata::NamedTuple: A named tuple containing the intercept value.
              source
              EpiAware.EpiAwareBase.generate_latentMethod
              generate_latent(latent_model::FixedIntercept, n) -> Any
              +

              Generate a latent intercept series with a fixed intercept value.

              Arguments

              • latent_model::FixedIntercept: The fixed intercept latent model.
              • n: The number of latent variables to generate.

              Returns

              • latent_vars: An array of length n filled with the fixed intercept value.
              • metadata: A named tuple containing the intercept value.
              source
              EpiAware.EpiAwareBase.generate_latentMethod
              generate_latent(obs_model::HierarchicalNormal, n) -> Any
              +
              function EpiAwareBase.generate_latent(obs_model::HierarchicalNormal, n)

              Generate latent variables from the hierarchical normal distribution.

              Arguments

              • obs_model::HierarchicalNormal: The hierarchical normal distribution model.
              • n: Number of latent variables to generate.

              Returns

              • η_t: Generated latent variables.
              • std: Standard deviation used in the generation.
              source
              EpiAware.EpiAwareBase.generate_latentMethod
              generate_latent(latent_model::Intercept, n) -> Any
              +

              Generate a latent intercept series.

              Arguments

              • latent_model::Intercept: The intercept model.
              • n::Int: The length of the intercept series.

              Returns

              • intercept::Vector{Float64}: The generated intercept series.
              • metadata::NamedTuple: A named tuple containing the intercept value.
              source
              EpiAware.EpiAwareBase.generate_latentMethod
              generate_latent(latent_model::RandomWalk, n) -> Any
               

              Implement the generate_latent function for the RandomWalk model.

              Example usage of generate_latent with RandomWalk type of latent process model

              using Distributions, Turing, EpiAware
               
               # Create a RandomWalk model
              @@ -30,5 +30,5 @@
               rw_model = generate_latent(rw, 10)

              Now we can use the Turing PPL API to sample underlying parameters and generate the unobserved infections.

              #Sample random parameters from prior
               θ = rand(rw_model)
               #Get random walk sample path as a generated quantities from the model
              -Z_t, _ = generated_quantities(rw_model, θ)
              source
              EpiAware.EpiAwareBase.generate_latentMethod
              generate_latent(model::TransformLatentModel, n) -> Any
              -
              generate_latent(model::TransformLatentModel, n)

              Generate latent variables using the specified TransformLatentModel.

              Arguments

              • model::TransformLatentModel: The TransformLatentModel to generate latent variables from.
              • n: The number of latent variables to generate.

              Returns

              • transformed: The transformed latent variables.
              • latent_aux: Additional auxiliary variables generated by the underlying latent model.
              source
              +Z_t, _ = generated_quantities(rw_model, θ)
              source
              EpiAware.EpiAwareBase.generate_latentMethod
              generate_latent(model::TransformLatentModel, n) -> Any
              +
              generate_latent(model::TransformLatentModel, n)

              Generate latent variables using the specified TransformLatentModel.

              Arguments

              • model::TransformLatentModel: The TransformLatentModel to generate latent variables from.
              • n: The number of latent variables to generate.

              Returns

              • transformed: The transformed latent variables.
              • latent_aux: Additional auxiliary variables generated by the underlying latent model.
              source
              diff --git a/dev/lib/EpiLatentModels/public/index.html b/dev/lib/EpiLatentModels/public/index.html index 152d8fd13..155790509 100644 --- a/dev/lib/EpiLatentModels/public/index.html +++ b/dev/lib/EpiLatentModels/public/index.html @@ -1,39 +1,39 @@ -Public API · EpiAware.jl

              Public Documentation

              Documentation for EpiLatentModels.jl's public interface.

              See the Internals section of the manual for internal package docs covering all submodules.

              Contents

              Index

              Public API

              EpiAware.EpiLatentModels.ARType
              struct AR{D<:Distributions.Sampleable, S<:Distributions.Sampleable, I<:Distributions.Sampleable, P<:Int64} <: AbstractTuringLatentModel

              The autoregressive (AR) model struct.

              Constructors

              • AR(damp_prior::Distribution, std_prior::Distribution, init_prior::Distribution; p::Int = 1): Constructs an AR model with the specified prior distributions for damping coefficients, standard deviation, and initial conditions. The order of the AR model can also be specified.

              • AR(; damp_priors::Vector{D} = [truncated(Normal(0.0, 0.05))], std_prior::Distribution = truncated(Normal(0.0, 0.05), 0.0, Inf), init_priors::Vector{I} = [Normal()]) where {D <: Distribution, I <: Distribution}: Constructs an AR model with the specified prior distributions for damping coefficients, standard deviation, and initial conditions. The order of the AR model is determined by the length of the damp_priors vector.

              • AR(damp_prior::Distribution, std_prior::Distribution, init_prior::Distribution, p::Int): Constructs an AR model with the specified prior distributions for damping coefficients, standard deviation, and initial conditions. The order of the AR model is explicitly specified.

              Examples

              using Distributions
              +Public API · EpiAware.jl

              Public Documentation

              Documentation for EpiLatentModels.jl's public interface.

              See the Internals section of the manual for internal package docs covering all submodules.

              Contents

              Index

              Public API

              EpiAware.EpiLatentModels.ARType
              struct AR{D<:Distributions.Sampleable, S<:Distributions.Sampleable, I<:Distributions.Sampleable, P<:Int64} <: AbstractTuringLatentModel

              The autoregressive (AR) model struct.

              Constructors

              • AR(damp_prior::Distribution, std_prior::Distribution, init_prior::Distribution; p::Int = 1): Constructs an AR model with the specified prior distributions for damping coefficients, standard deviation, and initial conditions. The order of the AR model can also be specified.

              • AR(; damp_priors::Vector{D} = [truncated(Normal(0.0, 0.05))], std_prior::Distribution = truncated(Normal(0.0, 0.05), 0.0, Inf), init_priors::Vector{I} = [Normal()]) where {D <: Distribution, I <: Distribution}: Constructs an AR model with the specified prior distributions for damping coefficients, standard deviation, and initial conditions. The order of the AR model is determined by the length of the damp_priors vector.

              • AR(damp_prior::Distribution, std_prior::Distribution, init_prior::Distribution, p::Int): Constructs an AR model with the specified prior distributions for damping coefficients, standard deviation, and initial conditions. The order of the AR model is explicitly specified.

              Examples

              using Distributions
               using EpiAware
               ar = AR()
               ar_model = generate_latent(ar, 10)
              -rand(ar_model)

              Fields

              • damp_prior::Distributions.Sampleable: Prior distribution for the damping coefficients.

              • std_prior::Distributions.Sampleable: Prior distribution for the standard deviation.

              • init_prior::Distributions.Sampleable: Prior distribution for the initial conditions

              • p::Int64: Order of the AR model.

              source
              EpiAware.EpiLatentModels.BroadcastLatentModelType
              struct BroadcastLatentModel{M<:AbstractTuringLatentModel, P<:Integer, B<:AbstractBroadcastRule} <: AbstractTuringLatentModel

              The BroadcastLatentModel struct represents a latent model that supports broadcasting of latent periods.

              Constructors

              • BroadcastLatentModel(;model::M; period::Int, broadcast_rule::B): Constructs a BroadcastLatentModel with the given model, period, and broadcast_rule.
              • BroadcastLatentModel(model::M, period::Int, broadcast_rule::B): An alternative constructor that allows the model, period, and broadcast_rule to be specified without keyword arguments.

              Examples

              using EpiAware, Turing
              +rand(ar_model)

              Fields

              • damp_prior::Distributions.Sampleable: Prior distribution for the damping coefficients.

              • std_prior::Distributions.Sampleable: Prior distribution for the standard deviation.

              • init_prior::Distributions.Sampleable: Prior distribution for the initial conditions

              • p::Int64: Order of the AR model.

              source
              EpiAware.EpiLatentModels.BroadcastLatentModelType
              struct BroadcastLatentModel{M<:AbstractTuringLatentModel, P<:Integer, B<:AbstractBroadcastRule} <: AbstractTuringLatentModel

              The BroadcastLatentModel struct represents a latent model that supports broadcasting of latent periods.

              Constructors

              • BroadcastLatentModel(;model::M; period::Int, broadcast_rule::B): Constructs a BroadcastLatentModel with the given model, period, and broadcast_rule.
              • BroadcastLatentModel(model::M, period::Int, broadcast_rule::B): An alternative constructor that allows the model, period, and broadcast_rule to be specified without keyword arguments.

              Examples

              using EpiAware, Turing
               each_model = BroadcastLatentModel(RandomWalk(), 7, RepeatEach())
               gen_each_model = generate_latent(each_model, 10)
               rand(gen_each_model)
               
               block_model = BroadcastLatentModel(RandomWalk(), 3, RepeatBlock())
               gen_block_model = generate_latent(block_model, 10)
              -rand(gen_block_model)

              Fields

              • model::AbstractTuringLatentModel: The underlying latent model.

              • period::Integer: The period of the broadcast.

              • broadcast_rule::AbstractBroadcastRule: The broadcast rule to be applied.

              source
              EpiAware.EpiLatentModels.CombineLatentModelsType
              struct CombineLatentModels{M<:(AbstractVector{<:AbstractTuringLatentModel}), P<:(AbstractVector{<:String})} <: AbstractTuringLatentModel

              The CombineLatentModels struct.

              This struct is used to combine multiple latent models into a single latent model. If a prefix is supplied wraps each model with PrefixLatentModel.

              Constructors

              • CombineLatentModels(models::M, prefixes::P) where {M <: AbstractVector{<:AbstractTuringLatentModel}, P <: AbstractVector{<:String}}: Constructs a CombineLatentModels instance with specified models and prefixes, ensuring that there are at least two models and the number of models and prefixes are equal.
              • CombineLatentModels(models::M) where {M <: AbstractVector{<:AbstractTuringLatentModel}}: Constructs a CombineLatentModels instance with specified models, automatically generating prefixes for each model. The

              automatic prefixes are of the form Combine.1, Combine.2, etc.

              Examples

              using EpiAware, Distributions
              +rand(gen_block_model)

              Fields

              • model::AbstractTuringLatentModel: The underlying latent model.

              • period::Integer: The period of the broadcast.

              • broadcast_rule::AbstractBroadcastRule: The broadcast rule to be applied.

              source
              EpiAware.EpiLatentModels.CombineLatentModelsType
              struct CombineLatentModels{M<:(AbstractVector{<:AbstractTuringLatentModel}), P<:(AbstractVector{<:String})} <: AbstractTuringLatentModel

              The CombineLatentModels struct.

              This struct is used to combine multiple latent models into a single latent model. If a prefix is supplied wraps each model with PrefixLatentModel.

              Constructors

              • CombineLatentModels(models::M, prefixes::P) where {M <: AbstractVector{<:AbstractTuringLatentModel}, P <: AbstractVector{<:String}}: Constructs a CombineLatentModels instance with specified models and prefixes, ensuring that there are at least two models and the number of models and prefixes are equal.
              • CombineLatentModels(models::M) where {M <: AbstractVector{<:AbstractTuringLatentModel}}: Constructs a CombineLatentModels instance with specified models, automatically generating prefixes for each model. The

              automatic prefixes are of the form Combine.1, Combine.2, etc.

              Examples

              using EpiAware, Distributions
               combined_model = CombineLatentModels([Intercept(Normal(2, 0.2)), AR()])
               latent_model = generate_latent(combined_model, 10)
              -latent_model()

              Fields

              • models::AbstractVector{<:AbstractTuringLatentModel}: A vector of latent models

              • prefixes::AbstractVector{<:String}: A vector of prefixes for the latent models

              source
              EpiAware.EpiLatentModels.ConcatLatentModelsType
              struct ConcatLatentModels{M<:(AbstractVector{<:AbstractTuringLatentModel}), N<:Int64, F<:Function, P<:(AbstractVector{<:String})} <: AbstractTuringLatentModel

              The ConcatLatentModels struct.

              This struct is used to concatenate multiple latent models into a single latent model.

              Constructors

              • ConcatLatentModels(models::M, no_models::I, dimension_adaptor::F, prefixes::P) where {M <: AbstractVector{<:AbstractTuringLatentModel}, I <: Int, F <: Function, P <: AbstractVector{String}}: Constructs a ConcatLatentModels instance with specified models, number of models, dimension adaptor, and prefixes.
              • ConcatLatentModels(models::M, dimension_adaptor::F; prefixes::P = "Concat." * string.(1:length(models))) where {M <: AbstractVector{<:AbstractTuringLatentModel}, F <: Function}: Constructs a ConcatLatentModels instance with specified models and dimension adaptor. The number of models is automatically determined as are the prefixes (of the form Concat.1, Concat.2, etc.) by default.
              • ConcatLatentModels(models::M; dimension_adaptor::Function, prefixes::P) where {M <: AbstractVector{<:AbstractTuringLatentModel}, P <: AbstractVector{String}}: Constructs a ConcatLatentModels instance with specified models, dimension adaptor, prefixes, and automatically determines the number of models.The default dimension adaptor is equal_dimensions. The default prefixes are of the form Concat.1, Concat.2, etc.
              • ConcatLatentModels(; models::M, dimension_adaptor::Function, prefixes::P) where {M <: AbstractVector{<:AbstractTuringLatentModel}, P <: AbstractVector{String}}: Constructs a ConcatLatentModels instance with specified models, dimension adaptor, prefixes, and automatically determines the number of models. The default dimension adaptor is equal_dimensions. The default prefixes are of the form Concat.1, Concat.2, etc.

              Examples

              using EpiAware, Distributions
              +latent_model()

              Fields

              • models::AbstractVector{<:AbstractTuringLatentModel}: A vector of latent models

              • prefixes::AbstractVector{<:String}: A vector of prefixes for the latent models

              source
              EpiAware.EpiLatentModels.ConcatLatentModelsType
              struct ConcatLatentModels{M<:(AbstractVector{<:AbstractTuringLatentModel}), N<:Int64, F<:Function, P<:(AbstractVector{<:String})} <: AbstractTuringLatentModel

              The ConcatLatentModels struct.

              This struct is used to concatenate multiple latent models into a single latent model.

              Constructors

              • ConcatLatentModels(models::M, no_models::I, dimension_adaptor::F, prefixes::P) where {M <: AbstractVector{<:AbstractTuringLatentModel}, I <: Int, F <: Function, P <: AbstractVector{String}}: Constructs a ConcatLatentModels instance with specified models, number of models, dimension adaptor, and prefixes.
              • ConcatLatentModels(models::M, dimension_adaptor::F; prefixes::P = "Concat." * string.(1:length(models))) where {M <: AbstractVector{<:AbstractTuringLatentModel}, F <: Function}: Constructs a ConcatLatentModels instance with specified models and dimension adaptor. The number of models is automatically determined as are the prefixes (of the form Concat.1, Concat.2, etc.) by default.
              • ConcatLatentModels(models::M; dimension_adaptor::Function, prefixes::P) where {M <: AbstractVector{<:AbstractTuringLatentModel}, P <: AbstractVector{String}}: Constructs a ConcatLatentModels instance with specified models, dimension adaptor, prefixes, and automatically determines the number of models.The default dimension adaptor is equal_dimensions. The default prefixes are of the form Concat.1, Concat.2, etc.
              • ConcatLatentModels(; models::M, dimension_adaptor::Function, prefixes::P) where {M <: AbstractVector{<:AbstractTuringLatentModel}, P <: AbstractVector{String}}: Constructs a ConcatLatentModels instance with specified models, dimension adaptor, prefixes, and automatically determines the number of models. The default dimension adaptor is equal_dimensions. The default prefixes are of the form Concat.1, Concat.2, etc.

              Examples

              using EpiAware, Distributions
               combined_model = ConcatLatentModels([Intercept(Normal(2, 0.2)), AR()])
               latent_model = generate_latent(combined_model, 10)
              -latent_model()

              Fields

              • models::AbstractVector{<:AbstractTuringLatentModel}: A vector of latent models

              • no_models::Int64: The number of models in the collection

              • dimension_adaptor::Function: The dimension function for the latent variables. By default this divides the number of latent variables by the number of models and returns a vector of dimensions rounding up the first element and rounding down the rest.

              • prefixes::AbstractVector{<:String}: A vector of prefixes for the latent models

              source
              EpiAware.EpiLatentModels.DiffLatentModelType
              struct DiffLatentModel{M<:AbstractTuringLatentModel, P<:Distributions.Distribution} <: AbstractTuringLatentModel

              Model the latent process as a d-fold differenced version of another process.

              Mathematical specification

              Let $\Delta$ be the differencing operator. If $\tilde{Z}_t$ is a realisation of undifferenced latent model supplied to DiffLatentModel, then the differenced process is given by,

              \[\Delta^{(d)} Z_t = \tilde{Z}_t, \quad t = d+1, \ldots.\]

              We can recover $Z_t$ by applying the inverse differencing operator $\Delta^{-1}$, which corresponds to the cumulative sum operator cumsum in Julia, d-times. The d initial terms $Z_1, \ldots, Z_d$ are inferred.

              Constructors

              • DiffLatentModel(latent_model, init_prior_distribution::Distribution; d::Int) Constructs a DiffLatentModel for d-fold differencing with latent_model as the undifferenced latent process. All initial terms have common prior init_prior_distribution.
              • DiffLatentModel(;model, init_priors::Vector{D} where {D <: Distribution}) Constructs a DiffLatentModel for d-fold differencing with latent_model as the undifferenced latent process. The d initial terms have priors given by the vector init_priors, therefore length(init_priors) sets d.

              Example usage with generate_latent

              generate_latent can be used to construct a Turing model for the differenced latent process. In this example, the underlying undifferenced process is a RandomWalk model.

              First, we construct a RandomWalk struct with an initial value prior and a step size standard deviation prior.

              using Distributions, EpiAware
              +latent_model()

              Fields

              • models::AbstractVector{<:AbstractTuringLatentModel}: A vector of latent models

              • no_models::Int64: The number of models in the collection

              • dimension_adaptor::Function: The dimension function for the latent variables. By default this divides the number of latent variables by the number of models and returns a vector of dimensions rounding up the first element and rounding down the rest.

              • prefixes::AbstractVector{<:String}: A vector of prefixes for the latent models

              source
              EpiAware.EpiLatentModels.DiffLatentModelType
              struct DiffLatentModel{M<:AbstractTuringLatentModel, P<:Distributions.Distribution} <: AbstractTuringLatentModel

              Model the latent process as a d-fold differenced version of another process.

              Mathematical specification

              Let $\Delta$ be the differencing operator. If $\tilde{Z}_t$ is a realisation of undifferenced latent model supplied to DiffLatentModel, then the differenced process is given by,

              \[\Delta^{(d)} Z_t = \tilde{Z}_t, \quad t = d+1, \ldots.\]

              We can recover $Z_t$ by applying the inverse differencing operator $\Delta^{-1}$, which corresponds to the cumulative sum operator cumsum in Julia, d-times. The d initial terms $Z_1, \ldots, Z_d$ are inferred.

              Constructors

              • DiffLatentModel(latent_model, init_prior_distribution::Distribution; d::Int) Constructs a DiffLatentModel for d-fold differencing with latent_model as the undifferenced latent process. All initial terms have common prior init_prior_distribution.
              • DiffLatentModel(;model, init_priors::Vector{D} where {D <: Distribution}) Constructs a DiffLatentModel for d-fold differencing with latent_model as the undifferenced latent process. The d initial terms have priors given by the vector init_priors, therefore length(init_priors) sets d.

              Example usage with generate_latent

              generate_latent can be used to construct a Turing model for the differenced latent process. In this example, the underlying undifferenced process is a RandomWalk model.

              First, we construct a RandomWalk struct with an initial value prior and a step size standard deviation prior.

              using Distributions, EpiAware
               rw = RandomWalk(Normal(0.0, 1.0), truncated(Normal(0.0, 0.05), 0.0, Inf))

              Then, we can use DiffLatentModel to construct a DiffLatentModel for d-fold differenced process with rw as the undifferenced latent process.

              We have two constructor options for DiffLatentModel. The first option is to supply a common prior distribution for the initial terms and specify d as follows:

              diff_model = DiffLatentModel(rw, Normal(); d = 2)

              Or we can supply a vector of priors for the initial terms and d is inferred as follows:

              diff_model2 = DiffLatentModel(;undiffmodel = rw, init_priors = [Normal(), Normal()])

              Then, we can use generate_latent to construct a Turing model for the differenced latent process generating a length n process,

              # Construct a Turing model
               n = 100
               difference_mdl = generate_latent(diff_model, n)

              Now we can use the Turing PPL API to sample underlying parameters and generate the unobserved latent process.

              #Sample random parameters from prior
               θ = rand(difference_mdl)
               #Get a sampled latent process as a generated quantity from the model
               (Z_t, _) = generated_quantities(difference_mdl, θ)
              -Z_t

              Fields

              • model::AbstractTuringLatentModel: Underlying latent model for the differenced process

              • init_prior::Distributions.Distribution: The prior distribution for the initial latent variables.

              • d::Int64: Number of times differenced.

              source
              EpiAware.EpiLatentModels.FixedInterceptType
              struct FixedIntercept{F<:Real} <: AbstractTuringIntercept

              A variant of the Intercept struct that represents a fixed intercept value for a latent model.

              Constructors

              • FixedIntercept(intercept) : Constructs a FixedIntercept instance with the specified intercept value.
              • FixedIntercept(; intercept) : Constructs a FixedIntercept instance with the specified intercept value using named arguments.

              Examples

              using EpiAware
              +Z_t

              Fields

              • model::AbstractTuringLatentModel: Underlying latent model for the differenced process

              • init_prior::Distributions.Distribution: The prior distribution for the initial latent variables.

              • d::Int64: Number of times differenced.

              source
              EpiAware.EpiLatentModels.FixedInterceptType
              struct FixedIntercept{F<:Real} <: AbstractTuringIntercept

              A variant of the Intercept struct that represents a fixed intercept value for a latent model.

              Constructors

              • FixedIntercept(intercept) : Constructs a FixedIntercept instance with the specified intercept value.
              • FixedIntercept(; intercept) : Constructs a FixedIntercept instance with the specified intercept value using named arguments.

              Examples

              using EpiAware
               fi = FixedIntercept(2.0)
               fi_model = generate_latent(fi, 10)
              -fi_model()

              Fields

              • intercept::Real
              source
              EpiAware.EpiLatentModels.HierarchicalNormalType
              struct HierarchicalNormal{R<:Real, D<:Distributions.Sampleable} <: AbstractTuringLatentModel

              The HierarchicalNormal struct represents a non-centered hierarchical normal distribution.

              Constructors

              • HierarchicalNormal(mean, std_prior): Constructs a HierarchicalNormal instance with the specified mean and standard deviation prior.
              • HierarchicalNormal(; mean = 0.0, std_prior = truncated(Normal(0,1), 0, Inf)): Constructs a HierarchicalNormal instance with the specified mean and standard deviation prior using named arguments and with default values.

              Examples

              using Distributions, EpiAware
              +fi_model()

              Fields

              • intercept::Real
              source
              EpiAware.EpiLatentModels.HierarchicalNormalType
              struct HierarchicalNormal{R<:Real, D<:Distributions.Sampleable} <: AbstractTuringLatentModel

              The HierarchicalNormal struct represents a non-centered hierarchical normal distribution.

              Constructors

              • HierarchicalNormal(mean, std_prior): Constructs a HierarchicalNormal instance with the specified mean and standard deviation prior.
              • HierarchicalNormal(; mean = 0.0, std_prior = truncated(Normal(0,1), 0, Inf)): Constructs a HierarchicalNormal instance with the specified mean and standard deviation prior using named arguments and with default values.

              Examples

              using Distributions, EpiAware
               hnorm = HierarchicalNormal(0.0, truncated(Normal(0, 1), 0, Inf))
               hnorm_model = generate_latent(hnorm, 10)
              -hnorm_model()

              Fields

              • mean::Real

              • std_prior::Distributions.Sampleable

              source
              EpiAware.EpiLatentModels.InterceptType
              struct Intercept{D<:Distributions.Sampleable} <: AbstractTuringIntercept

              The Intercept struct is used to model the intercept of a latent process. It broadcasts a single intercept value to a length n latent process.

              Constructors

              • Intercept(intercept_prior)
              • Intercept(; intercept_prior)

              Examples

              using Distributions, Turing, EpiAware
              +hnorm_model()

              Fields

              • mean::Real

              • std_prior::Distributions.Sampleable

              source
              EpiAware.EpiLatentModels.InterceptType
              struct Intercept{D<:Distributions.Sampleable} <: AbstractTuringIntercept

              The Intercept struct is used to model the intercept of a latent process. It broadcasts a single intercept value to a length n latent process.

              Constructors

              • Intercept(intercept_prior)
              • Intercept(; intercept_prior)

              Examples

              using Distributions, Turing, EpiAware
               int = Intercept(Normal(0, 1))
               int_model = generate_latent(int, 10)
               rand(int_model)
              -int_model()

              Fields

              • intercept_prior::Distributions.Sampleable: Prior distribution for the intercept.
              source
              EpiAware.EpiLatentModels.PrefixLatentModelType
              struct PrefixLatentModel{M<:AbstractTuringLatentModel, P<:String} <: AbstractTuringLatentModel
              Generate a latent model with a prefix. A lightweight wrapper around `EpiAwareUtils.prefix_submodel`.
              +int_model()

              Fields

              • intercept_prior::Distributions.Sampleable: Prior distribution for the intercept.
              source
              EpiAware.EpiLatentModels.PrefixLatentModelType
              struct PrefixLatentModel{M<:AbstractTuringLatentModel, P<:String} <: AbstractTuringLatentModel
              Generate a latent model with a prefix. A lightweight wrapper around `EpiAwareUtils.prefix_submodel`.
               
               # Constructors
               - `PrefixLatentModel(model::M, prefix::P)`: Create a `PrefixLatentModel` with the latent model `model` and the prefix `prefix`.
              @@ -45,7 +45,7 @@
               latent_model = PrefixLatentModel(model = HierarchicalNormal(), prefix = "Test")
               mdl = generate_latent(latent_model, 10)
               rand(mdl)
              -```

              Fields

              • model::AbstractTuringLatentModel: The latent model

              • prefix::String: The prefix for the latent model

              source
              EpiAware.EpiLatentModels.RandomWalkType
              struct RandomWalk{D<:Distributions.Sampleable, S<:Distributions.Sampleable} <: AbstractTuringLatentModel

              Model latent process $Z_t$ as a random walk.

              Mathematical specification

              The random walk $Z_t$ is specified as a parameteric transformation of the white noise sequence $(\epsilon_t)_{t\geq 1}$,

              \[Z_t = Z_0 + \sigma \sum_{i = 1}^t \epsilon_t\]

              Constructing a random walk requires specifying:

              • An init_prior as a prior for $Z_0$. Default is Normal().
              • A std_prior for $\sigma$. The default is HalfNormal with a mean of 0.25.

              Constructors

              • RandomWalk(; init_prior, std_prior)

              Example usage with generate_latent

              generate_latent can be used to construct a Turing model for the random walk $Z_t$.

              First, we construct a RandomWalk struct with priors,

              using Distributions, Turing, EpiAware
              +```

              Fields

              • model::AbstractTuringLatentModel: The latent model

              • prefix::String: The prefix for the latent model

              source
              EpiAware.EpiLatentModels.RandomWalkType
              struct RandomWalk{D<:Distributions.Sampleable, S<:Distributions.Sampleable} <: AbstractTuringLatentModel

              Model latent process $Z_t$ as a random walk.

              Mathematical specification

              The random walk $Z_t$ is specified as a parameteric transformation of the white noise sequence $(\epsilon_t)_{t\geq 1}$,

              \[Z_t = Z_0 + \sigma \sum_{i = 1}^t \epsilon_t\]

              Constructing a random walk requires specifying:

              • An init_prior as a prior for $Z_0$. Default is Normal().
              • A std_prior for $\sigma$. The default is HalfNormal with a mean of 0.25.

              Constructors

              • RandomWalk(; init_prior, std_prior)

              Example usage with generate_latent

              generate_latent can be used to construct a Turing model for the random walk $Z_t$.

              First, we construct a RandomWalk struct with priors,

              using Distributions, Turing, EpiAware
               
               # Create a RandomWalk model
               rw = RandomWalk(init_prior = Normal(2., 1.),
              @@ -53,25 +53,25 @@
               rw_model = generate_latent(rw, 10)

              Now we can use the Turing PPL API to sample underlying parameters and generate the unobserved infections.

              #Sample random parameters from prior
               θ = rand(rw_model)
               #Get random walk sample path as a generated quantities from the model
              -Z_t, _ = generated_quantities(rw_model, θ)

              Fields

              • init_prior::Distributions.Sampleable

              • std_prior::Distributions.Sampleable

              source
              EpiAware.EpiLatentModels.RepeatBlockType
              struct RepeatBlock <: AbstractBroadcastRule

              RepeatBlock is a struct that represents a broadcasting rule. It is a subtype of AbstractBroadcastRule.

              It repeats the latent process in blocks of size period. An example of this rule is to repeat the latent process in blocks of size 7 to model a weekly process (though for this we also provide the broadcast_weekly helper function).

              Examples

              using EpiAware
              +Z_t, _ = generated_quantities(rw_model, θ)

              Fields

              • init_prior::Distributions.Sampleable

              • std_prior::Distributions.Sampleable

              source
              EpiAware.EpiLatentModels.RepeatBlockType
              struct RepeatBlock <: AbstractBroadcastRule

              RepeatBlock is a struct that represents a broadcasting rule. It is a subtype of AbstractBroadcastRule.

              It repeats the latent process in blocks of size period. An example of this rule is to repeat the latent process in blocks of size 7 to model a weekly process (though for this we also provide the broadcast_weekly helper function).

              Examples

              using EpiAware
               rule = RepeatBlock()
               latent = [1, 2, 3, 4, 5]
               n = 10
               period = 2
              -broadcast_rule(rule, latent, n, period)

              Fields

              source
              EpiAware.EpiLatentModels.RepeatEachType
              struct RepeatEach <: AbstractBroadcastRule

              RepeatEach is a struct that represents a broadcasting rule. It is a subtype of AbstractBroadcastRule.

              It repeats the latent process at each period. An example of this rule is to repeat the latent process at each day of the week (though for this we also provide the dayofweek helper function).

              Examples

              using EpiAware
              +broadcast_rule(rule, latent, n, period)

              Fields

              source
              EpiAware.EpiLatentModels.RepeatEachType
              struct RepeatEach <: AbstractBroadcastRule

              RepeatEach is a struct that represents a broadcasting rule. It is a subtype of AbstractBroadcastRule.

              It repeats the latent process at each period. An example of this rule is to repeat the latent process at each day of the week (though for this we also provide the dayofweek helper function).

              Examples

              using EpiAware
               rule = RepeatEach()
               latent = [1, 2, 3]
               n = 10
               period = 2
              -broadcast_rule(rule, latent, n, period)

              Fields

              source
              EpiAware.EpiLatentModels.TransformLatentModelType
              struct TransformLatentModel{M<:AbstractTuringLatentModel, F<:Function} <: AbstractTuringLatentModel

              The TransformLatentModel struct represents a latent model that applies a transformation function to the latent variables generated by another latent model.

              Constructors

              • TransformLatentModel(model, trans_function): Constructs a TransformLatentModel instance with the specified latent model and transformation function.
              • TransformLatentModel(; model, trans_function): Constructs a TransformLatentModel instance with the specified latent model and transformation function using named arguments.

              Example

              using EpiAware, Distributions
              +broadcast_rule(rule, latent, n, period)

              Fields

              source
              EpiAware.EpiLatentModels.TransformLatentModelType
              struct TransformLatentModel{M<:AbstractTuringLatentModel, F<:Function} <: AbstractTuringLatentModel

              The TransformLatentModel struct represents a latent model that applies a transformation function to the latent variables generated by another latent model.

              Constructors

              • TransformLatentModel(model, trans_function): Constructs a TransformLatentModel instance with the specified latent model and transformation function.
              • TransformLatentModel(; model, trans_function): Constructs a TransformLatentModel instance with the specified latent model and transformation function using named arguments.

              Example

              using EpiAware, Distributions
               trans = TransformLatentModel(Intercept(Normal(2, 0.2)), x -> x .|> exp)
               trans_model = generate_latent(trans, 5)
              -trans_model()

              Fields

              • model::AbstractTuringLatentModel: The latent model to transform.

              • trans_function::Function: The transformation function.

              source
              EpiAware.EpiLatentModels.broadcast_dayofweekMethod
              broadcast_dayofweek(
                   model::AbstractTuringLatentModel;
                   link
               ) -> BroadcastLatentModel{TransformLatentModel{M, EpiAware.EpiLatentModels.var"#42#44"}, Int64, RepeatEach} where M<:AbstractTuringLatentModel
              -

              Constructs a BroadcastLatentModel appropriate for modelling the day of the week for a given AbstractTuringLatentModel.

              Arguments

              • model::AbstractTuringLatentModel: The latent model to be repeated.
              • link::Function: The link function to transform the latent model before broadcasting

              to periodic weekly. Default is x -> 7 * softmax(x) which implements constraint of the sum week effects to be 7.

              Returns

              • BroadcastLatentModel: The broadcast latent model.
              source
              EpiAware.EpiLatentModels.broadcast_weeklyMethod
              broadcast_weekly(
              +

              Constructs a BroadcastLatentModel appropriate for modelling the day of the week for a given AbstractTuringLatentModel.

              Arguments

              • model::AbstractTuringLatentModel: The latent model to be repeated.
              • link::Function: The link function to transform the latent model before broadcasting

              to periodic weekly. Default is x -> 7 * softmax(x) which implements constraint of the sum week effects to be 7.

              Returns

              • BroadcastLatentModel: The broadcast latent model.
              source
              EpiAware.EpiLatentModels.broadcast_weeklyMethod
              broadcast_weekly(
                   model::AbstractTuringLatentModel
               ) -> BroadcastLatentModel{<:AbstractTuringLatentModel, Int64, RepeatBlock}
              -

              Constructs a BroadcastLatentModel appropriate for modelling piecewise constant weekly processes for a given AbstractTuringLatentModel.

              Arguments

              • model::AbstractTuringLatentModel: The latent model to be repeated.

              Returns

              • BroadcastLatentModel: The broadcast latent model.
              source
              EpiAware.EpiLatentModels.equal_dimensionsMethod
              equal_dimensions(n::Int64, m::Int64) -> Vector{Int64}
              -

              Return a vector of dimensions that are equal or as close as possible, given the total number of elements n and the number of dimensions m. The default dimension adaptor for ConcatLatentModels.

              Arguments

              • n::Int: The total number of elements.
              • m::Int: The number of dimensions.

              Returns

              • dims::AbstractVector{Int}: A vector of dimensions, where the first element is the ceiling of n / m and the remaining elements are the floor of n / m.
              source
              +

              Constructs a BroadcastLatentModel appropriate for modelling piecewise constant weekly processes for a given AbstractTuringLatentModel.

              Arguments

              • model::AbstractTuringLatentModel: The latent model to be repeated.

              Returns

              • BroadcastLatentModel: The broadcast latent model.
              source
              EpiAware.EpiLatentModels.equal_dimensionsMethod
              equal_dimensions(n::Int64, m::Int64) -> Vector{Int64}
              +

              Return a vector of dimensions that are equal or as close as possible, given the total number of elements n and the number of dimensions m. The default dimension adaptor for ConcatLatentModels.

              Arguments

              • n::Int: The total number of elements.
              • m::Int: The number of dimensions.

              Returns

              • dims::AbstractVector{Int}: A vector of dimensions, where the first element is the ceiling of n / m and the remaining elements are the floor of n / m.
              source
              diff --git a/dev/lib/EpiObsModels/index.html b/dev/lib/EpiObsModels/index.html index 11dfa761a..2cc0e248e 100644 --- a/dev/lib/EpiObsModels/index.html +++ b/dev/lib/EpiObsModels/index.html @@ -1,2 +1,2 @@ -Overview · EpiAware.jl
              +Overview · EpiAware.jl
              diff --git a/dev/lib/EpiObsModels/internals/index.html b/dev/lib/EpiObsModels/internals/index.html index 0fb33c2fa..562355c06 100644 --- a/dev/lib/EpiObsModels/internals/index.html +++ b/dev/lib/EpiObsModels/internals/index.html @@ -1,36 +1,36 @@ -Internal API · EpiAware.jl

              Internal Documentation

              Documentation for EpiObsModels.jl's internal interface.

              Contents

              Index

              Internal API

              EpiAware.EpiAwareBase.generate_observationsMethod
              generate_observations(
              +Internal API · EpiAware.jl

              Internal Documentation

              Documentation for EpiObsModels.jl's internal interface.

              Contents

              Index

              Internal API

              EpiAware.EpiAwareBase.generate_observationsMethod
              generate_observations(
                   obs_model::AbstractTuringObservationErrorModel,
                   y_t,
                   Y_t
               ) -> Any
              -

              Generates observations from an observation error model. It provides support for missing values in observations (y_t), and missing values at the beginning of the expected observations (Y_t). It also pads the expected observations with a small value (1e-6) to mitigate potential numerical issues.

              It dispatches to the observation_error function to generate the observation error distribution which uses priors generated by generate_observation_error_priors submodel. For most observation error models specific implementations of observation_error and generate_observation_error_priors are required but a specific implementation of generate_observations is not required.

              source
              EpiAware.EpiAwareBase.generate_observationsMethod
              generate_observations(
              +

              Generates observations from an observation error model. It provides support for missing values in observations (y_t), and missing values at the beginning of the expected observations (Y_t). It also pads the expected observations with a small value (1e-6) to mitigate potential numerical issues.

              It dispatches to the observation_error function to generate the observation error distribution which uses priors generated by generate_observation_error_priors submodel. For most observation error models specific implementations of observation_error and generate_observation_error_priors are required but a specific implementation of generate_observations is not required.

              source
              EpiAware.EpiAwareBase.generate_observationsMethod
              generate_observations(
                   obs_model::Ascertainment,
                   y_t,
                   Y_t
               ) -> Any
              -

              Generates observations based on the LatentDelay observation model.

              Arguments

              • obs_model::Ascertainment: The Ascertainment model.
              • y_t: The current state of the observations.
              • Y_t` : The expected observations.

              Returns

              • y_t: The updated observations.
              • expected_aux: Additional expected observation-related variables.
              • obs_aux: Additional observation-related variables.
              source
              EpiAware.EpiAwareBase.generate_observationsMethod
              generate_observations(
              +

              Generates observations based on the LatentDelay observation model.

              Arguments

              • obs_model::Ascertainment: The Ascertainment model.
              • y_t: The current state of the observations.
              • Y_t` : The expected observations.

              Returns

              • y_t: The updated observations.
              • expected_aux: Additional expected observation-related variables.
              • obs_aux: Additional observation-related variables.
              source
              EpiAware.EpiAwareBase.generate_observationsMethod
              generate_observations(
                   obs_model::LatentDelay,
                   y_t,
                   Y_t
               ) -> Any
              -

              Generates observations based on the LatentDelay observation model.

              Arguments

              • obs_model::LatentDelay: The LatentDelay observation model.
              • y_t: The current observations.
              • I_t: The current infection indicator.

              Returns

              • y_t: The updated observations.
              • obs_aux: Additional observation-related variables.
              source
              EpiAware.EpiAwareBase.generate_observationsMethod
              generate_observations(
              +

              Generates observations based on the LatentDelay observation model.

              Arguments

              • obs_model::LatentDelay: The LatentDelay observation model.
              • y_t: The current observations.
              • I_t: The current infection indicator.

              Returns

              • y_t: The updated observations.
              • obs_aux: Additional observation-related variables.
              source
              EpiAware.EpiAwareBase.generate_observationsMethod
              generate_observations(
                   obs_model::StackObservationModels,
                   y_t::NamedTuple,
                   Y_t::AbstractVector
               ) -> Any
              -

              Generate observations from a stack of observation models. Maps Y_t to a NamedTuple of the same length as y_t assuming a 1 to many mapping.

              Arguments

              • obs_model::StackObservationModels: The stack of observation models.
              • y_t::NamedTuple: The observed values.
              • Y_t::AbstractVector: The expected values.
              source
              EpiAware.EpiAwareBase.generate_observationsMethod
              generate_observations(
              +

              Generate observations from a stack of observation models. Maps Y_t to a NamedTuple of the same length as y_t assuming a 1 to many mapping.

              Arguments

              • obs_model::StackObservationModels: The stack of observation models.
              • y_t::NamedTuple: The observed values.
              • Y_t::AbstractVector: The expected values.
              source
              EpiAware.EpiAwareBase.generate_observationsMethod
              generate_observations(
                   obs_model::StackObservationModels,
                   y_t::NamedTuple,
                   Y_t::NamedTuple
               ) -> Any
              -

              Generate observations from a stack of observation models. Assumes a 1 to 1 mapping between y_t and Y_t.

              Arguments

              • obs_model::StackObservationModels: The stack of observation models.
              • y_t::NamedTuple: The observed values.
              • Y_t::NamedTuple: The expected values.
              source
              EpiAware.EpiObsModels.NegativeBinomialMeanClustMethod
              NegativeBinomialMeanClust(
              +

              Generate observations from a stack of observation models. Assumes a 1 to 1 mapping between y_t and Y_t.

              Arguments

              • obs_model::StackObservationModels: The stack of observation models.
              • y_t::NamedTuple: The observed values.
              • Y_t::NamedTuple: The expected values.
              source
              EpiAware.EpiObsModels.NegativeBinomialMeanClustMethod
              NegativeBinomialMeanClust(
                   μ,
                   α
               ) -> Union{Distributions.DiscreteUniform, Distributions.NegativeBinomial}
              -

              Compute the mean-cluster factor negative binomial distribution.

              Arguments

              • μ: The mean of the distribution.
              • α: The clustering factor parameter.

              Returns

              A NegativeBinomial distribution object.

              source
              EpiAware.EpiObsModels.generate_observation_kernelMethod
              generate_observation_kernel(
              +

              Compute the mean-cluster factor negative binomial distribution.

              Arguments

              • μ: The mean of the distribution.
              • α: The clustering factor parameter.

              Returns

              A NegativeBinomial distribution object.

              source
              EpiAware.EpiObsModels.generate_observation_kernelMethod
              generate_observation_kernel(
                   delay_int,
                   time_horizon;
                   partial
               ) -> Any
              -

              Generate an observation kernel matrix based on the given delay interval and time horizon.

              Arguments

              • delay_int::Vector{Float64}: The delay PMF vector.
              • time_horizon::Int: The number of time steps of the observation period.
              • partial::Bool: Whether to generate a partial observation kernel matrix.

              Returns

              • K::SparseMatrixCSC{Float64, Int}: The observation kernel matrix.
              source
              +

              Generate an observation kernel matrix based on the given delay interval and time horizon.

              Arguments

              • delay_int::Vector{Float64}: The delay PMF vector.
              • time_horizon::Int: The number of time steps of the observation period.
              • partial::Bool: Whether to generate a partial observation kernel matrix.

              Returns

              • K::SparseMatrixCSC{Float64, Int}: The observation kernel matrix.
              source
              diff --git a/dev/lib/EpiObsModels/public/index.html b/dev/lib/EpiObsModels/public/index.html index 6162be165..b229f1687 100644 --- a/dev/lib/EpiObsModels/public/index.html +++ b/dev/lib/EpiObsModels/public/index.html @@ -1,17 +1,17 @@ -Public API · EpiAware.jl

              Public Documentation

              Documentation for EpiObsModels.jl's public interface.

              See the Internals section of the manual for internal package docs covering all submodules.

              Contents

              Index

              Public API

              EpiAware.EpiObsModels.AscertainmentType
              struct Ascertainment{M<:AbstractTuringObservationModel, T<:AbstractTuringLatentModel, F<:Function, P<:String} <: AbstractTuringObservationModel

              The Ascertainment struct represents an observation model that incorporates a ascertainment model. If a latent_prefixis supplied the latent_model is wrapped in a call to PrefixLatentModel.

              Constructors

              • Ascertainment(model::M, latent_model::T, link::F, latent_prefix::P) where {M <: AbstractTuringObservationModel, T <: AbstractTuringLatentModel, F <: Function, P <: String}: Constructs an Ascertainment instance with the specified observation model, latent model, link function, and latent prefix.
              • Ascertainment(; model::M, latent_model::T, link::F, latent_prefix::P) where {M <: AbstractTuringObservationModel, T <: AbstractTuringLatentModel, F <: Function, P <: String}: Constructs an Ascertainment instance with the specified observation model, latent model, link function, and latent prefix.

              Examples

              using EpiAware, Turing
              +Public API · EpiAware.jl

              Public Documentation

              Documentation for EpiObsModels.jl's public interface.

              See the Internals section of the manual for internal package docs covering all submodules.

              Contents

              Index

              Public API

              EpiAware.EpiObsModels.AscertainmentType
              struct Ascertainment{M<:AbstractTuringObservationModel, T<:AbstractTuringLatentModel, F<:Function, P<:String} <: AbstractTuringObservationModel

              The Ascertainment struct represents an observation model that incorporates a ascertainment model. If a latent_prefixis supplied the latent_model is wrapped in a call to PrefixLatentModel.

              Constructors

              • Ascertainment(model::M, latent_model::T, link::F, latent_prefix::P) where {M <: AbstractTuringObservationModel, T <: AbstractTuringLatentModel, F <: Function, P <: String}: Constructs an Ascertainment instance with the specified observation model, latent model, link function, and latent prefix.
              • Ascertainment(; model::M, latent_model::T, link::F, latent_prefix::P) where {M <: AbstractTuringObservationModel, T <: AbstractTuringLatentModel, F <: Function, P <: String}: Constructs an Ascertainment instance with the specified observation model, latent model, link function, and latent prefix.

              Examples

              using EpiAware, Turing
               obs = Ascertainment(model = NegativeBinomialError(), latent_model = FixedIntercept(0.1))
               gen_obs = generate_observations(obs, missing, fill(100, 10))
              -rand(gen_obs)

              Fields

              • model::AbstractTuringObservationModel: The underlying observation model.

              • latent_model::AbstractTuringLatentModel: The latent model.

              • link::Function: The link function used to transform the latent model to the observed data.

              • latent_prefix::String

              source
              EpiAware.EpiObsModels.LatentDelayType
              struct LatentDelay{M<:AbstractTuringObservationModel, T<:(AbstractVector{<:Real})} <: AbstractTuringObservationModel

              The LatentDelay struct represents an observation model that introduces a latent delay in the observations. It is a subtype of AbstractTuringObservationModel.

              Note that the LatentDelay observation model shortens the observation vector by the length of the delay distribution and this is then passed to the underlying observation model. This is to prevent fitting to partially observed data.

              Fields

              • model::M: The underlying observation model.
              • pmf::T: The probability mass function (PMF) representing the delay distribution.

              Constructors

              • LatentDelay(model::M, distribution::C; D = nothing, Δd = 1.0) where {M <: AbstractTuringObservationModel, C <: ContinuousDistribution}: Constructs a LatentDelay object with the given underlying observation model and continuous distribution. The D parameter specifies the right truncation of the distribution, with default D = nothing indicates that the distribution should be truncated at its 99th percentile rounded to nearest multiple of Δd. The Δd parameter specifies the width of each delay interval.

              • LatentDelay(model::M, pmf::T) where {M <: AbstractTuringObservationModel, T <: AbstractVector{<:Real}}: Constructs a LatentDelay object with the given underlying observation model and delay PMF.

              Examples

              using Distributions, Turing, EpiAware
              +rand(gen_obs)

              Fields

              • model::AbstractTuringObservationModel: The underlying observation model.

              • latent_model::AbstractTuringLatentModel: The latent model.

              • link::Function: The link function used to transform the latent model to the observed data.

              • latent_prefix::String

              source
              EpiAware.EpiObsModels.LatentDelayType
              struct LatentDelay{M<:AbstractTuringObservationModel, T<:(AbstractVector{<:Real})} <: AbstractTuringObservationModel

              The LatentDelay struct represents an observation model that introduces a latent delay in the observations. It is a subtype of AbstractTuringObservationModel.

              Note that the LatentDelay observation model shortens the observation vector by the length of the delay distribution and this is then passed to the underlying observation model. This is to prevent fitting to partially observed data.

              Fields

              • model::M: The underlying observation model.
              • pmf::T: The probability mass function (PMF) representing the delay distribution.

              Constructors

              • LatentDelay(model::M, distribution::C; D = nothing, Δd = 1.0) where {M <: AbstractTuringObservationModel, C <: ContinuousDistribution}: Constructs a LatentDelay object with the given underlying observation model and continuous distribution. The D parameter specifies the right truncation of the distribution, with default D = nothing indicates that the distribution should be truncated at its 99th percentile rounded to nearest multiple of Δd. The Δd parameter specifies the width of each delay interval.

              • LatentDelay(model::M, pmf::T) where {M <: AbstractTuringObservationModel, T <: AbstractVector{<:Real}}: Constructs a LatentDelay object with the given underlying observation model and delay PMF.

              Examples

              using Distributions, Turing, EpiAware
               obs = LatentDelay(NegativeBinomialError(), truncated(Normal(5.0, 2.0), 0.0, Inf))
               obs_model = generate_observations(obs, missing, fill(10, 10))
              -rand(obs_model)

              Fields

              • model::AbstractTuringObservationModel

              • pmf::AbstractVector{<:Real}

              source
              EpiAware.EpiObsModels.NegativeBinomialErrorType
              struct NegativeBinomialError{S<:Distributions.Sampleable} <: AbstractTuringObservationErrorModel

              The NegativeBinomialError struct represents an observation model for negative binomial errors. It is a subtype of AbstractTuringObservationModel.

              Constructors

              • NegativeBinomialError(; cluster_factor_prior::Distribution = HalfNormal(0.1)): Constructs a NegativeBinomialError object with default values for the cluster factor prior.
              • NegativeBinomialError(cluster_factor_prior::Distribution): Constructs a NegativeBinomialError object with a specified cluster factor prior.

              Examples

              using Distributions, Turing, EpiAware
              +rand(obs_model)

              Fields

              • model::AbstractTuringObservationModel

              • pmf::AbstractVector{<:Real}

              source
              EpiAware.EpiObsModels.NegativeBinomialErrorType
              struct NegativeBinomialError{S<:Distributions.Sampleable} <: AbstractTuringObservationErrorModel

              The NegativeBinomialError struct represents an observation model for negative binomial errors. It is a subtype of AbstractTuringObservationModel.

              Constructors

              • NegativeBinomialError(; cluster_factor_prior::Distribution = HalfNormal(0.1)): Constructs a NegativeBinomialError object with default values for the cluster factor prior.
              • NegativeBinomialError(cluster_factor_prior::Distribution): Constructs a NegativeBinomialError object with a specified cluster factor prior.

              Examples

              using Distributions, Turing, EpiAware
               nb = NegativeBinomialError()
               nb_model = generate_observations(nb, missing, fill(10, 10))
              -rand(nb_model)

              Fields

              • cluster_factor_prior::Distributions.Sampleable: The prior distribution for the cluster factor.
              source
              EpiAware.EpiObsModels.PoissonErrorType
              struct PoissonError <: AbstractTuringObservationErrorModel

              The PoissonError struct represents an observation model for Poisson errors. It is a subtype of AbstractTuringObservationErrorModel.

              Constructors

              • PoissonError(): Constructs a PoissonError object.

              Examples

              using Distributions, Turing, EpiAware
              +rand(nb_model)

              Fields

              • cluster_factor_prior::Distributions.Sampleable: The prior distribution for the cluster factor.
              source
              EpiAware.EpiObsModels.PoissonErrorType
              struct PoissonError <: AbstractTuringObservationErrorModel

              The PoissonError struct represents an observation model for Poisson errors. It is a subtype of AbstractTuringObservationErrorModel.

              Constructors

              • PoissonError(): Constructs a PoissonError object.

              Examples

              using Distributions, Turing, EpiAware
               poi = PoissonError()
               poi_model = generate_observations(poi, missing, fill(10, 10))
              -rand(poi_model)

              Fields

              source
              EpiAware.EpiObsModels.PrefixObservationModelType
              struct PrefixObservationModel{M<:AbstractTuringObservationModel, P<:String} <: AbstractTuringObservationModel
              Generate an observation model with a prefix. A lightweight wrapper around `EpiAwareUtils.prefix_submodel`.
              +rand(poi_model)

              Fields

              source
              EpiAware.EpiObsModels.PrefixObservationModelType
              struct PrefixObservationModel{M<:AbstractTuringObservationModel, P<:String} <: AbstractTuringObservationModel
              Generate an observation model with a prefix. A lightweight wrapper around `EpiAwareUtils.prefix_submodel`.
               
               # Constructors
               - `PrefixObservationModel(model::M, prefix::P)`: Create a `PrefixObservationModel` with the observation model `model` and the prefix `prefix`.
              @@ -23,7 +23,7 @@
               observation_model = PrefixObservationModel(Poisson(), "Test")
               obs = generate_observations(observation_model, 10)
               rand(obs)
              -```

              Fields

              • model::AbstractTuringObservationModel: The observation model

              • prefix::String: The prefix for the observation model

              source
              EpiAware.EpiObsModels.StackObservationModelsType
              struct StackObservationModels{M<:(AbstractVector{<:AbstractTuringObservationModel}), N<:(AbstractVector{<:AbstractString})} <: AbstractTuringObservationModel

              A stack of observation models that are looped over to generate observations for each model in the stack. Note that the model names are used to prefix the parameters in each model (so if I have a model named cases and a parameter y_t, the parameter in the model will be cases.y_t). Inside the constructor PrefixObservationModel is wrapped around each observation model.

              Constructors

              • StackObservationModels(models::Vector{<:AbstractTuringObservationModel}, model_names::Vector{<:AbstractString}): Construct a StackObservationModels object with a vector of observation models and a vector of model names.
                • `StackObservationModels(; models::Vector{<:AbstractTuringObservationModel},
                model_names::Vector{<:AbstractString}): Construct aStackObservationModels` object with a vector of observation models and a vector of model names.
              • StackObservationModels(models::NamedTuple{names, T}): Construct a StackObservationModels object with a named tuple of observation models. The model names are automatically generated from the keys of the named tuple.

              Example

              using EpiAware, Turing
              +```

              Fields

              • model::AbstractTuringObservationModel: The observation model

              • prefix::String: The prefix for the observation model

              source
              EpiAware.EpiObsModels.StackObservationModelsType
              struct StackObservationModels{M<:(AbstractVector{<:AbstractTuringObservationModel}), N<:(AbstractVector{<:AbstractString})} <: AbstractTuringObservationModel

              A stack of observation models that are looped over to generate observations for each model in the stack. Note that the model names are used to prefix the parameters in each model (so if I have a model named cases and a parameter y_t, the parameter in the model will be cases.y_t). Inside the constructor PrefixObservationModel is wrapped around each observation model.

              Constructors

              • StackObservationModels(models::Vector{<:AbstractTuringObservationModel}, model_names::Vector{<:AbstractString}): Construct a StackObservationModels object with a vector of observation models and a vector of model names.
                • `StackObservationModels(; models::Vector{<:AbstractTuringObservationModel},
                model_names::Vector{<:AbstractString}): Construct aStackObservationModels` object with a vector of observation models and a vector of model names.
              • StackObservationModels(models::NamedTuple{names, T}): Construct a StackObservationModels object with a named tuple of observation models. The model names are automatically generated from the keys of the named tuple.

              Example

              using EpiAware, Turing
               
               obs = StackObservationModels(
                   (cases = PoissonError(), deaths = NegativeBinomialError())
              @@ -37,7 +37,7 @@
               cases_y_t
               
               deaths_y_t = group(samples, "deaths.y_t")
              -deaths_y_t

              Fields

              • models::AbstractVector{<:AbstractTuringObservationModel}: A vector of observation models.

              • model_names::AbstractVector{<:AbstractString}: A vector of observation model names

              source
              EpiAware.EpiObsModels.ascertainment_dayofweekMethod
              ascertainment_dayofweek(
              +deaths_y_t

              Fields

              • models::AbstractVector{<:AbstractTuringObservationModel}: A vector of observation models.

              • model_names::AbstractVector{<:AbstractString}: A vector of observation model names

              source
              EpiAware.EpiObsModels.ascertainment_dayofweekMethod
              ascertainment_dayofweek(
                   model::AbstractTuringObservationModel;
                   latent_model,
                   link,
              @@ -47,27 +47,27 @@
               obs = ascertainment_dayofweek(PoissonError())
               gen_obs = generate_observations(obs, missing, fill(100, 14))
               gen_obs()
              -rand(gen_obs)
              source
              EpiAware.EpiObsModels.generate_observation_error_priorsMethod
              generate_observation_error_priors(
                   obs_model::AbstractTuringObservationErrorModel,
                   y_t,
                   Y_t
               ) -> Any
              -

              Generates priors for the observation error model. This should return a named tuple containing the priors required for generating the observation error distribution.

              source
              EpiAware.EpiObsModels.generate_observation_error_priorsMethod
              generate_observation_error_priors(
                   obs_model::NegativeBinomialError,
                   Y_t,
                   y_t
               ) -> Any
              -

              Generates observation error priors based on the NegativeBinomialError observation model. This function generates the cluster factor prior for the negative binomial error model.

              source
              EpiAware.EpiObsModels.observation_errorMethod
              observation_error(
              +

              Generates observation error priors based on the NegativeBinomialError observation model. This function generates the cluster factor prior for the negative binomial error model.

              source
              EpiAware.EpiObsModels.observation_errorMethod
              observation_error(
                   obs_model::AbstractTuringObservationErrorModel,
                   Y_t
               ) -> Distributions.Poisson
              -

              The observation error distribution for the observation error model. This function should return the distribution for the observation error given the expected observation value Y_t and the priors generated by generate_observation_error_priors.

              source
              EpiAware.EpiObsModels.observation_errorMethod
              observation_error(
              +

              The observation error distribution for the observation error model. This function should return the distribution for the observation error given the expected observation value Y_t and the priors generated by generate_observation_error_priors.

              source
              EpiAware.EpiObsModels.observation_errorMethod
              observation_error(
                   obs_model::NegativeBinomialError,
                   Y_t,
                   sq_cluster_factor
               ) -> Union{Distributions.DiscreteUniform, Distributions.NegativeBinomial}
              -

              This function generates the observation error model based on the negative binomial error model with a positive shift. It dispatches to the NegativeBinomialMeanClust distribution.

              source
              EpiAware.EpiObsModels.observation_errorMethod
              observation_error(
              +

              This function generates the observation error model based on the negative binomial error model with a positive shift. It dispatches to the NegativeBinomialMeanClust distribution.

              source
              EpiAware.EpiObsModels.observation_errorMethod
              observation_error(
                   obs_model::PoissonError,
                   Y_t
               ) -> Distributions.Poisson
              -

              The observation error model for Poisson errors. This function generates the observation error model based on the Poisson error model.

              source
              +

              The observation error model for Poisson errors. This function generates the observation error model based on the Poisson error model.

              source
              diff --git a/dev/lib/index.html b/dev/lib/index.html index ea43fb890..7f85e7d46 100644 --- a/dev/lib/index.html +++ b/dev/lib/index.html @@ -1,2 +1,2 @@ -Overview · EpiAware.jl

              API reference

              Welcome to the EpiAware API reference! This section is designed to help you understand the API of the package which is split into submodules.

              The EpiAware package itself contains no functions or types. Instead, it re-exports the functions and types from its submodules. See the sidebar for the list of submodules.

              +Overview · EpiAware.jl

              API reference

              Welcome to the EpiAware API reference! This section is designed to help you understand the API of the package which is split into submodules.

              The EpiAware package itself contains no functions or types. Instead, it re-exports the functions and types from its submodules. See the sidebar for the list of submodules.

              diff --git a/dev/lib/internals/index.html b/dev/lib/internals/index.html index 318bd071c..d83995879 100644 --- a/dev/lib/internals/index.html +++ b/dev/lib/internals/index.html @@ -1,2 +1,2 @@ -Internal API · EpiAware.jl
              +Internal API · EpiAware.jl
              diff --git a/dev/lib/public/index.html b/dev/lib/public/index.html index 1990270b3..7ce758f8c 100644 --- a/dev/lib/public/index.html +++ b/dev/lib/public/index.html @@ -1,2 +1,2 @@ -Public API · EpiAware.jl
              +Public API · EpiAware.jl
              diff --git a/dev/overview/index.html b/dev/overview/index.html index 7afdf7e1a..13c3effd4 100644 --- a/dev/overview/index.html +++ b/dev/overview/index.html @@ -1,2 +1,2 @@ -Overview · EpiAware.jl

              Overview of the EpiAware Software Ecosystem

              EpiAware is not a standard toolkit for infectious disease modelling.

              It seeks to be highly modular and composable for advanced users whilst still providing opinionated workflows for those who are new to the field. Developed by the authors behind other widely used infectious disease modelling packages such as EpiNow2, epinowcast, and epidist, alongside experts in infectious disease modelling in Julia,EpiAware is designed to go beyond the capabilities of these packages by providing a more flexible and extensible framework for modelling and inference of infectious disease dynamics.

              Package Features

              • Flexible: The package is designed to be flexible and extensible, and to provide a consistent interface for fitting and simulating models.
              • Modular: The package is designed to be modular, with a clear separation between the model and the data.
              • Extensible: The package is designed to be extensible, with a clear separation between the model and the data.
              • Consistent: The package is designed to provide a consistent interface for fitting and simulating models.
              • Efficient: The package is designed to be efficient, with a clear separation between the model and the data.

              Package structure

              EpiAware.jl is a wrapper around a series of submodules, each of which provides a different aspect of the package's functionality (much like the tidyverse in R). The package is designed to be modular, with a clear separation between modules and between modules and data. Currently included modules are:

              • EpiAwareBase: The core module, which provides the underlying abstract types and functions for the package.
              • EpiAwareUtils: A utility module, which provides a series of utility functions for working with the package.
              • EpiInference: An inference module, which provides a series of functions for fitting models to data. Builds on top of Turing.jl.
              • EpiInfModels: Provides tools for composing models of the disease transmission process. Builds on top of Turing.jl, in particular the DynamicPPL.jl interface.
              • EpiLatentModels: Provides tools for composing latent models such as random walks, autoregressive models, etc. Builds on top of DynamicPPL.jl. Used by all other modelling modules to define latent processes.
              • EpiObsModels: Provides tools for composing observation models, such as Poisson, Binomial, etc. Builds on top of DynamicPPL.jl.

              Using the package

              We support two primary workflows for using the package:

              • EpiProblem: A high-level interface for defining and fitting models to data. This is the recommended way to use the package.
              • Turing interface: A lower-level interface for defining and fitting models to data. This is the more flexible way to use the package and may also be more familiar to users of Turing.jl.

              See the getting started section for tutorials on each of these workflows.

              +Overview · EpiAware.jl

              Overview of the EpiAware Software Ecosystem

              EpiAware is not a standard toolkit for infectious disease modelling.

              It seeks to be highly modular and composable for advanced users whilst still providing opinionated workflows for those who are new to the field. Developed by the authors behind other widely used infectious disease modelling packages such as EpiNow2, epinowcast, and epidist, alongside experts in infectious disease modelling in Julia,EpiAware is designed to go beyond the capabilities of these packages by providing a more flexible and extensible framework for modelling and inference of infectious disease dynamics.

              Package Features

              • Flexible: The package is designed to be flexible and extensible, and to provide a consistent interface for fitting and simulating models.
              • Modular: The package is designed to be modular, with a clear separation between the model and the data.
              • Extensible: The package is designed to be extensible, with a clear separation between the model and the data.
              • Consistent: The package is designed to provide a consistent interface for fitting and simulating models.
              • Efficient: The package is designed to be efficient, with a clear separation between the model and the data.

              Package structure

              EpiAware.jl is a wrapper around a series of submodules, each of which provides a different aspect of the package's functionality (much like the tidyverse in R). The package is designed to be modular, with a clear separation between modules and between modules and data. Currently included modules are:

              • EpiAwareBase: The core module, which provides the underlying abstract types and functions for the package.
              • EpiAwareUtils: A utility module, which provides a series of utility functions for working with the package.
              • EpiInference: An inference module, which provides a series of functions for fitting models to data. Builds on top of Turing.jl.
              • EpiInfModels: Provides tools for composing models of the disease transmission process. Builds on top of Turing.jl, in particular the DynamicPPL.jl interface.
              • EpiLatentModels: Provides tools for composing latent models such as random walks, autoregressive models, etc. Builds on top of DynamicPPL.jl. Used by all other modelling modules to define latent processes.
              • EpiObsModels: Provides tools for composing observation models, such as Poisson, Binomial, etc. Builds on top of DynamicPPL.jl.

              Using the package

              We support two primary workflows for using the package:

              • EpiProblem: A high-level interface for defining and fitting models to data. This is the recommended way to use the package.
              • Turing interface: A lower-level interface for defining and fitting models to data. This is the more flexible way to use the package and may also be more familiar to users of Turing.jl.

              See the getting started section for tutorials on each of these workflows.

              diff --git a/dev/release-notes/index.html b/dev/release-notes/index.html index 2f8721850..e67acebcc 100644 --- a/dev/release-notes/index.html +++ b/dev/release-notes/index.html @@ -1,2 +1,2 @@ -Release notes · EpiAware.jl
              +Release notes · EpiAware.jl
              diff --git a/dev/search_index.js b/dev/search_index.js index 17d3aa549..e1230a96c 100644 --- a/dev/search_index.js +++ b/dev/search_index.js @@ -1,3 +1,3 @@ var documenterSearchIndex = {"docs": -[{"location":"getting-started/installation/#Installation","page":"Installation","title":"Installation","text":"","category":"section"},{"location":"getting-started/installation/","page":"Installation","title":"Installation","text":"Eventually, EpiAware is likely to be added to the Julia registry. Until then, you can install it from the /EpiAware sub-directory of this repository by running the following command in the Julia REPL:","category":"page"},{"location":"getting-started/installation/","page":"Installation","title":"Installation","text":"using Pkg; Pkg.add(url=\"https://github.com/CDCgov/Rt-without-renewal\", subdir=\"EpiAware\")","category":"page"},{"location":"lib/EpiInfModels/#EpiInfModels.jl","page":"Overview","title":"EpiInfModels.jl","text":"","category":"section"},{"location":"lib/EpiInfModels/","page":"Overview","title":"Overview","text":"This package provides infectious disease transmission models for the EpiAware ecosystem.","category":"page"},{"location":"lib/EpiInfModels/#API","page":"Overview","title":"API","text":"","category":"section"},{"location":"lib/EpiInfModels/","page":"Overview","title":"Overview","text":"Pages = [\"lib/EpiInfModels/public.md\", \"lib/EpiInfModels/internals.md\"]","category":"page"},{"location":"getting-started/quickstart/#Quickstart","page":"Quickstart","title":"Quickstart","text":"","category":"section"},{"location":"getting-started/quickstart/","page":"Quickstart","title":"Quickstart","text":"Get up and running with EpiAware in just a few minutes using this quickstart guide.","category":"page"},{"location":"lib/EpiLatentModels/#EpiLatentModels.jl","page":"Overview","title":"EpiLatentModels.jl","text":"","category":"section"},{"location":"lib/EpiLatentModels/","page":"Overview","title":"Overview","text":"This package provides latent variable models for the EpiAware ecosystem.","category":"page"},{"location":"lib/EpiLatentModels/#API","page":"Overview","title":"API","text":"","category":"section"},{"location":"lib/EpiLatentModels/","page":"Overview","title":"Overview","text":"Pages = [\"lib/EpiLatentModels/public.md\", \"lib/EpiLatentModels/internals.md\"]","category":"page"},{"location":"lib/#api-reference","page":"Overview","title":"API reference","text":"","category":"section"},{"location":"lib/","page":"Overview","title":"Overview","text":"Welcome to the EpiAware API reference! This section is designed to help you understand the API of the package which is split into submodules.","category":"page"},{"location":"lib/","page":"Overview","title":"Overview","text":"The EpiAware package itself contains no functions or types. Instead, it re-exports the functions and types from its submodules. See the sidebar for the list of submodules.","category":"page"},{"location":"lib/EpiLatentModels/internals/#Internal-Documentation","page":"Internal API","title":"Internal Documentation","text":"","category":"section"},{"location":"lib/EpiLatentModels/internals/","page":"Internal API","title":"Internal API","text":"Documentation for EpiLatentModels.jl's internal interface.","category":"page"},{"location":"lib/EpiLatentModels/internals/#Contents","page":"Internal API","title":"Contents","text":"","category":"section"},{"location":"lib/EpiLatentModels/internals/","page":"Internal API","title":"Internal API","text":"Pages = [\"internals.md\"]\nDepth = 2:2","category":"page"},{"location":"lib/EpiLatentModels/internals/#Index","page":"Internal API","title":"Index","text":"","category":"section"},{"location":"lib/EpiLatentModels/internals/","page":"Internal API","title":"Internal API","text":"Pages = [\"internals.md\"]","category":"page"},{"location":"lib/EpiLatentModels/internals/#Internal-API","page":"Internal API","title":"Internal API","text":"","category":"section"},{"location":"lib/EpiLatentModels/internals/","page":"Internal API","title":"Internal API","text":"Modules = [EpiAware.EpiLatentModels]\nPublic = false","category":"page"},{"location":"lib/EpiLatentModels/internals/#EpiAware.EpiAwareBase.broadcast_n-Tuple{RepeatBlock, Any, Any}","page":"Internal API","title":"EpiAware.EpiAwareBase.broadcast_n","text":"broadcast_n(_::RepeatBlock, n, period) -> Any\n\n\nA function that returns the length of the latent periods to generate using the RepeatBlock rule which is equal n divided by the period and rounded up to the nearest integer.\n\nArguments\n\nrule::RepeatBlock: The broadcasting rule.\nn: The number of samples to generate.\nperiod: The period of the broadcast.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiLatentModels/internals/#EpiAware.EpiAwareBase.broadcast_n-Tuple{RepeatEach, Any, Any}","page":"Internal API","title":"EpiAware.EpiAwareBase.broadcast_n","text":"broadcast_n(_::RepeatEach, n, period) -> Any\n\n\nA function that returns the length of the latent periods to generate using the RepeatEach rule which is equal to the period.\n\nArguments\n\nrule::RepeatEach: The broadcasting rule.\nn: The number of samples to generate.\nperiod: The period of the broadcast.\n\nReturns\n\nm: The length of the latent periods to generate.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiLatentModels/internals/#EpiAware.EpiAwareBase.broadcast_rule-Tuple{RepeatBlock, Any, Any, Any}","page":"Internal API","title":"EpiAware.EpiAwareBase.broadcast_rule","text":"broadcast_rule(_::RepeatBlock, latent, n, period) -> Any\n\n\nbroadcast_rule is a function that applies the RepeatBlock rule to the latent process latent to generate n samples.\n\nArguments\n\nrule::RepeatBlock: The broadcasting rule.\nlatent::Vector: The latent process.\nn: The number of samples to generate.\nperiod: The period of the broadcast.\n\nReturns\n\nlatent: The generated broadcasted latent periods.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiLatentModels/internals/#EpiAware.EpiAwareBase.broadcast_rule-Tuple{RepeatEach, Any, Any, Any}","page":"Internal API","title":"EpiAware.EpiAwareBase.broadcast_rule","text":"broadcast_rule(_::RepeatEach, latent, n, period) -> Any\n\n\nbroadcast_rule is a function that applies the RepeatEach rule to the latent process latent to generate n samples.\n\nArguments\n\nrule::RepeatEach: The broadcasting rule.\nlatent::Vector: The latent process.\nn: The number of samples to generate.\nperiod: The period of the broadcast.\n\nReturns\n\nlatent: The generated broadcasted latent periods.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiLatentModels/internals/#EpiAware.EpiAwareBase.generate_latent-Tuple{AR, Any}","page":"Internal API","title":"EpiAware.EpiAwareBase.generate_latent","text":"generate_latent(latent_model::AR, n) -> Any\n\n\nGenerate a latent AR series.\n\nArguments\n\nlatent_model::AR: The AR model.\nn::Int: The length of the AR series.\n\nReturns\n\nar::Vector{Float64}: The generated AR series.\nparams::NamedTuple: A named tuple containing the generated parameters (σ_AR, ar_init, damp_AR).\n\nNotes\n\nThe length of damp_prior and init_prior must be the same.\nn must be longer than the order of the autoregressive process.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiLatentModels/internals/#EpiAware.EpiAwareBase.generate_latent-Tuple{BroadcastLatentModel, Any}","page":"Internal API","title":"EpiAware.EpiAwareBase.generate_latent","text":"generate_latent(model::BroadcastLatentModel, n) -> Any\n\n\nGenerates latent periods using the specified model and n number of samples.\n\nArguments\n\nmodel::BroadcastLatentModel: The broadcast latent model.\nn::Any: The number of samples to generate.\n\nReturns\n\nbroadcasted_latent: The generated broadcasted latent periods.\nlatent_period_aux...: Additional auxiliary information about the latent periods.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiLatentModels/internals/#EpiAware.EpiAwareBase.generate_latent-Tuple{CombineLatentModels, Any}","page":"Internal API","title":"EpiAware.EpiAwareBase.generate_latent","text":"generate_latent(\n latent_models::CombineLatentModels,\n n\n) -> Any\n\n\nGenerate latent variables using a combination of multiple latent models.\n\nArguments\n\nlatent_models::CombineLatentModels: An instance of the CombineLatentModels type representing the collection of latent models.\nn: The number of latent variables to generate.\n\nReturns\n\ncombined_latents: The combined latent variables generated from all the models.\nlatent_aux: A tuple containing the auxiliary latent variables generated from each individual model.\n\nExample\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiLatentModels/internals/#EpiAware.EpiAwareBase.generate_latent-Tuple{ConcatLatentModels, Any}","page":"Internal API","title":"EpiAware.EpiAwareBase.generate_latent","text":"generate_latent(latent_models::ConcatLatentModels, n) -> Any\n\n\nGenerate latent variables by concatenating multiple latent models.\n\nArguments\n\nlatent_models::ConcatLatentModels: An instance of the ConcatLatentModels type representing the collection of latent models.\nn: The number of latent variables to generate.\n\nReturns\n\nconcatenated_latents: The combined latent variables generated from all the models.\nlatent_aux: A tuple containing the auxiliary latent variables generated from each individual model.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiLatentModels/internals/#EpiAware.EpiAwareBase.generate_latent-Tuple{DiffLatentModel, Any}","page":"Internal API","title":"EpiAware.EpiAwareBase.generate_latent","text":"generate_latent(latent_model::DiffLatentModel, n) -> Any\n\n\nGenerate a Turing model for n-step latent process Z_t using a differenced latent model defined by latent_model.\n\nArguments\n\nlatent_model::DiffLatentModel: The differential latent model.\nn: The length of the latent variables.\n\nTuring model specifications\n\nSampled random variables\n\nlatent_init: The initial latent process variables.\nOther random variables defined by model<:AbstractTuringLatentModel field of the undifferenced model.\n\nGenerated quantities\n\nA tuple containing the generated latent process as its first argument and a NamedTuple of sampled auxiliary variables as second argument.\n\nExample usage with DiffLatentModel model constructor\n\ngenerate_latent can be used to construct a Turing model for the differenced latent process. In this example, the underlying undifferenced process is a RandomWalk model.\n\nFirst, we construct a RandomWalk struct with an initial value prior and a step size standard deviation prior.\n\nusing Distributions, EpiAware\nrw = RandomWalk(Normal(0.0, 1.0), truncated(Normal(0.0, 0.05), 0.0, Inf))\n\nThen, we can use DiffLatentModel to construct a DiffLatentModel for d-fold differenced process with rw as the undifferenced latent process.\n\nWe have two constructor options for DiffLatentModel. The first option is to supply a common prior distribution for the initial terms and specify d as follows:\n\ndiff_model = DiffLatentModel(rw, Normal(); d = 2)\n\nOr we can supply a vector of priors for the initial terms and d is inferred as follows:\n\ndiff_model2 = DiffLatentModel(;undiffmodel = rw, init_priors = [Normal(), Normal()])\n\nThen, we can use generate_latent to construct a Turing model for the differenced latent process generating a length n process,\n\n# Construct a Turing model\nn = 100\ndifference_mdl = generate_latent(diff_model, n)\n\nNow we can use the Turing PPL API to sample underlying parameters and generate the unobserved latent process.\n\n#Sample random parameters from prior\nθ = rand(difference_mdl)\n#Get a sampled latent process as a generated quantity from the model\n(Z_t, _) = generated_quantities(difference_mdl, θ)\nZ_t\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiLatentModels/internals/#EpiAware.EpiAwareBase.generate_latent-Tuple{FixedIntercept, Any}","page":"Internal API","title":"EpiAware.EpiAwareBase.generate_latent","text":"generate_latent(latent_model::FixedIntercept, n) -> Any\n\n\nGenerate a latent intercept series with a fixed intercept value.\n\nArguments\n\nlatent_model::FixedIntercept: The fixed intercept latent model.\nn: The number of latent variables to generate.\n\nReturns\n\nlatent_vars: An array of length n filled with the fixed intercept value.\nmetadata: A named tuple containing the intercept value.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiLatentModels/internals/#EpiAware.EpiAwareBase.generate_latent-Tuple{HierarchicalNormal, Any}","page":"Internal API","title":"EpiAware.EpiAwareBase.generate_latent","text":"generate_latent(obs_model::HierarchicalNormal, n) -> Any\n\n\nfunction EpiAwareBase.generate_latent(obs_model::HierarchicalNormal, n)\n\nGenerate latent variables from the hierarchical normal distribution.\n\nArguments\n\nobs_model::HierarchicalNormal: The hierarchical normal distribution model.\nn: Number of latent variables to generate.\n\nReturns\n\nη_t: Generated latent variables.\nstd: Standard deviation used in the generation.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiLatentModels/internals/#EpiAware.EpiAwareBase.generate_latent-Tuple{Intercept, Any}","page":"Internal API","title":"EpiAware.EpiAwareBase.generate_latent","text":"generate_latent(latent_model::Intercept, n) -> Any\n\n\nGenerate a latent intercept series.\n\nArguments\n\nlatent_model::Intercept: The intercept model.\nn::Int: The length of the intercept series.\n\nReturns\n\nintercept::Vector{Float64}: The generated intercept series.\nmetadata::NamedTuple: A named tuple containing the intercept value.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiLatentModels/internals/#EpiAware.EpiAwareBase.generate_latent-Tuple{RandomWalk, Any}","page":"Internal API","title":"EpiAware.EpiAwareBase.generate_latent","text":"generate_latent(latent_model::RandomWalk, n) -> Any\n\n\nImplement the generate_latent function for the RandomWalk model.\n\nExample usage of generate_latent with RandomWalk type of latent process model\n\nusing Distributions, Turing, EpiAware\n\n# Create a RandomWalk model\nrw = RandomWalk(init_prior = Normal(2., 1.),\n std_prior = HalfNormal(0.1))\n\nThen, we can use generate_latent to construct a Turing model for a 10 step random walk.\n\n# Construct a Turing model\nrw_model = generate_latent(rw, 10)\n\nNow we can use the Turing PPL API to sample underlying parameters and generate the unobserved infections.\n\n#Sample random parameters from prior\nθ = rand(rw_model)\n#Get random walk sample path as a generated quantities from the model\nZ_t, _ = generated_quantities(rw_model, θ)\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiLatentModels/internals/#EpiAware.EpiAwareBase.generate_latent-Tuple{TransformLatentModel, Any}","page":"Internal API","title":"EpiAware.EpiAwareBase.generate_latent","text":"generate_latent(model::TransformLatentModel, n) -> Any\n\n\ngenerate_latent(model::TransformLatentModel, n)\n\nGenerate latent variables using the specified TransformLatentModel.\n\nArguments\n\nmodel::TransformLatentModel: The TransformLatentModel to generate latent variables from.\nn: The number of latent variables to generate.\n\nReturns\n\ntransformed: The transformed latent variables.\nlatent_aux: Additional auxiliary variables generated by the underlying latent model.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiObsModels/public/#Public-Documentation","page":"Public API","title":"Public Documentation","text":"","category":"section"},{"location":"lib/EpiObsModels/public/","page":"Public API","title":"Public API","text":"Documentation for EpiObsModels.jl's public interface.","category":"page"},{"location":"lib/EpiObsModels/public/","page":"Public API","title":"Public API","text":"See the Internals section of the manual for internal package docs covering all submodules.","category":"page"},{"location":"lib/EpiObsModels/public/#Contents","page":"Public API","title":"Contents","text":"","category":"section"},{"location":"lib/EpiObsModels/public/","page":"Public API","title":"Public API","text":"Pages = [\"public.md\"]\nDepth = 2:2","category":"page"},{"location":"lib/EpiObsModels/public/#Index","page":"Public API","title":"Index","text":"","category":"section"},{"location":"lib/EpiObsModels/public/","page":"Public API","title":"Public API","text":"Pages = [\"public.md\"]","category":"page"},{"location":"lib/EpiObsModels/public/#Public-API","page":"Public API","title":"Public API","text":"","category":"section"},{"location":"lib/EpiObsModels/public/","page":"Public API","title":"Public API","text":"Modules = [EpiAware.EpiObsModels]\nPrivate = false","category":"page"},{"location":"lib/EpiObsModels/public/#EpiAware.EpiObsModels","page":"Public API","title":"EpiAware.EpiObsModels","text":"Module for defining observation models.\n\n\n\n\n\n","category":"module"},{"location":"lib/EpiObsModels/public/#EpiAware.EpiObsModels.Ascertainment","page":"Public API","title":"EpiAware.EpiObsModels.Ascertainment","text":"struct Ascertainment{M<:AbstractTuringObservationModel, T<:AbstractTuringLatentModel, F<:Function, P<:String} <: AbstractTuringObservationModel\n\nThe Ascertainment struct represents an observation model that incorporates a ascertainment model. If a latent_prefixis supplied the latent_model is wrapped in a call to PrefixLatentModel.\n\nConstructors\n\nAscertainment(model::M, latent_model::T, link::F, latent_prefix::P) where {M <: AbstractTuringObservationModel, T <: AbstractTuringLatentModel, F <: Function, P <: String}: Constructs an Ascertainment instance with the specified observation model, latent model, link function, and latent prefix.\nAscertainment(; model::M, latent_model::T, link::F, latent_prefix::P) where {M <: AbstractTuringObservationModel, T <: AbstractTuringLatentModel, F <: Function, P <: String}: Constructs an Ascertainment instance with the specified observation model, latent model, link function, and latent prefix.\n\nExamples\n\nusing EpiAware, Turing\nobs = Ascertainment(model = NegativeBinomialError(), latent_model = FixedIntercept(0.1))\ngen_obs = generate_observations(obs, missing, fill(100, 10))\nrand(gen_obs)\n\n\n\nFields\n\nmodel::AbstractTuringObservationModel: The underlying observation model.\nlatent_model::AbstractTuringLatentModel: The latent model.\nlink::Function: The link function used to transform the latent model to the observed data.\nlatent_prefix::String\n\n\n\n\n\n","category":"type"},{"location":"lib/EpiObsModels/public/#EpiAware.EpiObsModels.LatentDelay","page":"Public API","title":"EpiAware.EpiObsModels.LatentDelay","text":"struct LatentDelay{M<:AbstractTuringObservationModel, T<:(AbstractVector{<:Real})} <: AbstractTuringObservationModel\n\nThe LatentDelay struct represents an observation model that introduces a latent delay in the observations. It is a subtype of AbstractTuringObservationModel.\n\nNote that the LatentDelay observation model shortens the observation vector by the length of the delay distribution and this is then passed to the underlying observation model. This is to prevent fitting to partially observed data.\n\nFields\n\nmodel::M: The underlying observation model.\npmf::T: The probability mass function (PMF) representing the delay distribution.\n\nConstructors\n\nLatentDelay(model::M, distribution::C; D = nothing, Δd = 1.0) where {M <: AbstractTuringObservationModel, C <: ContinuousDistribution}: Constructs a LatentDelay object with the given underlying observation model and continuous distribution. The D parameter specifies the right truncation of the distribution, with default D = nothing indicates that the distribution should be truncated at its 99th percentile rounded to nearest multiple of Δd. The Δd parameter specifies the width of each delay interval.\nLatentDelay(model::M, pmf::T) where {M <: AbstractTuringObservationModel, T <: AbstractVector{<:Real}}: Constructs a LatentDelay object with the given underlying observation model and delay PMF.\n\nExamples\n\nusing Distributions, Turing, EpiAware\nobs = LatentDelay(NegativeBinomialError(), truncated(Normal(5.0, 2.0), 0.0, Inf))\nobs_model = generate_observations(obs, missing, fill(10, 10))\nrand(obs_model)\n\n\n\nFields\n\nmodel::AbstractTuringObservationModel\npmf::AbstractVector{<:Real}\n\n\n\n\n\n","category":"type"},{"location":"lib/EpiObsModels/public/#EpiAware.EpiObsModels.NegativeBinomialError","page":"Public API","title":"EpiAware.EpiObsModels.NegativeBinomialError","text":"struct NegativeBinomialError{S<:Distributions.Sampleable} <: AbstractTuringObservationErrorModel\n\nThe NegativeBinomialError struct represents an observation model for negative binomial errors. It is a subtype of AbstractTuringObservationModel.\n\nConstructors\n\nNegativeBinomialError(; cluster_factor_prior::Distribution = HalfNormal(0.1)): Constructs a NegativeBinomialError object with default values for the cluster factor prior.\nNegativeBinomialError(cluster_factor_prior::Distribution): Constructs a NegativeBinomialError object with a specified cluster factor prior.\n\nExamples\n\nusing Distributions, Turing, EpiAware\nnb = NegativeBinomialError()\nnb_model = generate_observations(nb, missing, fill(10, 10))\nrand(nb_model)\n\n\n\nFields\n\ncluster_factor_prior::Distributions.Sampleable: The prior distribution for the cluster factor.\n\n\n\n\n\n","category":"type"},{"location":"lib/EpiObsModels/public/#EpiAware.EpiObsModels.PoissonError","page":"Public API","title":"EpiAware.EpiObsModels.PoissonError","text":"struct PoissonError <: AbstractTuringObservationErrorModel\n\nThe PoissonError struct represents an observation model for Poisson errors. It is a subtype of AbstractTuringObservationErrorModel.\n\nConstructors\n\nPoissonError(): Constructs a PoissonError object.\n\nExamples\n\nusing Distributions, Turing, EpiAware\npoi = PoissonError()\npoi_model = generate_observations(poi, missing, fill(10, 10))\nrand(poi_model)\n\n\n\nFields\n\n\n\n\n\n","category":"type"},{"location":"lib/EpiObsModels/public/#EpiAware.EpiObsModels.PrefixObservationModel","page":"Public API","title":"EpiAware.EpiObsModels.PrefixObservationModel","text":"struct PrefixObservationModel{M<:AbstractTuringObservationModel, P<:String} <: AbstractTuringObservationModel\n\nGenerate an observation model with a prefix. A lightweight wrapper around `EpiAwareUtils.prefix_submodel`.\n\n# Constructors\n- `PrefixObservationModel(model::M, prefix::P)`: Create a `PrefixObservationModel` with the observation model `model` and the prefix `prefix`.\n- `PrefixObservationModel(; model::M, prefix::P)`: Create a `PrefixObservationModel` with the observation model `model` and the prefix `prefix`.\n\n# Examples\n```julia\nusing EpiAware\nobservation_model = PrefixObservationModel(Poisson(), \"Test\")\nobs = generate_observations(observation_model, 10)\nrand(obs)\n```\n\n\n\nFields\n\nmodel::AbstractTuringObservationModel: The observation model\nprefix::String: The prefix for the observation model\n\n\n\n\n\n","category":"type"},{"location":"lib/EpiObsModels/public/#EpiAware.EpiObsModels.StackObservationModels","page":"Public API","title":"EpiAware.EpiObsModels.StackObservationModels","text":"struct StackObservationModels{M<:(AbstractVector{<:AbstractTuringObservationModel}), N<:(AbstractVector{<:AbstractString})} <: AbstractTuringObservationModel\n\nA stack of observation models that are looped over to generate observations for each model in the stack. Note that the model names are used to prefix the parameters in each model (so if I have a model named cases and a parameter y_t, the parameter in the model will be cases.y_t). Inside the constructor PrefixObservationModel is wrapped around each observation model.\n\nConstructors\n\nStackObservationModels(models::Vector{<:AbstractTuringObservationModel}, model_names::Vector{<:AbstractString}): Construct a StackObservationModels object with a vector of observation models and a vector of model names.\n`StackObservationModels(; models::Vector{<:AbstractTuringObservationModel},\nmodel_names::Vector{<:AbstractString}): Construct aStackObservationModels` object with a vector of observation models and a vector of model names.\nStackObservationModels(models::NamedTuple{names, T}): Construct a StackObservationModels object with a named tuple of observation models. The model names are automatically generated from the keys of the named tuple.\n\nExample\n\nusing EpiAware, Turing\n\nobs = StackObservationModels(\n (cases = PoissonError(), deaths = NegativeBinomialError())\n)\ny_t = (cases = missing, deaths = missing)\nobs_model = generate_observations(obs, y_t, fill(10, 10))\nrand(obs_model)\nsamples = sample(obs_model, Prior(), 100; progress = false)\n\ncases_y_t = group(samples, \"cases.y_t\")\ncases_y_t\n\ndeaths_y_t = group(samples, \"deaths.y_t\")\ndeaths_y_t\n\n\n\nFields\n\nmodels::AbstractVector{<:AbstractTuringObservationModel}: A vector of observation models.\nmodel_names::AbstractVector{<:AbstractString}: A vector of observation model names\n\n\n\n\n\n","category":"type"},{"location":"lib/EpiObsModels/public/#EpiAware.EpiObsModels.ascertainment_dayofweek-Tuple{AbstractTuringObservationModel}","page":"Public API","title":"EpiAware.EpiObsModels.ascertainment_dayofweek","text":"ascertainment_dayofweek(\n model::AbstractTuringObservationModel;\n latent_model,\n link,\n latent_prefix\n) -> Ascertainment{M, AbstractTuringLatentModel, EpiAware.EpiObsModels.var\"#16#18\", String} where M<:AbstractTuringObservationModel\n\n\nCreate an Ascertainment object that models the ascertainment process based on the day of the week.\n\nArguments\n\nmodel::AbstractTuringObservationModel: The observation model to be used.\nlatent_model::AbstractTuringLatentModel: The latent model to be used. Default is HierarchicalNormal() which is a hierarchical normal distribution.\nlink: The link function to be used. Default is the identity map x -> x.\n\nThis function is used to transform the latent model after broadcasting to periodic weekly has been applied.\n\nlatent_prefix: The prefix to be used for the latent model. Default is \"DayofWeek\".\n\nReturns\n\nAscertainment: The Ascertainment object that models the ascertainment process based on the day of the week.\n\nExamples\n\nusing EpiAware\nobs = ascertainment_dayofweek(PoissonError())\ngen_obs = generate_observations(obs, missing, fill(100, 14))\ngen_obs()\nrand(gen_obs)\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiObsModels/public/#EpiAware.EpiObsModels.generate_observation_error_priors-Tuple{AbstractTuringObservationErrorModel, Any, Any}","page":"Public API","title":"EpiAware.EpiObsModels.generate_observation_error_priors","text":"generate_observation_error_priors(\n obs_model::AbstractTuringObservationErrorModel,\n y_t,\n Y_t\n) -> Any\n\n\nGenerates priors for the observation error model. This should return a named tuple containing the priors required for generating the observation error distribution.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiObsModels/public/#EpiAware.EpiObsModels.generate_observation_error_priors-Tuple{NegativeBinomialError, Any, Any}","page":"Public API","title":"EpiAware.EpiObsModels.generate_observation_error_priors","text":"generate_observation_error_priors(\n obs_model::NegativeBinomialError,\n Y_t,\n y_t\n) -> Any\n\n\nGenerates observation error priors based on the NegativeBinomialError observation model. This function generates the cluster factor prior for the negative binomial error model.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiObsModels/public/#EpiAware.EpiObsModels.observation_error-Tuple{AbstractTuringObservationErrorModel, Any}","page":"Public API","title":"EpiAware.EpiObsModels.observation_error","text":"observation_error(\n obs_model::AbstractTuringObservationErrorModel,\n Y_t\n) -> Distributions.Poisson\n\n\nThe observation error distribution for the observation error model. This function should return the distribution for the observation error given the expected observation value Y_t and the priors generated by generate_observation_error_priors.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiObsModels/public/#EpiAware.EpiObsModels.observation_error-Tuple{NegativeBinomialError, Any, Any}","page":"Public API","title":"EpiAware.EpiObsModels.observation_error","text":"observation_error(\n obs_model::NegativeBinomialError,\n Y_t,\n sq_cluster_factor\n) -> Union{Distributions.DiscreteUniform, Distributions.NegativeBinomial}\n\n\nThis function generates the observation error model based on the negative binomial error model with a positive shift. It dispatches to the NegativeBinomialMeanClust distribution.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiObsModels/public/#EpiAware.EpiObsModels.observation_error-Tuple{PoissonError, Any}","page":"Public API","title":"EpiAware.EpiObsModels.observation_error","text":"observation_error(\n obs_model::PoissonError,\n Y_t\n) -> Distributions.Poisson\n\n\nThe observation error model for Poisson errors. This function generates the observation error model based on the Poisson error model.\n\n\n\n\n\n","category":"method"},{"location":"getting-started/explainers/julia/#Julia-for-EpiAware","page":"Working with Julia","title":"Julia for EpiAware","text":"","category":"section"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"Julia is a programming language aimed at technical computing. This guide is aimed at helping you set up Julia on your system and pointing towards resources for learning more.","category":"page"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"[!NOTE] If you are familar with other languages with tooling for technical computing (e.g. R, MATLAB, Python) these noteworthy differences may be useful.","category":"page"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"Pages = [\"getting-started/tutorials/julia.md\"]\nDepth = 3","category":"page"},{"location":"getting-started/explainers/julia/#What-this-guide-is-and-isn't","page":"Working with Julia","title":"What this guide is and isn't","text":"","category":"section"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"This isn't a guide to learning the Julia programming language. Instead we providing an opinionated guide to setting up your system to use Julia effectively in project workflows aimed at people with familiarity with Julia but have maybe only developed projects in other languages (e.g. R, MATLAB, Python).","category":"page"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"If you want to learn more about the Julia programming language, we recommend the following resources:","category":"page"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"Julia Documentation - getting started.\nJulia Academy.\nJulia learning resources.\nJuliaHub.\nJulia Discourse.\nJulia Slack.","category":"page"},{"location":"getting-started/explainers/julia/#Julia-Installation-with-Juliaup","page":"Working with Julia","title":"Julia Installation with Juliaup","text":"","category":"section"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"Download Juliaup: This is a cross-platform installer/updater for the Julia programming language. It simplifies the process of installing and managing Julia versions. Go to the Juliaup GitHub repository or to the official Julia website for installation instructions.\nVerify Installation: Open a terminal (or Command Prompt on Windows) and type julia to start the Julia REPL (Read-Eval-Print Loop). You should see a Julia prompt julia>.","category":"page"},{"location":"getting-started/explainers/julia/#Basic-usage-of-Juliaup","page":"Working with Julia","title":"Basic usage of Juliaup","text":"","category":"section"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"Juliaup is a tool for managing Julia installations on your system. It allows you to install, update, and switch between different versions of Julia. Details are available at the Juliaup GitHub repository, but here are some examples of common commands:","category":"page"},{"location":"getting-started/explainers/julia/#Add-a-specific-version-of-Julia","page":"Working with Julia","title":"Add a specific version of Julia","text":"","category":"section"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"Juliaup default installs the latest release version of Julia. To install a specific version, use the add command followed by the version number. For example, to install Julia version 1.9.3, use the following command:","category":"page"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"% juliaup add 1.9.3","category":"page"},{"location":"getting-started/explainers/julia/#Use-a-specific-version-of-Julia","page":"Working with Julia","title":"Use a specific version of Julia","text":"","category":"section"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"To switch between different versions of Julia, use + julia-version after the julia command. For example, to use Julia version 1.9.3, use the following command:","category":"page"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"% julia +1.9.3","category":"page"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"This will use the specified version of Julia for the current REPL. In general, adding the + julia-version flag after the julia command will execute using the specified version of Julia.","category":"page"},{"location":"getting-started/explainers/julia/#Check-versions-of-Julia-installed","page":"Working with Julia","title":"Check versions of Julia installed","text":"","category":"section"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"To see a list of all the versions of Julia installed on your system, use the following command:","category":"page"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"% juliaup list","category":"page"},{"location":"getting-started/explainers/julia/#Update-Julia-(all-versions-installed)","page":"Working with Julia","title":"Update Julia (all versions installed)","text":"","category":"section"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"This will update all versions of Julia installed on your system to their latest release versions.","category":"page"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"% juliaup update","category":"page"},{"location":"getting-started/explainers/julia/#Usage-of-Julia-environments","page":"Working with Julia","title":"Usage of Julia environments","text":"","category":"section"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"The environment of a Julia project determines which packages, and their version, are available to the project. This is useful when you want to ensure that a project uses a specific version of a package, or when you want to isolate the project from other projects on your system. As per other languages, Julia environments are useful for managing dependencies and ensuring reproducibility.","category":"page"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"The most common usage of environments is to create a new explicit environment for a project in a directory. This creates a Project.toml file in the directory that specifies the dependencies for the project and a Manifest.toml file that specifies the exact versions of the dependencies, and their underlying dependencies. We'll discuss how to set up a new environment for a project in the REPL section.","category":"page"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"Julia environments can be stacked. This means that you can have a primary environment embedded in the stacked environment, along with secondary environment(s) that define common packages to be available to many projects.","category":"page"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"From a project development point of view, most commonly the project environment will be the primary environment, isolated from other project environments. And the environment of the Julia version installation (e.g. the @v1.10 env) will be a secondary environment because its in the default LOAD_PATH Julia environmental variable. You can add packages to the Julia version environment that you want to be available to all projects as we'll show in the REPL section. See section Recommended packages for the primary Julia environment for our recommendations.","category":"page"},{"location":"getting-started/explainers/julia/#Using-the-Julia-REPL-in-projects","page":"Working with Julia","title":"Using the Julia REPL in projects","text":"","category":"section"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"The Julia REPL (Read-Eval-Print Loop) is an interactive programming environment that takes single user inputs (i.e., single expressions), evaluates them, and returns the result to the user.","category":"page"},{"location":"getting-started/explainers/julia/#Package-management-programmatically-and-from-REPL","page":"Working with Julia","title":"Package management programmatically and from REPL","text":"","category":"section"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"Julia has a built-in package manager called Pkg, which is documented briefly here and in more detail here. The package manager is used to install, update, and manage Julia packages and environments.","category":"page"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"You can use Pkg programmatically as a normal Julia package, which is often done in scripts. For example, if we wanted to install the OrdinaryDiffEq package as part of executing a julia script, we would add the following lines to the script:","category":"page"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"using Pkg\nPkg.add(\"OrdinaryDiffEq\")","category":"page"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"However, you can also use the package manager interactively from the REPL. In our opinion, this is the more common usage of package management in Julia project development.","category":"page"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"For example, to install the OrdinaryDiffEq package from the REPL you can switch to package mode by typing ] and then type add OrdinaryDiffEq. To exit package mode, type backspace.","category":"page"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"julia> ]\n(@v1.10) pkg> add OrdinaryDiffEq","category":"page"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"This workflow is often more convenient than the programmatic interface, especially when setting packages you want to install to the environment for your julia installation, e.g the @v1.10 environment for julia 1.10.","category":"page"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"By default, the environment for a julia installation is stacked as a primary environment, so that the packages you install in the julia installation environment are available to all projects.","category":"page"},{"location":"getting-started/explainers/julia/#Using-the-Julia-REPL-to-set-up-active-project-environments","page":"Working with Julia","title":"Using the Julia REPL to set up active project environments","text":"","category":"section"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"To set a new active project environment, you can use the Pkg package manager from the REPL with the command activate with a local directory path. The project environment is named after the directory hosting the Project.toml file. After activating the project environment, you can manage packages to the project environment, as well as use packages from the primary stacked environment as described above.","category":"page"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"Here is an example of how you can create a new environment for a project when the REPL working directory is in some directory /myproject, and then add OrdinaryDiffEq to the project environment:","category":"page"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"julia> pwd() #Check your directory\n# \"path/to/myproject\"\njulia> ]\n(@v1.10) pkg> activate .\n(myproject) pkg> add OrdinaryDiffEq","category":"page"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"Note that if the project directory doesn't have a Project.toml file, one will be created when you add the first package to the project environment.","category":"page"},{"location":"getting-started/explainers/julia/#Experimenting-with-Julia-from-REPL-using-a-temporary-environment","page":"Working with Julia","title":"Experimenting with Julia from REPL using a temporary environment","text":"","category":"section"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"It is quite common to want to experiment with new Julia packages and code snippets. A convenient way to do this without setting up a new project environment or adding dependencies to the primary environment is to use a temporary environment. To do this:","category":"page"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"julia> ]\n(@v1.10) pkg> activate --temp\n(jl_FTIz6j) pkg> add InterestingPackage","category":"page"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"This will create a temporary environment, stacked with the primary environment, that is not saved to disk, and you can add packages to this environment without affecting the primary environment or any project environments. When you exit the REPL, the temporary environment will be deleted.","category":"page"},{"location":"getting-started/explainers/julia/#Recommended-packages-for-the-\"global\"-Julia-version-environment","page":"Working with Julia","title":"Recommended packages for the \"global\" Julia version environment","text":"","category":"section"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"In our view these packages are useful for your Julia version environment, e.g. v1.10 env, which will be available to other environments.","category":"page"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"Revise: For modifying package code and using the changes without restarting Julia session.\nTerm: For pretty and stylized REPL output (including error messages).\nJuliaFormatter: For code formatting.\nDocumenter: For local documentation generation.\nPluto: A native Julia notebook for interactive development.\nTestEnv: For easy use of test environments for package testing.\nUnicodePlots: For simple and quick plotting in the REPL without needing to install a fully featured plotting package.","category":"page"},{"location":"getting-started/explainers/julia/#startup.jl-recommendation","page":"Working with Julia","title":"startup.jl recommendation","text":"","category":"section"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"Revise and Term useful to have available in every Julia session. It is convenient to have these packages loaded automatically when you start a Julia session by adding a startup.jl file. This file should be located in the ~/.julia/config directory. Here is an example of a startup.jl file that loads the Revise and Term:","category":"page"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"atreplinit() do repl\n # Load Revise if it is installed\n try\n @eval using Revise\n catch e\n @warn \"error while importing Revise\" e\n end\n # Load Term if it is installed\n try\n @eval using Term\n @eval install_term_repr()\n @eval install_term_stacktrace()\n catch e\n @warn \"error while importing Term\" e\n end\nend\n","category":"page"},{"location":"getting-started/explainers/julia/#Developing-a-EpiAware-project-from-VS-Code","page":"Working with Julia","title":"Developing a EpiAware-project from VS-Code","text":"","category":"section"},{"location":"getting-started/explainers/julia/#Julia-extension-for-VS-Code","page":"Working with Julia","title":"Julia extension for VS-Code","text":"","category":"section"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"Visual Studio Code (VS-Code) is a popular code editor that supports Julia development. The Julia extension for VS-Code provides an interactive development environment that will be familiar to users of other scientific IDEs (e.g. developing R projects in RStudio or using the MATLAB application).","category":"page"},{"location":"getting-started/explainers/julia/#Features-of-the-Julia-extension-for-VS-Code","page":"Working with Julia","title":"Features of the Julia extension for VS-Code","text":"","category":"section"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"It is worth reading both the VS-Code documentation and the Julia extension documentation, however, here are some highlights:","category":"page"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"Julia REPL: The Julia extension provides an integrated REPL in the TERMINAL pane that allows you to interact with Julia code directly from the editor. For example, you can run code snippets from highlighting or code blocks defined by ## comments in the scripts.\nPlotting: By default, plots generated by featured plotting packages (e.g. Plots.jl) will be displayed in a Plot pane generated by the VS-Code editor.\nJulia Tab: The Julia extension provides a Julia tab with the following sub-tabs:\nWorkspace: This allows you to inspect the modules, functions and variables in your current REPL session. For variables that can be understood as a Table, you can view them in a tabular format from the workspace tab.\nDocumentation: This allows you to view the documentation for functions and types in the Julia standard library and any packages you have installed.\nPlot Navigator: This allows you to navigate the plots generated by the featured plotting packages.\nTesting: The Julia extension provides interaction between the Testing tab in VS-Code with Julia tests defined using the Julia package TestItems macro @testitem run with TestItemRunner.","category":"page"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"Other standard IDE features are Code completion, Code linting, Code formatting, Debugging, and Profiling.","category":"page"},{"location":"getting-started/explainers/julia/#Recommended-settings-for-the-Julia-extension-in-VS-Code","page":"Working with Julia","title":"Recommended settings for the Julia extension in VS-Code","text":"","category":"section"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"The settings of the Julia extension can be found by accessing Preferences: Open User Settings from the command palette in VS-Code and then searching for Julia.","category":"page"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"We recommend the following workplace settings saved in a file .vscode/settings.json relative to your working directory:","category":"page"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"{\n \"[julia]\": {\n \"editor.detectIndentation\": false,\n \"editor.insertSpaces\": true,\n \"editor.tabSize\": 4,\n \"files.insertFinalNewline\": true,\n \"files.trimFinalNewlines\": true,\n \"files.trimTrailingWhitespace\": true,\n \"editor.rulers\": [80],\n \"files.eol\": \"\\n\"\n },\n \"julia.liveTestFile\": \"path/to/runtests.jl\",\n \"julia.environmentPath\": \"path/to/project/directory\",\n}","category":"page"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"These settings set basic code formatting and whitespace settings for Julia files, as well as setting the path to the test file for the project and the path to the project directory for the environment.","category":"page"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"The VS-Code command Julia: Start REPL will start a REPL in TERMINAL tab in the editor with the environment set to the project directory and the Testing tab will detect the defined tests for the project.","category":"page"},{"location":"getting-started/explainers/julia/#Literate-programming-with-Julia-in-EpiAware","page":"Working with Julia","title":"Literate programming with Julia in EpiAware","text":"","category":"section"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"Its common to develop technical computing projects using a literate programming style, where code and documentation are interwoven. Julia supports this style of programming through a number of packages. In EpiAware we recommend the following:","category":"page"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"Pluto: A native Julia notebook for interactive development. Pluto notebooks are reactive, meaning that the output of all cells are updated as input changes. Installation instructions are available here. Pluto notebook files have the extension .jl and can be run as scripts.\nQuarto: A literate programming tool that allows you to write documents in markdown with embedded Julia code. Installation instructions are available here. Quarto files have the extension .qmd.","category":"page"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"We use Pluto for interactive development and Quarto for generating reports and academic articles. Both tools are useful for developing reproducible workflows.","category":"page"},{"location":"getting-started/explainers/inference/#Inference","page":"Inference","title":"Inference","text":"","category":"section"},{"location":"lib/EpiInference/public/#Public-Documentation","page":"Public API","title":"Public Documentation","text":"","category":"section"},{"location":"lib/EpiInference/public/","page":"Public API","title":"Public API","text":"Documentation for EpiInference.jl's public interface.","category":"page"},{"location":"lib/EpiInference/public/","page":"Public API","title":"Public API","text":"See the Internals section of the manual for internal package docs covering all submodules.","category":"page"},{"location":"lib/EpiInference/public/#Contents","page":"Public API","title":"Contents","text":"","category":"section"},{"location":"lib/EpiInference/public/","page":"Public API","title":"Public API","text":"Pages = [\"public.md\"]\nDepth = 2:2","category":"page"},{"location":"lib/EpiInference/public/#Index","page":"Public API","title":"Index","text":"","category":"section"},{"location":"lib/EpiInference/public/","page":"Public API","title":"Public API","text":"Pages = [\"public.md\"]","category":"page"},{"location":"lib/EpiInference/public/#Public-API","page":"Public API","title":"Public API","text":"","category":"section"},{"location":"lib/EpiInference/public/","page":"Public API","title":"Public API","text":"Modules = [EpiAware.EpiInference]\nPrivate = false","category":"page"},{"location":"lib/EpiInference/public/#EpiAware.EpiInference","page":"Public API","title":"EpiAware.EpiInference","text":"Module for defining inference methods.\n\n\n\n\n\n","category":"module"},{"location":"lib/EpiInference/public/#EpiAware.EpiInference.ManyPathfinder","page":"Public API","title":"EpiAware.EpiInference.ManyPathfinder","text":"struct ManyPathfinder <: AbstractEpiOptMethod\n\nA variational inference method that runs manypathfinder.\n\n\n\nFields\n\nndraws::Int64: Number of draws per pathfinder run.\nnruns::Int64: Number of many pathfinder runs.\nmaxiters::Int64: Maximum number of optimization iterations for each run.\nmax_tries::Int64: Maximum number of tries if all runs fail.\n\n\n\n\n\n","category":"type"},{"location":"lib/EpiInference/public/#EpiAware.EpiInference.NUTSampler","page":"Public API","title":"EpiAware.EpiInference.NUTSampler","text":"struct NUTSampler{A<:ADTypes.AbstractADType, E<:AbstractMCMC.AbstractMCMCEnsemble, M} <: AbstractEpiSamplingMethod\n\nA NUTS method for sampling from a DynamicPPL.Model object.\n\nThe NUTSampler struct represents using the No-U-Turn Sampler (NUTS) to sample from the distribution defined by a DynamicPPL.Model.\n\n\n\nFields\n\ntarget_acceptance::Float64: The target acceptance rate for the sampler.\nadtype::ADTypes.AbstractADType: The automatic differentiation type used for computing gradients.\nmcmc_parallel::AbstractMCMC.AbstractMCMCEnsemble: The parallelization strategy for the MCMC sampler.\nnchains::Int64: The number of MCMC chains to run.\nmax_depth::Int64: Tree depth limit for the NUTS sampler.\nΔ_max::Float64: Divergence threshold for the NUTS sampler.\ninit_ϵ::Float64: The initial step size for the NUTS sampler.\nndraws::Int64: The number of samples to draw from each chain.\nmetricT::Any: The metric type to use for the HMC sampler.\n\n\n\n\n\n","category":"type"},{"location":"lib/EpiInference/public/#EpiAware.EpiInference.manypathfinder-Tuple{DynamicPPL.Model, Any}","page":"Public API","title":"EpiAware.EpiInference.manypathfinder","text":"manypathfinder(\n mdl::DynamicPPL.Model,\n ndraws;\n nruns,\n maxiters,\n max_tries,\n kwargs...\n) -> Any\n\n\nRun multiple instances of the pathfinder algorithm and returns the pathfinder run with the largest ELBO estimate.\n\nArguments\n\nmdl::DynamicPPL.Model: The model to perform inference on.\nnruns::Int: The number of pathfinder runs to perform.\nndraws::Int: The number of draws per pathfinder run, readjusted to be at least as large as the number of chains.\nnchains::Int: The number of chains that will be initialised by pathfinder draws.\nmaxiters::Int: The maximum number of optimizer iterations per pathfinder run.\nmax_tries::Int: The maximum number of extra tries to find a valid pathfinder result.\nkwargs...: Additional keyword arguments passed to pathfinder.\n\nReturns\n\nbest_pfs::PathfinderResult: Best pathfinder result by estimated ELBO.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiLatentModels/public/#Public-Documentation","page":"Public API","title":"Public Documentation","text":"","category":"section"},{"location":"lib/EpiLatentModels/public/","page":"Public API","title":"Public API","text":"Documentation for EpiLatentModels.jl's public interface.","category":"page"},{"location":"lib/EpiLatentModels/public/","page":"Public API","title":"Public API","text":"See the Internals section of the manual for internal package docs covering all submodules.","category":"page"},{"location":"lib/EpiLatentModels/public/#Contents","page":"Public API","title":"Contents","text":"","category":"section"},{"location":"lib/EpiLatentModels/public/","page":"Public API","title":"Public API","text":"Pages = [\"public.md\"]\nDepth = 2:2","category":"page"},{"location":"lib/EpiLatentModels/public/#Index","page":"Public API","title":"Index","text":"","category":"section"},{"location":"lib/EpiLatentModels/public/","page":"Public API","title":"Public API","text":"Pages = [\"public.md\"]","category":"page"},{"location":"lib/EpiLatentModels/public/#Public-API","page":"Public API","title":"Public API","text":"","category":"section"},{"location":"lib/EpiLatentModels/public/","page":"Public API","title":"Public API","text":"Modules = [EpiAware.EpiLatentModels]\nPrivate = false","category":"page"},{"location":"lib/EpiLatentModels/public/#EpiAware.EpiLatentModels","page":"Public API","title":"EpiAware.EpiLatentModels","text":"Module for defining latent models.\n\n\n\n\n\n","category":"module"},{"location":"lib/EpiLatentModels/public/#EpiAware.EpiLatentModels.AR","page":"Public API","title":"EpiAware.EpiLatentModels.AR","text":"struct AR{D<:Distributions.Sampleable, S<:Distributions.Sampleable, I<:Distributions.Sampleable, P<:Int64} <: AbstractTuringLatentModel\n\nThe autoregressive (AR) model struct.\n\nConstructors\n\nAR(damp_prior::Distribution, std_prior::Distribution, init_prior::Distribution; p::Int = 1): Constructs an AR model with the specified prior distributions for damping coefficients, standard deviation, and initial conditions. The order of the AR model can also be specified.\nAR(; damp_priors::Vector{D} = [truncated(Normal(0.0, 0.05))], std_prior::Distribution = truncated(Normal(0.0, 0.05), 0.0, Inf), init_priors::Vector{I} = [Normal()]) where {D <: Distribution, I <: Distribution}: Constructs an AR model with the specified prior distributions for damping coefficients, standard deviation, and initial conditions. The order of the AR model is determined by the length of the damp_priors vector.\nAR(damp_prior::Distribution, std_prior::Distribution, init_prior::Distribution, p::Int): Constructs an AR model with the specified prior distributions for damping coefficients, standard deviation, and initial conditions. The order of the AR model is explicitly specified.\n\nExamples\n\nusing Distributions\nusing EpiAware\nar = AR()\nar_model = generate_latent(ar, 10)\nrand(ar_model)\n\n\n\nFields\n\ndamp_prior::Distributions.Sampleable: Prior distribution for the damping coefficients.\nstd_prior::Distributions.Sampleable: Prior distribution for the standard deviation.\ninit_prior::Distributions.Sampleable: Prior distribution for the initial conditions\np::Int64: Order of the AR model.\n\n\n\n\n\n","category":"type"},{"location":"lib/EpiLatentModels/public/#EpiAware.EpiLatentModels.BroadcastLatentModel","page":"Public API","title":"EpiAware.EpiLatentModels.BroadcastLatentModel","text":"struct BroadcastLatentModel{M<:AbstractTuringLatentModel, P<:Integer, B<:AbstractBroadcastRule} <: AbstractTuringLatentModel\n\nThe BroadcastLatentModel struct represents a latent model that supports broadcasting of latent periods.\n\nConstructors\n\nBroadcastLatentModel(;model::M; period::Int, broadcast_rule::B): Constructs a BroadcastLatentModel with the given model, period, and broadcast_rule.\nBroadcastLatentModel(model::M, period::Int, broadcast_rule::B): An alternative constructor that allows the model, period, and broadcast_rule to be specified without keyword arguments.\n\nExamples\n\nusing EpiAware, Turing\neach_model = BroadcastLatentModel(RandomWalk(), 7, RepeatEach())\ngen_each_model = generate_latent(each_model, 10)\nrand(gen_each_model)\n\nblock_model = BroadcastLatentModel(RandomWalk(), 3, RepeatBlock())\ngen_block_model = generate_latent(block_model, 10)\nrand(gen_block_model)\n\n\n\nFields\n\nmodel::AbstractTuringLatentModel: The underlying latent model.\nperiod::Integer: The period of the broadcast.\nbroadcast_rule::AbstractBroadcastRule: The broadcast rule to be applied.\n\n\n\n\n\n","category":"type"},{"location":"lib/EpiLatentModels/public/#EpiAware.EpiLatentModels.CombineLatentModels","page":"Public API","title":"EpiAware.EpiLatentModels.CombineLatentModels","text":"struct CombineLatentModels{M<:(AbstractVector{<:AbstractTuringLatentModel}), P<:(AbstractVector{<:String})} <: AbstractTuringLatentModel\n\nThe CombineLatentModels struct.\n\nThis struct is used to combine multiple latent models into a single latent model. If a prefix is supplied wraps each model with PrefixLatentModel.\n\nConstructors\n\nCombineLatentModels(models::M, prefixes::P) where {M <: AbstractVector{<:AbstractTuringLatentModel}, P <: AbstractVector{<:String}}: Constructs a CombineLatentModels instance with specified models and prefixes, ensuring that there are at least two models and the number of models and prefixes are equal.\nCombineLatentModels(models::M) where {M <: AbstractVector{<:AbstractTuringLatentModel}}: Constructs a CombineLatentModels instance with specified models, automatically generating prefixes for each model. The\n\nautomatic prefixes are of the form Combine.1, Combine.2, etc.\n\nExamples\n\nusing EpiAware, Distributions\ncombined_model = CombineLatentModels([Intercept(Normal(2, 0.2)), AR()])\nlatent_model = generate_latent(combined_model, 10)\nlatent_model()\n\n\n\nFields\n\nmodels::AbstractVector{<:AbstractTuringLatentModel}: A vector of latent models\nprefixes::AbstractVector{<:String}: A vector of prefixes for the latent models\n\n\n\n\n\n","category":"type"},{"location":"lib/EpiLatentModels/public/#EpiAware.EpiLatentModels.ConcatLatentModels","page":"Public API","title":"EpiAware.EpiLatentModels.ConcatLatentModels","text":"struct ConcatLatentModels{M<:(AbstractVector{<:AbstractTuringLatentModel}), N<:Int64, F<:Function, P<:(AbstractVector{<:String})} <: AbstractTuringLatentModel\n\nThe ConcatLatentModels struct.\n\nThis struct is used to concatenate multiple latent models into a single latent model.\n\nConstructors\n\nConcatLatentModels(models::M, no_models::I, dimension_adaptor::F, prefixes::P) where {M <: AbstractVector{<:AbstractTuringLatentModel}, I <: Int, F <: Function, P <: AbstractVector{String}}: Constructs a ConcatLatentModels instance with specified models, number of models, dimension adaptor, and prefixes.\nConcatLatentModels(models::M, dimension_adaptor::F; prefixes::P = \"Concat.\" * string.(1:length(models))) where {M <: AbstractVector{<:AbstractTuringLatentModel}, F <: Function}: Constructs a ConcatLatentModels instance with specified models and dimension adaptor. The number of models is automatically determined as are the prefixes (of the form Concat.1, Concat.2, etc.) by default.\nConcatLatentModels(models::M; dimension_adaptor::Function, prefixes::P) where {M <: AbstractVector{<:AbstractTuringLatentModel}, P <: AbstractVector{String}}: Constructs a ConcatLatentModels instance with specified models, dimension adaptor, prefixes, and automatically determines the number of models.The default dimension adaptor is equal_dimensions. The default prefixes are of the form Concat.1, Concat.2, etc.\nConcatLatentModels(; models::M, dimension_adaptor::Function, prefixes::P) where {M <: AbstractVector{<:AbstractTuringLatentModel}, P <: AbstractVector{String}}: Constructs a ConcatLatentModels instance with specified models, dimension adaptor, prefixes, and automatically determines the number of models. The default dimension adaptor is equal_dimensions. The default prefixes are of the form Concat.1, Concat.2, etc.\n\nExamples\n\nusing EpiAware, Distributions\ncombined_model = ConcatLatentModels([Intercept(Normal(2, 0.2)), AR()])\nlatent_model = generate_latent(combined_model, 10)\nlatent_model()\n\n\n\nFields\n\nmodels::AbstractVector{<:AbstractTuringLatentModel}: A vector of latent models\nno_models::Int64: The number of models in the collection\ndimension_adaptor::Function: The dimension function for the latent variables. By default this divides the number of latent variables by the number of models and returns a vector of dimensions rounding up the first element and rounding down the rest.\nprefixes::AbstractVector{<:String}: A vector of prefixes for the latent models\n\n\n\n\n\n","category":"type"},{"location":"lib/EpiLatentModels/public/#EpiAware.EpiLatentModels.DiffLatentModel","page":"Public API","title":"EpiAware.EpiLatentModels.DiffLatentModel","text":"struct DiffLatentModel{M<:AbstractTuringLatentModel, P<:Distributions.Distribution} <: AbstractTuringLatentModel\n\nModel the latent process as a d-fold differenced version of another process.\n\nMathematical specification\n\nLet Delta be the differencing operator. If tildeZ_t is a realisation of undifferenced latent model supplied to DiffLatentModel, then the differenced process is given by,\n\nDelta^(d) Z_t = tildeZ_t quad t = d+1 ldots\n\nWe can recover Z_t by applying the inverse differencing operator Delta^-1, which corresponds to the cumulative sum operator cumsum in Julia, d-times. The d initial terms Z_1 ldots Z_d are inferred.\n\nConstructors\n\nDiffLatentModel(latent_model, init_prior_distribution::Distribution; d::Int) Constructs a DiffLatentModel for d-fold differencing with latent_model as the undifferenced latent process. All initial terms have common prior init_prior_distribution.\nDiffLatentModel(;model, init_priors::Vector{D} where {D <: Distribution}) Constructs a DiffLatentModel for d-fold differencing with latent_model as the undifferenced latent process. The d initial terms have priors given by the vector init_priors, therefore length(init_priors) sets d.\n\nExample usage with generate_latent\n\ngenerate_latent can be used to construct a Turing model for the differenced latent process. In this example, the underlying undifferenced process is a RandomWalk model.\n\nFirst, we construct a RandomWalk struct with an initial value prior and a step size standard deviation prior.\n\nusing Distributions, EpiAware\nrw = RandomWalk(Normal(0.0, 1.0), truncated(Normal(0.0, 0.05), 0.0, Inf))\n\nThen, we can use DiffLatentModel to construct a DiffLatentModel for d-fold differenced process with rw as the undifferenced latent process.\n\nWe have two constructor options for DiffLatentModel. The first option is to supply a common prior distribution for the initial terms and specify d as follows:\n\ndiff_model = DiffLatentModel(rw, Normal(); d = 2)\n\nOr we can supply a vector of priors for the initial terms and d is inferred as follows:\n\ndiff_model2 = DiffLatentModel(;undiffmodel = rw, init_priors = [Normal(), Normal()])\n\nThen, we can use generate_latent to construct a Turing model for the differenced latent process generating a length n process,\n\n# Construct a Turing model\nn = 100\ndifference_mdl = generate_latent(diff_model, n)\n\nNow we can use the Turing PPL API to sample underlying parameters and generate the unobserved latent process.\n\n#Sample random parameters from prior\nθ = rand(difference_mdl)\n#Get a sampled latent process as a generated quantity from the model\n(Z_t, _) = generated_quantities(difference_mdl, θ)\nZ_t\n\n\n\nFields\n\nmodel::AbstractTuringLatentModel: Underlying latent model for the differenced process\ninit_prior::Distributions.Distribution: The prior distribution for the initial latent variables.\nd::Int64: Number of times differenced.\n\n\n\n\n\n","category":"type"},{"location":"lib/EpiLatentModels/public/#EpiAware.EpiLatentModels.FixedIntercept","page":"Public API","title":"EpiAware.EpiLatentModels.FixedIntercept","text":"struct FixedIntercept{F<:Real} <: AbstractTuringIntercept\n\nA variant of the Intercept struct that represents a fixed intercept value for a latent model.\n\nConstructors\n\nFixedIntercept(intercept) : Constructs a FixedIntercept instance with the specified intercept value.\nFixedIntercept(; intercept) : Constructs a FixedIntercept instance with the specified intercept value using named arguments.\n\nExamples\n\nusing EpiAware\nfi = FixedIntercept(2.0)\nfi_model = generate_latent(fi, 10)\nfi_model()\n\n\n\nFields\n\nintercept::Real\n\n\n\n\n\n","category":"type"},{"location":"lib/EpiLatentModels/public/#EpiAware.EpiLatentModels.HierarchicalNormal","page":"Public API","title":"EpiAware.EpiLatentModels.HierarchicalNormal","text":"struct HierarchicalNormal{R<:Real, D<:Distributions.Sampleable} <: AbstractTuringLatentModel\n\nThe HierarchicalNormal struct represents a non-centered hierarchical normal distribution.\n\nConstructors\n\nHierarchicalNormal(mean, std_prior): Constructs a HierarchicalNormal instance with the specified mean and standard deviation prior.\nHierarchicalNormal(; mean = 0.0, std_prior = truncated(Normal(0,1), 0, Inf)): Constructs a HierarchicalNormal instance with the specified mean and standard deviation prior using named arguments and with default values.\n\nExamples\n\nusing Distributions, EpiAware\nhnorm = HierarchicalNormal(0.0, truncated(Normal(0, 1), 0, Inf))\nhnorm_model = generate_latent(hnorm, 10)\nhnorm_model()\n\n\n\nFields\n\nmean::Real\nstd_prior::Distributions.Sampleable\n\n\n\n\n\n","category":"type"},{"location":"lib/EpiLatentModels/public/#EpiAware.EpiLatentModels.Intercept","page":"Public API","title":"EpiAware.EpiLatentModels.Intercept","text":"struct Intercept{D<:Distributions.Sampleable} <: AbstractTuringIntercept\n\nThe Intercept struct is used to model the intercept of a latent process. It broadcasts a single intercept value to a length n latent process.\n\nConstructors\n\nIntercept(intercept_prior)\nIntercept(; intercept_prior)\n\nExamples\n\nusing Distributions, Turing, EpiAware\nint = Intercept(Normal(0, 1))\nint_model = generate_latent(int, 10)\nrand(int_model)\nint_model()\n\n\n\nFields\n\nintercept_prior::Distributions.Sampleable: Prior distribution for the intercept.\n\n\n\n\n\n","category":"type"},{"location":"lib/EpiLatentModels/public/#EpiAware.EpiLatentModels.PrefixLatentModel","page":"Public API","title":"EpiAware.EpiLatentModels.PrefixLatentModel","text":"struct PrefixLatentModel{M<:AbstractTuringLatentModel, P<:String} <: AbstractTuringLatentModel\n\nGenerate a latent model with a prefix. A lightweight wrapper around `EpiAwareUtils.prefix_submodel`.\n\n# Constructors\n- `PrefixLatentModel(model::M, prefix::P)`: Create a `PrefixLatentModel` with the latent model `model` and the prefix `prefix`.\n- `PrefixLatentModel(; model::M, prefix::P)`: Create a `PrefixLatentModel` with the latent model `model` and the prefix `prefix`.\n\n# Examples\n```julia\nusing EpiAware\nlatent_model = PrefixLatentModel(model = HierarchicalNormal(), prefix = \"Test\")\nmdl = generate_latent(latent_model, 10)\nrand(mdl)\n```\n\n\n\nFields\n\nmodel::AbstractTuringLatentModel: The latent model\nprefix::String: The prefix for the latent model\n\n\n\n\n\n","category":"type"},{"location":"lib/EpiLatentModels/public/#EpiAware.EpiLatentModels.RandomWalk","page":"Public API","title":"EpiAware.EpiLatentModels.RandomWalk","text":"struct RandomWalk{D<:Distributions.Sampleable, S<:Distributions.Sampleable} <: AbstractTuringLatentModel\n\nModel latent process Z_t as a random walk.\n\nMathematical specification\n\nThe random walk Z_t is specified as a parameteric transformation of the white noise sequence (epsilon_t)_tgeq 1,\n\nZ_t = Z_0 + sigma sum_i = 1^t epsilon_t\n\nConstructing a random walk requires specifying:\n\nAn init_prior as a prior for Z_0. Default is Normal().\nA std_prior for sigma. The default is HalfNormal with a mean of 0.25.\n\nConstructors\n\nRandomWalk(; init_prior, std_prior)\n\nExample usage with generate_latent\n\ngenerate_latent can be used to construct a Turing model for the random walk Z_t.\n\nFirst, we construct a RandomWalk struct with priors,\n\nusing Distributions, Turing, EpiAware\n\n# Create a RandomWalk model\nrw = RandomWalk(init_prior = Normal(2., 1.),\n std_prior = HalfNormal(0.1))\n\nThen, we can use generate_latent to construct a Turing model for a 10 step random walk.\n\n# Construct a Turing model\nrw_model = generate_latent(rw, 10)\n\nNow we can use the Turing PPL API to sample underlying parameters and generate the unobserved infections.\n\n#Sample random parameters from prior\nθ = rand(rw_model)\n#Get random walk sample path as a generated quantities from the model\nZ_t, _ = generated_quantities(rw_model, θ)\n\n\n\nFields\n\ninit_prior::Distributions.Sampleable\nstd_prior::Distributions.Sampleable\n\n\n\n\n\n","category":"type"},{"location":"lib/EpiLatentModels/public/#EpiAware.EpiLatentModels.RepeatBlock","page":"Public API","title":"EpiAware.EpiLatentModels.RepeatBlock","text":"struct RepeatBlock <: AbstractBroadcastRule\n\nRepeatBlock is a struct that represents a broadcasting rule. It is a subtype of AbstractBroadcastRule.\n\nIt repeats the latent process in blocks of size period. An example of this rule is to repeat the latent process in blocks of size 7 to model a weekly process (though for this we also provide the broadcast_weekly helper function).\n\nExamples\n\nusing EpiAware\nrule = RepeatBlock()\nlatent = [1, 2, 3, 4, 5]\nn = 10\nperiod = 2\nbroadcast_rule(rule, latent, n, period)\n\n\n\nFields\n\n\n\n\n\n","category":"type"},{"location":"lib/EpiLatentModels/public/#EpiAware.EpiLatentModels.RepeatEach","page":"Public API","title":"EpiAware.EpiLatentModels.RepeatEach","text":"struct RepeatEach <: AbstractBroadcastRule\n\nRepeatEach is a struct that represents a broadcasting rule. It is a subtype of AbstractBroadcastRule.\n\nIt repeats the latent process at each period. An example of this rule is to repeat the latent process at each day of the week (though for this we also provide the dayofweek helper function).\n\nExamples\n\nusing EpiAware\nrule = RepeatEach()\nlatent = [1, 2, 3]\nn = 10\nperiod = 2\nbroadcast_rule(rule, latent, n, period)\n\n\n\nFields\n\n\n\n\n\n","category":"type"},{"location":"lib/EpiLatentModels/public/#EpiAware.EpiLatentModels.TransformLatentModel","page":"Public API","title":"EpiAware.EpiLatentModels.TransformLatentModel","text":"struct TransformLatentModel{M<:AbstractTuringLatentModel, F<:Function} <: AbstractTuringLatentModel\n\nThe TransformLatentModel struct represents a latent model that applies a transformation function to the latent variables generated by another latent model.\n\nConstructors\n\nTransformLatentModel(model, trans_function): Constructs a TransformLatentModel instance with the specified latent model and transformation function.\nTransformLatentModel(; model, trans_function): Constructs a TransformLatentModel instance with the specified latent model and transformation function using named arguments.\n\nExample\n\nusing EpiAware, Distributions\ntrans = TransformLatentModel(Intercept(Normal(2, 0.2)), x -> x .|> exp)\ntrans_model = generate_latent(trans, 5)\ntrans_model()\n\n\n\nFields\n\nmodel::AbstractTuringLatentModel: The latent model to transform.\ntrans_function::Function: The transformation function.\n\n\n\n\n\n","category":"type"},{"location":"lib/EpiLatentModels/public/#EpiAware.EpiLatentModels.broadcast_dayofweek-Tuple{AbstractTuringLatentModel}","page":"Public API","title":"EpiAware.EpiLatentModels.broadcast_dayofweek","text":"broadcast_dayofweek(\n model::AbstractTuringLatentModel;\n link\n) -> BroadcastLatentModel{TransformLatentModel{M, EpiAware.EpiLatentModels.var\"#42#44\"}, Int64, RepeatEach} where M<:AbstractTuringLatentModel\n\n\nConstructs a BroadcastLatentModel appropriate for modelling the day of the week for a given AbstractTuringLatentModel.\n\nArguments\n\nmodel::AbstractTuringLatentModel: The latent model to be repeated.\nlink::Function: The link function to transform the latent model before broadcasting\n\nto periodic weekly. Default is x -> 7 * softmax(x) which implements constraint of the sum week effects to be 7.\n\nReturns\n\nBroadcastLatentModel: The broadcast latent model.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiLatentModels/public/#EpiAware.EpiLatentModels.broadcast_weekly-Tuple{AbstractTuringLatentModel}","page":"Public API","title":"EpiAware.EpiLatentModels.broadcast_weekly","text":"broadcast_weekly(\n model::AbstractTuringLatentModel\n) -> BroadcastLatentModel{<:AbstractTuringLatentModel, Int64, RepeatBlock}\n\n\nConstructs a BroadcastLatentModel appropriate for modelling piecewise constant weekly processes for a given AbstractTuringLatentModel.\n\nArguments\n\nmodel::AbstractTuringLatentModel: The latent model to be repeated.\n\nReturns\n\nBroadcastLatentModel: The broadcast latent model.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiLatentModels/public/#EpiAware.EpiLatentModels.equal_dimensions-Tuple{Int64, Int64}","page":"Public API","title":"EpiAware.EpiLatentModels.equal_dimensions","text":"equal_dimensions(n::Int64, m::Int64) -> Vector{Int64}\n\n\nReturn a vector of dimensions that are equal or as close as possible, given the total number of elements n and the number of dimensions m. The default dimension adaptor for ConcatLatentModels.\n\nArguments\n\nn::Int: The total number of elements.\nm::Int: The number of dimensions.\n\nReturns\n\ndims::AbstractVector{Int}: A vector of dimensions, where the first element is the ceiling of n / m and the remaining elements are the floor of n / m.\n\n\n\n\n\n","category":"method"},{"location":"getting-started/faq/#Frequently-asked-questions","page":"Frequently asked questions","title":"Frequently asked questions","text":"","category":"section"},{"location":"getting-started/faq/","page":"Frequently asked questions","title":"Frequently asked questions","text":"This page contains a list of frequently asked questions about the EpiAware package. If you have a question that is not answered here, please open a discussion on the GitHub repository.","category":"page"},{"location":"getting-started/faq/","page":"Frequently asked questions","title":"Frequently asked questions","text":"Pages = [\"lib/getting-started/faq.md\"]","category":"page"},{"location":"getting-started/faq/#Pluto-scripts","page":"Frequently asked questions","title":"Pluto scripts","text":"","category":"section"},{"location":"getting-started/faq/","page":"Frequently asked questions","title":"Frequently asked questions","text":"We use Pluto.jl scripts as part of our documentation and testing. The scripts are located in docs/src/examples and can be run using the Pluto.jl package. We recommend using the version of Pluto that is pinned in the Project.toml file defining the documentation environment. An entry point to running or developing this documentation is the docs/pluto-scripts.sh bash shell script. Run this from the root directory of this repository.","category":"page"},{"location":"getting-started/explainers/latent-models/#Latent-models","page":"Latent models","title":"Latent models","text":"","category":"section"},{"location":"lib/internals/#Internal-Documentation","page":"Internal API","title":"Internal Documentation","text":"","category":"section"},{"location":"lib/internals/","page":"Internal API","title":"Internal API","text":"Documentation for EpiAware.jl's internal interface.","category":"page"},{"location":"lib/internals/#Contents","page":"Internal API","title":"Contents","text":"","category":"section"},{"location":"lib/internals/","page":"Internal API","title":"Internal API","text":"Pages = [\"internals.md\"]\nDepth = 2:2","category":"page"},{"location":"lib/internals/#Index","page":"Internal API","title":"Index","text":"","category":"section"},{"location":"lib/internals/","page":"Internal API","title":"Internal API","text":"Pages = [\"internals.md\"]","category":"page"},{"location":"lib/internals/#Internal-API","page":"Internal API","title":"Internal API","text":"","category":"section"},{"location":"lib/internals/","page":"Internal API","title":"Internal API","text":"Modules = [EpiAware]\nPublic = false","category":"page"},{"location":"getting-started/explainers/intro/#Introduction","page":"Introduction to EpiAware","title":"Introduction","text":"","category":"section"},{"location":"getting-started/explainers/intro/","page":"Introduction to EpiAware","title":"Introduction to EpiAware","text":"The diagram below shows the relationship between the modules in the package for a typical workflow.","category":"page"},{"location":"getting-started/explainers/intro/","page":"Introduction to EpiAware","title":"Introduction to EpiAware","text":"flowchart LR\n\nA[\"Underlying GI\nBijector\"]\n\nEpiModel[\"AbstractTuringEpiModel\n----------------------\nChoice of target\nfor latent process:\n\nDirectInfections\n ExpGrowthRate\n Renewal\"]\n\nInitModel[\"Priors for\ninitial scale of incidence\"]\n\nDataW[Data wrangling and QC]\n\n\nObsData[\"Observational Data\n---------------------\nObs. cases y_t\"]\n\nLatentProcPriors[\"Latent process priors\"]\n\nLatentProc[\"AbstractTuringLatentModel\n---------------------\nRandomWalk\"]\n\nObsModelPriors[\"Observation model priors\nchoice of delayed obs. model\"]\n\nObsModel[\"AbstractObservationModel\n---------------------\nDelayObservations\"]\n\nE[\"Turing model constructor\n---------------------\ngenerate_epiaware\"]\n\nG[Posterior draws]\nH[Posterior checking]\nI[Post-processing]\n\n\n\nA --> EpiData\nEpiData --> EpiModel\nInitModel --> EpiModel\nEpiModel -->E\nObsData-->E\nDataW-.->ObsData\nLatentProcPriors-->LatentProc\nLatentProc-->E\nObsModelPriors-->ObsModel\nObsModel-->E\n\n\nE-->|sample...NUTS...| G\nG-->H\nH-->I","category":"page"},{"location":"lib/EpiAwareBase/internals/#Internal-Documentation","page":"Internal API","title":"Internal Documentation","text":"","category":"section"},{"location":"lib/EpiAwareBase/internals/","page":"Internal API","title":"Internal API","text":"Documentation for EpiAwareBase.jl's internal interface.","category":"page"},{"location":"lib/EpiAwareBase/internals/#Contents","page":"Internal API","title":"Contents","text":"","category":"section"},{"location":"lib/EpiAwareBase/internals/#Contents-2","page":"Internal API","title":"Contents","text":"","category":"section"},{"location":"lib/EpiAwareBase/internals/","page":"Internal API","title":"Internal API","text":"Pages = [\"internals.md\"]\nDepth = 2:2","category":"page"},{"location":"lib/EpiAwareBase/internals/#Index","page":"Internal API","title":"Index","text":"","category":"section"},{"location":"lib/EpiAwareBase/internals/","page":"Internal API","title":"Internal API","text":"Pages = [\"internals.md\"]","category":"page"},{"location":"lib/EpiAwareBase/internals/","page":"Internal API","title":"Internal API","text":"Modules = [EpiAware.EpiAwareBase]\nPublic = false","category":"page"},{"location":"lib/EpiInfModels/internals/#Internal-Documentation","page":"Internal API","title":"Internal Documentation","text":"","category":"section"},{"location":"lib/EpiInfModels/internals/","page":"Internal API","title":"Internal API","text":"Documentation for EpiInfModels.jl's internal interface.","category":"page"},{"location":"lib/EpiInfModels/internals/#Contents","page":"Internal API","title":"Contents","text":"","category":"section"},{"location":"lib/EpiInfModels/internals/","page":"Internal API","title":"Internal API","text":"Pages = [\"internals.md\"]\nDepth = 2:2","category":"page"},{"location":"lib/EpiInfModels/internals/#Index","page":"Internal API","title":"Index","text":"","category":"section"},{"location":"lib/EpiInfModels/internals/","page":"Internal API","title":"Internal API","text":"Pages = [\"internals.md\"]","category":"page"},{"location":"lib/EpiInfModels/internals/#Internal-API","page":"Internal API","title":"Internal API","text":"","category":"section"},{"location":"lib/EpiInfModels/internals/","page":"Internal API","title":"Internal API","text":"Modules = [EpiAware.EpiInfModels]\nPublic = false","category":"page"},{"location":"lib/EpiInfModels/internals/#EpiAware.EpiAwareBase.generate_latent_infs-Tuple{AbstractTuringRenewal, Any}","page":"Internal API","title":"EpiAware.EpiAwareBase.generate_latent_infs","text":"generate_latent_infs(\n epi_model::AbstractTuringRenewal,\n _Rt\n) -> Any\n\n\nImplement the generate_latent_infs function for the Renewal model.\n\nExample usage with Renewal type of model for unobserved infection process\n\ngenerate_latent_infs can be used to construct a Turing model for the latent infections conditional on the sample path of a latent process. In this example, we generate a sample of a white noise latent process.\n\nFirst, we construct an Renewal struct with an EpiData object, an initialisation prior and a transformation function.\n\nusing Distributions, Turing, EpiAware\ngen_int = [0.2, 0.3, 0.5]\ng = exp\n\n# Create an EpiData object\ndata = EpiData(gen_int, g)\n\n# Create an Renewal model\nrenewal_model = Renewal(data = data, initialisation_prior = Normal())\n\nThen, we can use generate_latent_infs to construct a Turing model for the unobserved infection generation model set by the type of renewal_model.\n\n# Construct a Turing model\nZ_t = randn(100) * 0.05\nlatent_inf = generate_latent_infs(renewal_model, Z_t)\n\nNow we can use the Turing PPL API to sample underlying parameters and generate the unobserved infections.\n\n# Sample from the unobserved infections model\n\n#Sample random parameters from prior\nθ = rand(latent_inf)\n#Get unobserved infections as a generated quantities from the model\nI_t = generated_quantities(latent_inf, θ)\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiInfModels/internals/#EpiAware.EpiAwareBase.generate_latent_infs-Tuple{DirectInfections, Any}","page":"Internal API","title":"EpiAware.EpiAwareBase.generate_latent_infs","text":"generate_latent_infs(\n epi_model::DirectInfections,\n Z_t\n) -> Any\n\n\nImplement the generate_latent_infs function for the DirectInfections model.\n\nExample usage with DirectInfections type of model for unobserved infection process\n\nFirst, we construct a DirectInfections struct with an EpiData object, an initialisation prior and a transformation function.\n\nusing Distributions, Turing, EpiAware\ngen_int = [0.2, 0.3, 0.5]\ng = exp\n\n# Create an EpiData object\ndata = EpiData(gen_int, g)\n\n# Create a DirectInfections model\ndirect_inf_model = DirectInfections(data = data, initialisation_prior = Normal())\n\nThen, we can use generate_latent_infs to construct a Turing model for the unobserved infection generation model set by the type of direct_inf_model.\n\n# Construct a Turing model\nZ_t = randn(100)\nlatent_inf = generate_latent_infs(direct_inf_model, Z_t)\n\nNow we can use the Turing PPL API to sample underlying parameters and generate the unobserved infections.\n\n# Sample from the unobserved infections model\n\n#Sample random parameters from prior\nθ = rand(latent_inf)\n#Get unobserved infections as a generated quantities from the model\nI_t = generated_quantities(latent_inf, θ)\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiInfModels/internals/#EpiAware.EpiAwareBase.generate_latent_infs-Tuple{ExpGrowthRate, Any}","page":"Internal API","title":"EpiAware.EpiAwareBase.generate_latent_infs","text":"generate_latent_infs(epi_model::ExpGrowthRate, rt) -> Any\n\n\nImplement the generate_latent_infs function for the ExpGrowthRate model.\n\nExample usage with ExpGrowthRate type of model for unobserved infection process\n\ngenerate_latent_infs can be used to construct a Turing model for the latent infections conditional on the sample path of a latent process. In this example, we generate a sample of a white noise latent process.\n\nFirst, we construct an ExpGrowthRate struct with an EpiData object, an initialisation prior and a transformation function.\n\nusing Distributions, Turing, EpiAware\ngen_int = [0.2, 0.3, 0.5]\ng = exp\n\n# Create an EpiData object\ndata = EpiData(gen_int, g)\n\n# Create an ExpGrowthRate model\nexp_growth_model = ExpGrowthRate(data = data, initialisation_prior = Normal())\n\nThen, we can use generate_latent_infs to construct a Turing model for the unobserved infection generation model set by the type of direct_inf_model.\n\n# Construct a Turing model\nZ_t = randn(100) * 0.05\nlatent_inf = generate_latent_infs(exp_growth_model, Z_t)\n\nNow we can use the Turing PPL API to sample underlying parameters and generate the unobserved infections.\n\n# Sample from the unobserved infections model\n\n#Sample random parameters from prior\nθ = rand(latent_inf)\n#Get unobserved infections as a generated quantities from the model\nI_t = generated_quantities(latent_inf, θ)\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiInfModels/internals/#EpiAware.EpiInfModels.make_renewal_init-Tuple{Renewal, Any, Any}","page":"Internal API","title":"EpiAware.EpiInfModels.make_renewal_init","text":"make_renewal_init(epi_model::Renewal, I₀, Rt) -> Any\n\n\nCreate the initial vector of infected individuals for a renewal model.\n\nArguments\n\nepi_model::Renewal: The renewal model.\nI₀: The initial number of infected individuals.\nRt: The time-varying reproduction number.\n\nReturns\n\nThe initial vector of infected individuals.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiInfModels/internals/#EpiAware.EpiInfModels.make_renewal_init-Tuple{RenewalWithPopulation, Any, Any}","page":"Internal API","title":"EpiAware.EpiInfModels.make_renewal_init","text":"make_renewal_init(\n epi_model::RenewalWithPopulation,\n I₀,\n Rt\n) -> Tuple{Any, Float64}\n\n\nConstructs the initial conditions for a renewal model with population.\n\nArguments\n\nepi_model::RenewalWithPopulation: The renewal model with population.\nI₀: The initial number of infected individuals.\nRt: The time-varying reproduction number.\n\nReturns\n\nA tuple containing the initial number of infected individuals at each generation\n\ninterval and the population size of susceptible/available people.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiInfModels/internals/#EpiAware.EpiInfModels.neg_MGF-Tuple{Any, AbstractVector}","page":"Internal API","title":"EpiAware.EpiInfModels.neg_MGF","text":"neg_MGF(r, w::AbstractVector) -> Any\n\n\nCompute the negative moment generating function (MGF) for a given rate r and weights w.\n\nArguments\n\nr: The rate parameter.\nw: An abstract vector of weights.\n\nReturns\n\nThe value of the negative MGF.\n\n\n\n\n\n","category":"method"},{"location":"getting-started/explainers/interfaces/#Interfaces","page":"Interfaces","title":"Interfaces","text":"","category":"section"},{"location":"getting-started/explainers/interfaces/","page":"Interfaces","title":"Interfaces","text":"We support two primary workflows for using the package:","category":"page"},{"location":"getting-started/explainers/interfaces/","page":"Interfaces","title":"Interfaces","text":"EpiProblem: A high-level interface for defining and fitting models to data. This is the recommended way to use the package.\nTuring interface: A lower-level interface for defining and fitting models to data. This is the more flexible way to use the package and may also be more familiar to users of Turing.jl.","category":"page"},{"location":"getting-started/explainers/interfaces/","page":"Interfaces","title":"Interfaces","text":"See the getting started section for tutorials on each of these workflows.","category":"page"},{"location":"getting-started/explainers/interfaces/#EpiProblem","page":"Interfaces","title":"EpiProblem","text":"","category":"section"},{"location":"getting-started/explainers/interfaces/","page":"Interfaces","title":"Interfaces","text":"Each module of the overall epidemiological model we are interested in is a Turing Model in its own right. In this section, we compose the individual models into the full epidemiological model using the EpiProblem struct.","category":"page"},{"location":"getting-started/explainers/interfaces/","page":"Interfaces","title":"Interfaces","text":"The constructor for an EpiProblem requires:","category":"page"},{"location":"getting-started/explainers/interfaces/","page":"Interfaces","title":"Interfaces","text":"An epi_model.\nA latent_model.\nAn observation_model.\nA tspan.","category":"page"},{"location":"getting-started/explainers/interfaces/","page":"Interfaces","title":"Interfaces","text":"The tspan set the range of the time index for the models.","category":"page"},{"location":"getting-started/explainers/interfaces/#Turing-interface","page":"Interfaces","title":"Turing interface","text":"","category":"section"},{"location":"getting-started/explainers/interfaces/","page":"Interfaces","title":"Interfaces","text":"The Turing interface is a lower-level interface for defining and fitting models to data. This is the more flexible way to use the package and may also be more familiar to users of Turing.jl.","category":"page"},{"location":"getting-started/tutorials/#Tutorials","page":"Overview","title":"Tutorials","text":"","category":"section"},{"location":"getting-started/tutorials/","page":"Overview","title":"Overview","text":"This section contains tutorials that will help you get started with EpiAware for specific tasks. See the sidebar for the list of tutorials.","category":"page"},{"location":"overview/#overview","page":"Overview","title":"Overview of the EpiAware Software Ecosystem","text":"","category":"section"},{"location":"overview/","page":"Overview","title":"Overview","text":"EpiAware is not a standard toolkit for infectious disease modelling.","category":"page"},{"location":"overview/","page":"Overview","title":"Overview","text":"It seeks to be highly modular and composable for advanced users whilst still providing opinionated workflows for those who are new to the field. Developed by the authors behind other widely used infectious disease modelling packages such as EpiNow2, epinowcast, and epidist, alongside experts in infectious disease modelling in Julia,EpiAware is designed to go beyond the capabilities of these packages by providing a more flexible and extensible framework for modelling and inference of infectious disease dynamics.","category":"page"},{"location":"overview/#Package-Features","page":"Overview","title":"Package Features","text":"","category":"section"},{"location":"overview/","page":"Overview","title":"Overview","text":"Flexible: The package is designed to be flexible and extensible, and to provide a consistent interface for fitting and simulating models.\nModular: The package is designed to be modular, with a clear separation between the model and the data.\nExtensible: The package is designed to be extensible, with a clear separation between the model and the data.\nConsistent: The package is designed to provide a consistent interface for fitting and simulating models.\nEfficient: The package is designed to be efficient, with a clear separation between the model and the data.","category":"page"},{"location":"overview/#Package-structure","page":"Overview","title":"Package structure","text":"","category":"section"},{"location":"overview/","page":"Overview","title":"Overview","text":"EpiAware.jl is a wrapper around a series of submodules, each of which provides a different aspect of the package's functionality (much like the tidyverse in R). The package is designed to be modular, with a clear separation between modules and between modules and data. Currently included modules are:","category":"page"},{"location":"overview/","page":"Overview","title":"Overview","text":"EpiAwareBase: The core module, which provides the underlying abstract types and functions for the package.\nEpiAwareUtils: A utility module, which provides a series of utility functions for working with the package.\nEpiInference: An inference module, which provides a series of functions for fitting models to data. Builds on top of Turing.jl.\nEpiInfModels: Provides tools for composing models of the disease transmission process. Builds on top of Turing.jl, in particular the DynamicPPL.jl interface.\nEpiLatentModels: Provides tools for composing latent models such as random walks, autoregressive models, etc. Builds on top of DynamicPPL.jl. Used by all other modelling modules to define latent processes.\nEpiObsModels: Provides tools for composing observation models, such as Poisson, Binomial, etc. Builds on top of DynamicPPL.jl.","category":"page"},{"location":"overview/#Using-the-package","page":"Overview","title":"Using the package","text":"","category":"section"},{"location":"overview/","page":"Overview","title":"Overview","text":"We support two primary workflows for using the package:","category":"page"},{"location":"overview/","page":"Overview","title":"Overview","text":"EpiProblem: A high-level interface for defining and fitting models to data. This is the recommended way to use the package.\nTuring interface: A lower-level interface for defining and fitting models to data. This is the more flexible way to use the package and may also be more familiar to users of Turing.jl.","category":"page"},{"location":"overview/","page":"Overview","title":"Overview","text":"See the getting started section for tutorials on each of these workflows.","category":"page"},{"location":"lib/EpiAwareUtils/internals/#Internal-Documentation","page":"Internal API","title":"Internal Documentation","text":"","category":"section"},{"location":"lib/EpiAwareUtils/internals/","page":"Internal API","title":"Internal API","text":"Documentation for EpiAwareUtils.jl's internal interface.","category":"page"},{"location":"lib/EpiAwareUtils/internals/#Contents","page":"Internal API","title":"Contents","text":"","category":"section"},{"location":"lib/EpiAwareUtils/internals/","page":"Internal API","title":"Internal API","text":"Pages = [\"internals.md\"]\nDepth = 2:2","category":"page"},{"location":"lib/EpiAwareUtils/internals/#Index","page":"Internal API","title":"Index","text":"","category":"section"},{"location":"lib/EpiAwareUtils/internals/","page":"Internal API","title":"Internal API","text":"Pages = [\"internals.md\"]","category":"page"},{"location":"lib/EpiAwareUtils/internals/#Internal-API","page":"Internal API","title":"Internal API","text":"","category":"section"},{"location":"lib/EpiAwareUtils/internals/","page":"Internal API","title":"Internal API","text":"Modules = [EpiAware.EpiAwareUtils]\nPublic = false","category":"page"},{"location":"lib/EpiAwareUtils/internals/#EpiAware.EpiAwareBase._apply_method","page":"Internal API","title":"EpiAware.EpiAwareBase._apply_method","text":"_apply_method(\n model::DynamicPPL.Model,\n method::DirectSample;\n ...\n) -> Any\n_apply_method(\n model::DynamicPPL.Model,\n method::DirectSample,\n prev_result;\n kwargs...\n) -> Any\n\n\nImplements direct sampling from a Turing model.\n\n\n\n\n\n","category":"function"},{"location":"lib/EpiAwareUtils/internals/#EpiAware.EpiAwareBase._apply_method-2","page":"Internal API","title":"EpiAware.EpiAwareBase._apply_method","text":"_apply_method(\n model::DynamicPPL.Model,\n method::AbstractEpiMethod;\n ...\n) -> Any\n_apply_method(\n model::DynamicPPL.Model,\n method::AbstractEpiMethod,\n prev_result;\n kwargs...\n) -> Any\n\n\nApply the inference/generative method method to the Model object mdl.\n\nArguments\n\nmodel::AbstractEpiModel: The model to apply the method to.\nmethod::AbstractEpiMethod: The epidemiological method to apply.\nprev_result: The previous result of the method.\nkwargs: Additional keyword arguments passed to the method.\n\nReturns\n\nnothing: If no concrete implementation is defined for the given method.\n\n\n\n\n\n","category":"function"},{"location":"lib/EpiAwareUtils/internals/#EpiAware.EpiAwareBase._apply_method-Tuple{DynamicPPL.Model, EpiMethod, Any}","page":"Internal API","title":"EpiAware.EpiAwareBase._apply_method","text":"_apply_method(\n model::DynamicPPL.Model,\n method::EpiMethod,\n prev_result;\n kwargs...\n) -> Any\n\n\nApply steps defined by an EpiMethod to a model object.\n\nThis function applies the steps defined by an EpiMethod object to a Model object. It iterates over the pre-sampler steps defined in the EpiMethod object and recursively applies them to the model. Finally, it applies the sampler step defined in the EpiMethod object to the model. The prev_result argument is used to pass the result obtained from applying the previous steps, if any.\n\nArguments\n\nmethod::EpiMethod: The EpiMethod object containing the steps to be applied.\nmodel::Model: The model object to which the steps will be applied.\nprev_result: The previous result obtained from applying the steps. Defaults to nothing.\nkwargs...: Additional keyword arguments that can be passed to the steps.\n\nReturns\n\nprev_result: The result obtained after applying the steps.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiAwareUtils/internals/#EpiAware.EpiAwareBase._apply_method-Tuple{DynamicPPL.Model, EpiMethod}","page":"Internal API","title":"EpiAware.EpiAwareBase._apply_method","text":"_apply_method(\n model::DynamicPPL.Model,\n method::EpiMethod;\n kwargs...\n) -> Any\n\n\nApply a method to a mode without previous results\n\nArguments\n\nmodel::Model: The model to apply the method to.\nmethod::EpiMethod: The method to apply.\nkwargs...: Additional keyword arguments.\n\nReturns\n\nThe result of applying the method to the model.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiAwareUtils/internals/#EpiAware.EpiAwareBase.condition_model-Tuple{DynamicPPL.Model, NamedTuple, NamedTuple}","page":"Internal API","title":"EpiAware.EpiAwareBase.condition_model","text":"condition_model(\n model::DynamicPPL.Model,\n fix_parameters::NamedTuple,\n condition_parameters::NamedTuple\n) -> Any\n\n\nApply the condition to the model by fixing the specified parameters and conditioning on the others.\n\nArguments\n\nmodel::Model: The model to be conditioned.\nfix_parameters::NamedTuple: The parameters to be fixed.\ncondition_parameters::NamedTuple: The parameters to be conditioned on.\n\nReturns\n\n_model: The conditioned model.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiAwareUtils/internals/#EpiAware.EpiAwareBase.generate_epiaware-Tuple{Any, Any, AbstractTuringEpiModel}","page":"Internal API","title":"EpiAware.EpiAwareBase.generate_epiaware","text":"generate_epiaware(\n y_t,\n time_steps,\n epi_model::AbstractTuringEpiModel;\n latent_model,\n observation_model\n)\n\n\nGenerate an epi-aware model given the observed data and model specifications.\n\nArguments\n\ny_t: Observed data.\ntime_steps: Number of time steps.\nepi_model: A Turing Epi model specification.\nlatent_model: A Turing Latent model specification.\nobservation_model: A Turing Observation model specification.\n\nReturns\n\nA DynamicPPPL.Model object.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiAwareUtils/internals/#EpiAware.EpiAwareBase.generated_observables-Tuple{DynamicPPL.Model, Any, Union{NamedTuple, MCMCChains.Chains}}","page":"Internal API","title":"EpiAware.EpiAwareBase.generated_observables","text":"generated_observables(\n model::DynamicPPL.Model,\n data,\n solution::Union{NamedTuple, MCMCChains.Chains}\n) -> EpiAwareObservables\n\n\nGenerate observables from a given model and solution including generated quantities.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiAwareUtils/internals/#EpiAware.EpiAwareUtils._apply_direct_sample-Tuple{Any, Any, Int64}","page":"Internal API","title":"EpiAware.EpiAwareUtils._apply_direct_sample","text":"_apply_direct_sample(\n model,\n method,\n n_samples::Int64;\n kwargs...\n) -> Any\n\n\nSample the model directly using Turing.Prior() and a NamedTuple of the sampled random variables along with generated quantities.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiAwareUtils/internals/#EpiAware.EpiAwareUtils._apply_direct_sample-Tuple{Any, Any, Nothing}","page":"Internal API","title":"EpiAware.EpiAwareUtils._apply_direct_sample","text":"_apply_direct_sample(\n model,\n method,\n n_samples::Nothing\n) -> Any\n\n\nSample the model directly using rand and return a single set of sampled random variables.\n\n\n\n\n\n","category":"method"},{"location":"#EpiAware.jl","page":"EpiAware.jl: Real-time infectious disease monitoring","title":"EpiAware.jl","text":"","category":"section"},{"location":"","page":"EpiAware.jl: Real-time infectious disease monitoring","title":"EpiAware.jl: Real-time infectious disease monitoring","text":"Infectious disease situational awareness modelling toolkit for Julia.","category":"page"},{"location":"#Where-to-start","page":"EpiAware.jl: Real-time infectious disease monitoring","title":"Where to start","text":"","category":"section"},{"location":"","page":"EpiAware.jl: Real-time infectious disease monitoring","title":"EpiAware.jl: Real-time infectious disease monitoring","text":"Want to get started running code? Check out the Getting Started Tutorials.\nWhat is EpiAware? Check out our Overview.\nWant to see some end-to-end examples? Check out our EpiAware showcase.\nWant to understand the API? Check out our API Reference.\nWant to chat with someone about EpiAware? Post on our GitHub Discussions.\nWant to contribute to EpiAware? Check out our Developer documentation.\nWant to see our code? Check out our GitHub Repository.","category":"page"},{"location":"lib/EpiInfModels/public/#Public-Documentation","page":"Public API","title":"Public Documentation","text":"","category":"section"},{"location":"lib/EpiInfModels/public/","page":"Public API","title":"Public API","text":"Documentation for EpiInfModels.jl's public interface.","category":"page"},{"location":"lib/EpiInfModels/public/","page":"Public API","title":"Public API","text":"See the Internals section of the manual for internal package docs covering all submodules.","category":"page"},{"location":"lib/EpiInfModels/public/#Contents","page":"Public API","title":"Contents","text":"","category":"section"},{"location":"lib/EpiInfModels/public/","page":"Public API","title":"Public API","text":"Pages = [\"public.md\"]\nDepth = 2:2","category":"page"},{"location":"lib/EpiInfModels/public/#Index","page":"Public API","title":"Index","text":"","category":"section"},{"location":"lib/EpiInfModels/public/","page":"Public API","title":"Public API","text":"Pages = [\"public.md\"]","category":"page"},{"location":"lib/EpiInfModels/public/#Public-API","page":"Public API","title":"Public API","text":"","category":"section"},{"location":"lib/EpiInfModels/public/","page":"Public API","title":"Public API","text":"Modules = [EpiAware.EpiInfModels]\nPrivate = false","category":"page"},{"location":"lib/EpiInfModels/public/#EpiAware.EpiInfModels","page":"Public API","title":"EpiAware.EpiInfModels","text":"Module for defining epidemiological models.\n\n\n\n\n\n","category":"module"},{"location":"lib/EpiInfModels/public/#EpiAware.EpiInfModels.DirectInfections","page":"Public API","title":"EpiAware.EpiInfModels.DirectInfections","text":"struct DirectInfections{S<:Distributions.Sampleable} <: AbstractTuringEpiModel\n\nModel unobserved/latent infections as a transformation on a sampled latent process.\n\nMathematical specification\n\nIf Z_t is a realisation of the latent model, then the unobserved/latent infections are given by\n\nI_t = g(hatI_0 + Z_t)\n\nwhere g is a transformation function and the unconstrained initial infections hatI_0 are sampled from a prior distribution.\n\nDirectInfections are constructed by passing an EpiData object data and an initialisation_prior for the prior distribution of hatI_0. The default initialisation_prior is Normal().\n\nConstructors\n\nDirectInfections(; data, initialisation_prior)\n\nExample usage with generate_latent_infs\n\ngenerate_latent_infs can be used to construct a Turing model for the latent infections conditional on the sample path of a latent process. In this example, we generate a sample of a white noise latent process.\n\nFirst, we construct a DirectInfections struct with an EpiData object, an initialisation prior and a transformation function.\n\nusing Distributions, Turing, EpiAware\ngen_int = [0.2, 0.3, 0.5]\ng = exp\n\n# Create an EpiData object\ndata = EpiData(gen_int, g)\n\n# Create a DirectInfections model\ndirect_inf_model = DirectInfections(data = data, initialisation_prior = Normal())\n\nThen, we can use generate_latent_infs to construct a Turing model for the unobserved infection generation model set by the type of direct_inf_model.\n\n# Construct a Turing model\nZ_t = randn(100)\nlatent_inf = generate_latent_infs(direct_inf_model, Z_t)\n\nNow we can use the Turing PPL API to sample underlying parameters and generate the unobserved infections.\n\n# Sample from the unobserved infections model\n\n#Sample random parameters from prior\nθ = rand(latent_inf)\n#Get unobserved infections as a generated quantities from the model\nI_t = generated_quantities(latent_inf, θ)\n\n\n\nFields\n\ndata::EpiData: Epidata object.\ninitialisation_prior::Distributions.Sampleable: Prior distribution for the initialisation of the infections. Default is Normal().\n\n\n\n\n\n","category":"type"},{"location":"lib/EpiInfModels/public/#EpiAware.EpiInfModels.EpiData","page":"Public API","title":"EpiAware.EpiInfModels.EpiData","text":"struct EpiData{T<:Real, F<:Function}\n\nThe EpiData struct represents epidemiological data used in infectious disease modeling.\n\nConstructors\n\nEpiData(gen_int, transformation::Function). Constructs an EpiData object with discrete\n\ngeneration interval gen_int and transformation function transformation.\n\nEpiData(;gen_distribution::ContinuousDistribution, D_gen, Δd = 1.0, transformation::Function = exp).\n\nConstructs an EpiData object with double interval censoring discretisation of the continuous next generation interval distribution gen_distribution with additional right truncation at D_gen. Δd sets the interval width (default = 1.0). transformation sets the transformation function\n\nExamples\n\nConstruction direct from discrete generation interval and transformation function:\n\nusing EpiAware\ngen_int = [0.2, 0.3, 0.5]\ng = exp\ndata = EpiData(gen_int, g)\n\nConstruction from continuous distribution for generation interval.\n\nusing Distributions\n\ngen_distribution = Uniform(0.0, 10.0)\n\ndata = EpiData(;gen_distribution\n D_gen = 10.0)\n\n\n\nFields\n\ngen_int::Vector{T} where T<:Real: Discrete generation interval.\nlen_gen_int::Integer: Length of the discrete generation interval.\ntransformation::Function: Transformation function defining constrained and unconstrained domain bijections.\n\n\n\n\n\n","category":"type"},{"location":"lib/EpiInfModels/public/#EpiAware.EpiInfModels.ExpGrowthRate","page":"Public API","title":"EpiAware.EpiInfModels.ExpGrowthRate","text":"struct ExpGrowthRate{S<:Distributions.Sampleable} <: AbstractTuringEpiModel\n\nModel unobserved/latent infections as due to time-varying exponential growth rate r_t which is generated by a latent process.\n\nMathematical specification\n\nIf Z_t is a realisation of the latent model, then the unobserved/latent infections are given by\n\nI_t = g(hatI_0) exp(Z_t)\n\nwhere g is a transformation function and the unconstrained initial infections hatI_0 are sampled from a prior distribution.\n\nExpGrowthRate are constructed by passing an EpiData object data and an initialisation_prior for the prior distribution of hatI_0. The default initialisation_prior is Normal().\n\nConstructor\n\nExpGrowthRate(; data, initialisation_prior).\n\nExample usage with generate_latent_infs\n\ngenerate_latent_infs can be used to construct a Turing model for the latent infections conditional on the sample path of a latent process. In this example, we generate a sample of a white noise latent process.\n\nFirst, we construct an ExpGrowthRate struct with an EpiData object, an initialisation prior and a transformation function.\n\nusing Distributions, Turing, EpiAware\ngen_int = [0.2, 0.3, 0.5]\ng = exp\n\n# Create an EpiData object\ndata = EpiData(gen_int, g)\n\n# Create an ExpGrowthRate model\nexp_growth_model = ExpGrowthRate(data = data, initialisation_prior = Normal())\n\nThen, we can use generate_latent_infs to construct a Turing model for the unobserved infection generation model set by the type of direct_inf_model.\n\n# Construct a Turing model\nZ_t = randn(100) * 0.05\nlatent_inf = generate_latent_infs(exp_growth_model, Z_t)\n\nNow we can use the Turing PPL API to sample underlying parameters and generate the unobserved infections.\n\n# Sample from the unobserved infections model\n\n#Sample random parameters from prior\nθ = rand(latent_inf)\n#Get unobserved infections as a generated quantities from the model\nI_t = generated_quantities(latent_inf, θ)\n\n\n\nFields\n\ndata::EpiData\ninitialisation_prior::Distributions.Sampleable\n\n\n\n\n\n","category":"type"},{"location":"lib/EpiInfModels/public/#EpiAware.EpiInfModels.Renewal","page":"Public API","title":"EpiAware.EpiInfModels.Renewal","text":"struct Renewal{S<:Distributions.Sampleable} <: AbstractTuringRenewal\n\nModel unobserved/latent infections as due to time-varying Renewal model with reproduction number mathcalR_t which is generated by a latent process.\n\nMathematical specification\n\nIf Z_t is a realisation of the latent model, then the unobserved/latent infections are given by\n\nbeginalign\nmathcalR_t = g(Z_t)\nI_t = mathcalR_t sum_i=1^n-1 I_t-i g_i qquad t geq 1 \nI_t = g(hatI_0) exp(r(mathcalR_1) t) qquad t leq 0\nendalign\n\nwhere g is a transformation function and the unconstrained initial infections hatI_0 are sampled from a prior distribution. The discrete generation interval is given by g_i.\n\nr(mathcalR_1) is the exponential growth rate implied by mathcalR_1) using the implicit relationship between the exponential growth rate and the reproduction number.\n\nmathcalR sum_j geq 1 g_j exp(- r j)= 1\n\nRenewal are constructed by passing an EpiData object data and an initialisation_prior for the prior distribution of hatI_0. The default initialisation_prior is Normal().\n\nConstructor\n\nRenewal(; data, initialisation_prior).\n\nExample usage with generate_latent_infs\n\ngenerate_latent_infs can be used to construct a Turing model for the latent infections conditional on the sample path of a latent process. In this example, we generate a sample of a white noise latent process.\n\nFirst, we construct an Renewal struct with an EpiData object, an initialisation prior and a transformation function.\n\nusing Distributions, Turing, EpiAware\ngen_int = [0.2, 0.3, 0.5]\ng = exp\n\n# Create an EpiData object\ndata = EpiData(gen_int, g)\n\n# Create an Renewal model\nrenewal_model = Renewal(data = data, initialisation_prior = Normal())\n\nThen, we can use generate_latent_infs to construct a Turing model for the unobserved infection generation model set by the type of direct_inf_model.\n\n# Construct a Turing model\nZ_t = randn(100) * 0.05\nlatent_inf = generate_latent_infs(renewal_model, Z_t)\n\nNow we can use the Turing PPL API to sample underlying parameters and generate the unobserved infections.\n\n# Sample from the unobserved infections model\n\n#Sample random parameters from prior\nθ = rand(latent_inf)\n#Get unobserved infections as a generated quantities from the model\nI_t = generated_quantities(latent_inf, θ)\n\n\n\nFields\n\ndata::EpiData\ninitialisation_prior::Distributions.Sampleable\n\n\n\n\n\n","category":"type"},{"location":"lib/EpiInfModels/public/#EpiAware.EpiInfModels.Renewal-Tuple{Any, Any}","page":"Public API","title":"EpiAware.EpiInfModels.Renewal","text":"function (epi_model::Renewal)(recent_incidence, Rt)\n\nCallable on a Renewal struct for compute new incidence based on recent incidence and Rt.\n\nMathematical specification\n\nThe new incidence is given by\n\nI_t = R_t sum_i=1^n-1 I_t-i g_i\n\nwhere I_t is the new incidence, R_t is the reproduction number, I_{t-i} is the recent incidence and g_i is the generation interval.\n\nArguments\n\nrecent_incidence: Array of recent incidence values.\nRt: Reproduction number.\n\nReturns\n\nTuple containing the updated incidence array and the new incidence value.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiInfModels/public/#EpiAware.EpiInfModels.RenewalWithPopulation","page":"Public API","title":"EpiAware.EpiInfModels.RenewalWithPopulation","text":"struct RenewalWithPopulation{S<:Distributions.Sampleable} <: AbstractTuringRenewal\n\nModel unobserved/latent infections as due to time-varying Renewal model with reproduction number mathcalR_t which is generated by a latent process and a population size of available people who can be infected N.\n\nMathematical specification\n\nIf Z_t is a realisation of the latent model, then the unobserved/latent infections are given by\n\nbeginalign\nmathcalR_t = g(Z_t)\nS_t = S_t-1 - I_t\nI_t = S_t-1 over NmathcalR_t sum_i=1^n-1 I_t-i g_i qquad t geq 1 \nI_t = g(hatI_0) exp(r(mathcalR_1) t) qquad t leq 0\nendalign\n\nwhere g is a transformation function and the unconstrained initial infections hatI_0 are sampled from a prior distribution. The discrete generation interval is given by g_i.\n\nr(mathcalR_1) is the exponential growth rate implied by mathcalR_1) using the implicit relationship between the exponential growth rate and the reproduction number.\n\nmathcalR sum_j geq 1 g_j exp(- r j)= 1\n\nRenewal are constructed by passing an EpiData object data and an initialisation_prior for the prior distribution of hatI_0. The default initialisation_prior is Normal().\n\nConstructor\n\nRenewalWithPopulation(; data, initialisation_prior, pop_size).\n\nExample usage with generate_latent_infs\n\ngenerate_latent_infs can be used to construct a Turing model for the latent infections conditional on the sample path of a latent process. In this example, we generate a sample of a white noise latent process.\n\nFirst, we construct an Renewal struct with an EpiData object, an initialisation prior and a transformation function.\n\nusing Distributions, Turing, EpiAware\ngen_int = [0.2, 0.3, 0.5]\ng = exp\n\n# Create an EpiData object\ndata = EpiData(gen_int, g)\n\n# Create an Renewal model\nrenewal_model = RenewalWithPopulation(data = data, initialisation_prior = Normal(), pop_size = 1e6)\n\nThen, we can use generate_latent_infs to construct a Turing model for the unobserved infection generation model set by the type of direct_inf_model.\n\n# Construct a Turing model\nZ_t = randn(100) * 0.05\nlatent_inf = generate_latent_infs(renewal_model, Z_t)\n\nNow we can use the Turing PPL API to sample underlying parameters and generate the unobserved infections.\n\n# Sample from the unobserved infections model\n\n#Sample random parameters from prior\nθ = rand(latent_inf)\n#Get unobserved infections as a generated quantities from the model\nI_t = generated_quantities(latent_inf, θ)\n\n\n\nFields\n\ndata::EpiData\ninitialisation_prior::Distributions.Sampleable\npop_size::Float64\n\n\n\n\n\n","category":"type"},{"location":"lib/EpiInfModels/public/#EpiAware.EpiInfModels.RenewalWithPopulation-Tuple{Any, Any}","page":"Public API","title":"EpiAware.EpiInfModels.RenewalWithPopulation","text":"function (epi_model::RenewalWithPopulation)(recent_incidence_and_available_sus, Rt)\n\nCallable on a RenewalWithPopulation struct for compute new incidence based on recent incidence, Rt and depletion of susceptibles.\n\nMathematical specification\n\nThe new incidence is given by\n\nI_t = S_t-1 N R_t sum_i=1^n-1 I_t-i g_i\n\nwhere I_t is the new incidence, R_t is the reproduction number, I_{t-i} is the recent incidence and g_i is the generation interval.\n\nArguments\n\nrecent_incidence_and_available_sus: A tuple with an array of recent incidence\n\nvalues and the remaining susceptible/available individuals.\n\nRt: Reproduction number.\n\nReturns\n\nTuple containing the updated incidence array and the new recent_incidence_and_available_sus\n\nvalue.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiInfModels/public/#EpiAware.EpiInfModels.R_to_r-Union{Tuple{T}, Tuple{Any, Vector{T}}} where T<:AbstractFloat","page":"Public API","title":"EpiAware.EpiInfModels.R_to_r","text":"R_to_r(\n R₀,\n w::Array{T<:AbstractFloat, 1};\n newton_steps,\n Δd\n) -> Any\n\n\nThis function computes an approximation to the exponential growth rate r given the reproductive ratio R₀ and the discretized generation interval w with discretized interval width Δd. This is based on the implicit solution of\n\nG(r) - 1 over R_0 = 0\n\nwhere\n\nG(r) = sum_i=1^n w_i e^-r i\n\nis the negative moment generating function (MGF) of the generation interval distribution.\n\nThe two step approximation is based on: 1. Direct solution of implicit equation for a small r approximation. 2. Improving the approximation using Newton's method for a fixed number of steps newton_steps.\n\nReturns:\n\nThe approximate value of r.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiInfModels/public/#EpiAware.EpiInfModels.expected_Rt-Tuple{EpiData, Vector{<:Real}}","page":"Public API","title":"EpiAware.EpiInfModels.expected_Rt","text":"expected_Rt(\n data::EpiData,\n infections::Vector{<:Real}\n) -> Any\n\n\nCalculate the expected Rt values based on the given EpiData object and infections.\n\nR_t = fracI_tsum_i=1^n I_t-i g_i\n\nArguments\n\ndata::EpiData: An instance of the EpiData type containing generation interval data.\ninfections::Vector{<:Real}: A vector of infection data.\n\nReturns\n\nexp_Rt::Vector{Float64}: A vector of expected Rt values.\n\nExamples\n\nusing EpiAware\n\ndata = EpiData([0.2, 0.3, 0.5], exp)\ninfections = [100, 200, 300, 400, 500]\nexpected_Rt(data, infections)\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiInfModels/public/#EpiAware.EpiInfModels.r_to_R-Tuple{Any, AbstractVector}","page":"Public API","title":"EpiAware.EpiInfModels.r_to_R","text":"r_to_R(r, w::AbstractVector) -> Any\n\n\nr_to_R(r, w)\n\nCompute the reproductive ratio given exponential growth rate r and discretized generation interval w.\n\nArguments\n\nr: The exponential growth rate.\nw: discretized generation interval.\n\nReturns\n\nThe reproductive ratio.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiAwareUtils/#EpiAwareUtils.jl","page":"Overview","title":"EpiAwareUtils.jl","text":"","category":"section"},{"location":"lib/EpiAwareUtils/","page":"Overview","title":"Overview","text":"This package provides utility functions for the EpiAware ecosystem.","category":"page"},{"location":"lib/EpiAwareUtils/#API","page":"Overview","title":"API","text":"","category":"section"},{"location":"lib/EpiAwareUtils/","page":"Overview","title":"Overview","text":"Pages = [\"lib/EpiAwareUtils/public.md\", \"lib/EpiAwareUtils/internals.md\"]","category":"page"},{"location":"lib/EpiInference/#EpiInference.jl","page":"Overview","title":"EpiInference.jl","text":"","category":"section"},{"location":"lib/EpiInference/","page":"Overview","title":"Overview","text":"This package provides inference algorithms for the EpiAware ecosystem.","category":"page"},{"location":"lib/EpiInference/#API","page":"Overview","title":"API","text":"","category":"section"},{"location":"lib/EpiInference/","page":"Overview","title":"Overview","text":"Pages = [\"lib/EpiInference/public.md\", \"lib/EpiInference/internals.md\"]","category":"page"},{"location":"lib/public/#Public-Documentation","page":"Public API","title":"Public Documentation","text":"","category":"section"},{"location":"lib/public/","page":"Public API","title":"Public API","text":"Documentation for EpiAware.jl's public interface.","category":"page"},{"location":"lib/public/","page":"Public API","title":"Public API","text":"See the Internals section of the manual for internal package docs covering all submodules.","category":"page"},{"location":"lib/public/#Contents","page":"Public API","title":"Contents","text":"","category":"section"},{"location":"lib/public/","page":"Public API","title":"Public API","text":"Pages = [\"public.md\"]\nDepth = 2:2","category":"page"},{"location":"lib/public/#Index","page":"Public API","title":"Index","text":"","category":"section"},{"location":"lib/public/","page":"Public API","title":"Public API","text":"Pages = [\"public.md\"]","category":"page"},{"location":"lib/public/#Public-API","page":"Public API","title":"Public API","text":"","category":"section"},{"location":"lib/public/","page":"Public API","title":"Public API","text":"Modules = [EpiAware]\nPrivate = false","category":"page"},{"location":"showcase/replications/mishra-2020/","page":"On the derivation of the renewal equation from an age-dependent branching process: an epidemic modelling perspective","title":"On the derivation of the renewal equation from an age-dependent branching process: an epidemic modelling perspective","text":"\n\n\n\n\n\n\n\n\n\n\n

              Getting started with EpiAware

              This tutorial introduces the basic functionality of EpiAware. EpiAware is a package for making inferences on epidemiological case/determined infection data using a model-based approach.

              It is common to conceptualise the generative process of public health data, e.g a time series of reported cases of an infectious pathogen, in a modular way. For example, it is common to abstract the underlying latent infection process away from downstream issues of observation, or to treat quanitites such as the time-varying reproduction number as being itself generated as a random process.

              EpiAware is built using the DynamicPPL probabilistic programming domain-specific language, which is part of the Turing PPL. The structural concept behind EpiAware is that each module of an epidemiological model is a self-contained TuringModel; that is each module is an object that can be conditioned on observable data and sampled from. A complete EpiAware model is the composition of these objects using the @submodel macro.

              \n\n","category":"page"},{"location":"showcase/replications/mishra-2020/#Example:-Early-COVID-19-case-data-in-South-Korea","page":"On the derivation of the renewal equation from an age-dependent branching process: an epidemic modelling perspective","title":"Example: Early COVID-19 case data in South Korea","text":"","category":"section"},{"location":"showcase/replications/mishra-2020/","page":"On the derivation of the renewal equation from an age-dependent branching process: an epidemic modelling perspective","title":"On the derivation of the renewal equation from an age-dependent branching process: an epidemic modelling perspective","text":"
              \n

              To demonstrate EpiAware we largely recreate an epidemiological model presented in On the derivation of the renewal equation from an age-dependent branching process: an epidemic modelling perspective, Mishra et al (2020). Mishra et al consider test-confirmed cases of COVID-19 in South Korea between January to July 2020. The components of the epidemilogical model they consider are:

              $$I_t = \\mu_t + R_t \\sum_{s\\geq 1} I_{t-s} g_s.$$

              Where \\(g_t\\) is a daily discretisation of the probability mass function of an estimated serial interval distribution:

              $$G \\sim \\text{Gamma}(6.5,0.62).$$

              And \\(\\mu_t\\) is an external importation of infection process.

              $$C_t \\sim \\text{NegBin}(\\text{mean} = I_t,~ \\text{overdispersion} = \\phi).$$

              In the examples below we are going to largely recreate the Mishra et al model, whilst emphasing that each component of the overall epidemiological model is, itself, a stand alone model that can be sampled from.

              \n\n\n
              TaskLocalRNG()
              \n\n\n

              Time-varying reproduction number as a LatentModel type

              EpiAware exposes a LatentModel type system; the purpose of which is to define stochastic processes which can be interpreted as generating time-varying parameters/quantities of interest.

              In the Mishra et al model the log-time varying reproductive number is a priori assumed to evolve as an auto-regressive process, AR(2):

              $$\\begin{align}\nZ_t &= \\log R_t, \\\\\nZ_t &= \\rho_1 Z_{t-1} + \\rho_2 Z_{t-2} + \\epsilon_t, \\\\\n\\epsilon_t &\\sim \\text{Normal}(0, \\sigma).\n\\end{align}$$

              \n\n\n

              EpiAware gives a concrete subtype AR <: AbstractLatentModel which defines this behaviour of the latent model. The user can supply the priors for \\(\\rho_1,\\rho_2\\), wich we call damp_priors, as well as for \\(\\sigma\\) (std_prior) and the initial values \\(Z_1, Z_2\\) (init_priors).

              \n\n
              ar = AR(\n    damp_priors = [truncated(Normal(0.8, 0.05), 0, 1),\n        truncated(Normal(0.05, 0.05), 0, 1)],\n    std_prior = HalfNormal(1.0),\n    init_priors = [Normal(-1.0, 0.1), Normal(-1.0, 0.1)]\n)
              \n
              AR{Product{Continuous, Truncated{Normal{Float64}, Continuous, Float64, Float64, Float64}, Vector{Truncated{Normal{Float64}, Continuous, Float64, Float64, Float64}}}, HalfNormal{Float64}, DistributionsAD.TuringScalMvNormal{Vector{Float64}, Float64}, Int64}(Distributions.Product{Distributions.Continuous, Distributions.Truncated{Distributions.Normal{Float64}, Distributions.Continuous, Float64, Float64, Float64}, Vector{Distributions.Truncated{Distributions.Normal{Float64}, Distributions.Continuous, Float64, Float64, Float64}}}(v=Truncated{Normal{Float64}, Continuous, Float64, Float64, Float64}[Truncated(Distributions.Normal{Float64}(μ=0.8, σ=0.05); lower=0.0, upper=1.0), Truncated(Distributions.Normal{Float64}(μ=0.05, σ=0.05); lower=0.0, upper=1.0)]), HalfNormal{Float64}(μ=1.0), DistributionsAD.TuringScalMvNormal{Vector{Float64}, Float64}(m=[-1.0, -1.0], σ=0.1), 2)
              \n\n\n

              The priors here are based on Mishra et al, note that we have decreased the a priori belief in the correlation parameter \\(\\rho_1\\).

              \n\n\n
              Turing model interface

              As mentioned above, we can use this instance of the AR latent model to construct a TuringModel which implements the probabilistic behaviour determined by ar.

              We do this with the constructor function generate_latent which combines ar with a number of time steps to generate for (in this case we choose 30).

              \n\n
              ar_mdl = generate_latent(ar, 30)
              \n
              Model{typeof(generate_latent), (:latent_model, :n), (), (), Tuple{AR{Product{Continuous, Truncated{Normal{Float64}, Continuous, Float64, Float64, Float64}, Vector{Truncated{Normal{Float64}, Continuous, Float64, Float64, Float64}}}, HalfNormal{Float64}, DistributionsAD.TuringScalMvNormal{Vector{Float64}, Float64}, Int64}, Int64}, Tuple{}, DefaultContext}(EpiAware.EpiAwareBase.generate_latent, (latent_model = AR{Product{Continuous, Truncated{Normal{Float64}, Continuous, Float64, Float64, Float64}, Vector{Truncated{Normal{Float64}, Continuous, Float64, Float64, Float64}}}, HalfNormal{Float64}, DistributionsAD.TuringScalMvNormal{Vector{Float64}, Float64}, Int64}(Distributions.Product{Distributions.Continuous, Distributions.Truncated{Distributions.Normal{Float64}, Distributions.Continuous, Float64, Float64, Float64}, Vector{Distributions.Truncated{Distributions.Normal{Float64}, Distributions.Continuous, Float64, Float64, Float64}}}(v=Truncated{Normal{Float64}, Continuous, Float64, Float64, Float64}[Truncated(Distributions.Normal{Float64}(μ=0.8, σ=0.05); lower=0.0, upper=1.0), Truncated(Distributions.Normal{Float64}(μ=0.05, σ=0.05); lower=0.0, upper=1.0)]), HalfNormal{Float64}(μ=1.0), DistributionsAD.TuringScalMvNormal{Vector{Float64}, Float64}(m=[-1.0, -1.0], σ=0.1), 2), n = 30), NamedTuple(), DefaultContext())
              \n\n\n

              We can sample from this model, which is useful for model diagnostic and prior predictive checking.

              \n\n\n\n\n\n

              And we can sample from this model with some parameters conditioned, for example with \\(\\sigma = 0\\). In this case the AR process is an initial perturbation model with return to baseline.

              \n\n
              cond_ar_mdl = ar_mdl | (σ_AR = 0.0,)
              \n
              Model{typeof(generate_latent), (:latent_model, :n), (), (), Tuple{AR{Product{Continuous, Truncated{Normal{Float64}, Continuous, Float64, Float64, Float64}, Vector{Truncated{Normal{Float64}, Continuous, Float64, Float64, Float64}}}, HalfNormal{Float64}, DistributionsAD.TuringScalMvNormal{Vector{Float64}, Float64}, Int64}, Int64}, Tuple{}, ConditionContext{@NamedTuple{σ_AR::Float64}, DefaultContext}}(EpiAware.EpiAwareBase.generate_latent, (latent_model = AR{Product{Continuous, Truncated{Normal{Float64}, Continuous, Float64, Float64, Float64}, Vector{Truncated{Normal{Float64}, Continuous, Float64, Float64, Float64}}}, HalfNormal{Float64}, DistributionsAD.TuringScalMvNormal{Vector{Float64}, Float64}, Int64}(Distributions.Product{Distributions.Continuous, Distributions.Truncated{Distributions.Normal{Float64}, Distributions.Continuous, Float64, Float64, Float64}, Vector{Distributions.Truncated{Distributions.Normal{Float64}, Distributions.Continuous, Float64, Float64, Float64}}}(v=Truncated{Normal{Float64}, Continuous, Float64, Float64, Float64}[Truncated(Distributions.Normal{Float64}(μ=0.8, σ=0.05); lower=0.0, upper=1.0), Truncated(Distributions.Normal{Float64}(μ=0.05, σ=0.05); lower=0.0, upper=1.0)]), HalfNormal{Float64}(μ=1.0), DistributionsAD.TuringScalMvNormal{Vector{Float64}, Float64}(m=[-1.0, -1.0], σ=0.1), 2), n = 30), NamedTuple(), ConditionContext((σ_AR = 0.0,), DynamicPPL.DefaultContext()))
              \n\n\n\n\n\n

              In this note, we are going to treat \\(R_t\\) as varying every two days. The reason for this is to 1) reduce the effective number of parameters, and 2) showcase the BroadcastLatentModel wrapper.

              In EpiAware we set this behaviour by wrapping a LatentModel in a BroadcastLatentModel. This allows us to set the broadcasting period and type. In this case we broadcast each latent process value over \\(2\\) days in a RepeatBlock.

              \n\n
              twod_ar = BroadcastLatentModel(ar, 2, RepeatBlock())
              \n
              BroadcastLatentModel{AR{Product{Continuous, Truncated{Normal{Float64}, Continuous, Float64, Float64, Float64}, Vector{Truncated{Normal{Float64}, Continuous, Float64, Float64, Float64}}}, HalfNormal{Float64}, DistributionsAD.TuringScalMvNormal{Vector{Float64}, Float64}, Int64}, Int64, RepeatBlock}(AR{Product{Continuous, Truncated{Normal{Float64}, Continuous, Float64, Float64, Float64}, Vector{Truncated{Normal{Float64}, Continuous, Float64, Float64, Float64}}}, HalfNormal{Float64}, DistributionsAD.TuringScalMvNormal{Vector{Float64}, Float64}, Int64}(Distributions.Product{Distributions.Continuous, Distributions.Truncated{Distributions.Normal{Float64}, Distributions.Continuous, Float64, Float64, Float64}, Vector{Distributions.Truncated{Distributions.Normal{Float64}, Distributions.Continuous, Float64, Float64, Float64}}}(v=Truncated{Normal{Float64}, Continuous, Float64, Float64, Float64}[Truncated(Distributions.Normal{Float64}(μ=0.8, σ=0.05); lower=0.0, upper=1.0), Truncated(Distributions.Normal{Float64}(μ=0.05, σ=0.05); lower=0.0, upper=1.0)]), HalfNormal{Float64}(μ=1.0), DistributionsAD.TuringScalMvNormal{Vector{Float64}, Float64}(m=[-1.0, -1.0], σ=0.1), 2), 2, RepeatBlock())
              \n\n\n\n\n\n

              The Renewal model as an EpiModel type

              EpiAware has an EpiModel type system which we use to set the behaviour of the latent infection model. In this case we want to implement a renewal model.

              To construct an EpiModel we need to supply some fixed data for the model contained in an EpiData object. The EpiData constructor performs double interval censoring to convert our continuous estimate of the generation interval into a discretized version \\(g_t\\). We also implement right truncation, the default is rounding the 99th percentile of the generation interval distribution, but this can be controlled using the keyword D_gen.

              \n\n
              truth_GI = Gamma(6.5, 0.62)
              \n
              Distributions.Gamma{Float64}(α=6.5, θ=0.62)
              \n\n
              model_data = EpiData(gen_distribution = truth_GI)
              \n
              EpiData{Float64, typeof(exp)}([0.026663134095601056, 0.14059778064943784, 0.2502660305615846, 0.24789569560506844, 0.1731751163417783, 0.09635404000022223, 0.04573437575216367, 0.019313826994143808], 8, exp)
              \n\n\n\n\n\n

              The user also needs to specify a prior for the log incidence at time zero, \\(\\log I_0\\). The initial history of latent infections \\(I_{-1}, I_{-2},\\dots\\) is constructed as

              $$I_t = e^{rt} I_0,\\qquad t = 0, -1, -2,...$$

              Where the exponential growth rate \\(r\\) is determined by the initial reproductive number \\(R_1\\) via the solution to the implicit equation,

              $$R_1 = 1 \\Big{/} \\sum_{t\\geq 1} e^{-rt} g_t$$

              \n\n
              log_I0_prior = Normal(log(1.0), 1.0)
              \n
              Distributions.Normal{Float64}(μ=0.0, σ=1.0)
              \n\n
              epi = RenewalWithPopulation(model_data, log_I0_prior, 1e8)
              \n
              RenewalWithPopulation{Normal{Float64}}(EpiData{Float64, typeof(exp)}([0.026663134095601056, 0.14059778064943784, 0.2502660305615846, 0.24789569560506844, 0.1731751163417783, 0.09635404000022223, 0.04573437575216367, 0.019313826994143808], 8, exp), Distributions.Normal{Float64}(μ=0.0, σ=1.0), 1.0e8)
              \n\n\n

              NB: We don't implement a background infection rate in this model.

              \n\n\n
              Turing model interface

              As mentioned above, we can use this instance of the Renewal latent infection model to construct a TuringModel which implements the probabilistic behaviour determined by epi.

              We do this with the constructor function generate_latent_infs which combines epi with a provided \\(\\log R_t\\) time series.

              Here we choose an example where \\(R_t\\) decreases from \\(R_t = 3\\) to \\(R_t = 0.5\\) over the course of 30 days.

              \n\n
              R_t_fixed = [0.5 + 2.5 / (1 + exp(t - 15)) for t in 1:30]
              \n
              30-element Vector{Float64}:\n 2.9999979211799306\n 2.9999943491892553\n 2.9999846395634946\n 2.99995824644538\n 2.9998865053282437\n 2.9996915135600344\n 2.999161624673834\n ⋮\n 0.500113494671756\n 0.5000417535546202\n 0.5000153604365055\n 0.5000056508107448\n 0.5000020788200692\n 0.5000007647555673
              \n\n
              latent_inf_mdl = generate_latent_infs(epi, log.(R_t_fixed))
              \n
              Model{typeof(generate_latent_infs), (:epi_model, :_Rt), (), (), Tuple{RenewalWithPopulation{Normal{Float64}}, Vector{Float64}}, Tuple{}, DefaultContext}(EpiAware.EpiAwareBase.generate_latent_infs, (epi_model = RenewalWithPopulation{Normal{Float64}}(EpiData{Float64, typeof(exp)}([0.026663134095601056, 0.14059778064943784, 0.2502660305615846, 0.24789569560506844, 0.1731751163417783, 0.09635404000022223, 0.04573437575216367, 0.019313826994143808], 8, exp), Distributions.Normal{Float64}(μ=0.0, σ=1.0), 1.0e8), _Rt = [1.0986115957278464, 1.098610405062754, 1.0986071685094998, 1.0985983707197156, 1.0985744563952262, 1.098509454567543, 1.0983327911702674, 1.097852790994088, 1.09654964358037, 1.0930193012626002  …  -0.6808598639891831, -0.6886022683659516, -0.6914718340845708, -0.6925303979295329, -0.6929202169746165, -0.6930636769372295, -0.6931164601588107, -0.6931358790023187, -0.6931430229284499, -0.6931456510499804]), NamedTuple(), DefaultContext())
              \n\n\n\n\n\n

              Negative Binomial Observations as an ObservationModel type

              In Mishra et al latent infections were assumed to occur on their observation day with negative binomial errors, this motivates using the serial interval (the time between onset of symptoms of a primary and secondary case) rather than generation interval distribution (the time between infection time of a primary and secondary case).

              Observation models are set in EpiAware as concrete subtypes of an ObservationModel. The Negative binomial error model without observation delays is set with a NegativeBinomialError struct. In Mishra et al the overdispersion parameter \\(\\phi\\) sets the relationship between the mean and variance of the negative binomial errors,

              $$\\text{var} = \\text{mean} + {\\text{mean}^2 \\over \\phi}.$$

              In EpiAware, we default to a prior on \\(\\sqrt{1/\\phi}\\) because this quantity has the dimensions of a standard deviation and, therefore, is easier to reason on a priori beliefs.

              \n\n
              obs = NegativeBinomialError(cluster_factor_prior = HalfNormal(0.15))
              \n
              NegativeBinomialError{HalfNormal{Float64}}(HalfNormal{Float64}(μ=0.15))
              \n\n\n
              Turing model interface

              We can construct a NegativeBinomialError model implementation as a TuringModel using generate_observations

              Turing uses missing arguments to indicate variables that are to be sampled. We use this to observe a forward model that samples observations, conditional on an underlying expected observation time series.

              \n\n\n

              First, we set an artificial expected cases curve.

              \n\n
              expected_cases = [1000 * exp(-(t - 15)^2 / (2 * 4)) for t in 1:30]
              \n
              30-element Vector{Float64}:\n 2.289734845645553e-8\n 6.691586091292782e-7\n 1.5229979744712628e-5\n 0.0002699578503363014\n 0.003726653172078671\n 0.04006529739295107\n 0.33546262790251186\n ⋮\n 0.003726653172078671\n 0.0002699578503363014\n 1.5229979744712628e-5\n 6.691586091292782e-7\n 2.289734845645553e-8\n 6.101936677605324e-10
              \n\n
              obs_mdl = generate_observations(obs, missing, expected_cases)
              \n
              Model{typeof(generate_observations), (:obs_model, :y_t, :Y_t), (), (:y_t,), Tuple{NegativeBinomialError{HalfNormal{Float64}}, Missing, Vector{Float64}}, Tuple{}, DefaultContext}(EpiAware.EpiAwareBase.generate_observations, (obs_model = NegativeBinomialError{HalfNormal{Float64}}(HalfNormal{Float64}(μ=0.15)), y_t = missing, Y_t = [2.289734845645553e-8, 6.691586091292782e-7, 1.5229979744712628e-5, 0.0002699578503363014, 0.003726653172078671, 0.04006529739295107, 0.33546262790251186, 2.187491118182885, 11.108996538242305, 43.93693362340742  …  11.108996538242305, 2.187491118182885, 0.33546262790251186, 0.04006529739295107, 0.003726653172078671, 0.0002699578503363014, 1.5229979744712628e-5, 6.691586091292782e-7, 2.289734845645553e-8, 6.101936677605324e-10]), NamedTuple(), DefaultContext())
              \n\n\n\n\n\n

              A reverse observation model, which samples the underlying latent infections conditional on observations would require a prior on the latent infections. This is the purpose of composing multiple models; as we'll see below the latent infection and latent \\(R_t\\) models are informative priors on the latent infection time series underlying the observations.

              \n\n\n

              Composing models into an EpiProblem

              As mentioned above, each module of the overall epidemiological model we are interested in is a TuringModel in its own right. In this section, we compose the individual models into the full epidemiological model using the EpiProblem struct.

              The constructor for an EpiProblem requires:

              The tspan set the range of the time index for the models.

              \n\n
              epi_prob = EpiProblem(epi_model = epi,\n    latent_model = twod_ar,\n    observation_model = obs,\n    tspan = (45, 80))
              \n
              EpiProblem{RenewalWithPopulation{Normal{Float64}}, BroadcastLatentModel{AR{Product{Continuous, Truncated{Normal{Float64}, Continuous, Float64, Float64, Float64}, Vector{Truncated{Normal{Float64}, Continuous, Float64, Float64, Float64}}}, HalfNormal{Float64}, DistributionsAD.TuringScalMvNormal{Vector{Float64}, Float64}, Int64}, Int64, RepeatBlock}, NegativeBinomialError{HalfNormal{Float64}}}(RenewalWithPopulation{Normal{Float64}}(EpiData{Float64, typeof(exp)}([0.026663134095601056, 0.14059778064943784, 0.2502660305615846, 0.24789569560506844, 0.1731751163417783, 0.09635404000022223, 0.04573437575216367, 0.019313826994143808], 8, exp), Distributions.Normal{Float64}(μ=0.0, σ=1.0), 1.0e8), BroadcastLatentModel{AR{Product{Continuous, Truncated{Normal{Float64}, Continuous, Float64, Float64, Float64}, Vector{Truncated{Normal{Float64}, Continuous, Float64, Float64, Float64}}}, HalfNormal{Float64}, DistributionsAD.TuringScalMvNormal{Vector{Float64}, Float64}, Int64}, Int64, RepeatBlock}(AR{Product{Continuous, Truncated{Normal{Float64}, Continuous, Float64, Float64, Float64}, Vector{Truncated{Normal{Float64}, Continuous, Float64, Float64, Float64}}}, HalfNormal{Float64}, DistributionsAD.TuringScalMvNormal{Vector{Float64}, Float64}, Int64}(Distributions.Product{Distributions.Continuous, Distributions.Truncated{Distributions.Normal{Float64}, Distributions.Continuous, Float64, Float64, Float64}, Vector{Distributions.Truncated{Distributions.Normal{Float64}, Distributions.Continuous, Float64, Float64, Float64}}}(v=Truncated{Normal{Float64}, Continuous, Float64, Float64, Float64}[Truncated(Distributions.Normal{Float64}(μ=0.8, σ=0.05); lower=0.0, upper=1.0), Truncated(Distributions.Normal{Float64}(μ=0.05, σ=0.05); lower=0.0, upper=1.0)]), HalfNormal{Float64}(μ=1.0), DistributionsAD.TuringScalMvNormal{Vector{Float64}, Float64}(m=[-1.0, -1.0], σ=0.1), 2), 2, RepeatBlock()), NegativeBinomialError{HalfNormal{Float64}}(HalfNormal{Float64}(μ=0.15)), (45, 80))
              \n\n","category":"page"},{"location":"showcase/replications/mishra-2020/#Inference-Methods","page":"On the derivation of the renewal equation from an age-dependent branching process: an epidemic modelling perspective","title":"Inference Methods","text":"","category":"section"},{"location":"showcase/replications/mishra-2020/","page":"On the derivation of the renewal equation from an age-dependent branching process: an epidemic modelling perspective","title":"On the derivation of the renewal equation from an age-dependent branching process: an epidemic modelling perspective","text":"
              \n

              We make inferences on the unobserved quantities, such as \\(R_t\\) by sampling from the model conditioned on the observed data. We generate the posterior samples using the No U-Turns (NUTS) sampler.

              To make NUTS more robust we provide manypathfinder, which is built on pathfinder variational inference from Pathfinder.jl. manypathfinder runs nruns pathfinder processes on the inference problem and returns the pathfinder run with maximum estimated ELBO.

              The composition of doing variational inference as a pre-sampler step which gets passed to NUTS initialisation is defined using the EpiMethod struct, where a sequence of pre-sampler steps can be be defined.

              EpiMethod also allows the specification of NUTS parameters, such as type of automatic differentiation, type of parallelism and number of parallel chains to sample.

              \n\n
              num_threads = min(10, Threads.nthreads())
              \n
              1
              \n\n
              inference_method = EpiMethod(\n    pre_sampler_steps = [ManyPathfinder(nruns = 4, maxiters = 100)],\n    sampler = NUTSampler(adtype = AutoReverseDiff(),\n        ndraws = 2000,\n        nchains = num_threads,\n        mcmc_parallel = MCMCThreads())\n)
              \n
              EpiMethod{ManyPathfinder, NUTSampler{AutoReverseDiff{false}, MCMCThreads, UnionAll}}(ManyPathfinder[ManyPathfinder(10, 4, 100, 100)], NUTSampler{AutoReverseDiff{false}, MCMCThreads, UnionAll}(0.8, AutoReverseDiff(), MCMCThreads(), 1, 10, 1000.0, 0.0, 2000, AdvancedHMC.DiagEuclideanMetric))
              \n\n","category":"page"},{"location":"showcase/replications/mishra-2020/#Inference-and-analysis","page":"On the derivation of the renewal equation from an age-dependent branching process: an epidemic modelling perspective","title":"Inference and analysis","text":"","category":"section"},{"location":"showcase/replications/mishra-2020/","page":"On the derivation of the renewal equation from an age-dependent branching process: an epidemic modelling perspective","title":"On the derivation of the renewal equation from an age-dependent branching process: an epidemic modelling perspective","text":"
              \n

              In the background of this note (see hidden top cell and short R script in this directory), we load daily reported cases from South Korea from Jan-July 2020 which were gathered using covidregionaldata from ECDC data archives.

              We supply the data as a NamedTuple with the y_t field containing the observed data, shortened to fit the chosen tspan of epi_prob.

              \n\n
              south_korea_data = (y_t = daily_cases[epi_prob.tspan[1]:epi_prob.tspan[2]],\n    dates = dates[epi_prob.tspan[1]:epi_prob.tspan[2]])
              \n
              (y_t = [0, 0, 0, 1, 1, 1, 15, 34, 75, 190  …  131, 242, 114, 110, 107, 76, 74, 84, 93, 152], dates = [Date(\"2020-02-13\"), Date(\"2020-02-14\"), Date(\"2020-02-15\"), Date(\"2020-02-16\"), Date(\"2020-02-17\"), Date(\"2020-02-18\"), Date(\"2020-02-19\"), Date(\"2020-02-20\"), Date(\"2020-02-21\"), Date(\"2020-02-22\")  …  Date(\"2020-03-10\"), Date(\"2020-03-11\"), Date(\"2020-03-12\"), Date(\"2020-03-13\"), Date(\"2020-03-14\"), Date(\"2020-03-15\"), Date(\"2020-03-16\"), Date(\"2020-03-17\"), Date(\"2020-03-18\"), Date(\"2020-03-19\")])
              \n\n\n

              Sampling with apply_method

              The apply_method function combines the elements above:

              And returns a collection of results:

              \n\n
              inference_results = apply_method(epi_prob,\n    inference_method,\n    south_korea_data\n)
              \n
              EpiAwareObservables(Model{typeof(generate_epiaware), (:y_t, :time_steps, :epi_model), (:latent_model, :observation_model), (), Tuple{Vector{Int64}, Int64, RenewalWithPopulation{Normal{Float64}}}, Tuple{BroadcastLatentModel{AR{Product{Continuous, Truncated{Normal{Float64}, Continuous, Float64, Float64, Float64}, Vector{Truncated{Normal{Float64}, Continuous, Float64, Float64, Float64}}}, HalfNormal{Float64}, DistributionsAD.TuringScalMvNormal{Vector{Float64}, Float64}, Int64}, Int64, RepeatBlock}, NegativeBinomialError{HalfNormal{Float64}}}, DefaultContext}(EpiAware.EpiAwareBase.generate_epiaware, (y_t = [0, 0, 0, 1, 1, 1, 15, 34, 75, 190  …  131, 242, 114, 110, 107, 76, 74, 84, 93, 152], time_steps = 36, epi_model = RenewalWithPopulation{Normal{Float64}}(EpiData{Float64, typeof(exp)}([0.026663134095601056, 0.14059778064943784, 0.2502660305615846, 0.24789569560506844, 0.1731751163417783, 0.09635404000022223, 0.04573437575216367, 0.019313826994143808], 8, exp), Distributions.Normal{Float64}(μ=0.0, σ=1.0), 1.0e8)), (latent_model = BroadcastLatentModel{AR{Product{Continuous, Truncated{Normal{Float64}, Continuous, Float64, Float64, Float64}, Vector{Truncated{Normal{Float64}, Continuous, Float64, Float64, Float64}}}, HalfNormal{Float64}, DistributionsAD.TuringScalMvNormal{Vector{Float64}, Float64}, Int64}, Int64, RepeatBlock}(AR{Product{Continuous, Truncated{Normal{Float64}, Continuous, Float64, Float64, Float64}, Vector{Truncated{Normal{Float64}, Continuous, Float64, Float64, Float64}}}, HalfNormal{Float64}, DistributionsAD.TuringScalMvNormal{Vector{Float64}, Float64}, Int64}(Distributions.Product{Distributions.Continuous, Distributions.Truncated{Distributions.Normal{Float64}, Distributions.Continuous, Float64, Float64, Float64}, Vector{Distributions.Truncated{Distributions.Normal{Float64}, Distributions.Continuous, Float64, Float64, Float64}}}(v=Truncated{Normal{Float64}, Continuous, Float64, Float64, Float64}[Truncated(Distributions.Normal{Float64}(μ=0.8, σ=0.05); lower=0.0, upper=1.0), Truncated(Distributions.Normal{Float64}(μ=0.05, σ=0.05); lower=0.0, upper=1.0)]), HalfNormal{Float64}(μ=1.0), DistributionsAD.TuringScalMvNormal{Vector{Float64}, Float64}(m=[-1.0, -1.0], σ=0.1), 2), 2, RepeatBlock()), observation_model = NegativeBinomialError{HalfNormal{Float64}}(HalfNormal{Float64}(μ=0.15))), DefaultContext()), nothing, MCMC chain (2000×35×1 Array{Float64, 3}), @NamedTuple{generated_y_t::Vector{Int64}, I_t::Vector{Float64}, Z_t::Vector{Float64}, process_aux::@NamedTuple{σ_AR::Float64, ar_init::Vector{Float64}, damp_AR::Vector{Float64}, sq_cluster_factor::Float64}}[(generated_y_t = [0, 0, 0, 1, 1, 1, 15, 34, 75, 190  …  131, 242, 114, 110, 107, 76, 74, 84, 93, 152], I_t = [0.6302189734369976, 0.4774713968245689, 0.3905291507562299, 0.3022359509208115, 0.9922833853995451, 0.813228204790894, 21.106447028610603, 46.10331357944557, 53.33687089383859, 152.24222960039674  …  197.5819007248144, 173.94553409919794, 136.98722629438038, 111.65633481799061, 125.31743099837803, 99.6995783777211, 78.81882944289, 68.09834544453484, 113.75830423055085, 99.6034860166183], Z_t = [-1.0832047855152138, -1.0832047855152138, -1.0146262702530706, -1.0146262702530706, 0.418711014559223, 0.418711014559223, 3.6849734508145495, 3.6849734508145495, 2.414227285537577, 2.414227285537577  …  -0.8921461057175676, -0.8921461057175676, -0.9481069026492762, -0.9481069026492762, -0.6086302626701813, -0.6086302626701813, -0.6492378533259052, -0.6492378533259052, 0.0048214101954354716, 0.0048214101954354716], process_aux = (σ_AR = 1.5841436659699561, ar_init = [-1.0832047855152138, -1.0146262702530706], damp_AR = [0.7640084446616473, 0.06809055715841618], sq_cluster_factor = 0.079180832239541)); (generated_y_t = [0, 0, 0, 1, 1, 1, 15, 34, 75, 190  …  131, 242, 114, 110, 107, 76, 74, 84, 93, 152], I_t = [0.9054036333499285, 0.7298094574188798, 0.5567385913041931, 0.4503846504021242, 2.230213896626074, 1.9065600991663039, 17.881558039189844, 32.4744970077826, 51.89540975761122, 128.44184641355815  …  178.21457047327442, 153.92366069174773, 150.53268696146284, 118.86938255651403, 120.72629891594556, 96.25096518758762, 111.96747397950845, 95.52634405260403, 165.56194047256344, 157.2302637345635], Z_t = [-0.8898357447217325, -0.8898357447217325, -0.9467061642702784, -0.9467061642702784, 0.8678971922522976, 0.8678971922522976, 2.9833461455222965, 2.9833461455222965, 2.4248084414242914, 2.4248084414242914  …  -1.108402692341453, -1.108402692341453, -0.9535543249686977, -0.9535543249686977, -0.6756561197376965, -0.6756561197376965, -0.3264624005485029, -0.3264624005485029, 0.33979129660429197, 0.33979129660429197], process_aux = (σ_AR = 2.006219571534054, ar_init = [-0.8898357447217325, -0.9467061642702784], damp_AR = [0.7477859993710714, 0.07099853573426045], sq_cluster_factor = 0.10824590568528863)); … ; (generated_y_t = [0, 0, 0, 1, 1, 1, 15, 34, 75, 190  …  131, 242, 114, 110, 107, 76, 74, 84, 93, 152], I_t = [1.2739313505255094, 0.9284479089848867, 0.8675168996177901, 0.6575416056195217, 1.7933463862437304, 1.4831973604222313, 18.312506724736963, 28.3160889159895, 82.39544494211103, 215.99113564106977  …  153.63601628462584, 135.00614788819811, 154.28236495292967, 124.1945925971968, 128.01665725054332, 106.31031490775568, 78.72349016967804, 70.33397592850444, 155.20469776895922, 138.04015530663935], Z_t = [-1.1712194264050033, -1.1712194264050033, -0.9365858749109013, -0.9365858749109013, 0.31385097788297855, 0.31385097788297855, 2.8525497842836396, 2.8525497842836396, 2.927661598221874, 2.927661598221874  …  -1.0354808546735808, -1.0354808546735808, -0.7278311981768211, -0.7278311981768211, -0.47094674087799177, -0.47094674087799177, -0.6315540092573445, -0.6315540092573445, 0.28437585348657035, 0.28437585348657035], process_aux = (σ_AR = 1.638797767408246, ar_init = [-1.1712194264050033, -0.9365858749109013], damp_AR = [0.7615374108450998, 0.061451939399942826], sq_cluster_factor = 0.1010913711477206)); (generated_y_t = [0, 0, 0, 1, 1, 1, 15, 34, 75, 190  …  131, 242, 114, 110, 107, 76, 74, 84, 93, 152], I_t = [0.36557026373911194, 0.28537577652833657, 0.24465754806075726, 0.19332007790512695, 0.5784430227066278, 0.4831367513694791, 23.986389990707373, 74.85371802000027, 40.67406402063849, 127.27792831196787  …  200.46755591770244, 177.25464086769261, 169.4193439834972, 139.64155100487525, 117.50767176549644, 98.4990070786369, 75.57177784500391, 64.52735423543758, 200.2979491781433, 173.46136967899554], Z_t = [-0.9990885088367124, -0.9990885088367124, -0.9097637407764456, -0.9097637407764456, 0.41166688293517095, 0.41166688293517095, 4.320290495933675, 4.320290495933675, 1.963418480789977, 1.963418480789977  …  -0.8273355767471939, -0.8273355767471939, -0.7012007179628654, -0.7012007179628654, -0.6810786163999226, -0.6810786163999226, -0.7819315466370461, -0.7819315466370461, 0.5240376203663384, 0.5240376203663384], process_aux = (σ_AR = 2.0368151186594696, ar_init = [-0.9990885088367124, -0.9097637407764456], damp_AR = [0.7551398290101086, 0.07370704512817201], sq_cluster_factor = 0.12321894564496723));;])
              \n\n\n

              Results and Predictive plotting

              We can spaghetti plot generated case data from the version of the model which hasn't conditioned on case data using posterior parameters inferred from the version conditioned on observed data. This is known as posterior predictive checking, and is a useful diagnostic tool for Bayesian inference (see here).

              Because we are using synthetic data we can also plot the model predictions for the unobserved infections and check that (at least in this example) we were able to capture some unobserved/latent variables in the process accurate.

              We find that the EpiAware model recovers the main finding in Mishra et al; that the \\(R_t\\) in South Korea peaked at a very high value (\\(R_t \\sim 10\\) at peak) before rapidly dropping below 1 in early March 2020.

              Note that, in reality, the peak \\(R_t\\) found here and in _Mishra et al) is unrealistically high, this might be due to a combination of:

              In a future note, we'll demonstrate having a time-varying ascertainment rate.

              \n\n\n\n\n\n

              Parameter inference

              We can interrogate the sampled chains directly from the samples field of the inference_results object.

              \n\n\n\n\n","category":"page"},{"location":"showcase/replications/mishra-2020/","page":"On the derivation of the renewal equation from an age-dependent branching process: an epidemic modelling perspective","title":"On the derivation of the renewal equation from an age-dependent branching process: an epidemic modelling perspective","text":"EditURL = \"https://github.com/CDCgov/Rt-without-renewal/blob/main/docs/src/showcase/replications/mishra-2020/index.jl\"","category":"page"},{"location":"lib/EpiAwareBase/public/#Public-Documentation","page":"Public API","title":"Public Documentation","text":"","category":"section"},{"location":"lib/EpiAwareBase/public/","page":"Public API","title":"Public API","text":"Documentation for EpiAwareBae.jl's public interface.","category":"page"},{"location":"lib/EpiAwareBase/public/","page":"Public API","title":"Public API","text":"See the Internals section of the manual for internal package docs covering all submodules.","category":"page"},{"location":"lib/EpiAwareBase/public/#Contents","page":"Public API","title":"Contents","text":"","category":"section"},{"location":"lib/EpiAwareBase/public/","page":"Public API","title":"Public API","text":"Pages = [\"public.md\"]\nDepth = 2:2","category":"page"},{"location":"lib/EpiAwareBase/public/#Index","page":"Public API","title":"Index","text":"","category":"section"},{"location":"lib/EpiAwareBase/public/","page":"Public API","title":"Public API","text":"Pages = [\"public.md\"]","category":"page"},{"location":"lib/EpiAwareBase/public/#Public-API","page":"Public API","title":"Public API","text":"","category":"section"},{"location":"lib/EpiAwareBase/public/","page":"Public API","title":"Public API","text":"Modules = [EpiAware.EpiAwareBase]\nPrivate = false","category":"page"},{"location":"lib/EpiAwareBase/public/#EpiAware.EpiAwareBase","page":"Public API","title":"EpiAware.EpiAwareBase","text":"Module for defining abstract epidemiological types.\n\n\n\n\n\n","category":"module"},{"location":"lib/EpiAwareBase/public/#EpiAware.EpiAwareBase.AbstractBroadcastRule","page":"Public API","title":"EpiAware.EpiAwareBase.AbstractBroadcastRule","text":"abstract type AbstractBroadcastRule\n\nAn abstract type representing a broadcast rule.\n\n\n\nFields\n\n\n\n\n\n","category":"type"},{"location":"lib/EpiAwareBase/public/#EpiAware.EpiAwareBase.AbstractEpiMethod","page":"Public API","title":"EpiAware.EpiAwareBase.AbstractEpiMethod","text":"abstract type AbstractEpiMethod\n\nAbstract supertype for all EpiAware inference/generative modelling methods.\n\n\n\nFields\n\n\n\n\n\n","category":"type"},{"location":"lib/EpiAwareBase/public/#EpiAware.EpiAwareBase.AbstractEpiModel","page":"Public API","title":"EpiAware.EpiAwareBase.AbstractEpiModel","text":"abstract type AbstractEpiModel <: AbstractModel\n\nThe abstract supertype for all structs that define a model for generating unobserved/latent infections.\n\n\n\nFields\n\n\n\n\n\n","category":"type"},{"location":"lib/EpiAwareBase/public/#EpiAware.EpiAwareBase.AbstractEpiOptMethod","page":"Public API","title":"EpiAware.EpiAwareBase.AbstractEpiOptMethod","text":"abstract type AbstractEpiOptMethod <: AbstractEpiMethod\n\nAbstract supertype for infence/generative methods that are based on optimization, e.g. MAP estimation or variational inference.\n\n\n\nFields\n\n\n\n\n\n","category":"type"},{"location":"lib/EpiAwareBase/public/#EpiAware.EpiAwareBase.AbstractEpiProblem","page":"Public API","title":"EpiAware.EpiAwareBase.AbstractEpiProblem","text":"abstract type AbstractEpiProblem\n\nAbstract supertype for all EpiAware problems.\n\n\n\nFields\n\n\n\n\n\n","category":"type"},{"location":"lib/EpiAwareBase/public/#EpiAware.EpiAwareBase.AbstractEpiSamplingMethod","page":"Public API","title":"EpiAware.EpiAwareBase.AbstractEpiSamplingMethod","text":"abstract type AbstractEpiSamplingMethod <: AbstractEpiMethod\n\nAbstract supertype for infence/generative methods that are based on sampling from the posterior distribution, e.g. NUTS.\n\n\n\nFields\n\n\n\n\n\n","category":"type"},{"location":"lib/EpiAwareBase/public/#EpiAware.EpiAwareBase.AbstractLatentModel","page":"Public API","title":"EpiAware.EpiAwareBase.AbstractLatentModel","text":"abstract type AbstractLatentModel <: AbstractModel\n\nThe abstract supertype for all structs that define a model for generating a latent process used in EpiAware models.\n\n\n\nFields\n\n\n\n\n\n","category":"type"},{"location":"lib/EpiAwareBase/public/#EpiAware.EpiAwareBase.AbstractObservationModel","page":"Public API","title":"EpiAware.EpiAwareBase.AbstractObservationModel","text":"abstract type AbstractObservationModel <: AbstractModel\n\nA type representing an abstract observation model that is a subtype of AbstractModel.\n\n\n\nFields\n\n\n\n\n\n","category":"type"},{"location":"lib/EpiAwareBase/public/#EpiAware.EpiAwareBase.AbstractTuringEpiModel","page":"Public API","title":"EpiAware.EpiAwareBase.AbstractTuringEpiModel","text":"abstract type AbstractTuringEpiModel <: AbstractEpiModel\n\nA abstract type representing a Turing-based epidemiological model.\n\n\n\nFields\n\n\n\n\n\n","category":"type"},{"location":"lib/EpiAwareBase/public/#EpiAware.EpiAwareBase.AbstractTuringIntercept","page":"Public API","title":"EpiAware.EpiAwareBase.AbstractTuringIntercept","text":"abstract type AbstractTuringIntercept <: AbstractTuringLatentModel\n\nA abstract type used to define the common interface for intercept models.\n\n\n\nFields\n\n\n\n\n\n","category":"type"},{"location":"lib/EpiAwareBase/public/#EpiAware.EpiAwareBase.AbstractTuringLatentModel","page":"Public API","title":"EpiAware.EpiAwareBase.AbstractTuringLatentModel","text":"abstract type AbstractTuringLatentModel <: AbstractLatentModel\n\nA abstract type representing a Turing-based Latent model.\n\n\n\nFields\n\n\n\n\n\n","category":"type"},{"location":"lib/EpiAwareBase/public/#EpiAware.EpiAwareBase.AbstractTuringObservationErrorModel","page":"Public API","title":"EpiAware.EpiAwareBase.AbstractTuringObservationErrorModel","text":"abstract type AbstractTuringObservationErrorModel <: AbstractTuringObservationModel\n\nThe abstract supertype for all structs that defines a Turing-based model for generating observation errors.\n\n\n\nFields\n\n\n\n\n\n","category":"type"},{"location":"lib/EpiAwareBase/public/#EpiAware.EpiAwareBase.AbstractTuringObservationModel","page":"Public API","title":"EpiAware.EpiAwareBase.AbstractTuringObservationModel","text":"abstract type AbstractTuringObservationModel <: AbstractObservationModel\n\nA abstract type representing a Turing-based observation model.\n\n\n\nFields\n\n\n\n\n\n","category":"type"},{"location":"lib/EpiAwareBase/public/#EpiAware.EpiAwareBase.AbstractTuringRenewal","page":"Public API","title":"EpiAware.EpiAwareBase.AbstractTuringRenewal","text":"abstract type AbstractTuringRenewal <: AbstractTuringEpiModel\n\nAbstract type for all Turing-based Renewal infection generating models.\n\n\n\nFields\n\n\n\n\n\n","category":"type"},{"location":"lib/EpiAwareBase/public/#EpiAware.EpiAwareBase.EpiAwareObservables","page":"Public API","title":"EpiAware.EpiAwareBase.EpiAwareObservables","text":"struct EpiAwareObservables\n\nThe EpiAwareObservables struct represents the observables used in the EpiAware model.\n\nFields\n\nmodel: The model used for the observables.\ndata: The data used for the observables.\nsamples: Samples from the posterior distribution.\ngenerated: The generated observables.\n\n\n\nFields\n\nmodel::Any\ndata::Any\nsamples::Any\ngenerated::Any\n\n\n\n\n\n","category":"type"},{"location":"lib/EpiAwareBase/public/#EpiAware.EpiAwareBase.EpiMethod","page":"Public API","title":"EpiAware.EpiAwareBase.EpiMethod","text":"struct EpiMethod{O<:AbstractEpiOptMethod, S<:AbstractEpiSamplingMethod} <: AbstractEpiMethod\n\nEpiMethod represents a method for performing EpiAware inference and/or generative modelling, which combines a sequence of optimization steps to pass initialisation information to a sampler method.\n\n\n\nFields\n\npre_sampler_steps::Vector{O} where O<:AbstractEpiOptMethod: Pre-sampler optimization steps.\nsampler::AbstractEpiSamplingMethod: Sampler method.\n\n\n\n\n\n","category":"type"},{"location":"lib/EpiAwareBase/public/#EpiAware.EpiAwareBase.EpiProblem","page":"Public API","title":"EpiAware.EpiAwareBase.EpiProblem","text":"struct EpiProblem{E<:AbstractEpiModel, L<:AbstractLatentModel, O<:AbstractObservationModel} <: AbstractEpiProblem\n\nDefines an inference/generative modelling problem for case data.\n\nEpiProblem wraps the underlying components of an epidemiological model:\n\nepi_model: An epidemiological model for unobserved infections.\nlatent_model: A latent model for underlying latent process.\nobservation_model: An observation model for observed cases.\n\nAlong with a tspan tuple for the time span of the case data.\n\n\n\nFields\n\nepi_model::AbstractEpiModel: Epidemiological model for unobserved infections.\nlatent_model::AbstractLatentModel: Latent model for underlying latent process.\nobservation_model::AbstractObservationModel: Observation model for observed cases.\ntspan::Tuple{Int64, Int64}: Time span for either inference or generative modelling of case time series.\n\n\n\n\n\n","category":"type"},{"location":"lib/EpiAwareBase/public/#EpiAware.EpiAwareBase._apply_method","page":"Public API","title":"EpiAware.EpiAwareBase._apply_method","text":"_apply_method(\n model::AbstractEpiModel,\n method::AbstractEpiMethod;\n ...\n)\n_apply_method(\n model::AbstractEpiModel,\n method::AbstractEpiMethod,\n prev_result;\n kwargs...\n)\n\n\nApply the inference/generative method method to the AbstractEpiModel object mdl.\n\nArguments\n\nmodel::AbstractEpiModel: The model to apply the method to.\nmethod::AbstractEpiMethod: The epidemiological method to apply.\nprev_result: The previous result of the method.\nkwargs: Additional keyword arguments passed to the method.\n\nReturns\n\nnothing: If no concrete implementation is defined for the given method.\n\n\n\n\n\n","category":"function"},{"location":"lib/EpiAwareBase/public/#EpiAware.EpiAwareBase.apply_method-Tuple{Any, Any, Any}","page":"Public API","title":"EpiAware.EpiAwareBase.apply_method","text":"apply_method(\n model,\n method,\n data;\n kwargs...\n) -> EpiAwareObservables\n\n\nWrap the _apply_method function by calling it with the given model, method, data, and optional keyword arguments (kwargs). The resulting solution is then passed to the generated_observables function, along with the model and input data, to compute the generated observables.\n\nArguments\n\nmodel: The model to apply the method to.\nmethod: The method to apply to the model.\ndata: The data to pass to the apply_method function.\nkwargs: Optional keyword arguments to pass to the apply_method function.\n\nReturns\n\nThe generated observables computed from the solution.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiAwareBase/public/#EpiAware.EpiAwareBase.apply_method-Tuple{Any, Any}","page":"Public API","title":"EpiAware.EpiAwareBase.apply_method","text":"apply_method(\n model,\n method;\n kwargs...\n) -> EpiAwareObservables\n\n\nCalls wrap_apply_method setting the data argument to nothing.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiAwareBase/public/#EpiAware.EpiAwareBase.apply_method-Tuple{EpiProblem, AbstractEpiMethod, Any}","page":"Public API","title":"EpiAware.EpiAwareBase.apply_method","text":"apply_method(\n epiproblem::EpiProblem,\n method::AbstractEpiMethod,\n data;\n fix_parameters,\n condition_parameters,\n kwargs...\n) -> EpiAwareObservables\n\n\nRun the EpiAware algorithm to estimate the parameters of an epidemiological model.\n\nArguments\n\nepiproblem::EpiProblem: An EpiProblem object specifying the epidemiological problem.\nmethod::EpiMethod: An EpiMethod object specifying the inference method.\ndata: The observed data used for inference.\n\nKeyword Arguments\n\nfix_parameters::NamedTuple: A NamedTuple of fixed parameters for the model.\ncondition_parameters::NamedTuple: A NamedTuple of conditioned parameters for the model.\nkwargs...: Additional keyword arguments passed to the inference methods.\n\nReturns\n\nA NamedTuple with a samples field which is the output of applying methods and a model field with the model used. Optionally, a gens field with the generated quantities from the model if that makes sense with the inference method.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiAwareBase/public/#EpiAware.EpiAwareBase.broadcast_n-Tuple{AbstractBroadcastRule, Any, Any, Any}","page":"Public API","title":"EpiAware.EpiAwareBase.broadcast_n","text":"broadcast_n(\n broadcast_rule::AbstractBroadcastRule,\n latent,\n n,\n period\n)\n\n\nThis function is used to define the behavior of broadcasting for a specific type of AbstractBroadcastRule.\n\nThe broadcast_n function returns the length of the latent periods to generate using the given broadcast_rule. Which model of broadcasting to be implemented is set by the type of broadcast_rule. If no implemention is defined for the given broadcast_rule, then EpiAware will return a warning and return nothing.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiAwareBase/public/#EpiAware.EpiAwareBase.broadcast_rule-Tuple{AbstractBroadcastRule, Any, Any}","page":"Public API","title":"EpiAware.EpiAwareBase.broadcast_rule","text":"broadcast_rule(\n broadcast_rule::AbstractBroadcastRule,\n n,\n period\n)\n\n\nThis function is used to define the behavior of broadcasting for a specific type of AbstractBroadcastRule.\n\nThe broadcast_rule function implements a model of broadcasting a latent process. Which model of broadcasting to be implemented is set by the type of broadcast_rule. If no implemention is defined for the given broadcast_rule, then EpiAware will return a warning and return nothing.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiAwareBase/public/#EpiAware.EpiAwareBase.condition_model-Tuple{Any, Any, Any}","page":"Public API","title":"EpiAware.EpiAwareBase.condition_model","text":"condition_model(\n model,\n fix_parameters,\n condition_parameters\n) -> Any\n\n\nCondition a model on fixed (i.e to a value) and conditioned (i.e to data) parameters.\n\nReturns\n\nmodel: The conditioned model.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiAwareBase/public/#EpiAware.EpiAwareBase.generate_epiaware-Tuple{Any, Any, AbstractEpiModel, AbstractLatentModel, AbstractObservationModel}","page":"Public API","title":"EpiAware.EpiAwareBase.generate_epiaware","text":"generate_epiaware(\n y_t,\n time_step,\n epi_model::AbstractEpiModel,\n latent_model::AbstractLatentModel,\n observation_model::AbstractObservationModel\n)\n\n\nCreate an epi-aware model using the specified epimodel, latentmodel, and observation_model.\n\nArguments\n\ny_t: The observed data.\ntime_steps: The time steps.\nepi_model: An abstract epi model.\nlatent_model: An abstract latent model.\nobservation_model: An abstract observation model.\n\nReturns\n\nnothing\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiAwareBase/public/#EpiAware.EpiAwareBase.generate_epiaware-Tuple{EpiProblem, Any}","page":"Public API","title":"EpiAware.EpiAwareBase.generate_epiaware","text":"generate_epiaware(epiproblem::EpiProblem, data) -> Any\n\n\nGenerate an epi-aware model given an EpiProblem and data.\n\nArguments\n\nepiproblem: Epi problem specification.\ndata: Observed data.\n\nReturns\n\nA tuple containing the generated quantities of the epi-aware model.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiAwareBase/public/#EpiAware.EpiAwareBase.generate_latent-Tuple{AbstractLatentModel, Any}","page":"Public API","title":"EpiAware.EpiAwareBase.generate_latent","text":"generate_latent(latent_model::AbstractLatentModel, n) -> Any\n\n\nConstructor function for a latent process path Z_t of length n.\n\nThe generate_latent function implements a model of generating a latent process. Which model for generating the latent process infections is implemented is set by the type of latent_model. If no implemention is defined for the type of latent_model, then EpiAware will pass a warning and return nothing.\n\nInterface to Turing.jl probablilistic programming language (PPL)\n\nApart from the no implementation fallback method, the generate_latent implementation function should return a constructor function for a DynamicPPL.Model object. Sample paths of Z_t are generated quantities of the constructed model. Priors for model parameters are fields of epi_model.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiAwareBase/public/#EpiAware.EpiAwareBase.generate_latent_infs-Tuple{AbstractEpiModel, Any}","page":"Public API","title":"EpiAware.EpiAwareBase.generate_latent_infs","text":"generate_latent_infs(\n epi_model::AbstractEpiModel,\n Z_t\n) -> Any\n\n\nConstructor function for unobserved/latent infections based on the type of epi_model <: AbstractEpimodel and a latent process path Z_t.\n\nThe generate_latent_infs function implements a model of generating unobserved/latent infections conditional on a latent process. Which model of generating unobserved/latent infections to be implemented is set by the type of epi_model. If no implemention is defined for the given epi_model, then EpiAware will return a warning and return nothing.\n\nInterface to Turing.jl probablilistic programming language (PPL)\n\nApart from the no implementation fallback method, the generate_latent_infs implementation function returns a constructor function for a DynamicPPL.Model object where the unobserved/latent infections are a generated quantity. Priors for model parameters are fields of epi_model.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiAwareBase/public/#EpiAware.EpiAwareBase.generate_observations-Tuple{AbstractObservationModel, Any, Any}","page":"Public API","title":"EpiAware.EpiAwareBase.generate_observations","text":"generate_observations(\n obs_model::AbstractObservationModel,\n y_t,\n Y_t\n) -> Any\n\n\nConstructor function for generating observations based on the given observation model.\n\nThe generate_observations function implements a model of generating observations based on the given observation model. Which model of generating observations to be implemented is set by the type of obs_model. If no implemention is defined for the given obs_model, then EpiAware will return a warning and return nothing.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiAwareBase/public/#EpiAware.EpiAwareBase.generated_observables-Tuple{Any, Any, Any}","page":"Public API","title":"EpiAware.EpiAwareBase.generated_observables","text":"generated_observables(\n model,\n data,\n solution\n) -> EpiAwareObservables\n\n\nGenerate observables from a given model and solution and return them as a EpiAwareObservables struct.\n\nArguments\n\nmodel: The model used for generating observables.\ndata: The data used for generating observables.\nsolution: The solution used for generating observables.\n\nReturns\n\nAn instance of EpiAwareObservables struct with the provided model, data, solution, and the generated observables if specified\n\n\n\n\n\n","category":"method"},{"location":"getting-started/explainers/#Explainers","page":"Overview","title":"Explainers","text":"","category":"section"},{"location":"getting-started/explainers/","page":"Overview","title":"Overview","text":"This section contains a series of explainers that provide a detailed overview of the EpiAware platform and its features. These explainers are designed to help you understand the platform and its capabilities, and to provide you with the information you need to get started using EpiAware. See the sidebar for the list of explainers.","category":"page"},{"location":"lib/EpiObsModels/internals/#Internal-Documentation","page":"Internal API","title":"Internal Documentation","text":"","category":"section"},{"location":"lib/EpiObsModels/internals/","page":"Internal API","title":"Internal API","text":"Documentation for EpiObsModels.jl's internal interface.","category":"page"},{"location":"lib/EpiObsModels/internals/#Contents","page":"Internal API","title":"Contents","text":"","category":"section"},{"location":"lib/EpiObsModels/internals/","page":"Internal API","title":"Internal API","text":"Pages = [\"internals.md\"]\nDepth = 2:2","category":"page"},{"location":"lib/EpiObsModels/internals/#Index","page":"Internal API","title":"Index","text":"","category":"section"},{"location":"lib/EpiObsModels/internals/","page":"Internal API","title":"Internal API","text":"Pages = [\"internals.md\"]","category":"page"},{"location":"lib/EpiObsModels/internals/#Internal-API","page":"Internal API","title":"Internal API","text":"","category":"section"},{"location":"lib/EpiObsModels/internals/","page":"Internal API","title":"Internal API","text":"Modules = [EpiAware.EpiObsModels]\nPublic = false","category":"page"},{"location":"lib/EpiObsModels/internals/#EpiAware.EpiAwareBase.generate_observations-Tuple{AbstractTuringObservationErrorModel, Any, Any}","page":"Internal API","title":"EpiAware.EpiAwareBase.generate_observations","text":"generate_observations(\n obs_model::AbstractTuringObservationErrorModel,\n y_t,\n Y_t\n) -> Any\n\n\nGenerates observations from an observation error model. It provides support for missing values in observations (y_t), and missing values at the beginning of the expected observations (Y_t). It also pads the expected observations with a small value (1e-6) to mitigate potential numerical issues.\n\nIt dispatches to the observation_error function to generate the observation error distribution which uses priors generated by generate_observation_error_priors submodel. For most observation error models specific implementations of observation_error and generate_observation_error_priors are required but a specific implementation of generate_observations is not required.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiObsModels/internals/#EpiAware.EpiAwareBase.generate_observations-Tuple{Ascertainment, Any, Any}","page":"Internal API","title":"EpiAware.EpiAwareBase.generate_observations","text":"generate_observations(\n obs_model::Ascertainment,\n y_t,\n Y_t\n) -> Any\n\n\nGenerates observations based on the LatentDelay observation model.\n\nArguments\n\nobs_model::Ascertainment: The Ascertainment model.\ny_t: The current state of the observations.\nY_t` : The expected observations.\n\nReturns\n\ny_t: The updated observations.\nexpected_aux: Additional expected observation-related variables.\nobs_aux: Additional observation-related variables.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiObsModels/internals/#EpiAware.EpiAwareBase.generate_observations-Tuple{LatentDelay, Any, Any}","page":"Internal API","title":"EpiAware.EpiAwareBase.generate_observations","text":"generate_observations(\n obs_model::LatentDelay,\n y_t,\n Y_t\n) -> Any\n\n\nGenerates observations based on the LatentDelay observation model.\n\nArguments\n\nobs_model::LatentDelay: The LatentDelay observation model.\ny_t: The current observations.\nI_t: The current infection indicator.\n\nReturns\n\ny_t: The updated observations.\nobs_aux: Additional observation-related variables.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiObsModels/internals/#EpiAware.EpiAwareBase.generate_observations-Tuple{StackObservationModels, NamedTuple, AbstractVector}","page":"Internal API","title":"EpiAware.EpiAwareBase.generate_observations","text":"generate_observations(\n obs_model::StackObservationModels,\n y_t::NamedTuple,\n Y_t::AbstractVector\n) -> Any\n\n\nGenerate observations from a stack of observation models. Maps Y_t to a NamedTuple of the same length as y_t assuming a 1 to many mapping.\n\nArguments\n\nobs_model::StackObservationModels: The stack of observation models.\ny_t::NamedTuple: The observed values.\nY_t::AbstractVector: The expected values.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiObsModels/internals/#EpiAware.EpiAwareBase.generate_observations-Tuple{StackObservationModels, NamedTuple, NamedTuple}","page":"Internal API","title":"EpiAware.EpiAwareBase.generate_observations","text":"generate_observations(\n obs_model::StackObservationModels,\n y_t::NamedTuple,\n Y_t::NamedTuple\n) -> Any\n\n\nGenerate observations from a stack of observation models. Assumes a 1 to 1 mapping between y_t and Y_t.\n\nArguments\n\nobs_model::StackObservationModels: The stack of observation models.\ny_t::NamedTuple: The observed values.\nY_t::NamedTuple: The expected values.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiObsModels/internals/#EpiAware.EpiObsModels.NegativeBinomialMeanClust-Tuple{Any, Any}","page":"Internal API","title":"EpiAware.EpiObsModels.NegativeBinomialMeanClust","text":"NegativeBinomialMeanClust(\n μ,\n α\n) -> Union{Distributions.DiscreteUniform, Distributions.NegativeBinomial}\n\n\nCompute the mean-cluster factor negative binomial distribution.\n\nArguments\n\nμ: The mean of the distribution.\nα: The clustering factor parameter.\n\nReturns\n\nA NegativeBinomial distribution object.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiObsModels/internals/#EpiAware.EpiObsModels.generate_observation_kernel-Tuple{Any, Any}","page":"Internal API","title":"EpiAware.EpiObsModels.generate_observation_kernel","text":"generate_observation_kernel(\n delay_int,\n time_horizon;\n partial\n) -> Any\n\n\nGenerate an observation kernel matrix based on the given delay interval and time horizon.\n\nArguments\n\ndelay_int::Vector{Float64}: The delay PMF vector.\ntime_horizon::Int: The number of time steps of the observation period.\npartial::Bool: Whether to generate a partial observation kernel matrix.\n\nReturns\n\nK::SparseMatrixCSC{Float64, Int}: The observation kernel matrix.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiInference/internals/#Internal-Documentation","page":"Internal API","title":"Internal Documentation","text":"","category":"section"},{"location":"lib/EpiInference/internals/","page":"Internal API","title":"Internal API","text":"Documentation for EpInference.jl's internal interface.","category":"page"},{"location":"lib/EpiInference/internals/#Contents","page":"Internal API","title":"Contents","text":"","category":"section"},{"location":"lib/EpiInference/internals/","page":"Internal API","title":"Internal API","text":"Pages = [\"internals.md\"]\nDepth = 2:2","category":"page"},{"location":"lib/EpiInference/internals/#Index","page":"Internal API","title":"Index","text":"","category":"section"},{"location":"lib/EpiInference/internals/","page":"Internal API","title":"Internal API","text":"Pages = [\"internals.md\"]","category":"page"},{"location":"lib/EpiInference/internals/#Internal-API","page":"Internal API","title":"Internal API","text":"","category":"section"},{"location":"lib/EpiInference/internals/","page":"Internal API","title":"Internal API","text":"Modules = [EpiAware.EpiInference]\nPublic = false","category":"page"},{"location":"lib/EpiInference/internals/#EpiAware.EpiAwareBase._apply_method","page":"Internal API","title":"EpiAware.EpiAwareBase._apply_method","text":"_apply_method(\n model::DynamicPPL.Model,\n method::ManyPathfinder;\n ...\n) -> Any\n_apply_method(\n model::DynamicPPL.Model,\n method::ManyPathfinder,\n prev_result;\n kwargs...\n) -> Any\n\n\nApply a ManyPathfinder method to a DynamicPPL.Model object.\n\nIf prev_result is a vector of real numbers, then the ManyPathfinder method is applied with the initial values set to prev_result. Otherwise, the ManyPathfinder method is run with default initial values generated.\n\n\n\n\n\n","category":"function"},{"location":"lib/EpiInference/internals/#EpiAware.EpiAwareBase._apply_method-2","page":"Internal API","title":"EpiAware.EpiAwareBase._apply_method","text":"_apply_method(\n model::DynamicPPL.Model,\n method::NUTSampler;\n ...\n) -> Any\n_apply_method(\n model::DynamicPPL.Model,\n method::NUTSampler,\n prev_result;\n kwargs...\n) -> Any\n\n\nApply NUTS sampling to a DynamicPPL.Model object with prev_result representing any initial results to use for sampler initialisation.\n\n\n\n\n\n","category":"function"},{"location":"lib/EpiInference/internals/#EpiAware.EpiInference._apply_nuts-Tuple{Any, Any, Any}","page":"Internal API","title":"EpiAware.EpiInference._apply_nuts","text":"_apply_nuts(model, method, prev_result; kwargs...) -> Any\n\n\nNo initialisation NUTS.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiInference/internals/#EpiAware.EpiInference._apply_nuts-Tuple{Any, Any, Pathfinder.PathfinderResult}","page":"Internal API","title":"EpiAware.EpiInference._apply_nuts","text":"_apply_nuts(\n model,\n method,\n prev_result::Pathfinder.PathfinderResult;\n kwargs...\n) -> Any\n\n\nInitialise NUTS with initial parameters from a Pathfinder result.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiInference/internals/#EpiAware.EpiInference._continue_manypathfinder!-Tuple{Any, DynamicPPL.Model}","page":"Internal API","title":"EpiAware.EpiInference._continue_manypathfinder!","text":"_continue_manypathfinder!(\n pfs,\n mdl::DynamicPPL.Model;\n max_tries,\n nruns,\n kwargs...\n)\n\n\nContinue running the pathfinder algorithm until a pathfinder succeeds or the maximum number of tries is reached.\n\nArguments\n\npfs: An array of pathfinder objects.\nmdl::DynamicPPL.Model: The model to perform inference on.\nmax_tries: The maximum number of tries to run the pathfinder algorithm. Default is Inf.\nnruns: The number of times to run the pathfinder function.\nkwargs...: Additional keyword arguments passed to pathfinder.\n\nReturns\n\npfs: The updated array of pathfinder objects.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiInference/internals/#EpiAware.EpiInference._get_best_elbo_pathfinder-Tuple{Any}","page":"Internal API","title":"EpiAware.EpiInference._get_best_elbo_pathfinder","text":"_get_best_elbo_pathfinder(pfs) -> Any\n\n\nSelects the pathfinder with the highest ELBO estimate from a list of pathfinders.\n\nArguments\n\npfs: A list of pathfinders results or Symbol values indicating failure.\n\nReturns\n\nThe pathfinder with the highest ELBO estimate.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiInference/internals/#EpiAware.EpiInference._run_manypathfinder-Tuple{DynamicPPL.Model}","page":"Internal API","title":"EpiAware.EpiInference._run_manypathfinder","text":"_run_manypathfinder(mdl::DynamicPPL.Model; nruns, kwargs...)\n\n\nRun pathfinder multiple times and store the results in an array. Fails safely.\n\nArguments\n\nmdl::DynamicPPL.Model: The Turing model to be used for inference.\nnruns: The number of times to run the pathfinder function.\nkwargs...: Additional keyword arguments passed to pathfinder.\n\nReturns\n\nAn array of PathfinderResult objects or Symbol values indicating success or failure.\n\n\n\n\n\n","category":"method"},{"location":"getting-started/explainers/modelling-infections/#Modelling-infections","page":"Modelling infections","title":"Modelling infections","text":"","category":"section"},{"location":"developer/contributing/#Contributing","page":"Contributing","title":"Contributing","text":"","category":"section"},{"location":"developer/contributing/","page":"Contributing","title":"Contributing","text":"This page details the some of the guidelines that should be followed when contributing to this package. It is adapted from Documenter.jl.","category":"page"},{"location":"developer/contributing/#Branches","page":"Contributing","title":"Branches","text":"","category":"section"},{"location":"developer/contributing/","page":"Contributing","title":"Contributing","text":"release-* branches are used for tagged minor versions of this package. This follows the same approach used in the main Julia repository, albeit on a much more modest scale.","category":"page"},{"location":"developer/contributing/","page":"Contributing","title":"Contributing","text":"Please open pull requests against the master branch rather than any of the release-* branches whenever possible.","category":"page"},{"location":"developer/contributing/#Backports","page":"Contributing","title":"Backports","text":"","category":"section"},{"location":"developer/contributing/","page":"Contributing","title":"Contributing","text":"Bug fixes are backported to the release-* branches using git cherry-pick -x by a EpiAware member and will become available in point releases of that particular minor version of the package.","category":"page"},{"location":"developer/contributing/","page":"Contributing","title":"Contributing","text":"Feel free to nominate commits that should be backported by opening an issue. Requests for new point releases to be tagged in METADATA.jl can also be made in the same way.","category":"page"},{"location":"developer/contributing/#release-*-branches","page":"Contributing","title":"release-* branches","text":"","category":"section"},{"location":"developer/contributing/","page":"Contributing","title":"Contributing","text":"Each new minor version x.y.0 gets a branch called release-x.y (a protected branch).\nNew versions are usually tagged only from the release-x.y branches.\nFor patch releases, changes get backported to the release-x.y branch via a single PR with the standard name \"Backports for x.y.z\" and label \"Type: Backport\". The PR message links to all the PRs that are providing commits to the backport. The PR gets merged as a merge commit (i.e. not squashed).\nThe old release-* branches may be removed once they have outlived their usefulness.\nPatch version milestones are used to keep track of which PRs get backported etc.","category":"page"},{"location":"developer/contributing/#Style-Guide","page":"Contributing","title":"Style Guide","text":"","category":"section"},{"location":"developer/contributing/","page":"Contributing","title":"Contributing","text":"Follow the style of the surrounding text when making changes. When adding new features please try to stick to the following points whenever applicable. This project follows the SciML style guide.","category":"page"},{"location":"developer/contributing/#Tests","page":"Contributing","title":"Tests","text":"","category":"section"},{"location":"developer/contributing/#Unit-tests","page":"Contributing","title":"Unit tests","text":"","category":"section"},{"location":"developer/contributing/","page":"Contributing","title":"Contributing","text":"As is conventional for Julia packages, unit tests are located at test/*.jl with the entrypoint test/runtests.jl.","category":"page"},{"location":"developer/contributing/#End-to-end-testing","page":"Contributing","title":"End to end testing","text":"","category":"section"},{"location":"developer/contributing/","page":"Contributing","title":"Contributing","text":"Tests that build example package docs from source and inspect the results (end to end tests) are located in /test/examples. The main entry points are test/examples/make.jl for building and test/examples/test.jl for doing some basic checks on the generated outputs.","category":"page"},{"location":"lib/EpiObsModels/#EpiObsModels.jl","page":"Overview","title":"EpiObsModels.jl","text":"","category":"section"},{"location":"lib/EpiObsModels/","page":"Overview","title":"Overview","text":"This package provides observation models for the EpiAware ecosystem.","category":"page"},{"location":"lib/EpiObsModels/#API","page":"Overview","title":"API","text":"","category":"section"},{"location":"lib/EpiObsModels/","page":"Overview","title":"Overview","text":"Pages = [\"lib/EpiObsModels/public.md\", \"lib/EpiObsModels/internals.md\"]","category":"page"},{"location":"developer/checklist/#Checklists","page":"Release checklist","title":"Checklists","text":"","category":"section"},{"location":"developer/checklist/","page":"Release checklist","title":"Release checklist","text":"The purpose of this page is to collate a series of checklists for commonly performed changes to the source code of EpiAware. It has been adapted from Documenter.jl.","category":"page"},{"location":"developer/checklist/","page":"Release checklist","title":"Release checklist","text":"In each case, copy the checklist into the description of the pull request.","category":"page"},{"location":"developer/checklist/#Making-a-release","page":"Release checklist","title":"Making a release","text":"","category":"section"},{"location":"developer/checklist/","page":"Release checklist","title":"Release checklist","text":"In preparation for a release, use the following checklist. These steps should be performed on a branch with an open pull request, either for a topic branch, or for a new branch release-1.y.z (\"Release version 1.y.z\") if multiple changes have accumulated on the master branch since the last release.","category":"page"},{"location":"developer/checklist/","page":"Release checklist","title":"Release checklist","text":"## Pre-release\n\n - [ ] Change the version number in `Project.toml`\n * If the release is breaking, increment MAJOR\n * If the release adds a new user-visible feature, increment MINOR\n * Otherwise (bug-fixes, documentation improvements), increment PATCH\n - [ ] Update `CHANGELOG.md`, following the existing style (in particular, make sure that the change log for this version has the correct version number and date).\n - [ ] Run `make changelog`, to make sure that all the issue references in `CHANGELOG.md` are up to date.\n - [ ] Check that the commit messages in this PR do not contain `[ci skip]`\n - [ ] Run https://github.com/JuliaDocs/Documenter.jl/actions/workflows/regression-tests.yml\n using a `workflow_dispatch` trigger to check for any changes that broke extensions.\n\n## The release\n\n - [ ] After merging the pull request, tag the release. There are two options for this:\n\n 1. [Comment `[at]JuliaRegistrator register` on the GitHub commit.](https://github.com/JuliaRegistries/Registrator.jl#via-the-github-app)\n 2. Use [JuliaHub's package registration feature](https://help.juliahub.com/juliahub/stable/contribute/#registrator) to trigger the registration.\n\n Either of those should automatically publish a new version to the Julia registry.\n - Once registered, the `TagBot.yml` workflow should create a tag, and rebuild the documentation for this tag.\n - These steps can take quite a bit of time (1 hour or more), so don't be surprised if the new documentation takes a while to appear.","category":"page"},{"location":"lib/EpiAwareBase/#EpiAwareBase.jl","page":"Overview","title":"EpiAwareBase.jl","text":"","category":"section"},{"location":"lib/EpiAwareBase/","page":"Overview","title":"Overview","text":"This package provides the core functionality for the EpiAware ecosystem. It is a dependency of all other EpiAware packages.","category":"page"},{"location":"lib/EpiAwareBase/#API","page":"Overview","title":"API","text":"","category":"section"},{"location":"lib/EpiAwareBase/","page":"Overview","title":"Overview","text":"Pages = [\"lib/EpiAwareBase/public.md\", \"lib/EpiAwareBase/internals.md\"]","category":"page"},{"location":"developer/#developer","page":"Overview","title":"Developer documentation","text":"","category":"section"},{"location":"developer/","page":"Overview","title":"Overview","text":"Welcome to the EpiAware developer documentation! This section is designed to help you get started with developing the package.","category":"page"},{"location":"lib/EpiAwareUtils/public/#Public-Documentation","page":"Public API","title":"Public Documentation","text":"","category":"section"},{"location":"lib/EpiAwareUtils/public/","page":"Public API","title":"Public API","text":"Documentation for EpiAwareBae.jl's public interface.","category":"page"},{"location":"lib/EpiAwareUtils/public/","page":"Public API","title":"Public API","text":"See the Internals section of the manual for internal package docs covering all submodules.","category":"page"},{"location":"lib/EpiAwareUtils/public/#Contents","page":"Public API","title":"Contents","text":"","category":"section"},{"location":"lib/EpiAwareUtils/public/","page":"Public API","title":"Public API","text":"Pages = [\"public.md\"]\nDepth = 2:2","category":"page"},{"location":"lib/EpiAwareUtils/public/#Index","page":"Public API","title":"Index","text":"","category":"section"},{"location":"lib/EpiAwareUtils/public/","page":"Public API","title":"Public API","text":"Pages = [\"public.md\"]","category":"page"},{"location":"lib/EpiAwareUtils/public/#Public-API","page":"Public API","title":"Public API","text":"","category":"section"},{"location":"lib/EpiAwareUtils/public/","page":"Public API","title":"Public API","text":"Modules = [EpiAware.EpiAwareUtils]\nPrivate = false","category":"page"},{"location":"lib/EpiAwareUtils/public/#EpiAware.EpiAwareUtils","page":"Public API","title":"EpiAware.EpiAwareUtils","text":"Module for defining utility functions.\n\n\n\n\n\n","category":"module"},{"location":"lib/EpiAwareUtils/public/#EpiAware.EpiAwareUtils.DirectSample","page":"Public API","title":"EpiAware.EpiAwareUtils.DirectSample","text":"struct DirectSample <: AbstractEpiSamplingMethod\n\nSample directly from a Turing model.\n\n\n\nFields\n\nn_samples::Union{Nothing, Int64}: Number of samples from a model. If an integer is provided, the model is sampled n_samples times using Turing.Prior() returning an MCMChains. Chain object. If nothing, the model is sampled once returning a NamedTuple object of the sampled random variables along with generated quantities\n\n\n\n\n\n","category":"type"},{"location":"lib/EpiAwareUtils/public/#EpiAware.EpiAwareUtils.HalfNormal","page":"Public API","title":"EpiAware.EpiAwareUtils.HalfNormal","text":"struct HalfNormal{T<:Real} <: Distributions.Distribution{Distributions.Univariate, Distributions.Continuous}\n\nCreate a half-normal prior distribution with the specified mean.\n\nArguments:\n\nμ: The mean of the half-normal distribution.\n\nReturns:\n\nA HalfNormal distribution with the specified mean.\n\nExamples:\n\nusing EpiAware, Distributions\n\nhn = HalfNormal(1.0)\n# output\nEpiAware.EpiAwareUtils.HalfNormal{Float64}(μ=1.0)\n\nfilter out all the values that are less than 0\n\nrand(hn)\n# output\n0.4508533245229199\n\ncdf(hn, 2)\n# output\n0.8894596502772643\n\nquantile(hn, 0.5)\n# output\n0.8453475393951495\n\nlogpdf(hn, 2)\n# output\n-3.1111166111445083\n\nmean(hn)\n# output\n1.0\n\nvar(hn)\n# output\n0.5707963267948966\n\n\n\nFields\n\nμ::Real\n\n\n\n\n\n","category":"type"},{"location":"lib/EpiAwareUtils/public/#EpiAware.EpiAwareUtils.censored_pmf-Tuple{Distributions.Distribution, Val{:single_censored}}","page":"Public API","title":"EpiAware.EpiAwareUtils.censored_pmf","text":"censored_pmf(\n dist::Distributions.Distribution,\n ::Val{:single_censored};\n primary_approximation_point,\n Δd,\n D\n)\n\n\nCreate a discrete probability mass function (PMF) from a given distribution, assuming that the primary event happens at primary_approximation_point * Δd within an intial censoring interval. Common single-censoring approximations are primary_approximation_point = 0 (left-hand approximation), primary_approximation_point = 1 (right-hand) and primary_approximation_point = 0.5 (midpoint).\n\nArguments\n\ndist: The distribution from which to create the PMF.\n::Val{:single_censored}: A dummy argument to dispatch to this method. The purpose of the Val\n\ntype argument is that to use single-censored approximation is an active decision.\n\nprimary_approximation_point: A approximation point for the primary time in its censoring interval.\n\nDefault is 0.5 for midpoint approximation.\n\nΔd: The step size for discretizing the domain. Default is 1.0.\nD: The upper bound of the domain. Must be greater than Δd.\n\nReturns\n\nA vector representing the PMF.\n\nRaises:\n\nAssertionError if the minimum value of dist is negative.\nAssertionError if Δd is not positive.\nAssertionError if D is not greater than Δd.\n\nExamples\n\nusing Distributions\nusing EpiAware.EpiAwareUtils\n\ndist = Exponential(1.0)\n\ncensored_pmf(dist, Val(:single_censored); D = 10) |>\n p -> round.(p, digits=3)\n\n# output\n10-element Vector{Float64}:\n 0.393\n 0.383\n 0.141\n 0.052\n 0.019\n 0.007\n 0.003\n 0.001\n 0.0\n 0.0\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiAwareUtils/public/#EpiAware.EpiAwareUtils.censored_pmf-Tuple{Distributions.Distribution}","page":"Public API","title":"EpiAware.EpiAwareUtils.censored_pmf","text":"censored_pmf(dist::Distributions.Distribution; Δd, D) -> Any\n\n\nCreate a discrete probability mass function (PMF) from a given distribution, assuming a uniform distribution over primary event times with censoring intervals of width Δd for both primary and secondary events. The CDF for the time from the left edge of the interval containing the primary event to the secondary event is created by direct numerical integration of the convolution of the CDF of dist with the uniform density on [0,Δd), the discrete PMF for double censored delays is then found using simple differencing on the CDF.\n\nArguments\n\ndist: The distribution from which to create the PMF.\nΔd: The step size for discretizing the domain. Default is 1.0.\nD: The upper bound of the domain. Must be greater than Δd. Default D = nothing\n\nindicates that the distribution should be truncated at its 99th percentile rounded to nearest multiple of Δd.\n\nReturns\n\nA vector representing the PMF.\n\nRaises\n\nAssertionError if the minimum value of dist is negative.\nAssertionError if Δd is not positive.\nAssertionError if D is shorter than Δd.\nAssertionError if D is not a multiple of Δd.\n\nExamples\n\nusing Distributions\nusing EpiAware.EpiAwareUtils\n\ndist = Exponential(1.0)\n\ncensored_pmf(dist; D = 10) |>\n p -> round.(p, digits=3)\n\n# output\n10-element Vector{Float64}:\n 0.368\n 0.4\n 0.147\n 0.054\n 0.02\n 0.007\n 0.003\n 0.001\n 0.0\n 0.0\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiAwareUtils/public/#EpiAware.EpiAwareUtils.get_param_array-Tuple{MCMCChains.Chains}","page":"Public API","title":"EpiAware.EpiAwareUtils.get_param_array","text":"get_param_array(chn::MCMCChains.Chains) -> Any\n\n\nExtract a parameter array from a Chains object chn that matches the shape of number of sample and chain pairs in chn.\n\nArguments\n\nchn::Chains: The Chains object containing the MCMC samples.\n\nReturns\n\nparam_array: An array of parameter samples, where each element corresponds to a single\n\nMCMC sample as a NamedTuple.\n\nExample\n\nSampling from a simple model which has both scalar and vector quantity random variables across 4 chains.\n\nusing Turing, MCMCChains, EpiAware\n\n@model function testmodel()\n y ~ Normal()\nend\nmdl = testmodel()\nchn = sample(mdl, Prior(), MCMCSerial(), 2, 1, progress=false)\n\nA = get_param_array(chn)\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiAwareUtils/public/#EpiAware.EpiAwareUtils.prefix_submodel-Tuple{AbstractModel, Function, String, Vararg{Any}}","page":"Public API","title":"EpiAware.EpiAwareUtils.prefix_submodel","text":"prefix_submodel(\n model::AbstractModel,\n fn::Function,\n prefix::String,\n kwargs...\n) -> Any\n\n\nGenerate a submodel with an optional prefix. A lightweight wrapper around the @submodel macro from DynamicPPL.jl.\n\nArguments\n\nmodel::AbstractModel: The model to be used.\nfn::Function: The Turing @model function to be applied to the model.\nprefix::String: The prefix to be used. If the prefix is an empty string, the submodel is created without a prefix.\n\nReturns\n\nsubmodel: The returns from the submodel are passed through.\n\nExamples\n\nusing EpiAware, DynamicPPL\n\nsubmodel = prefix_submodel(FixedIntercept(0.1), generate_latent, string(1), 2)\nsubmodel\n# output\nModel{typeof(prefix_submodel), (:model, :fn, :prefix, Symbol(\"#splat#kwargs\")), (), (), Tuple{FixedIntercept{Float64}, typeof(generate_latent), String, Tuple{Int64}}, Tuple{}, DefaultContext}(EpiAware.EpiAwareUtils.prefix_submodel, (model = FixedIntercept{Float64}(0.1), fn = EpiAware.EpiAwareBase.generate_latent, prefix = \"1\", var\"#splat#kwargs\" = (2,)), NamedTuple(), DefaultContext())\n\nWe can now draw a sample from the submodel.\n\nrand(submodel)\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiAwareUtils/public/#EpiAware.EpiAwareUtils.scan-Union{Tuple{F}, Tuple{F, Any, Any}} where F<:AbstractModel","page":"Public API","title":"EpiAware.EpiAwareUtils.scan","text":"scan(f::AbstractModel, init, xs) -> Tuple{Any, Any}\n\n\nApply f to each element of xs and accumulate the results.\n\nf must be a callable on a sub-type of AbstractModel.\n\nDesign note\n\nscan is being restricted to AbstractModel sub-types to ensure: 1. That compiler specialization is activated 2. Also avoids potential compiler overhead from specialisation on f<: Function.\n\nArguments\n\nf: A callable/functor that takes two arguments, carry and x, and returns a new carry and a result y.\ninit: The initial value for the carry variable.\nxs: An iterable collection of elements.\n\nReturns\n\nys: An array containing the results of applying f to each element of xs.\ncarry: The final value of the carry variable after processing all elements of xs.\n\nExamples\n\n```jldoctest using EpiAware\n\nstruct Adder <: EpiAwareBase.AbstractModel end function (a::Adder)(carry, x) carry + x, carry + x end\n\nscan(Adder(), 0, 1:5) #output ([1, 3, 6, 10, 15], 15)\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiAwareUtils/public/#EpiAware.EpiAwareUtils.spread_draws-Tuple{MCMCChains.Chains}","page":"Public API","title":"EpiAware.EpiAwareUtils.spread_draws","text":"spread_draws(chn::MCMCChains.Chains) -> DataFrames.DataFrame\n\n\nspread_draws(chn::Chains)\n\nConverts a Chains object into a DataFrame in tidybayes format.\n\nArguments\n\nchn::Chains: The Chains object to be converted.\n\nReturns\n\ndf::DataFrame: The converted DataFrame.\n\n\n\n\n\n","category":"method"},{"location":"release-notes/","page":"Release notes","title":"Release notes","text":"EditURL = \"https://github.com/JuliaDocs/Documenter.jl/blob/master/CHANGELOG.md\"","category":"page"},{"location":"release-notes/#Release-notes","page":"Release notes","title":"Release notes","text":"","category":"section"},{"location":"release-notes/","page":"Release notes","title":"Release notes","text":"The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.","category":"page"},{"location":"release-notes/#Unreleased","page":"Release notes","title":"Unreleased","text":"","category":"section"},{"location":"release-notes/#Added","page":"Release notes","title":"Added","text":"","category":"section"},{"location":"release-notes/#Changed","page":"Release notes","title":"Changed","text":"","category":"section"},{"location":"release-notes/#Fixed","page":"Release notes","title":"Fixed","text":"","category":"section"},{"location":"getting-started/#getting-started","page":"Overview","title":"Getting started","text":"","category":"section"},{"location":"getting-started/","page":"Overview","title":"Overview","text":"Note that this section of the documentation is still under construction. Please see replications for the most up-to-date information. Please feel free to contribute to the documentation by submitting a pull request.","category":"page"},{"location":"getting-started/","page":"Overview","title":"Overview","text":"Welcome to the EpiAware documentation! This section is designed to help you get started with the package. It includes a frequently asked questions (FAQ) section, a series of explainers that provide a detailed overview of the platform and its features, and tutorials that will help you get started with EpiAware for specific tasks. See the sidebar for the list of topics.","category":"page"},{"location":"getting-started/explainers/observation-models/#Observation-models","page":"Observation models","title":"Observation models","text":"","category":"section"},{"location":"showcase/#showcase","page":"Overview","title":"EpiAware Showcase","text":"","category":"section"},{"location":"showcase/","page":"Overview","title":"Overview","text":"Here we showcase the capabilities of EpiAware in action. If you have a showcase you would like to add, please submit a pull request.","category":"page"}] +[{"location":"getting-started/installation/#Installation","page":"Installation","title":"Installation","text":"","category":"section"},{"location":"getting-started/installation/","page":"Installation","title":"Installation","text":"Eventually, EpiAware is likely to be added to the Julia registry. Until then, you can install it from the /EpiAware sub-directory of this repository by running the following command in the Julia REPL:","category":"page"},{"location":"getting-started/installation/","page":"Installation","title":"Installation","text":"using Pkg; Pkg.add(url=\"https://github.com/CDCgov/Rt-without-renewal\", subdir=\"EpiAware\")","category":"page"},{"location":"lib/EpiInfModels/#EpiInfModels.jl","page":"Overview","title":"EpiInfModels.jl","text":"","category":"section"},{"location":"lib/EpiInfModels/","page":"Overview","title":"Overview","text":"This package provides infectious disease transmission models for the EpiAware ecosystem.","category":"page"},{"location":"lib/EpiInfModels/#API","page":"Overview","title":"API","text":"","category":"section"},{"location":"lib/EpiInfModels/","page":"Overview","title":"Overview","text":"Pages = [\"lib/EpiInfModels/public.md\", \"lib/EpiInfModels/internals.md\"]","category":"page"},{"location":"getting-started/quickstart/#Quickstart","page":"Quickstart","title":"Quickstart","text":"","category":"section"},{"location":"getting-started/quickstart/","page":"Quickstart","title":"Quickstart","text":"Get up and running with EpiAware in just a few minutes using this quickstart guide.","category":"page"},{"location":"lib/EpiLatentModels/#EpiLatentModels.jl","page":"Overview","title":"EpiLatentModels.jl","text":"","category":"section"},{"location":"lib/EpiLatentModels/","page":"Overview","title":"Overview","text":"This package provides latent variable models for the EpiAware ecosystem.","category":"page"},{"location":"lib/EpiLatentModels/#API","page":"Overview","title":"API","text":"","category":"section"},{"location":"lib/EpiLatentModels/","page":"Overview","title":"Overview","text":"Pages = [\"lib/EpiLatentModels/public.md\", \"lib/EpiLatentModels/internals.md\"]","category":"page"},{"location":"lib/#api-reference","page":"Overview","title":"API reference","text":"","category":"section"},{"location":"lib/","page":"Overview","title":"Overview","text":"Welcome to the EpiAware API reference! This section is designed to help you understand the API of the package which is split into submodules.","category":"page"},{"location":"lib/","page":"Overview","title":"Overview","text":"The EpiAware package itself contains no functions or types. Instead, it re-exports the functions and types from its submodules. See the sidebar for the list of submodules.","category":"page"},{"location":"lib/EpiLatentModels/internals/#Internal-Documentation","page":"Internal API","title":"Internal Documentation","text":"","category":"section"},{"location":"lib/EpiLatentModels/internals/","page":"Internal API","title":"Internal API","text":"Documentation for EpiLatentModels.jl's internal interface.","category":"page"},{"location":"lib/EpiLatentModels/internals/#Contents","page":"Internal API","title":"Contents","text":"","category":"section"},{"location":"lib/EpiLatentModels/internals/","page":"Internal API","title":"Internal API","text":"Pages = [\"internals.md\"]\nDepth = 2:2","category":"page"},{"location":"lib/EpiLatentModels/internals/#Index","page":"Internal API","title":"Index","text":"","category":"section"},{"location":"lib/EpiLatentModels/internals/","page":"Internal API","title":"Internal API","text":"Pages = [\"internals.md\"]","category":"page"},{"location":"lib/EpiLatentModels/internals/#Internal-API","page":"Internal API","title":"Internal API","text":"","category":"section"},{"location":"lib/EpiLatentModels/internals/","page":"Internal API","title":"Internal API","text":"Modules = [EpiAware.EpiLatentModels]\nPublic = false","category":"page"},{"location":"lib/EpiLatentModels/internals/#EpiAware.EpiAwareBase.broadcast_n-Tuple{RepeatBlock, Any, Any}","page":"Internal API","title":"EpiAware.EpiAwareBase.broadcast_n","text":"broadcast_n(_::RepeatBlock, n, period) -> Any\n\n\nA function that returns the length of the latent periods to generate using the RepeatBlock rule which is equal n divided by the period and rounded up to the nearest integer.\n\nArguments\n\nrule::RepeatBlock: The broadcasting rule.\nn: The number of samples to generate.\nperiod: The period of the broadcast.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiLatentModels/internals/#EpiAware.EpiAwareBase.broadcast_n-Tuple{RepeatEach, Any, Any}","page":"Internal API","title":"EpiAware.EpiAwareBase.broadcast_n","text":"broadcast_n(_::RepeatEach, n, period) -> Any\n\n\nA function that returns the length of the latent periods to generate using the RepeatEach rule which is equal to the period.\n\nArguments\n\nrule::RepeatEach: The broadcasting rule.\nn: The number of samples to generate.\nperiod: The period of the broadcast.\n\nReturns\n\nm: The length of the latent periods to generate.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiLatentModels/internals/#EpiAware.EpiAwareBase.broadcast_rule-Tuple{RepeatBlock, Any, Any, Any}","page":"Internal API","title":"EpiAware.EpiAwareBase.broadcast_rule","text":"broadcast_rule(_::RepeatBlock, latent, n, period) -> Any\n\n\nbroadcast_rule is a function that applies the RepeatBlock rule to the latent process latent to generate n samples.\n\nArguments\n\nrule::RepeatBlock: The broadcasting rule.\nlatent::Vector: The latent process.\nn: The number of samples to generate.\nperiod: The period of the broadcast.\n\nReturns\n\nlatent: The generated broadcasted latent periods.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiLatentModels/internals/#EpiAware.EpiAwareBase.broadcast_rule-Tuple{RepeatEach, Any, Any, Any}","page":"Internal API","title":"EpiAware.EpiAwareBase.broadcast_rule","text":"broadcast_rule(_::RepeatEach, latent, n, period) -> Any\n\n\nbroadcast_rule is a function that applies the RepeatEach rule to the latent process latent to generate n samples.\n\nArguments\n\nrule::RepeatEach: The broadcasting rule.\nlatent::Vector: The latent process.\nn: The number of samples to generate.\nperiod: The period of the broadcast.\n\nReturns\n\nlatent: The generated broadcasted latent periods.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiLatentModels/internals/#EpiAware.EpiAwareBase.generate_latent-Tuple{AR, Any}","page":"Internal API","title":"EpiAware.EpiAwareBase.generate_latent","text":"generate_latent(latent_model::AR, n) -> Any\n\n\nGenerate a latent AR series.\n\nArguments\n\nlatent_model::AR: The AR model.\nn::Int: The length of the AR series.\n\nReturns\n\nar::Vector{Float64}: The generated AR series.\nparams::NamedTuple: A named tuple containing the generated parameters (σ_AR, ar_init, damp_AR).\n\nNotes\n\nThe length of damp_prior and init_prior must be the same.\nn must be longer than the order of the autoregressive process.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiLatentModels/internals/#EpiAware.EpiAwareBase.generate_latent-Tuple{BroadcastLatentModel, Any}","page":"Internal API","title":"EpiAware.EpiAwareBase.generate_latent","text":"generate_latent(model::BroadcastLatentModel, n) -> Any\n\n\nGenerates latent periods using the specified model and n number of samples.\n\nArguments\n\nmodel::BroadcastLatentModel: The broadcast latent model.\nn::Any: The number of samples to generate.\n\nReturns\n\nbroadcasted_latent: The generated broadcasted latent periods.\nlatent_period_aux...: Additional auxiliary information about the latent periods.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiLatentModels/internals/#EpiAware.EpiAwareBase.generate_latent-Tuple{CombineLatentModels, Any}","page":"Internal API","title":"EpiAware.EpiAwareBase.generate_latent","text":"generate_latent(\n latent_models::CombineLatentModels,\n n\n) -> Any\n\n\nGenerate latent variables using a combination of multiple latent models.\n\nArguments\n\nlatent_models::CombineLatentModels: An instance of the CombineLatentModels type representing the collection of latent models.\nn: The number of latent variables to generate.\n\nReturns\n\ncombined_latents: The combined latent variables generated from all the models.\nlatent_aux: A tuple containing the auxiliary latent variables generated from each individual model.\n\nExample\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiLatentModels/internals/#EpiAware.EpiAwareBase.generate_latent-Tuple{ConcatLatentModels, Any}","page":"Internal API","title":"EpiAware.EpiAwareBase.generate_latent","text":"generate_latent(latent_models::ConcatLatentModels, n) -> Any\n\n\nGenerate latent variables by concatenating multiple latent models.\n\nArguments\n\nlatent_models::ConcatLatentModels: An instance of the ConcatLatentModels type representing the collection of latent models.\nn: The number of latent variables to generate.\n\nReturns\n\nconcatenated_latents: The combined latent variables generated from all the models.\nlatent_aux: A tuple containing the auxiliary latent variables generated from each individual model.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiLatentModels/internals/#EpiAware.EpiAwareBase.generate_latent-Tuple{DiffLatentModel, Any}","page":"Internal API","title":"EpiAware.EpiAwareBase.generate_latent","text":"generate_latent(latent_model::DiffLatentModel, n) -> Any\n\n\nGenerate a Turing model for n-step latent process Z_t using a differenced latent model defined by latent_model.\n\nArguments\n\nlatent_model::DiffLatentModel: The differential latent model.\nn: The length of the latent variables.\n\nTuring model specifications\n\nSampled random variables\n\nlatent_init: The initial latent process variables.\nOther random variables defined by model<:AbstractTuringLatentModel field of the undifferenced model.\n\nGenerated quantities\n\nA tuple containing the generated latent process as its first argument and a NamedTuple of sampled auxiliary variables as second argument.\n\nExample usage with DiffLatentModel model constructor\n\ngenerate_latent can be used to construct a Turing model for the differenced latent process. In this example, the underlying undifferenced process is a RandomWalk model.\n\nFirst, we construct a RandomWalk struct with an initial value prior and a step size standard deviation prior.\n\nusing Distributions, EpiAware\nrw = RandomWalk(Normal(0.0, 1.0), truncated(Normal(0.0, 0.05), 0.0, Inf))\n\nThen, we can use DiffLatentModel to construct a DiffLatentModel for d-fold differenced process with rw as the undifferenced latent process.\n\nWe have two constructor options for DiffLatentModel. The first option is to supply a common prior distribution for the initial terms and specify d as follows:\n\ndiff_model = DiffLatentModel(rw, Normal(); d = 2)\n\nOr we can supply a vector of priors for the initial terms and d is inferred as follows:\n\ndiff_model2 = DiffLatentModel(;undiffmodel = rw, init_priors = [Normal(), Normal()])\n\nThen, we can use generate_latent to construct a Turing model for the differenced latent process generating a length n process,\n\n# Construct a Turing model\nn = 100\ndifference_mdl = generate_latent(diff_model, n)\n\nNow we can use the Turing PPL API to sample underlying parameters and generate the unobserved latent process.\n\n#Sample random parameters from prior\nθ = rand(difference_mdl)\n#Get a sampled latent process as a generated quantity from the model\n(Z_t, _) = generated_quantities(difference_mdl, θ)\nZ_t\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiLatentModels/internals/#EpiAware.EpiAwareBase.generate_latent-Tuple{FixedIntercept, Any}","page":"Internal API","title":"EpiAware.EpiAwareBase.generate_latent","text":"generate_latent(latent_model::FixedIntercept, n) -> Any\n\n\nGenerate a latent intercept series with a fixed intercept value.\n\nArguments\n\nlatent_model::FixedIntercept: The fixed intercept latent model.\nn: The number of latent variables to generate.\n\nReturns\n\nlatent_vars: An array of length n filled with the fixed intercept value.\nmetadata: A named tuple containing the intercept value.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiLatentModels/internals/#EpiAware.EpiAwareBase.generate_latent-Tuple{HierarchicalNormal, Any}","page":"Internal API","title":"EpiAware.EpiAwareBase.generate_latent","text":"generate_latent(obs_model::HierarchicalNormal, n) -> Any\n\n\nfunction EpiAwareBase.generate_latent(obs_model::HierarchicalNormal, n)\n\nGenerate latent variables from the hierarchical normal distribution.\n\nArguments\n\nobs_model::HierarchicalNormal: The hierarchical normal distribution model.\nn: Number of latent variables to generate.\n\nReturns\n\nη_t: Generated latent variables.\nstd: Standard deviation used in the generation.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiLatentModels/internals/#EpiAware.EpiAwareBase.generate_latent-Tuple{Intercept, Any}","page":"Internal API","title":"EpiAware.EpiAwareBase.generate_latent","text":"generate_latent(latent_model::Intercept, n) -> Any\n\n\nGenerate a latent intercept series.\n\nArguments\n\nlatent_model::Intercept: The intercept model.\nn::Int: The length of the intercept series.\n\nReturns\n\nintercept::Vector{Float64}: The generated intercept series.\nmetadata::NamedTuple: A named tuple containing the intercept value.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiLatentModels/internals/#EpiAware.EpiAwareBase.generate_latent-Tuple{RandomWalk, Any}","page":"Internal API","title":"EpiAware.EpiAwareBase.generate_latent","text":"generate_latent(latent_model::RandomWalk, n) -> Any\n\n\nImplement the generate_latent function for the RandomWalk model.\n\nExample usage of generate_latent with RandomWalk type of latent process model\n\nusing Distributions, Turing, EpiAware\n\n# Create a RandomWalk model\nrw = RandomWalk(init_prior = Normal(2., 1.),\n std_prior = HalfNormal(0.1))\n\nThen, we can use generate_latent to construct a Turing model for a 10 step random walk.\n\n# Construct a Turing model\nrw_model = generate_latent(rw, 10)\n\nNow we can use the Turing PPL API to sample underlying parameters and generate the unobserved infections.\n\n#Sample random parameters from prior\nθ = rand(rw_model)\n#Get random walk sample path as a generated quantities from the model\nZ_t, _ = generated_quantities(rw_model, θ)\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiLatentModels/internals/#EpiAware.EpiAwareBase.generate_latent-Tuple{TransformLatentModel, Any}","page":"Internal API","title":"EpiAware.EpiAwareBase.generate_latent","text":"generate_latent(model::TransformLatentModel, n) -> Any\n\n\ngenerate_latent(model::TransformLatentModel, n)\n\nGenerate latent variables using the specified TransformLatentModel.\n\nArguments\n\nmodel::TransformLatentModel: The TransformLatentModel to generate latent variables from.\nn: The number of latent variables to generate.\n\nReturns\n\ntransformed: The transformed latent variables.\nlatent_aux: Additional auxiliary variables generated by the underlying latent model.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiObsModels/public/#Public-Documentation","page":"Public API","title":"Public Documentation","text":"","category":"section"},{"location":"lib/EpiObsModels/public/","page":"Public API","title":"Public API","text":"Documentation for EpiObsModels.jl's public interface.","category":"page"},{"location":"lib/EpiObsModels/public/","page":"Public API","title":"Public API","text":"See the Internals section of the manual for internal package docs covering all submodules.","category":"page"},{"location":"lib/EpiObsModels/public/#Contents","page":"Public API","title":"Contents","text":"","category":"section"},{"location":"lib/EpiObsModels/public/","page":"Public API","title":"Public API","text":"Pages = [\"public.md\"]\nDepth = 2:2","category":"page"},{"location":"lib/EpiObsModels/public/#Index","page":"Public API","title":"Index","text":"","category":"section"},{"location":"lib/EpiObsModels/public/","page":"Public API","title":"Public API","text":"Pages = [\"public.md\"]","category":"page"},{"location":"lib/EpiObsModels/public/#Public-API","page":"Public API","title":"Public API","text":"","category":"section"},{"location":"lib/EpiObsModels/public/","page":"Public API","title":"Public API","text":"Modules = [EpiAware.EpiObsModels]\nPrivate = false","category":"page"},{"location":"lib/EpiObsModels/public/#EpiAware.EpiObsModels","page":"Public API","title":"EpiAware.EpiObsModels","text":"Module for defining observation models.\n\n\n\n\n\n","category":"module"},{"location":"lib/EpiObsModels/public/#EpiAware.EpiObsModels.Ascertainment","page":"Public API","title":"EpiAware.EpiObsModels.Ascertainment","text":"struct Ascertainment{M<:AbstractTuringObservationModel, T<:AbstractTuringLatentModel, F<:Function, P<:String} <: AbstractTuringObservationModel\n\nThe Ascertainment struct represents an observation model that incorporates a ascertainment model. If a latent_prefixis supplied the latent_model is wrapped in a call to PrefixLatentModel.\n\nConstructors\n\nAscertainment(model::M, latent_model::T, link::F, latent_prefix::P) where {M <: AbstractTuringObservationModel, T <: AbstractTuringLatentModel, F <: Function, P <: String}: Constructs an Ascertainment instance with the specified observation model, latent model, link function, and latent prefix.\nAscertainment(; model::M, latent_model::T, link::F, latent_prefix::P) where {M <: AbstractTuringObservationModel, T <: AbstractTuringLatentModel, F <: Function, P <: String}: Constructs an Ascertainment instance with the specified observation model, latent model, link function, and latent prefix.\n\nExamples\n\nusing EpiAware, Turing\nobs = Ascertainment(model = NegativeBinomialError(), latent_model = FixedIntercept(0.1))\ngen_obs = generate_observations(obs, missing, fill(100, 10))\nrand(gen_obs)\n\n\n\nFields\n\nmodel::AbstractTuringObservationModel: The underlying observation model.\nlatent_model::AbstractTuringLatentModel: The latent model.\nlink::Function: The link function used to transform the latent model to the observed data.\nlatent_prefix::String\n\n\n\n\n\n","category":"type"},{"location":"lib/EpiObsModels/public/#EpiAware.EpiObsModels.LatentDelay","page":"Public API","title":"EpiAware.EpiObsModels.LatentDelay","text":"struct LatentDelay{M<:AbstractTuringObservationModel, T<:(AbstractVector{<:Real})} <: AbstractTuringObservationModel\n\nThe LatentDelay struct represents an observation model that introduces a latent delay in the observations. It is a subtype of AbstractTuringObservationModel.\n\nNote that the LatentDelay observation model shortens the observation vector by the length of the delay distribution and this is then passed to the underlying observation model. This is to prevent fitting to partially observed data.\n\nFields\n\nmodel::M: The underlying observation model.\npmf::T: The probability mass function (PMF) representing the delay distribution.\n\nConstructors\n\nLatentDelay(model::M, distribution::C; D = nothing, Δd = 1.0) where {M <: AbstractTuringObservationModel, C <: ContinuousDistribution}: Constructs a LatentDelay object with the given underlying observation model and continuous distribution. The D parameter specifies the right truncation of the distribution, with default D = nothing indicates that the distribution should be truncated at its 99th percentile rounded to nearest multiple of Δd. The Δd parameter specifies the width of each delay interval.\nLatentDelay(model::M, pmf::T) where {M <: AbstractTuringObservationModel, T <: AbstractVector{<:Real}}: Constructs a LatentDelay object with the given underlying observation model and delay PMF.\n\nExamples\n\nusing Distributions, Turing, EpiAware\nobs = LatentDelay(NegativeBinomialError(), truncated(Normal(5.0, 2.0), 0.0, Inf))\nobs_model = generate_observations(obs, missing, fill(10, 10))\nrand(obs_model)\n\n\n\nFields\n\nmodel::AbstractTuringObservationModel\npmf::AbstractVector{<:Real}\n\n\n\n\n\n","category":"type"},{"location":"lib/EpiObsModels/public/#EpiAware.EpiObsModels.NegativeBinomialError","page":"Public API","title":"EpiAware.EpiObsModels.NegativeBinomialError","text":"struct NegativeBinomialError{S<:Distributions.Sampleable} <: AbstractTuringObservationErrorModel\n\nThe NegativeBinomialError struct represents an observation model for negative binomial errors. It is a subtype of AbstractTuringObservationModel.\n\nConstructors\n\nNegativeBinomialError(; cluster_factor_prior::Distribution = HalfNormal(0.1)): Constructs a NegativeBinomialError object with default values for the cluster factor prior.\nNegativeBinomialError(cluster_factor_prior::Distribution): Constructs a NegativeBinomialError object with a specified cluster factor prior.\n\nExamples\n\nusing Distributions, Turing, EpiAware\nnb = NegativeBinomialError()\nnb_model = generate_observations(nb, missing, fill(10, 10))\nrand(nb_model)\n\n\n\nFields\n\ncluster_factor_prior::Distributions.Sampleable: The prior distribution for the cluster factor.\n\n\n\n\n\n","category":"type"},{"location":"lib/EpiObsModels/public/#EpiAware.EpiObsModels.PoissonError","page":"Public API","title":"EpiAware.EpiObsModels.PoissonError","text":"struct PoissonError <: AbstractTuringObservationErrorModel\n\nThe PoissonError struct represents an observation model for Poisson errors. It is a subtype of AbstractTuringObservationErrorModel.\n\nConstructors\n\nPoissonError(): Constructs a PoissonError object.\n\nExamples\n\nusing Distributions, Turing, EpiAware\npoi = PoissonError()\npoi_model = generate_observations(poi, missing, fill(10, 10))\nrand(poi_model)\n\n\n\nFields\n\n\n\n\n\n","category":"type"},{"location":"lib/EpiObsModels/public/#EpiAware.EpiObsModels.PrefixObservationModel","page":"Public API","title":"EpiAware.EpiObsModels.PrefixObservationModel","text":"struct PrefixObservationModel{M<:AbstractTuringObservationModel, P<:String} <: AbstractTuringObservationModel\n\nGenerate an observation model with a prefix. A lightweight wrapper around `EpiAwareUtils.prefix_submodel`.\n\n# Constructors\n- `PrefixObservationModel(model::M, prefix::P)`: Create a `PrefixObservationModel` with the observation model `model` and the prefix `prefix`.\n- `PrefixObservationModel(; model::M, prefix::P)`: Create a `PrefixObservationModel` with the observation model `model` and the prefix `prefix`.\n\n# Examples\n```julia\nusing EpiAware\nobservation_model = PrefixObservationModel(Poisson(), \"Test\")\nobs = generate_observations(observation_model, 10)\nrand(obs)\n```\n\n\n\nFields\n\nmodel::AbstractTuringObservationModel: The observation model\nprefix::String: The prefix for the observation model\n\n\n\n\n\n","category":"type"},{"location":"lib/EpiObsModels/public/#EpiAware.EpiObsModels.StackObservationModels","page":"Public API","title":"EpiAware.EpiObsModels.StackObservationModels","text":"struct StackObservationModels{M<:(AbstractVector{<:AbstractTuringObservationModel}), N<:(AbstractVector{<:AbstractString})} <: AbstractTuringObservationModel\n\nA stack of observation models that are looped over to generate observations for each model in the stack. Note that the model names are used to prefix the parameters in each model (so if I have a model named cases and a parameter y_t, the parameter in the model will be cases.y_t). Inside the constructor PrefixObservationModel is wrapped around each observation model.\n\nConstructors\n\nStackObservationModels(models::Vector{<:AbstractTuringObservationModel}, model_names::Vector{<:AbstractString}): Construct a StackObservationModels object with a vector of observation models and a vector of model names.\n`StackObservationModels(; models::Vector{<:AbstractTuringObservationModel},\nmodel_names::Vector{<:AbstractString}): Construct aStackObservationModels` object with a vector of observation models and a vector of model names.\nStackObservationModels(models::NamedTuple{names, T}): Construct a StackObservationModels object with a named tuple of observation models. The model names are automatically generated from the keys of the named tuple.\n\nExample\n\nusing EpiAware, Turing\n\nobs = StackObservationModels(\n (cases = PoissonError(), deaths = NegativeBinomialError())\n)\ny_t = (cases = missing, deaths = missing)\nobs_model = generate_observations(obs, y_t, fill(10, 10))\nrand(obs_model)\nsamples = sample(obs_model, Prior(), 100; progress = false)\n\ncases_y_t = group(samples, \"cases.y_t\")\ncases_y_t\n\ndeaths_y_t = group(samples, \"deaths.y_t\")\ndeaths_y_t\n\n\n\nFields\n\nmodels::AbstractVector{<:AbstractTuringObservationModel}: A vector of observation models.\nmodel_names::AbstractVector{<:AbstractString}: A vector of observation model names\n\n\n\n\n\n","category":"type"},{"location":"lib/EpiObsModels/public/#EpiAware.EpiObsModels.ascertainment_dayofweek-Tuple{AbstractTuringObservationModel}","page":"Public API","title":"EpiAware.EpiObsModels.ascertainment_dayofweek","text":"ascertainment_dayofweek(\n model::AbstractTuringObservationModel;\n latent_model,\n link,\n latent_prefix\n) -> Ascertainment{M, AbstractTuringLatentModel, EpiAware.EpiObsModels.var\"#16#18\", String} where M<:AbstractTuringObservationModel\n\n\nCreate an Ascertainment object that models the ascertainment process based on the day of the week.\n\nArguments\n\nmodel::AbstractTuringObservationModel: The observation model to be used.\nlatent_model::AbstractTuringLatentModel: The latent model to be used. Default is HierarchicalNormal() which is a hierarchical normal distribution.\nlink: The link function to be used. Default is the identity map x -> x.\n\nThis function is used to transform the latent model after broadcasting to periodic weekly has been applied.\n\nlatent_prefix: The prefix to be used for the latent model. Default is \"DayofWeek\".\n\nReturns\n\nAscertainment: The Ascertainment object that models the ascertainment process based on the day of the week.\n\nExamples\n\nusing EpiAware\nobs = ascertainment_dayofweek(PoissonError())\ngen_obs = generate_observations(obs, missing, fill(100, 14))\ngen_obs()\nrand(gen_obs)\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiObsModels/public/#EpiAware.EpiObsModels.generate_observation_error_priors-Tuple{AbstractTuringObservationErrorModel, Any, Any}","page":"Public API","title":"EpiAware.EpiObsModels.generate_observation_error_priors","text":"generate_observation_error_priors(\n obs_model::AbstractTuringObservationErrorModel,\n y_t,\n Y_t\n) -> Any\n\n\nGenerates priors for the observation error model. This should return a named tuple containing the priors required for generating the observation error distribution.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiObsModels/public/#EpiAware.EpiObsModels.generate_observation_error_priors-Tuple{NegativeBinomialError, Any, Any}","page":"Public API","title":"EpiAware.EpiObsModels.generate_observation_error_priors","text":"generate_observation_error_priors(\n obs_model::NegativeBinomialError,\n Y_t,\n y_t\n) -> Any\n\n\nGenerates observation error priors based on the NegativeBinomialError observation model. This function generates the cluster factor prior for the negative binomial error model.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiObsModels/public/#EpiAware.EpiObsModels.observation_error-Tuple{AbstractTuringObservationErrorModel, Any}","page":"Public API","title":"EpiAware.EpiObsModels.observation_error","text":"observation_error(\n obs_model::AbstractTuringObservationErrorModel,\n Y_t\n) -> Distributions.Poisson\n\n\nThe observation error distribution for the observation error model. This function should return the distribution for the observation error given the expected observation value Y_t and the priors generated by generate_observation_error_priors.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiObsModels/public/#EpiAware.EpiObsModels.observation_error-Tuple{NegativeBinomialError, Any, Any}","page":"Public API","title":"EpiAware.EpiObsModels.observation_error","text":"observation_error(\n obs_model::NegativeBinomialError,\n Y_t,\n sq_cluster_factor\n) -> Union{Distributions.DiscreteUniform, Distributions.NegativeBinomial}\n\n\nThis function generates the observation error model based on the negative binomial error model with a positive shift. It dispatches to the NegativeBinomialMeanClust distribution.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiObsModels/public/#EpiAware.EpiObsModels.observation_error-Tuple{PoissonError, Any}","page":"Public API","title":"EpiAware.EpiObsModels.observation_error","text":"observation_error(\n obs_model::PoissonError,\n Y_t\n) -> Distributions.Poisson\n\n\nThe observation error model for Poisson errors. This function generates the observation error model based on the Poisson error model.\n\n\n\n\n\n","category":"method"},{"location":"getting-started/explainers/julia/#Julia-for-EpiAware","page":"Working with Julia","title":"Julia for EpiAware","text":"","category":"section"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"Julia is a programming language aimed at technical computing. This guide is aimed at helping you set up Julia on your system and pointing towards resources for learning more.","category":"page"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"[!NOTE] If you are familar with other languages with tooling for technical computing (e.g. R, MATLAB, Python) these noteworthy differences may be useful.","category":"page"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"Pages = [\"getting-started/tutorials/julia.md\"]\nDepth = 3","category":"page"},{"location":"getting-started/explainers/julia/#What-this-guide-is-and-isn't","page":"Working with Julia","title":"What this guide is and isn't","text":"","category":"section"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"This isn't a guide to learning the Julia programming language. Instead we providing an opinionated guide to setting up your system to use Julia effectively in project workflows aimed at people with familiarity with Julia but have maybe only developed projects in other languages (e.g. R, MATLAB, Python).","category":"page"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"If you want to learn more about the Julia programming language, we recommend the following resources:","category":"page"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"Julia Documentation - getting started.\nJulia Academy.\nJulia learning resources.\nJuliaHub.\nJulia Discourse.\nJulia Slack.","category":"page"},{"location":"getting-started/explainers/julia/#Julia-Installation-with-Juliaup","page":"Working with Julia","title":"Julia Installation with Juliaup","text":"","category":"section"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"Download Juliaup: This is a cross-platform installer/updater for the Julia programming language. It simplifies the process of installing and managing Julia versions. Go to the Juliaup GitHub repository or to the official Julia website for installation instructions.\nVerify Installation: Open a terminal (or Command Prompt on Windows) and type julia to start the Julia REPL (Read-Eval-Print Loop). You should see a Julia prompt julia>.","category":"page"},{"location":"getting-started/explainers/julia/#Basic-usage-of-Juliaup","page":"Working with Julia","title":"Basic usage of Juliaup","text":"","category":"section"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"Juliaup is a tool for managing Julia installations on your system. It allows you to install, update, and switch between different versions of Julia. Details are available at the Juliaup GitHub repository, but here are some examples of common commands:","category":"page"},{"location":"getting-started/explainers/julia/#Add-a-specific-version-of-Julia","page":"Working with Julia","title":"Add a specific version of Julia","text":"","category":"section"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"Juliaup default installs the latest release version of Julia. To install a specific version, use the add command followed by the version number. For example, to install Julia version 1.9.3, use the following command:","category":"page"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"% juliaup add 1.9.3","category":"page"},{"location":"getting-started/explainers/julia/#Use-a-specific-version-of-Julia","page":"Working with Julia","title":"Use a specific version of Julia","text":"","category":"section"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"To switch between different versions of Julia, use + julia-version after the julia command. For example, to use Julia version 1.9.3, use the following command:","category":"page"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"% julia +1.9.3","category":"page"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"This will use the specified version of Julia for the current REPL. In general, adding the + julia-version flag after the julia command will execute using the specified version of Julia.","category":"page"},{"location":"getting-started/explainers/julia/#Check-versions-of-Julia-installed","page":"Working with Julia","title":"Check versions of Julia installed","text":"","category":"section"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"To see a list of all the versions of Julia installed on your system, use the following command:","category":"page"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"% juliaup list","category":"page"},{"location":"getting-started/explainers/julia/#Update-Julia-(all-versions-installed)","page":"Working with Julia","title":"Update Julia (all versions installed)","text":"","category":"section"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"This will update all versions of Julia installed on your system to their latest release versions.","category":"page"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"% juliaup update","category":"page"},{"location":"getting-started/explainers/julia/#Usage-of-Julia-environments","page":"Working with Julia","title":"Usage of Julia environments","text":"","category":"section"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"The environment of a Julia project determines which packages, and their version, are available to the project. This is useful when you want to ensure that a project uses a specific version of a package, or when you want to isolate the project from other projects on your system. As per other languages, Julia environments are useful for managing dependencies and ensuring reproducibility.","category":"page"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"The most common usage of environments is to create a new explicit environment for a project in a directory. This creates a Project.toml file in the directory that specifies the dependencies for the project and a Manifest.toml file that specifies the exact versions of the dependencies, and their underlying dependencies. We'll discuss how to set up a new environment for a project in the REPL section.","category":"page"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"Julia environments can be stacked. This means that you can have a primary environment embedded in the stacked environment, along with secondary environment(s) that define common packages to be available to many projects.","category":"page"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"From a project development point of view, most commonly the project environment will be the primary environment, isolated from other project environments. And the environment of the Julia version installation (e.g. the @v1.10 env) will be a secondary environment because its in the default LOAD_PATH Julia environmental variable. You can add packages to the Julia version environment that you want to be available to all projects as we'll show in the REPL section. See section Recommended packages for the primary Julia environment for our recommendations.","category":"page"},{"location":"getting-started/explainers/julia/#Using-the-Julia-REPL-in-projects","page":"Working with Julia","title":"Using the Julia REPL in projects","text":"","category":"section"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"The Julia REPL (Read-Eval-Print Loop) is an interactive programming environment that takes single user inputs (i.e., single expressions), evaluates them, and returns the result to the user.","category":"page"},{"location":"getting-started/explainers/julia/#Package-management-programmatically-and-from-REPL","page":"Working with Julia","title":"Package management programmatically and from REPL","text":"","category":"section"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"Julia has a built-in package manager called Pkg, which is documented briefly here and in more detail here. The package manager is used to install, update, and manage Julia packages and environments.","category":"page"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"You can use Pkg programmatically as a normal Julia package, which is often done in scripts. For example, if we wanted to install the OrdinaryDiffEq package as part of executing a julia script, we would add the following lines to the script:","category":"page"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"using Pkg\nPkg.add(\"OrdinaryDiffEq\")","category":"page"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"However, you can also use the package manager interactively from the REPL. In our opinion, this is the more common usage of package management in Julia project development.","category":"page"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"For example, to install the OrdinaryDiffEq package from the REPL you can switch to package mode by typing ] and then type add OrdinaryDiffEq. To exit package mode, type backspace.","category":"page"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"julia> ]\n(@v1.10) pkg> add OrdinaryDiffEq","category":"page"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"This workflow is often more convenient than the programmatic interface, especially when setting packages you want to install to the environment for your julia installation, e.g the @v1.10 environment for julia 1.10.","category":"page"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"By default, the environment for a julia installation is stacked as a primary environment, so that the packages you install in the julia installation environment are available to all projects.","category":"page"},{"location":"getting-started/explainers/julia/#Using-the-Julia-REPL-to-set-up-active-project-environments","page":"Working with Julia","title":"Using the Julia REPL to set up active project environments","text":"","category":"section"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"To set a new active project environment, you can use the Pkg package manager from the REPL with the command activate with a local directory path. The project environment is named after the directory hosting the Project.toml file. After activating the project environment, you can manage packages to the project environment, as well as use packages from the primary stacked environment as described above.","category":"page"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"Here is an example of how you can create a new environment for a project when the REPL working directory is in some directory /myproject, and then add OrdinaryDiffEq to the project environment:","category":"page"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"julia> pwd() #Check your directory\n# \"path/to/myproject\"\njulia> ]\n(@v1.10) pkg> activate .\n(myproject) pkg> add OrdinaryDiffEq","category":"page"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"Note that if the project directory doesn't have a Project.toml file, one will be created when you add the first package to the project environment.","category":"page"},{"location":"getting-started/explainers/julia/#Experimenting-with-Julia-from-REPL-using-a-temporary-environment","page":"Working with Julia","title":"Experimenting with Julia from REPL using a temporary environment","text":"","category":"section"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"It is quite common to want to experiment with new Julia packages and code snippets. A convenient way to do this without setting up a new project environment or adding dependencies to the primary environment is to use a temporary environment. To do this:","category":"page"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"julia> ]\n(@v1.10) pkg> activate --temp\n(jl_FTIz6j) pkg> add InterestingPackage","category":"page"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"This will create a temporary environment, stacked with the primary environment, that is not saved to disk, and you can add packages to this environment without affecting the primary environment or any project environments. When you exit the REPL, the temporary environment will be deleted.","category":"page"},{"location":"getting-started/explainers/julia/#Recommended-packages-for-the-\"global\"-Julia-version-environment","page":"Working with Julia","title":"Recommended packages for the \"global\" Julia version environment","text":"","category":"section"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"In our view these packages are useful for your Julia version environment, e.g. v1.10 env, which will be available to other environments.","category":"page"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"Revise: For modifying package code and using the changes without restarting Julia session.\nTerm: For pretty and stylized REPL output (including error messages).\nJuliaFormatter: For code formatting.\nDocumenter: For local documentation generation.\nPluto: A native Julia notebook for interactive development.\nTestEnv: For easy use of test environments for package testing.\nUnicodePlots: For simple and quick plotting in the REPL without needing to install a fully featured plotting package.","category":"page"},{"location":"getting-started/explainers/julia/#startup.jl-recommendation","page":"Working with Julia","title":"startup.jl recommendation","text":"","category":"section"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"Revise and Term useful to have available in every Julia session. It is convenient to have these packages loaded automatically when you start a Julia session by adding a startup.jl file. This file should be located in the ~/.julia/config directory. Here is an example of a startup.jl file that loads the Revise and Term:","category":"page"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"atreplinit() do repl\n # Load Revise if it is installed\n try\n @eval using Revise\n catch e\n @warn \"error while importing Revise\" e\n end\n # Load Term if it is installed\n try\n @eval using Term\n @eval install_term_repr()\n @eval install_term_stacktrace()\n catch e\n @warn \"error while importing Term\" e\n end\nend\n","category":"page"},{"location":"getting-started/explainers/julia/#Developing-a-EpiAware-project-from-VS-Code","page":"Working with Julia","title":"Developing a EpiAware-project from VS-Code","text":"","category":"section"},{"location":"getting-started/explainers/julia/#Julia-extension-for-VS-Code","page":"Working with Julia","title":"Julia extension for VS-Code","text":"","category":"section"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"Visual Studio Code (VS-Code) is a popular code editor that supports Julia development. The Julia extension for VS-Code provides an interactive development environment that will be familiar to users of other scientific IDEs (e.g. developing R projects in RStudio or using the MATLAB application).","category":"page"},{"location":"getting-started/explainers/julia/#Features-of-the-Julia-extension-for-VS-Code","page":"Working with Julia","title":"Features of the Julia extension for VS-Code","text":"","category":"section"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"It is worth reading both the VS-Code documentation and the Julia extension documentation, however, here are some highlights:","category":"page"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"Julia REPL: The Julia extension provides an integrated REPL in the TERMINAL pane that allows you to interact with Julia code directly from the editor. For example, you can run code snippets from highlighting or code blocks defined by ## comments in the scripts.\nPlotting: By default, plots generated by featured plotting packages (e.g. Plots.jl) will be displayed in a Plot pane generated by the VS-Code editor.\nJulia Tab: The Julia extension provides a Julia tab with the following sub-tabs:\nWorkspace: This allows you to inspect the modules, functions and variables in your current REPL session. For variables that can be understood as a Table, you can view them in a tabular format from the workspace tab.\nDocumentation: This allows you to view the documentation for functions and types in the Julia standard library and any packages you have installed.\nPlot Navigator: This allows you to navigate the plots generated by the featured plotting packages.\nTesting: The Julia extension provides interaction between the Testing tab in VS-Code with Julia tests defined using the Julia package TestItems macro @testitem run with TestItemRunner.","category":"page"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"Other standard IDE features are Code completion, Code linting, Code formatting, Debugging, and Profiling.","category":"page"},{"location":"getting-started/explainers/julia/#Recommended-settings-for-the-Julia-extension-in-VS-Code","page":"Working with Julia","title":"Recommended settings for the Julia extension in VS-Code","text":"","category":"section"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"The settings of the Julia extension can be found by accessing Preferences: Open User Settings from the command palette in VS-Code and then searching for Julia.","category":"page"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"We recommend the following workplace settings saved in a file .vscode/settings.json relative to your working directory:","category":"page"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"{\n \"[julia]\": {\n \"editor.detectIndentation\": false,\n \"editor.insertSpaces\": true,\n \"editor.tabSize\": 4,\n \"files.insertFinalNewline\": true,\n \"files.trimFinalNewlines\": true,\n \"files.trimTrailingWhitespace\": true,\n \"editor.rulers\": [80],\n \"files.eol\": \"\\n\"\n },\n \"julia.liveTestFile\": \"path/to/runtests.jl\",\n \"julia.environmentPath\": \"path/to/project/directory\",\n}","category":"page"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"These settings set basic code formatting and whitespace settings for Julia files, as well as setting the path to the test file for the project and the path to the project directory for the environment.","category":"page"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"The VS-Code command Julia: Start REPL will start a REPL in TERMINAL tab in the editor with the environment set to the project directory and the Testing tab will detect the defined tests for the project.","category":"page"},{"location":"getting-started/explainers/julia/#Literate-programming-with-Julia-in-EpiAware","page":"Working with Julia","title":"Literate programming with Julia in EpiAware","text":"","category":"section"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"Its common to develop technical computing projects using a literate programming style, where code and documentation are interwoven. Julia supports this style of programming through a number of packages. In EpiAware we recommend the following:","category":"page"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"Pluto: A native Julia notebook for interactive development. Pluto notebooks are reactive, meaning that the output of all cells are updated as input changes. Installation instructions are available here. Pluto notebook files have the extension .jl and can be run as scripts.\nQuarto: A literate programming tool that allows you to write documents in markdown with embedded Julia code. Installation instructions are available here. Quarto files have the extension .qmd.","category":"page"},{"location":"getting-started/explainers/julia/","page":"Working with Julia","title":"Working with Julia","text":"We use Pluto for interactive development and Quarto for generating reports and academic articles. Both tools are useful for developing reproducible workflows.","category":"page"},{"location":"getting-started/explainers/inference/#Inference","page":"Inference","title":"Inference","text":"","category":"section"},{"location":"lib/EpiInference/public/#Public-Documentation","page":"Public API","title":"Public Documentation","text":"","category":"section"},{"location":"lib/EpiInference/public/","page":"Public API","title":"Public API","text":"Documentation for EpiInference.jl's public interface.","category":"page"},{"location":"lib/EpiInference/public/","page":"Public API","title":"Public API","text":"See the Internals section of the manual for internal package docs covering all submodules.","category":"page"},{"location":"lib/EpiInference/public/#Contents","page":"Public API","title":"Contents","text":"","category":"section"},{"location":"lib/EpiInference/public/","page":"Public API","title":"Public API","text":"Pages = [\"public.md\"]\nDepth = 2:2","category":"page"},{"location":"lib/EpiInference/public/#Index","page":"Public API","title":"Index","text":"","category":"section"},{"location":"lib/EpiInference/public/","page":"Public API","title":"Public API","text":"Pages = [\"public.md\"]","category":"page"},{"location":"lib/EpiInference/public/#Public-API","page":"Public API","title":"Public API","text":"","category":"section"},{"location":"lib/EpiInference/public/","page":"Public API","title":"Public API","text":"Modules = [EpiAware.EpiInference]\nPrivate = false","category":"page"},{"location":"lib/EpiInference/public/#EpiAware.EpiInference","page":"Public API","title":"EpiAware.EpiInference","text":"Module for defining inference methods.\n\n\n\n\n\n","category":"module"},{"location":"lib/EpiInference/public/#EpiAware.EpiInference.ManyPathfinder","page":"Public API","title":"EpiAware.EpiInference.ManyPathfinder","text":"struct ManyPathfinder <: AbstractEpiOptMethod\n\nA variational inference method that runs manypathfinder.\n\n\n\nFields\n\nndraws::Int64: Number of draws per pathfinder run.\nnruns::Int64: Number of many pathfinder runs.\nmaxiters::Int64: Maximum number of optimization iterations for each run.\nmax_tries::Int64: Maximum number of tries if all runs fail.\n\n\n\n\n\n","category":"type"},{"location":"lib/EpiInference/public/#EpiAware.EpiInference.NUTSampler","page":"Public API","title":"EpiAware.EpiInference.NUTSampler","text":"struct NUTSampler{A<:ADTypes.AbstractADType, E<:AbstractMCMC.AbstractMCMCEnsemble, M} <: AbstractEpiSamplingMethod\n\nA NUTS method for sampling from a DynamicPPL.Model object.\n\nThe NUTSampler struct represents using the No-U-Turn Sampler (NUTS) to sample from the distribution defined by a DynamicPPL.Model.\n\n\n\nFields\n\ntarget_acceptance::Float64: The target acceptance rate for the sampler.\nadtype::ADTypes.AbstractADType: The automatic differentiation type used for computing gradients.\nmcmc_parallel::AbstractMCMC.AbstractMCMCEnsemble: The parallelization strategy for the MCMC sampler.\nnchains::Int64: The number of MCMC chains to run.\nmax_depth::Int64: Tree depth limit for the NUTS sampler.\nΔ_max::Float64: Divergence threshold for the NUTS sampler.\ninit_ϵ::Float64: The initial step size for the NUTS sampler.\nndraws::Int64: The number of samples to draw from each chain.\nmetricT::Any: The metric type to use for the HMC sampler.\n\n\n\n\n\n","category":"type"},{"location":"lib/EpiInference/public/#EpiAware.EpiInference.manypathfinder-Tuple{DynamicPPL.Model, Any}","page":"Public API","title":"EpiAware.EpiInference.manypathfinder","text":"manypathfinder(\n mdl::DynamicPPL.Model,\n ndraws;\n nruns,\n maxiters,\n max_tries,\n kwargs...\n) -> Any\n\n\nRun multiple instances of the pathfinder algorithm and returns the pathfinder run with the largest ELBO estimate.\n\nArguments\n\nmdl::DynamicPPL.Model: The model to perform inference on.\nnruns::Int: The number of pathfinder runs to perform.\nndraws::Int: The number of draws per pathfinder run, readjusted to be at least as large as the number of chains.\nnchains::Int: The number of chains that will be initialised by pathfinder draws.\nmaxiters::Int: The maximum number of optimizer iterations per pathfinder run.\nmax_tries::Int: The maximum number of extra tries to find a valid pathfinder result.\nkwargs...: Additional keyword arguments passed to pathfinder.\n\nReturns\n\nbest_pfs::PathfinderResult: Best pathfinder result by estimated ELBO.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiLatentModels/public/#Public-Documentation","page":"Public API","title":"Public Documentation","text":"","category":"section"},{"location":"lib/EpiLatentModels/public/","page":"Public API","title":"Public API","text":"Documentation for EpiLatentModels.jl's public interface.","category":"page"},{"location":"lib/EpiLatentModels/public/","page":"Public API","title":"Public API","text":"See the Internals section of the manual for internal package docs covering all submodules.","category":"page"},{"location":"lib/EpiLatentModels/public/#Contents","page":"Public API","title":"Contents","text":"","category":"section"},{"location":"lib/EpiLatentModels/public/","page":"Public API","title":"Public API","text":"Pages = [\"public.md\"]\nDepth = 2:2","category":"page"},{"location":"lib/EpiLatentModels/public/#Index","page":"Public API","title":"Index","text":"","category":"section"},{"location":"lib/EpiLatentModels/public/","page":"Public API","title":"Public API","text":"Pages = [\"public.md\"]","category":"page"},{"location":"lib/EpiLatentModels/public/#Public-API","page":"Public API","title":"Public API","text":"","category":"section"},{"location":"lib/EpiLatentModels/public/","page":"Public API","title":"Public API","text":"Modules = [EpiAware.EpiLatentModels]\nPrivate = false","category":"page"},{"location":"lib/EpiLatentModels/public/#EpiAware.EpiLatentModels","page":"Public API","title":"EpiAware.EpiLatentModels","text":"Module for defining latent models.\n\n\n\n\n\n","category":"module"},{"location":"lib/EpiLatentModels/public/#EpiAware.EpiLatentModels.AR","page":"Public API","title":"EpiAware.EpiLatentModels.AR","text":"struct AR{D<:Distributions.Sampleable, S<:Distributions.Sampleable, I<:Distributions.Sampleable, P<:Int64} <: AbstractTuringLatentModel\n\nThe autoregressive (AR) model struct.\n\nConstructors\n\nAR(damp_prior::Distribution, std_prior::Distribution, init_prior::Distribution; p::Int = 1): Constructs an AR model with the specified prior distributions for damping coefficients, standard deviation, and initial conditions. The order of the AR model can also be specified.\nAR(; damp_priors::Vector{D} = [truncated(Normal(0.0, 0.05))], std_prior::Distribution = truncated(Normal(0.0, 0.05), 0.0, Inf), init_priors::Vector{I} = [Normal()]) where {D <: Distribution, I <: Distribution}: Constructs an AR model with the specified prior distributions for damping coefficients, standard deviation, and initial conditions. The order of the AR model is determined by the length of the damp_priors vector.\nAR(damp_prior::Distribution, std_prior::Distribution, init_prior::Distribution, p::Int): Constructs an AR model with the specified prior distributions for damping coefficients, standard deviation, and initial conditions. The order of the AR model is explicitly specified.\n\nExamples\n\nusing Distributions\nusing EpiAware\nar = AR()\nar_model = generate_latent(ar, 10)\nrand(ar_model)\n\n\n\nFields\n\ndamp_prior::Distributions.Sampleable: Prior distribution for the damping coefficients.\nstd_prior::Distributions.Sampleable: Prior distribution for the standard deviation.\ninit_prior::Distributions.Sampleable: Prior distribution for the initial conditions\np::Int64: Order of the AR model.\n\n\n\n\n\n","category":"type"},{"location":"lib/EpiLatentModels/public/#EpiAware.EpiLatentModels.BroadcastLatentModel","page":"Public API","title":"EpiAware.EpiLatentModels.BroadcastLatentModel","text":"struct BroadcastLatentModel{M<:AbstractTuringLatentModel, P<:Integer, B<:AbstractBroadcastRule} <: AbstractTuringLatentModel\n\nThe BroadcastLatentModel struct represents a latent model that supports broadcasting of latent periods.\n\nConstructors\n\nBroadcastLatentModel(;model::M; period::Int, broadcast_rule::B): Constructs a BroadcastLatentModel with the given model, period, and broadcast_rule.\nBroadcastLatentModel(model::M, period::Int, broadcast_rule::B): An alternative constructor that allows the model, period, and broadcast_rule to be specified without keyword arguments.\n\nExamples\n\nusing EpiAware, Turing\neach_model = BroadcastLatentModel(RandomWalk(), 7, RepeatEach())\ngen_each_model = generate_latent(each_model, 10)\nrand(gen_each_model)\n\nblock_model = BroadcastLatentModel(RandomWalk(), 3, RepeatBlock())\ngen_block_model = generate_latent(block_model, 10)\nrand(gen_block_model)\n\n\n\nFields\n\nmodel::AbstractTuringLatentModel: The underlying latent model.\nperiod::Integer: The period of the broadcast.\nbroadcast_rule::AbstractBroadcastRule: The broadcast rule to be applied.\n\n\n\n\n\n","category":"type"},{"location":"lib/EpiLatentModels/public/#EpiAware.EpiLatentModels.CombineLatentModels","page":"Public API","title":"EpiAware.EpiLatentModels.CombineLatentModels","text":"struct CombineLatentModels{M<:(AbstractVector{<:AbstractTuringLatentModel}), P<:(AbstractVector{<:String})} <: AbstractTuringLatentModel\n\nThe CombineLatentModels struct.\n\nThis struct is used to combine multiple latent models into a single latent model. If a prefix is supplied wraps each model with PrefixLatentModel.\n\nConstructors\n\nCombineLatentModels(models::M, prefixes::P) where {M <: AbstractVector{<:AbstractTuringLatentModel}, P <: AbstractVector{<:String}}: Constructs a CombineLatentModels instance with specified models and prefixes, ensuring that there are at least two models and the number of models and prefixes are equal.\nCombineLatentModels(models::M) where {M <: AbstractVector{<:AbstractTuringLatentModel}}: Constructs a CombineLatentModels instance with specified models, automatically generating prefixes for each model. The\n\nautomatic prefixes are of the form Combine.1, Combine.2, etc.\n\nExamples\n\nusing EpiAware, Distributions\ncombined_model = CombineLatentModels([Intercept(Normal(2, 0.2)), AR()])\nlatent_model = generate_latent(combined_model, 10)\nlatent_model()\n\n\n\nFields\n\nmodels::AbstractVector{<:AbstractTuringLatentModel}: A vector of latent models\nprefixes::AbstractVector{<:String}: A vector of prefixes for the latent models\n\n\n\n\n\n","category":"type"},{"location":"lib/EpiLatentModels/public/#EpiAware.EpiLatentModels.ConcatLatentModels","page":"Public API","title":"EpiAware.EpiLatentModels.ConcatLatentModels","text":"struct ConcatLatentModels{M<:(AbstractVector{<:AbstractTuringLatentModel}), N<:Int64, F<:Function, P<:(AbstractVector{<:String})} <: AbstractTuringLatentModel\n\nThe ConcatLatentModels struct.\n\nThis struct is used to concatenate multiple latent models into a single latent model.\n\nConstructors\n\nConcatLatentModels(models::M, no_models::I, dimension_adaptor::F, prefixes::P) where {M <: AbstractVector{<:AbstractTuringLatentModel}, I <: Int, F <: Function, P <: AbstractVector{String}}: Constructs a ConcatLatentModels instance with specified models, number of models, dimension adaptor, and prefixes.\nConcatLatentModels(models::M, dimension_adaptor::F; prefixes::P = \"Concat.\" * string.(1:length(models))) where {M <: AbstractVector{<:AbstractTuringLatentModel}, F <: Function}: Constructs a ConcatLatentModels instance with specified models and dimension adaptor. The number of models is automatically determined as are the prefixes (of the form Concat.1, Concat.2, etc.) by default.\nConcatLatentModels(models::M; dimension_adaptor::Function, prefixes::P) where {M <: AbstractVector{<:AbstractTuringLatentModel}, P <: AbstractVector{String}}: Constructs a ConcatLatentModels instance with specified models, dimension adaptor, prefixes, and automatically determines the number of models.The default dimension adaptor is equal_dimensions. The default prefixes are of the form Concat.1, Concat.2, etc.\nConcatLatentModels(; models::M, dimension_adaptor::Function, prefixes::P) where {M <: AbstractVector{<:AbstractTuringLatentModel}, P <: AbstractVector{String}}: Constructs a ConcatLatentModels instance with specified models, dimension adaptor, prefixes, and automatically determines the number of models. The default dimension adaptor is equal_dimensions. The default prefixes are of the form Concat.1, Concat.2, etc.\n\nExamples\n\nusing EpiAware, Distributions\ncombined_model = ConcatLatentModels([Intercept(Normal(2, 0.2)), AR()])\nlatent_model = generate_latent(combined_model, 10)\nlatent_model()\n\n\n\nFields\n\nmodels::AbstractVector{<:AbstractTuringLatentModel}: A vector of latent models\nno_models::Int64: The number of models in the collection\ndimension_adaptor::Function: The dimension function for the latent variables. By default this divides the number of latent variables by the number of models and returns a vector of dimensions rounding up the first element and rounding down the rest.\nprefixes::AbstractVector{<:String}: A vector of prefixes for the latent models\n\n\n\n\n\n","category":"type"},{"location":"lib/EpiLatentModels/public/#EpiAware.EpiLatentModels.DiffLatentModel","page":"Public API","title":"EpiAware.EpiLatentModels.DiffLatentModel","text":"struct DiffLatentModel{M<:AbstractTuringLatentModel, P<:Distributions.Distribution} <: AbstractTuringLatentModel\n\nModel the latent process as a d-fold differenced version of another process.\n\nMathematical specification\n\nLet Delta be the differencing operator. If tildeZ_t is a realisation of undifferenced latent model supplied to DiffLatentModel, then the differenced process is given by,\n\nDelta^(d) Z_t = tildeZ_t quad t = d+1 ldots\n\nWe can recover Z_t by applying the inverse differencing operator Delta^-1, which corresponds to the cumulative sum operator cumsum in Julia, d-times. The d initial terms Z_1 ldots Z_d are inferred.\n\nConstructors\n\nDiffLatentModel(latent_model, init_prior_distribution::Distribution; d::Int) Constructs a DiffLatentModel for d-fold differencing with latent_model as the undifferenced latent process. All initial terms have common prior init_prior_distribution.\nDiffLatentModel(;model, init_priors::Vector{D} where {D <: Distribution}) Constructs a DiffLatentModel for d-fold differencing with latent_model as the undifferenced latent process. The d initial terms have priors given by the vector init_priors, therefore length(init_priors) sets d.\n\nExample usage with generate_latent\n\ngenerate_latent can be used to construct a Turing model for the differenced latent process. In this example, the underlying undifferenced process is a RandomWalk model.\n\nFirst, we construct a RandomWalk struct with an initial value prior and a step size standard deviation prior.\n\nusing Distributions, EpiAware\nrw = RandomWalk(Normal(0.0, 1.0), truncated(Normal(0.0, 0.05), 0.0, Inf))\n\nThen, we can use DiffLatentModel to construct a DiffLatentModel for d-fold differenced process with rw as the undifferenced latent process.\n\nWe have two constructor options for DiffLatentModel. The first option is to supply a common prior distribution for the initial terms and specify d as follows:\n\ndiff_model = DiffLatentModel(rw, Normal(); d = 2)\n\nOr we can supply a vector of priors for the initial terms and d is inferred as follows:\n\ndiff_model2 = DiffLatentModel(;undiffmodel = rw, init_priors = [Normal(), Normal()])\n\nThen, we can use generate_latent to construct a Turing model for the differenced latent process generating a length n process,\n\n# Construct a Turing model\nn = 100\ndifference_mdl = generate_latent(diff_model, n)\n\nNow we can use the Turing PPL API to sample underlying parameters and generate the unobserved latent process.\n\n#Sample random parameters from prior\nθ = rand(difference_mdl)\n#Get a sampled latent process as a generated quantity from the model\n(Z_t, _) = generated_quantities(difference_mdl, θ)\nZ_t\n\n\n\nFields\n\nmodel::AbstractTuringLatentModel: Underlying latent model for the differenced process\ninit_prior::Distributions.Distribution: The prior distribution for the initial latent variables.\nd::Int64: Number of times differenced.\n\n\n\n\n\n","category":"type"},{"location":"lib/EpiLatentModels/public/#EpiAware.EpiLatentModels.FixedIntercept","page":"Public API","title":"EpiAware.EpiLatentModels.FixedIntercept","text":"struct FixedIntercept{F<:Real} <: AbstractTuringIntercept\n\nA variant of the Intercept struct that represents a fixed intercept value for a latent model.\n\nConstructors\n\nFixedIntercept(intercept) : Constructs a FixedIntercept instance with the specified intercept value.\nFixedIntercept(; intercept) : Constructs a FixedIntercept instance with the specified intercept value using named arguments.\n\nExamples\n\nusing EpiAware\nfi = FixedIntercept(2.0)\nfi_model = generate_latent(fi, 10)\nfi_model()\n\n\n\nFields\n\nintercept::Real\n\n\n\n\n\n","category":"type"},{"location":"lib/EpiLatentModels/public/#EpiAware.EpiLatentModels.HierarchicalNormal","page":"Public API","title":"EpiAware.EpiLatentModels.HierarchicalNormal","text":"struct HierarchicalNormal{R<:Real, D<:Distributions.Sampleable} <: AbstractTuringLatentModel\n\nThe HierarchicalNormal struct represents a non-centered hierarchical normal distribution.\n\nConstructors\n\nHierarchicalNormal(mean, std_prior): Constructs a HierarchicalNormal instance with the specified mean and standard deviation prior.\nHierarchicalNormal(; mean = 0.0, std_prior = truncated(Normal(0,1), 0, Inf)): Constructs a HierarchicalNormal instance with the specified mean and standard deviation prior using named arguments and with default values.\n\nExamples\n\nusing Distributions, EpiAware\nhnorm = HierarchicalNormal(0.0, truncated(Normal(0, 1), 0, Inf))\nhnorm_model = generate_latent(hnorm, 10)\nhnorm_model()\n\n\n\nFields\n\nmean::Real\nstd_prior::Distributions.Sampleable\n\n\n\n\n\n","category":"type"},{"location":"lib/EpiLatentModels/public/#EpiAware.EpiLatentModels.Intercept","page":"Public API","title":"EpiAware.EpiLatentModels.Intercept","text":"struct Intercept{D<:Distributions.Sampleable} <: AbstractTuringIntercept\n\nThe Intercept struct is used to model the intercept of a latent process. It broadcasts a single intercept value to a length n latent process.\n\nConstructors\n\nIntercept(intercept_prior)\nIntercept(; intercept_prior)\n\nExamples\n\nusing Distributions, Turing, EpiAware\nint = Intercept(Normal(0, 1))\nint_model = generate_latent(int, 10)\nrand(int_model)\nint_model()\n\n\n\nFields\n\nintercept_prior::Distributions.Sampleable: Prior distribution for the intercept.\n\n\n\n\n\n","category":"type"},{"location":"lib/EpiLatentModels/public/#EpiAware.EpiLatentModels.PrefixLatentModel","page":"Public API","title":"EpiAware.EpiLatentModels.PrefixLatentModel","text":"struct PrefixLatentModel{M<:AbstractTuringLatentModel, P<:String} <: AbstractTuringLatentModel\n\nGenerate a latent model with a prefix. A lightweight wrapper around `EpiAwareUtils.prefix_submodel`.\n\n# Constructors\n- `PrefixLatentModel(model::M, prefix::P)`: Create a `PrefixLatentModel` with the latent model `model` and the prefix `prefix`.\n- `PrefixLatentModel(; model::M, prefix::P)`: Create a `PrefixLatentModel` with the latent model `model` and the prefix `prefix`.\n\n# Examples\n```julia\nusing EpiAware\nlatent_model = PrefixLatentModel(model = HierarchicalNormal(), prefix = \"Test\")\nmdl = generate_latent(latent_model, 10)\nrand(mdl)\n```\n\n\n\nFields\n\nmodel::AbstractTuringLatentModel: The latent model\nprefix::String: The prefix for the latent model\n\n\n\n\n\n","category":"type"},{"location":"lib/EpiLatentModels/public/#EpiAware.EpiLatentModels.RandomWalk","page":"Public API","title":"EpiAware.EpiLatentModels.RandomWalk","text":"struct RandomWalk{D<:Distributions.Sampleable, S<:Distributions.Sampleable} <: AbstractTuringLatentModel\n\nModel latent process Z_t as a random walk.\n\nMathematical specification\n\nThe random walk Z_t is specified as a parameteric transformation of the white noise sequence (epsilon_t)_tgeq 1,\n\nZ_t = Z_0 + sigma sum_i = 1^t epsilon_t\n\nConstructing a random walk requires specifying:\n\nAn init_prior as a prior for Z_0. Default is Normal().\nA std_prior for sigma. The default is HalfNormal with a mean of 0.25.\n\nConstructors\n\nRandomWalk(; init_prior, std_prior)\n\nExample usage with generate_latent\n\ngenerate_latent can be used to construct a Turing model for the random walk Z_t.\n\nFirst, we construct a RandomWalk struct with priors,\n\nusing Distributions, Turing, EpiAware\n\n# Create a RandomWalk model\nrw = RandomWalk(init_prior = Normal(2., 1.),\n std_prior = HalfNormal(0.1))\n\nThen, we can use generate_latent to construct a Turing model for a 10 step random walk.\n\n# Construct a Turing model\nrw_model = generate_latent(rw, 10)\n\nNow we can use the Turing PPL API to sample underlying parameters and generate the unobserved infections.\n\n#Sample random parameters from prior\nθ = rand(rw_model)\n#Get random walk sample path as a generated quantities from the model\nZ_t, _ = generated_quantities(rw_model, θ)\n\n\n\nFields\n\ninit_prior::Distributions.Sampleable\nstd_prior::Distributions.Sampleable\n\n\n\n\n\n","category":"type"},{"location":"lib/EpiLatentModels/public/#EpiAware.EpiLatentModels.RepeatBlock","page":"Public API","title":"EpiAware.EpiLatentModels.RepeatBlock","text":"struct RepeatBlock <: AbstractBroadcastRule\n\nRepeatBlock is a struct that represents a broadcasting rule. It is a subtype of AbstractBroadcastRule.\n\nIt repeats the latent process in blocks of size period. An example of this rule is to repeat the latent process in blocks of size 7 to model a weekly process (though for this we also provide the broadcast_weekly helper function).\n\nExamples\n\nusing EpiAware\nrule = RepeatBlock()\nlatent = [1, 2, 3, 4, 5]\nn = 10\nperiod = 2\nbroadcast_rule(rule, latent, n, period)\n\n\n\nFields\n\n\n\n\n\n","category":"type"},{"location":"lib/EpiLatentModels/public/#EpiAware.EpiLatentModels.RepeatEach","page":"Public API","title":"EpiAware.EpiLatentModels.RepeatEach","text":"struct RepeatEach <: AbstractBroadcastRule\n\nRepeatEach is a struct that represents a broadcasting rule. It is a subtype of AbstractBroadcastRule.\n\nIt repeats the latent process at each period. An example of this rule is to repeat the latent process at each day of the week (though for this we also provide the dayofweek helper function).\n\nExamples\n\nusing EpiAware\nrule = RepeatEach()\nlatent = [1, 2, 3]\nn = 10\nperiod = 2\nbroadcast_rule(rule, latent, n, period)\n\n\n\nFields\n\n\n\n\n\n","category":"type"},{"location":"lib/EpiLatentModels/public/#EpiAware.EpiLatentModels.TransformLatentModel","page":"Public API","title":"EpiAware.EpiLatentModels.TransformLatentModel","text":"struct TransformLatentModel{M<:AbstractTuringLatentModel, F<:Function} <: AbstractTuringLatentModel\n\nThe TransformLatentModel struct represents a latent model that applies a transformation function to the latent variables generated by another latent model.\n\nConstructors\n\nTransformLatentModel(model, trans_function): Constructs a TransformLatentModel instance with the specified latent model and transformation function.\nTransformLatentModel(; model, trans_function): Constructs a TransformLatentModel instance with the specified latent model and transformation function using named arguments.\n\nExample\n\nusing EpiAware, Distributions\ntrans = TransformLatentModel(Intercept(Normal(2, 0.2)), x -> x .|> exp)\ntrans_model = generate_latent(trans, 5)\ntrans_model()\n\n\n\nFields\n\nmodel::AbstractTuringLatentModel: The latent model to transform.\ntrans_function::Function: The transformation function.\n\n\n\n\n\n","category":"type"},{"location":"lib/EpiLatentModels/public/#EpiAware.EpiLatentModels.broadcast_dayofweek-Tuple{AbstractTuringLatentModel}","page":"Public API","title":"EpiAware.EpiLatentModels.broadcast_dayofweek","text":"broadcast_dayofweek(\n model::AbstractTuringLatentModel;\n link\n) -> BroadcastLatentModel{TransformLatentModel{M, EpiAware.EpiLatentModels.var\"#42#44\"}, Int64, RepeatEach} where M<:AbstractTuringLatentModel\n\n\nConstructs a BroadcastLatentModel appropriate for modelling the day of the week for a given AbstractTuringLatentModel.\n\nArguments\n\nmodel::AbstractTuringLatentModel: The latent model to be repeated.\nlink::Function: The link function to transform the latent model before broadcasting\n\nto periodic weekly. Default is x -> 7 * softmax(x) which implements constraint of the sum week effects to be 7.\n\nReturns\n\nBroadcastLatentModel: The broadcast latent model.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiLatentModels/public/#EpiAware.EpiLatentModels.broadcast_weekly-Tuple{AbstractTuringLatentModel}","page":"Public API","title":"EpiAware.EpiLatentModels.broadcast_weekly","text":"broadcast_weekly(\n model::AbstractTuringLatentModel\n) -> BroadcastLatentModel{<:AbstractTuringLatentModel, Int64, RepeatBlock}\n\n\nConstructs a BroadcastLatentModel appropriate for modelling piecewise constant weekly processes for a given AbstractTuringLatentModel.\n\nArguments\n\nmodel::AbstractTuringLatentModel: The latent model to be repeated.\n\nReturns\n\nBroadcastLatentModel: The broadcast latent model.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiLatentModels/public/#EpiAware.EpiLatentModels.equal_dimensions-Tuple{Int64, Int64}","page":"Public API","title":"EpiAware.EpiLatentModels.equal_dimensions","text":"equal_dimensions(n::Int64, m::Int64) -> Vector{Int64}\n\n\nReturn a vector of dimensions that are equal or as close as possible, given the total number of elements n and the number of dimensions m. The default dimension adaptor for ConcatLatentModels.\n\nArguments\n\nn::Int: The total number of elements.\nm::Int: The number of dimensions.\n\nReturns\n\ndims::AbstractVector{Int}: A vector of dimensions, where the first element is the ceiling of n / m and the remaining elements are the floor of n / m.\n\n\n\n\n\n","category":"method"},{"location":"getting-started/faq/#Frequently-asked-questions","page":"Frequently asked questions","title":"Frequently asked questions","text":"","category":"section"},{"location":"getting-started/faq/","page":"Frequently asked questions","title":"Frequently asked questions","text":"This page contains a list of frequently asked questions about the EpiAware package. If you have a question that is not answered here, please open a discussion on the GitHub repository.","category":"page"},{"location":"getting-started/faq/","page":"Frequently asked questions","title":"Frequently asked questions","text":"Pages = [\"lib/getting-started/faq.md\"]","category":"page"},{"location":"getting-started/faq/#Pluto-scripts","page":"Frequently asked questions","title":"Pluto scripts","text":"","category":"section"},{"location":"getting-started/faq/","page":"Frequently asked questions","title":"Frequently asked questions","text":"We use Pluto.jl scripts as part of our documentation and testing. The scripts are located in docs/src/examples and can be run using the Pluto.jl package. We recommend using the version of Pluto that is pinned in the Project.toml file defining the documentation environment. An entry point to running or developing this documentation is the docs/pluto-scripts.sh bash shell script. Run this from the root directory of this repository.","category":"page"},{"location":"getting-started/explainers/latent-models/#Latent-models","page":"Latent models","title":"Latent models","text":"","category":"section"},{"location":"lib/internals/#Internal-Documentation","page":"Internal API","title":"Internal Documentation","text":"","category":"section"},{"location":"lib/internals/","page":"Internal API","title":"Internal API","text":"Documentation for EpiAware.jl's internal interface.","category":"page"},{"location":"lib/internals/#Contents","page":"Internal API","title":"Contents","text":"","category":"section"},{"location":"lib/internals/","page":"Internal API","title":"Internal API","text":"Pages = [\"internals.md\"]\nDepth = 2:2","category":"page"},{"location":"lib/internals/#Index","page":"Internal API","title":"Index","text":"","category":"section"},{"location":"lib/internals/","page":"Internal API","title":"Internal API","text":"Pages = [\"internals.md\"]","category":"page"},{"location":"lib/internals/#Internal-API","page":"Internal API","title":"Internal API","text":"","category":"section"},{"location":"lib/internals/","page":"Internal API","title":"Internal API","text":"Modules = [EpiAware]\nPublic = false","category":"page"},{"location":"getting-started/explainers/intro/#Introduction","page":"Introduction to EpiAware","title":"Introduction","text":"","category":"section"},{"location":"getting-started/explainers/intro/","page":"Introduction to EpiAware","title":"Introduction to EpiAware","text":"The diagram below shows the relationship between the modules in the package for a typical workflow.","category":"page"},{"location":"getting-started/explainers/intro/","page":"Introduction to EpiAware","title":"Introduction to EpiAware","text":"flowchart LR\n\nA[\"Underlying GI\nBijector\"]\n\nEpiModel[\"AbstractTuringEpiModel\n----------------------\nChoice of target\nfor latent process:\n\nDirectInfections\n ExpGrowthRate\n Renewal\"]\n\nInitModel[\"Priors for\ninitial scale of incidence\"]\n\nDataW[Data wrangling and QC]\n\n\nObsData[\"Observational Data\n---------------------\nObs. cases y_t\"]\n\nLatentProcPriors[\"Latent process priors\"]\n\nLatentProc[\"AbstractTuringLatentModel\n---------------------\nRandomWalk\"]\n\nObsModelPriors[\"Observation model priors\nchoice of delayed obs. model\"]\n\nObsModel[\"AbstractObservationModel\n---------------------\nDelayObservations\"]\n\nE[\"Turing model constructor\n---------------------\ngenerate_epiaware\"]\n\nG[Posterior draws]\nH[Posterior checking]\nI[Post-processing]\n\n\n\nA --> EpiData\nEpiData --> EpiModel\nInitModel --> EpiModel\nEpiModel -->E\nObsData-->E\nDataW-.->ObsData\nLatentProcPriors-->LatentProc\nLatentProc-->E\nObsModelPriors-->ObsModel\nObsModel-->E\n\n\nE-->|sample...NUTS...| G\nG-->H\nH-->I","category":"page"},{"location":"lib/EpiAwareBase/internals/#Internal-Documentation","page":"Internal API","title":"Internal Documentation","text":"","category":"section"},{"location":"lib/EpiAwareBase/internals/","page":"Internal API","title":"Internal API","text":"Documentation for EpiAwareBase.jl's internal interface.","category":"page"},{"location":"lib/EpiAwareBase/internals/#Contents","page":"Internal API","title":"Contents","text":"","category":"section"},{"location":"lib/EpiAwareBase/internals/#Contents-2","page":"Internal API","title":"Contents","text":"","category":"section"},{"location":"lib/EpiAwareBase/internals/","page":"Internal API","title":"Internal API","text":"Pages = [\"internals.md\"]\nDepth = 2:2","category":"page"},{"location":"lib/EpiAwareBase/internals/#Index","page":"Internal API","title":"Index","text":"","category":"section"},{"location":"lib/EpiAwareBase/internals/","page":"Internal API","title":"Internal API","text":"Pages = [\"internals.md\"]","category":"page"},{"location":"lib/EpiAwareBase/internals/","page":"Internal API","title":"Internal API","text":"Modules = [EpiAware.EpiAwareBase]\nPublic = false","category":"page"},{"location":"lib/EpiInfModels/internals/#Internal-Documentation","page":"Internal API","title":"Internal Documentation","text":"","category":"section"},{"location":"lib/EpiInfModels/internals/","page":"Internal API","title":"Internal API","text":"Documentation for EpiInfModels.jl's internal interface.","category":"page"},{"location":"lib/EpiInfModels/internals/#Contents","page":"Internal API","title":"Contents","text":"","category":"section"},{"location":"lib/EpiInfModels/internals/","page":"Internal API","title":"Internal API","text":"Pages = [\"internals.md\"]\nDepth = 2:2","category":"page"},{"location":"lib/EpiInfModels/internals/#Index","page":"Internal API","title":"Index","text":"","category":"section"},{"location":"lib/EpiInfModels/internals/","page":"Internal API","title":"Internal API","text":"Pages = [\"internals.md\"]","category":"page"},{"location":"lib/EpiInfModels/internals/#Internal-API","page":"Internal API","title":"Internal API","text":"","category":"section"},{"location":"lib/EpiInfModels/internals/","page":"Internal API","title":"Internal API","text":"Modules = [EpiAware.EpiInfModels]\nPublic = false","category":"page"},{"location":"lib/EpiInfModels/internals/#EpiAware.EpiAwareBase.generate_latent_infs-Tuple{AbstractTuringRenewal, Any}","page":"Internal API","title":"EpiAware.EpiAwareBase.generate_latent_infs","text":"generate_latent_infs(\n epi_model::AbstractTuringRenewal,\n _Rt\n) -> Any\n\n\nImplement the generate_latent_infs function for the Renewal model.\n\nExample usage with Renewal type of model for unobserved infection process\n\ngenerate_latent_infs can be used to construct a Turing model for the latent infections conditional on the sample path of a latent process. In this example, we generate a sample of a white noise latent process.\n\nFirst, we construct an Renewal struct with an EpiData object, an initialisation prior and a transformation function.\n\nusing Distributions, Turing, EpiAware\ngen_int = [0.2, 0.3, 0.5]\ng = exp\n\n# Create an EpiData object\ndata = EpiData(gen_int, g)\n\n# Create an Renewal model\nrenewal_model = Renewal(data = data, initialisation_prior = Normal())\n\nThen, we can use generate_latent_infs to construct a Turing model for the unobserved infection generation model set by the type of renewal_model.\n\n# Construct a Turing model\nZ_t = randn(100) * 0.05\nlatent_inf = generate_latent_infs(renewal_model, Z_t)\n\nNow we can use the Turing PPL API to sample underlying parameters and generate the unobserved infections.\n\n# Sample from the unobserved infections model\n\n#Sample random parameters from prior\nθ = rand(latent_inf)\n#Get unobserved infections as a generated quantities from the model\nI_t = generated_quantities(latent_inf, θ)\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiInfModels/internals/#EpiAware.EpiAwareBase.generate_latent_infs-Tuple{DirectInfections, Any}","page":"Internal API","title":"EpiAware.EpiAwareBase.generate_latent_infs","text":"generate_latent_infs(\n epi_model::DirectInfections,\n Z_t\n) -> Any\n\n\nImplement the generate_latent_infs function for the DirectInfections model.\n\nExample usage with DirectInfections type of model for unobserved infection process\n\nFirst, we construct a DirectInfections struct with an EpiData object, an initialisation prior and a transformation function.\n\nusing Distributions, Turing, EpiAware\ngen_int = [0.2, 0.3, 0.5]\ng = exp\n\n# Create an EpiData object\ndata = EpiData(gen_int, g)\n\n# Create a DirectInfections model\ndirect_inf_model = DirectInfections(data = data, initialisation_prior = Normal())\n\nThen, we can use generate_latent_infs to construct a Turing model for the unobserved infection generation model set by the type of direct_inf_model.\n\n# Construct a Turing model\nZ_t = randn(100)\nlatent_inf = generate_latent_infs(direct_inf_model, Z_t)\n\nNow we can use the Turing PPL API to sample underlying parameters and generate the unobserved infections.\n\n# Sample from the unobserved infections model\n\n#Sample random parameters from prior\nθ = rand(latent_inf)\n#Get unobserved infections as a generated quantities from the model\nI_t = generated_quantities(latent_inf, θ)\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiInfModels/internals/#EpiAware.EpiAwareBase.generate_latent_infs-Tuple{ExpGrowthRate, Any}","page":"Internal API","title":"EpiAware.EpiAwareBase.generate_latent_infs","text":"generate_latent_infs(epi_model::ExpGrowthRate, rt) -> Any\n\n\nImplement the generate_latent_infs function for the ExpGrowthRate model.\n\nExample usage with ExpGrowthRate type of model for unobserved infection process\n\ngenerate_latent_infs can be used to construct a Turing model for the latent infections conditional on the sample path of a latent process. In this example, we generate a sample of a white noise latent process.\n\nFirst, we construct an ExpGrowthRate struct with an EpiData object, an initialisation prior and a transformation function.\n\nusing Distributions, Turing, EpiAware\ngen_int = [0.2, 0.3, 0.5]\ng = exp\n\n# Create an EpiData object\ndata = EpiData(gen_int, g)\n\n# Create an ExpGrowthRate model\nexp_growth_model = ExpGrowthRate(data = data, initialisation_prior = Normal())\n\nThen, we can use generate_latent_infs to construct a Turing model for the unobserved infection generation model set by the type of direct_inf_model.\n\n# Construct a Turing model\nZ_t = randn(100) * 0.05\nlatent_inf = generate_latent_infs(exp_growth_model, Z_t)\n\nNow we can use the Turing PPL API to sample underlying parameters and generate the unobserved infections.\n\n# Sample from the unobserved infections model\n\n#Sample random parameters from prior\nθ = rand(latent_inf)\n#Get unobserved infections as a generated quantities from the model\nI_t = generated_quantities(latent_inf, θ)\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiInfModels/internals/#EpiAware.EpiInfModels.make_renewal_init-Tuple{Renewal, Any, Any}","page":"Internal API","title":"EpiAware.EpiInfModels.make_renewal_init","text":"make_renewal_init(epi_model::Renewal, I₀, Rt) -> Any\n\n\nCreate the initial vector of infected individuals for a renewal model.\n\nArguments\n\nepi_model::Renewal: The renewal model.\nI₀: The initial number of infected individuals.\nRt: The time-varying reproduction number.\n\nReturns\n\nThe initial vector of infected individuals.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiInfModels/internals/#EpiAware.EpiInfModels.make_renewal_init-Tuple{RenewalWithPopulation, Any, Any}","page":"Internal API","title":"EpiAware.EpiInfModels.make_renewal_init","text":"make_renewal_init(\n epi_model::RenewalWithPopulation,\n I₀,\n Rt\n) -> Tuple{Any, Float64}\n\n\nConstructs the initial conditions for a renewal model with population.\n\nArguments\n\nepi_model::RenewalWithPopulation: The renewal model with population.\nI₀: The initial number of infected individuals.\nRt: The time-varying reproduction number.\n\nReturns\n\nA tuple containing the initial number of infected individuals at each generation\n\ninterval and the population size of susceptible/available people.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiInfModels/internals/#EpiAware.EpiInfModels.neg_MGF-Tuple{Any, AbstractVector}","page":"Internal API","title":"EpiAware.EpiInfModels.neg_MGF","text":"neg_MGF(r, w::AbstractVector) -> Any\n\n\nCompute the negative moment generating function (MGF) for a given rate r and weights w.\n\nArguments\n\nr: The rate parameter.\nw: An abstract vector of weights.\n\nReturns\n\nThe value of the negative MGF.\n\n\n\n\n\n","category":"method"},{"location":"getting-started/explainers/interfaces/#Interfaces","page":"Interfaces","title":"Interfaces","text":"","category":"section"},{"location":"getting-started/explainers/interfaces/","page":"Interfaces","title":"Interfaces","text":"We support two primary workflows for using the package:","category":"page"},{"location":"getting-started/explainers/interfaces/","page":"Interfaces","title":"Interfaces","text":"EpiProblem: A high-level interface for defining and fitting models to data. This is the recommended way to use the package.\nTuring interface: A lower-level interface for defining and fitting models to data. This is the more flexible way to use the package and may also be more familiar to users of Turing.jl.","category":"page"},{"location":"getting-started/explainers/interfaces/","page":"Interfaces","title":"Interfaces","text":"See the getting started section for tutorials on each of these workflows.","category":"page"},{"location":"getting-started/explainers/interfaces/#EpiProblem","page":"Interfaces","title":"EpiProblem","text":"","category":"section"},{"location":"getting-started/explainers/interfaces/","page":"Interfaces","title":"Interfaces","text":"Each module of the overall epidemiological model we are interested in is a Turing Model in its own right. In this section, we compose the individual models into the full epidemiological model using the EpiProblem struct.","category":"page"},{"location":"getting-started/explainers/interfaces/","page":"Interfaces","title":"Interfaces","text":"The constructor for an EpiProblem requires:","category":"page"},{"location":"getting-started/explainers/interfaces/","page":"Interfaces","title":"Interfaces","text":"An epi_model.\nA latent_model.\nAn observation_model.\nA tspan.","category":"page"},{"location":"getting-started/explainers/interfaces/","page":"Interfaces","title":"Interfaces","text":"The tspan set the range of the time index for the models.","category":"page"},{"location":"getting-started/explainers/interfaces/#Turing-interface","page":"Interfaces","title":"Turing interface","text":"","category":"section"},{"location":"getting-started/explainers/interfaces/","page":"Interfaces","title":"Interfaces","text":"The Turing interface is a lower-level interface for defining and fitting models to data. This is the more flexible way to use the package and may also be more familiar to users of Turing.jl.","category":"page"},{"location":"getting-started/tutorials/#Tutorials","page":"Overview","title":"Tutorials","text":"","category":"section"},{"location":"getting-started/tutorials/","page":"Overview","title":"Overview","text":"This section contains tutorials that will help you get started with EpiAware for specific tasks. See the sidebar for the list of tutorials.","category":"page"},{"location":"overview/#overview","page":"Overview","title":"Overview of the EpiAware Software Ecosystem","text":"","category":"section"},{"location":"overview/","page":"Overview","title":"Overview","text":"EpiAware is not a standard toolkit for infectious disease modelling.","category":"page"},{"location":"overview/","page":"Overview","title":"Overview","text":"It seeks to be highly modular and composable for advanced users whilst still providing opinionated workflows for those who are new to the field. Developed by the authors behind other widely used infectious disease modelling packages such as EpiNow2, epinowcast, and epidist, alongside experts in infectious disease modelling in Julia,EpiAware is designed to go beyond the capabilities of these packages by providing a more flexible and extensible framework for modelling and inference of infectious disease dynamics.","category":"page"},{"location":"overview/#Package-Features","page":"Overview","title":"Package Features","text":"","category":"section"},{"location":"overview/","page":"Overview","title":"Overview","text":"Flexible: The package is designed to be flexible and extensible, and to provide a consistent interface for fitting and simulating models.\nModular: The package is designed to be modular, with a clear separation between the model and the data.\nExtensible: The package is designed to be extensible, with a clear separation between the model and the data.\nConsistent: The package is designed to provide a consistent interface for fitting and simulating models.\nEfficient: The package is designed to be efficient, with a clear separation between the model and the data.","category":"page"},{"location":"overview/#Package-structure","page":"Overview","title":"Package structure","text":"","category":"section"},{"location":"overview/","page":"Overview","title":"Overview","text":"EpiAware.jl is a wrapper around a series of submodules, each of which provides a different aspect of the package's functionality (much like the tidyverse in R). The package is designed to be modular, with a clear separation between modules and between modules and data. Currently included modules are:","category":"page"},{"location":"overview/","page":"Overview","title":"Overview","text":"EpiAwareBase: The core module, which provides the underlying abstract types and functions for the package.\nEpiAwareUtils: A utility module, which provides a series of utility functions for working with the package.\nEpiInference: An inference module, which provides a series of functions for fitting models to data. Builds on top of Turing.jl.\nEpiInfModels: Provides tools for composing models of the disease transmission process. Builds on top of Turing.jl, in particular the DynamicPPL.jl interface.\nEpiLatentModels: Provides tools for composing latent models such as random walks, autoregressive models, etc. Builds on top of DynamicPPL.jl. Used by all other modelling modules to define latent processes.\nEpiObsModels: Provides tools for composing observation models, such as Poisson, Binomial, etc. Builds on top of DynamicPPL.jl.","category":"page"},{"location":"overview/#Using-the-package","page":"Overview","title":"Using the package","text":"","category":"section"},{"location":"overview/","page":"Overview","title":"Overview","text":"We support two primary workflows for using the package:","category":"page"},{"location":"overview/","page":"Overview","title":"Overview","text":"EpiProblem: A high-level interface for defining and fitting models to data. This is the recommended way to use the package.\nTuring interface: A lower-level interface for defining and fitting models to data. This is the more flexible way to use the package and may also be more familiar to users of Turing.jl.","category":"page"},{"location":"overview/","page":"Overview","title":"Overview","text":"See the getting started section for tutorials on each of these workflows.","category":"page"},{"location":"lib/EpiAwareUtils/internals/#Internal-Documentation","page":"Internal API","title":"Internal Documentation","text":"","category":"section"},{"location":"lib/EpiAwareUtils/internals/","page":"Internal API","title":"Internal API","text":"Documentation for EpiAwareUtils.jl's internal interface.","category":"page"},{"location":"lib/EpiAwareUtils/internals/#Contents","page":"Internal API","title":"Contents","text":"","category":"section"},{"location":"lib/EpiAwareUtils/internals/","page":"Internal API","title":"Internal API","text":"Pages = [\"internals.md\"]\nDepth = 2:2","category":"page"},{"location":"lib/EpiAwareUtils/internals/#Index","page":"Internal API","title":"Index","text":"","category":"section"},{"location":"lib/EpiAwareUtils/internals/","page":"Internal API","title":"Internal API","text":"Pages = [\"internals.md\"]","category":"page"},{"location":"lib/EpiAwareUtils/internals/#Internal-API","page":"Internal API","title":"Internal API","text":"","category":"section"},{"location":"lib/EpiAwareUtils/internals/","page":"Internal API","title":"Internal API","text":"Modules = [EpiAware.EpiAwareUtils]\nPublic = false","category":"page"},{"location":"lib/EpiAwareUtils/internals/#EpiAware.EpiAwareBase._apply_method","page":"Internal API","title":"EpiAware.EpiAwareBase._apply_method","text":"_apply_method(\n model::DynamicPPL.Model,\n method::DirectSample;\n ...\n) -> Any\n_apply_method(\n model::DynamicPPL.Model,\n method::DirectSample,\n prev_result;\n kwargs...\n) -> Any\n\n\nImplements direct sampling from a Turing model.\n\n\n\n\n\n","category":"function"},{"location":"lib/EpiAwareUtils/internals/#EpiAware.EpiAwareBase._apply_method-2","page":"Internal API","title":"EpiAware.EpiAwareBase._apply_method","text":"_apply_method(\n model::DynamicPPL.Model,\n method::AbstractEpiMethod;\n ...\n) -> Any\n_apply_method(\n model::DynamicPPL.Model,\n method::AbstractEpiMethod,\n prev_result;\n kwargs...\n) -> Any\n\n\nApply the inference/generative method method to the Model object mdl.\n\nArguments\n\nmodel::AbstractEpiModel: The model to apply the method to.\nmethod::AbstractEpiMethod: The epidemiological method to apply.\nprev_result: The previous result of the method.\nkwargs: Additional keyword arguments passed to the method.\n\nReturns\n\nnothing: If no concrete implementation is defined for the given method.\n\n\n\n\n\n","category":"function"},{"location":"lib/EpiAwareUtils/internals/#EpiAware.EpiAwareBase._apply_method-Tuple{DynamicPPL.Model, EpiMethod, Any}","page":"Internal API","title":"EpiAware.EpiAwareBase._apply_method","text":"_apply_method(\n model::DynamicPPL.Model,\n method::EpiMethod,\n prev_result;\n kwargs...\n) -> Any\n\n\nApply steps defined by an EpiMethod to a model object.\n\nThis function applies the steps defined by an EpiMethod object to a Model object. It iterates over the pre-sampler steps defined in the EpiMethod object and recursively applies them to the model. Finally, it applies the sampler step defined in the EpiMethod object to the model. The prev_result argument is used to pass the result obtained from applying the previous steps, if any.\n\nArguments\n\nmethod::EpiMethod: The EpiMethod object containing the steps to be applied.\nmodel::Model: The model object to which the steps will be applied.\nprev_result: The previous result obtained from applying the steps. Defaults to nothing.\nkwargs...: Additional keyword arguments that can be passed to the steps.\n\nReturns\n\nprev_result: The result obtained after applying the steps.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiAwareUtils/internals/#EpiAware.EpiAwareBase._apply_method-Tuple{DynamicPPL.Model, EpiMethod}","page":"Internal API","title":"EpiAware.EpiAwareBase._apply_method","text":"_apply_method(\n model::DynamicPPL.Model,\n method::EpiMethod;\n kwargs...\n) -> Any\n\n\nApply a method to a mode without previous results\n\nArguments\n\nmodel::Model: The model to apply the method to.\nmethod::EpiMethod: The method to apply.\nkwargs...: Additional keyword arguments.\n\nReturns\n\nThe result of applying the method to the model.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiAwareUtils/internals/#EpiAware.EpiAwareBase.condition_model-Tuple{DynamicPPL.Model, NamedTuple, NamedTuple}","page":"Internal API","title":"EpiAware.EpiAwareBase.condition_model","text":"condition_model(\n model::DynamicPPL.Model,\n fix_parameters::NamedTuple,\n condition_parameters::NamedTuple\n) -> Any\n\n\nApply the condition to the model by fixing the specified parameters and conditioning on the others.\n\nArguments\n\nmodel::Model: The model to be conditioned.\nfix_parameters::NamedTuple: The parameters to be fixed.\ncondition_parameters::NamedTuple: The parameters to be conditioned on.\n\nReturns\n\n_model: The conditioned model.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiAwareUtils/internals/#EpiAware.EpiAwareBase.generate_epiaware-Tuple{Any, Any, AbstractTuringEpiModel}","page":"Internal API","title":"EpiAware.EpiAwareBase.generate_epiaware","text":"generate_epiaware(\n y_t,\n time_steps,\n epi_model::AbstractTuringEpiModel;\n latent_model,\n observation_model\n)\n\n\nGenerate an epi-aware model given the observed data and model specifications.\n\nArguments\n\ny_t: Observed data.\ntime_steps: Number of time steps.\nepi_model: A Turing Epi model specification.\nlatent_model: A Turing Latent model specification.\nobservation_model: A Turing Observation model specification.\n\nReturns\n\nA DynamicPPPL.Model object.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiAwareUtils/internals/#EpiAware.EpiAwareBase.generated_observables-Tuple{DynamicPPL.Model, Any, Union{NamedTuple, MCMCChains.Chains}}","page":"Internal API","title":"EpiAware.EpiAwareBase.generated_observables","text":"generated_observables(\n model::DynamicPPL.Model,\n data,\n solution::Union{NamedTuple, MCMCChains.Chains}\n) -> EpiAwareObservables\n\n\nGenerate observables from a given model and solution including generated quantities.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiAwareUtils/internals/#EpiAware.EpiAwareUtils._apply_direct_sample-Tuple{Any, Any, Int64}","page":"Internal API","title":"EpiAware.EpiAwareUtils._apply_direct_sample","text":"_apply_direct_sample(\n model,\n method,\n n_samples::Int64;\n kwargs...\n) -> Any\n\n\nSample the model directly using Turing.Prior() and a NamedTuple of the sampled random variables along with generated quantities.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiAwareUtils/internals/#EpiAware.EpiAwareUtils._apply_direct_sample-Tuple{Any, Any, Nothing}","page":"Internal API","title":"EpiAware.EpiAwareUtils._apply_direct_sample","text":"_apply_direct_sample(\n model,\n method,\n n_samples::Nothing\n) -> Any\n\n\nSample the model directly using rand and return a single set of sampled random variables.\n\n\n\n\n\n","category":"method"},{"location":"#EpiAware.jl","page":"EpiAware.jl: Real-time infectious disease monitoring","title":"EpiAware.jl","text":"","category":"section"},{"location":"","page":"EpiAware.jl: Real-time infectious disease monitoring","title":"EpiAware.jl: Real-time infectious disease monitoring","text":"Infectious disease situational awareness modelling toolkit for Julia.","category":"page"},{"location":"#Where-to-start","page":"EpiAware.jl: Real-time infectious disease monitoring","title":"Where to start","text":"","category":"section"},{"location":"","page":"EpiAware.jl: Real-time infectious disease monitoring","title":"EpiAware.jl: Real-time infectious disease monitoring","text":"Want to get started running code? Check out the Getting Started Tutorials.\nWhat is EpiAware? Check out our Overview.\nWant to see some end-to-end examples? Check out our EpiAware showcase.\nWant to understand the API? Check out our API Reference.\nWant to chat with someone about EpiAware? Post on our GitHub Discussions.\nWant to contribute to EpiAware? Check out our Developer documentation.\nWant to see our code? Check out our GitHub Repository.","category":"page"},{"location":"lib/EpiInfModels/public/#Public-Documentation","page":"Public API","title":"Public Documentation","text":"","category":"section"},{"location":"lib/EpiInfModels/public/","page":"Public API","title":"Public API","text":"Documentation for EpiInfModels.jl's public interface.","category":"page"},{"location":"lib/EpiInfModels/public/","page":"Public API","title":"Public API","text":"See the Internals section of the manual for internal package docs covering all submodules.","category":"page"},{"location":"lib/EpiInfModels/public/#Contents","page":"Public API","title":"Contents","text":"","category":"section"},{"location":"lib/EpiInfModels/public/","page":"Public API","title":"Public API","text":"Pages = [\"public.md\"]\nDepth = 2:2","category":"page"},{"location":"lib/EpiInfModels/public/#Index","page":"Public API","title":"Index","text":"","category":"section"},{"location":"lib/EpiInfModels/public/","page":"Public API","title":"Public API","text":"Pages = [\"public.md\"]","category":"page"},{"location":"lib/EpiInfModels/public/#Public-API","page":"Public API","title":"Public API","text":"","category":"section"},{"location":"lib/EpiInfModels/public/","page":"Public API","title":"Public API","text":"Modules = [EpiAware.EpiInfModels]\nPrivate = false","category":"page"},{"location":"lib/EpiInfModels/public/#EpiAware.EpiInfModels","page":"Public API","title":"EpiAware.EpiInfModels","text":"Module for defining epidemiological models.\n\n\n\n\n\n","category":"module"},{"location":"lib/EpiInfModels/public/#EpiAware.EpiInfModels.DirectInfections","page":"Public API","title":"EpiAware.EpiInfModels.DirectInfections","text":"struct DirectInfections{S<:Distributions.Sampleable} <: AbstractTuringEpiModel\n\nModel unobserved/latent infections as a transformation on a sampled latent process.\n\nMathematical specification\n\nIf Z_t is a realisation of the latent model, then the unobserved/latent infections are given by\n\nI_t = g(hatI_0 + Z_t)\n\nwhere g is a transformation function and the unconstrained initial infections hatI_0 are sampled from a prior distribution.\n\nDirectInfections are constructed by passing an EpiData object data and an initialisation_prior for the prior distribution of hatI_0. The default initialisation_prior is Normal().\n\nConstructors\n\nDirectInfections(; data, initialisation_prior)\n\nExample usage with generate_latent_infs\n\ngenerate_latent_infs can be used to construct a Turing model for the latent infections conditional on the sample path of a latent process. In this example, we generate a sample of a white noise latent process.\n\nFirst, we construct a DirectInfections struct with an EpiData object, an initialisation prior and a transformation function.\n\nusing Distributions, Turing, EpiAware\ngen_int = [0.2, 0.3, 0.5]\ng = exp\n\n# Create an EpiData object\ndata = EpiData(gen_int, g)\n\n# Create a DirectInfections model\ndirect_inf_model = DirectInfections(data = data, initialisation_prior = Normal())\n\nThen, we can use generate_latent_infs to construct a Turing model for the unobserved infection generation model set by the type of direct_inf_model.\n\n# Construct a Turing model\nZ_t = randn(100)\nlatent_inf = generate_latent_infs(direct_inf_model, Z_t)\n\nNow we can use the Turing PPL API to sample underlying parameters and generate the unobserved infections.\n\n# Sample from the unobserved infections model\n\n#Sample random parameters from prior\nθ = rand(latent_inf)\n#Get unobserved infections as a generated quantities from the model\nI_t = generated_quantities(latent_inf, θ)\n\n\n\nFields\n\ndata::EpiData: Epidata object.\ninitialisation_prior::Distributions.Sampleable: Prior distribution for the initialisation of the infections. Default is Normal().\n\n\n\n\n\n","category":"type"},{"location":"lib/EpiInfModels/public/#EpiAware.EpiInfModels.EpiData","page":"Public API","title":"EpiAware.EpiInfModels.EpiData","text":"struct EpiData{T<:Real, F<:Function}\n\nThe EpiData struct represents epidemiological data used in infectious disease modeling.\n\nConstructors\n\nEpiData(gen_int, transformation::Function). Constructs an EpiData object with discrete\n\ngeneration interval gen_int and transformation function transformation.\n\nEpiData(;gen_distribution::ContinuousDistribution, D_gen, Δd = 1.0, transformation::Function = exp).\n\nConstructs an EpiData object with double interval censoring discretisation of the continuous next generation interval distribution gen_distribution with additional right truncation at D_gen. Δd sets the interval width (default = 1.0). transformation sets the transformation function\n\nExamples\n\nConstruction direct from discrete generation interval and transformation function:\n\nusing EpiAware\ngen_int = [0.2, 0.3, 0.5]\ng = exp\ndata = EpiData(gen_int, g)\n\nConstruction from continuous distribution for generation interval.\n\nusing Distributions\n\ngen_distribution = Uniform(0.0, 10.0)\n\ndata = EpiData(;gen_distribution\n D_gen = 10.0)\n\n\n\nFields\n\ngen_int::Vector{T} where T<:Real: Discrete generation interval.\nlen_gen_int::Integer: Length of the discrete generation interval.\ntransformation::Function: Transformation function defining constrained and unconstrained domain bijections.\n\n\n\n\n\n","category":"type"},{"location":"lib/EpiInfModels/public/#EpiAware.EpiInfModels.ExpGrowthRate","page":"Public API","title":"EpiAware.EpiInfModels.ExpGrowthRate","text":"struct ExpGrowthRate{S<:Distributions.Sampleable} <: AbstractTuringEpiModel\n\nModel unobserved/latent infections as due to time-varying exponential growth rate r_t which is generated by a latent process.\n\nMathematical specification\n\nIf Z_t is a realisation of the latent model, then the unobserved/latent infections are given by\n\nI_t = g(hatI_0) exp(Z_t)\n\nwhere g is a transformation function and the unconstrained initial infections hatI_0 are sampled from a prior distribution.\n\nExpGrowthRate are constructed by passing an EpiData object data and an initialisation_prior for the prior distribution of hatI_0. The default initialisation_prior is Normal().\n\nConstructor\n\nExpGrowthRate(; data, initialisation_prior).\n\nExample usage with generate_latent_infs\n\ngenerate_latent_infs can be used to construct a Turing model for the latent infections conditional on the sample path of a latent process. In this example, we generate a sample of a white noise latent process.\n\nFirst, we construct an ExpGrowthRate struct with an EpiData object, an initialisation prior and a transformation function.\n\nusing Distributions, Turing, EpiAware\ngen_int = [0.2, 0.3, 0.5]\ng = exp\n\n# Create an EpiData object\ndata = EpiData(gen_int, g)\n\n# Create an ExpGrowthRate model\nexp_growth_model = ExpGrowthRate(data = data, initialisation_prior = Normal())\n\nThen, we can use generate_latent_infs to construct a Turing model for the unobserved infection generation model set by the type of direct_inf_model.\n\n# Construct a Turing model\nZ_t = randn(100) * 0.05\nlatent_inf = generate_latent_infs(exp_growth_model, Z_t)\n\nNow we can use the Turing PPL API to sample underlying parameters and generate the unobserved infections.\n\n# Sample from the unobserved infections model\n\n#Sample random parameters from prior\nθ = rand(latent_inf)\n#Get unobserved infections as a generated quantities from the model\nI_t = generated_quantities(latent_inf, θ)\n\n\n\nFields\n\ndata::EpiData\ninitialisation_prior::Distributions.Sampleable\n\n\n\n\n\n","category":"type"},{"location":"lib/EpiInfModels/public/#EpiAware.EpiInfModels.Renewal","page":"Public API","title":"EpiAware.EpiInfModels.Renewal","text":"struct Renewal{S<:Distributions.Sampleable} <: AbstractTuringRenewal\n\nModel unobserved/latent infections as due to time-varying Renewal model with reproduction number mathcalR_t which is generated by a latent process.\n\nMathematical specification\n\nIf Z_t is a realisation of the latent model, then the unobserved/latent infections are given by\n\nbeginalign\nmathcalR_t = g(Z_t)\nI_t = mathcalR_t sum_i=1^n-1 I_t-i g_i qquad t geq 1 \nI_t = g(hatI_0) exp(r(mathcalR_1) t) qquad t leq 0\nendalign\n\nwhere g is a transformation function and the unconstrained initial infections hatI_0 are sampled from a prior distribution. The discrete generation interval is given by g_i.\n\nr(mathcalR_1) is the exponential growth rate implied by mathcalR_1) using the implicit relationship between the exponential growth rate and the reproduction number.\n\nmathcalR sum_j geq 1 g_j exp(- r j)= 1\n\nRenewal are constructed by passing an EpiData object data and an initialisation_prior for the prior distribution of hatI_0. The default initialisation_prior is Normal().\n\nConstructor\n\nRenewal(; data, initialisation_prior).\n\nExample usage with generate_latent_infs\n\ngenerate_latent_infs can be used to construct a Turing model for the latent infections conditional on the sample path of a latent process. In this example, we generate a sample of a white noise latent process.\n\nFirst, we construct an Renewal struct with an EpiData object, an initialisation prior and a transformation function.\n\nusing Distributions, Turing, EpiAware\ngen_int = [0.2, 0.3, 0.5]\ng = exp\n\n# Create an EpiData object\ndata = EpiData(gen_int, g)\n\n# Create an Renewal model\nrenewal_model = Renewal(data = data, initialisation_prior = Normal())\n\nThen, we can use generate_latent_infs to construct a Turing model for the unobserved infection generation model set by the type of direct_inf_model.\n\n# Construct a Turing model\nZ_t = randn(100) * 0.05\nlatent_inf = generate_latent_infs(renewal_model, Z_t)\n\nNow we can use the Turing PPL API to sample underlying parameters and generate the unobserved infections.\n\n# Sample from the unobserved infections model\n\n#Sample random parameters from prior\nθ = rand(latent_inf)\n#Get unobserved infections as a generated quantities from the model\nI_t = generated_quantities(latent_inf, θ)\n\n\n\nFields\n\ndata::EpiData\ninitialisation_prior::Distributions.Sampleable\n\n\n\n\n\n","category":"type"},{"location":"lib/EpiInfModels/public/#EpiAware.EpiInfModels.Renewal-Tuple{Any, Any}","page":"Public API","title":"EpiAware.EpiInfModels.Renewal","text":"function (epi_model::Renewal)(recent_incidence, Rt)\n\nCallable on a Renewal struct for compute new incidence based on recent incidence and Rt.\n\nMathematical specification\n\nThe new incidence is given by\n\nI_t = R_t sum_i=1^n-1 I_t-i g_i\n\nwhere I_t is the new incidence, R_t is the reproduction number, I_{t-i} is the recent incidence and g_i is the generation interval.\n\nArguments\n\nrecent_incidence: Array of recent incidence values.\nRt: Reproduction number.\n\nReturns\n\nTuple containing the updated incidence array and the new incidence value.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiInfModels/public/#EpiAware.EpiInfModels.RenewalWithPopulation","page":"Public API","title":"EpiAware.EpiInfModels.RenewalWithPopulation","text":"struct RenewalWithPopulation{S<:Distributions.Sampleable} <: AbstractTuringRenewal\n\nModel unobserved/latent infections as due to time-varying Renewal model with reproduction number mathcalR_t which is generated by a latent process and a population size of available people who can be infected N.\n\nMathematical specification\n\nIf Z_t is a realisation of the latent model, then the unobserved/latent infections are given by\n\nbeginalign\nmathcalR_t = g(Z_t)\nS_t = S_t-1 - I_t\nI_t = S_t-1 over NmathcalR_t sum_i=1^n-1 I_t-i g_i qquad t geq 1 \nI_t = g(hatI_0) exp(r(mathcalR_1) t) qquad t leq 0\nendalign\n\nwhere g is a transformation function and the unconstrained initial infections hatI_0 are sampled from a prior distribution. The discrete generation interval is given by g_i.\n\nr(mathcalR_1) is the exponential growth rate implied by mathcalR_1) using the implicit relationship between the exponential growth rate and the reproduction number.\n\nmathcalR sum_j geq 1 g_j exp(- r j)= 1\n\nRenewal are constructed by passing an EpiData object data and an initialisation_prior for the prior distribution of hatI_0. The default initialisation_prior is Normal().\n\nConstructor\n\nRenewalWithPopulation(; data, initialisation_prior, pop_size).\n\nExample usage with generate_latent_infs\n\ngenerate_latent_infs can be used to construct a Turing model for the latent infections conditional on the sample path of a latent process. In this example, we generate a sample of a white noise latent process.\n\nFirst, we construct an Renewal struct with an EpiData object, an initialisation prior and a transformation function.\n\nusing Distributions, Turing, EpiAware\ngen_int = [0.2, 0.3, 0.5]\ng = exp\n\n# Create an EpiData object\ndata = EpiData(gen_int, g)\n\n# Create an Renewal model\nrenewal_model = RenewalWithPopulation(data = data, initialisation_prior = Normal(), pop_size = 1e6)\n\nThen, we can use generate_latent_infs to construct a Turing model for the unobserved infection generation model set by the type of direct_inf_model.\n\n# Construct a Turing model\nZ_t = randn(100) * 0.05\nlatent_inf = generate_latent_infs(renewal_model, Z_t)\n\nNow we can use the Turing PPL API to sample underlying parameters and generate the unobserved infections.\n\n# Sample from the unobserved infections model\n\n#Sample random parameters from prior\nθ = rand(latent_inf)\n#Get unobserved infections as a generated quantities from the model\nI_t = generated_quantities(latent_inf, θ)\n\n\n\nFields\n\ndata::EpiData\ninitialisation_prior::Distributions.Sampleable\npop_size::Float64\n\n\n\n\n\n","category":"type"},{"location":"lib/EpiInfModels/public/#EpiAware.EpiInfModels.RenewalWithPopulation-Tuple{Any, Any}","page":"Public API","title":"EpiAware.EpiInfModels.RenewalWithPopulation","text":"function (epi_model::RenewalWithPopulation)(recent_incidence_and_available_sus, Rt)\n\nCallable on a RenewalWithPopulation struct for compute new incidence based on recent incidence, Rt and depletion of susceptibles.\n\nMathematical specification\n\nThe new incidence is given by\n\nI_t = S_t-1 N R_t sum_i=1^n-1 I_t-i g_i\n\nwhere I_t is the new incidence, R_t is the reproduction number, I_{t-i} is the recent incidence and g_i is the generation interval.\n\nArguments\n\nrecent_incidence_and_available_sus: A tuple with an array of recent incidence\n\nvalues and the remaining susceptible/available individuals.\n\nRt: Reproduction number.\n\nReturns\n\nTuple containing the updated incidence array and the new recent_incidence_and_available_sus\n\nvalue.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiInfModels/public/#EpiAware.EpiInfModels.R_to_r-Union{Tuple{T}, Tuple{Any, Vector{T}}} where T<:AbstractFloat","page":"Public API","title":"EpiAware.EpiInfModels.R_to_r","text":"R_to_r(\n R₀,\n w::Array{T<:AbstractFloat, 1};\n newton_steps,\n Δd\n) -> Any\n\n\nThis function computes an approximation to the exponential growth rate r given the reproductive ratio R₀ and the discretized generation interval w with discretized interval width Δd. This is based on the implicit solution of\n\nG(r) - 1 over R_0 = 0\n\nwhere\n\nG(r) = sum_i=1^n w_i e^-r i\n\nis the negative moment generating function (MGF) of the generation interval distribution.\n\nThe two step approximation is based on: 1. Direct solution of implicit equation for a small r approximation. 2. Improving the approximation using Newton's method for a fixed number of steps newton_steps.\n\nReturns:\n\nThe approximate value of r.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiInfModels/public/#EpiAware.EpiInfModels.expected_Rt-Tuple{EpiData, Vector{<:Real}}","page":"Public API","title":"EpiAware.EpiInfModels.expected_Rt","text":"expected_Rt(\n data::EpiData,\n infections::Vector{<:Real}\n) -> Any\n\n\nCalculate the expected Rt values based on the given EpiData object and infections.\n\nR_t = fracI_tsum_i=1^n I_t-i g_i\n\nArguments\n\ndata::EpiData: An instance of the EpiData type containing generation interval data.\ninfections::Vector{<:Real}: A vector of infection data.\n\nReturns\n\nexp_Rt::Vector{Float64}: A vector of expected Rt values.\n\nExamples\n\nusing EpiAware\n\ndata = EpiData([0.2, 0.3, 0.5], exp)\ninfections = [100, 200, 300, 400, 500]\nexpected_Rt(data, infections)\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiInfModels/public/#EpiAware.EpiInfModels.r_to_R-Tuple{Any, AbstractVector}","page":"Public API","title":"EpiAware.EpiInfModels.r_to_R","text":"r_to_R(r, w::AbstractVector) -> Any\n\n\nr_to_R(r, w)\n\nCompute the reproductive ratio given exponential growth rate r and discretized generation interval w.\n\nArguments\n\nr: The exponential growth rate.\nw: discretized generation interval.\n\nReturns\n\nThe reproductive ratio.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiAwareUtils/#EpiAwareUtils.jl","page":"Overview","title":"EpiAwareUtils.jl","text":"","category":"section"},{"location":"lib/EpiAwareUtils/","page":"Overview","title":"Overview","text":"This package provides utility functions for the EpiAware ecosystem.","category":"page"},{"location":"lib/EpiAwareUtils/#API","page":"Overview","title":"API","text":"","category":"section"},{"location":"lib/EpiAwareUtils/","page":"Overview","title":"Overview","text":"Pages = [\"lib/EpiAwareUtils/public.md\", \"lib/EpiAwareUtils/internals.md\"]","category":"page"},{"location":"lib/EpiInference/#EpiInference.jl","page":"Overview","title":"EpiInference.jl","text":"","category":"section"},{"location":"lib/EpiInference/","page":"Overview","title":"Overview","text":"This package provides inference algorithms for the EpiAware ecosystem.","category":"page"},{"location":"lib/EpiInference/#API","page":"Overview","title":"API","text":"","category":"section"},{"location":"lib/EpiInference/","page":"Overview","title":"Overview","text":"Pages = [\"lib/EpiInference/public.md\", \"lib/EpiInference/internals.md\"]","category":"page"},{"location":"lib/public/#Public-Documentation","page":"Public API","title":"Public Documentation","text":"","category":"section"},{"location":"lib/public/","page":"Public API","title":"Public API","text":"Documentation for EpiAware.jl's public interface.","category":"page"},{"location":"lib/public/","page":"Public API","title":"Public API","text":"See the Internals section of the manual for internal package docs covering all submodules.","category":"page"},{"location":"lib/public/#Contents","page":"Public API","title":"Contents","text":"","category":"section"},{"location":"lib/public/","page":"Public API","title":"Public API","text":"Pages = [\"public.md\"]\nDepth = 2:2","category":"page"},{"location":"lib/public/#Index","page":"Public API","title":"Index","text":"","category":"section"},{"location":"lib/public/","page":"Public API","title":"Public API","text":"Pages = [\"public.md\"]","category":"page"},{"location":"lib/public/#Public-API","page":"Public API","title":"Public API","text":"","category":"section"},{"location":"lib/public/","page":"Public API","title":"Public API","text":"Modules = [EpiAware]\nPrivate = false","category":"page"},{"location":"showcase/replications/mishra-2020/","page":"On the derivation of the renewal equation from an age-dependent branching process: an epidemic modelling perspective","title":"On the derivation of the renewal equation from an age-dependent branching process: an epidemic modelling perspective","text":"\n\n\n\n\n\n\n\n\n\n\n

              Getting started with EpiAware

              This tutorial introduces the basic functionality of EpiAware. EpiAware is a package for making inferences on epidemiological case/determined infection data using a model-based approach.

              It is common to conceptualise the generative process of public health data, e.g a time series of reported cases of an infectious pathogen, in a modular way. For example, it is common to abstract the underlying latent infection process away from downstream issues of observation, or to treat quanitites such as the time-varying reproduction number as being itself generated as a random process.

              EpiAware is built using the DynamicPPL probabilistic programming domain-specific language, which is part of the Turing PPL. The structural concept behind EpiAware is that each module of an epidemiological model is a self-contained TuringModel; that is each module is an object that can be conditioned on observable data and sampled from. A complete EpiAware model is the composition of these objects using the @submodel macro.

              \n\n","category":"page"},{"location":"showcase/replications/mishra-2020/#Example:-Early-COVID-19-case-data-in-South-Korea","page":"On the derivation of the renewal equation from an age-dependent branching process: an epidemic modelling perspective","title":"Example: Early COVID-19 case data in South Korea","text":"","category":"section"},{"location":"showcase/replications/mishra-2020/","page":"On the derivation of the renewal equation from an age-dependent branching process: an epidemic modelling perspective","title":"On the derivation of the renewal equation from an age-dependent branching process: an epidemic modelling perspective","text":"
              \n

              To demonstrate EpiAware we largely recreate an epidemiological model presented in On the derivation of the renewal equation from an age-dependent branching process: an epidemic modelling perspective, Mishra et al (2020). Mishra et al consider test-confirmed cases of COVID-19 in South Korea between January to July 2020. The components of the epidemilogical model they consider are:

              $$I_t = \\mu_t + R_t \\sum_{s\\geq 1} I_{t-s} g_s.$$

              Where \\(g_t\\) is a daily discretisation of the probability mass function of an estimated serial interval distribution:

              $$G \\sim \\text{Gamma}(6.5,0.62).$$

              And \\(\\mu_t\\) is an external importation of infection process.

              $$C_t \\sim \\text{NegBin}(\\text{mean} = I_t,~ \\text{overdispersion} = \\phi).$$

              In the examples below we are going to largely recreate the Mishra et al model, whilst emphasing that each component of the overall epidemiological model is, itself, a stand alone model that can be sampled from.

              \n\n\n
              TaskLocalRNG()
              \n\n\n

              Time-varying reproduction number as a LatentModel type

              EpiAware exposes a LatentModel type system; the purpose of which is to define stochastic processes which can be interpreted as generating time-varying parameters/quantities of interest.

              In the Mishra et al model the log-time varying reproductive number is a priori assumed to evolve as an auto-regressive process, AR(2):

              $$\\begin{align}\nZ_t &= \\log R_t, \\\\\nZ_t &= \\rho_1 Z_{t-1} + \\rho_2 Z_{t-2} + \\epsilon_t, \\\\\n\\epsilon_t &\\sim \\text{Normal}(0, \\sigma).\n\\end{align}$$

              \n\n\n

              EpiAware gives a concrete subtype AR <: AbstractLatentModel which defines this behaviour of the latent model. The user can supply the priors for \\(\\rho_1,\\rho_2\\), wich we call damp_priors, as well as for \\(\\sigma\\) (std_prior) and the initial values \\(Z_1, Z_2\\) (init_priors).

              \n\n
              ar = AR(\n    damp_priors = [truncated(Normal(0.8, 0.05), 0, 1),\n        truncated(Normal(0.05, 0.05), 0, 1)],\n    std_prior = HalfNormal(1.0),\n    init_priors = [Normal(-1.0, 0.1), Normal(-1.0, 0.1)]\n)
              \n
              AR{Product{Continuous, Truncated{Normal{Float64}, Continuous, Float64, Float64, Float64}, Vector{Truncated{Normal{Float64}, Continuous, Float64, Float64, Float64}}}, HalfNormal{Float64}, DistributionsAD.TuringScalMvNormal{Vector{Float64}, Float64}, Int64}(Distributions.Product{Distributions.Continuous, Distributions.Truncated{Distributions.Normal{Float64}, Distributions.Continuous, Float64, Float64, Float64}, Vector{Distributions.Truncated{Distributions.Normal{Float64}, Distributions.Continuous, Float64, Float64, Float64}}}(v=Truncated{Normal{Float64}, Continuous, Float64, Float64, Float64}[Truncated(Distributions.Normal{Float64}(μ=0.8, σ=0.05); lower=0.0, upper=1.0), Truncated(Distributions.Normal{Float64}(μ=0.05, σ=0.05); lower=0.0, upper=1.0)]), HalfNormal{Float64}(μ=1.0), DistributionsAD.TuringScalMvNormal{Vector{Float64}, Float64}(m=[-1.0, -1.0], σ=0.1), 2)
              \n\n\n

              The priors here are based on Mishra et al, note that we have decreased the a priori belief in the correlation parameter \\(\\rho_1\\).

              \n\n\n
              Turing model interface

              As mentioned above, we can use this instance of the AR latent model to construct a TuringModel which implements the probabilistic behaviour determined by ar.

              We do this with the constructor function generate_latent which combines ar with a number of time steps to generate for (in this case we choose 30).

              \n\n
              ar_mdl = generate_latent(ar, 30)
              \n
              Model{typeof(generate_latent), (:latent_model, :n), (), (), Tuple{AR{Product{Continuous, Truncated{Normal{Float64}, Continuous, Float64, Float64, Float64}, Vector{Truncated{Normal{Float64}, Continuous, Float64, Float64, Float64}}}, HalfNormal{Float64}, DistributionsAD.TuringScalMvNormal{Vector{Float64}, Float64}, Int64}, Int64}, Tuple{}, DefaultContext}(EpiAware.EpiAwareBase.generate_latent, (latent_model = AR{Product{Continuous, Truncated{Normal{Float64}, Continuous, Float64, Float64, Float64}, Vector{Truncated{Normal{Float64}, Continuous, Float64, Float64, Float64}}}, HalfNormal{Float64}, DistributionsAD.TuringScalMvNormal{Vector{Float64}, Float64}, Int64}(Distributions.Product{Distributions.Continuous, Distributions.Truncated{Distributions.Normal{Float64}, Distributions.Continuous, Float64, Float64, Float64}, Vector{Distributions.Truncated{Distributions.Normal{Float64}, Distributions.Continuous, Float64, Float64, Float64}}}(v=Truncated{Normal{Float64}, Continuous, Float64, Float64, Float64}[Truncated(Distributions.Normal{Float64}(μ=0.8, σ=0.05); lower=0.0, upper=1.0), Truncated(Distributions.Normal{Float64}(μ=0.05, σ=0.05); lower=0.0, upper=1.0)]), HalfNormal{Float64}(μ=1.0), DistributionsAD.TuringScalMvNormal{Vector{Float64}, Float64}(m=[-1.0, -1.0], σ=0.1), 2), n = 30), NamedTuple(), DefaultContext())
              \n\n\n

              We can sample from this model, which is useful for model diagnostic and prior predictive checking.

              \n\n\n\n\n\n

              And we can sample from this model with some parameters conditioned, for example with \\(\\sigma = 0\\). In this case the AR process is an initial perturbation model with return to baseline.

              \n\n
              cond_ar_mdl = ar_mdl | (σ_AR = 0.0,)
              \n
              Model{typeof(generate_latent), (:latent_model, :n), (), (), Tuple{AR{Product{Continuous, Truncated{Normal{Float64}, Continuous, Float64, Float64, Float64}, Vector{Truncated{Normal{Float64}, Continuous, Float64, Float64, Float64}}}, HalfNormal{Float64}, DistributionsAD.TuringScalMvNormal{Vector{Float64}, Float64}, Int64}, Int64}, Tuple{}, ConditionContext{@NamedTuple{σ_AR::Float64}, DefaultContext}}(EpiAware.EpiAwareBase.generate_latent, (latent_model = AR{Product{Continuous, Truncated{Normal{Float64}, Continuous, Float64, Float64, Float64}, Vector{Truncated{Normal{Float64}, Continuous, Float64, Float64, Float64}}}, HalfNormal{Float64}, DistributionsAD.TuringScalMvNormal{Vector{Float64}, Float64}, Int64}(Distributions.Product{Distributions.Continuous, Distributions.Truncated{Distributions.Normal{Float64}, Distributions.Continuous, Float64, Float64, Float64}, Vector{Distributions.Truncated{Distributions.Normal{Float64}, Distributions.Continuous, Float64, Float64, Float64}}}(v=Truncated{Normal{Float64}, Continuous, Float64, Float64, Float64}[Truncated(Distributions.Normal{Float64}(μ=0.8, σ=0.05); lower=0.0, upper=1.0), Truncated(Distributions.Normal{Float64}(μ=0.05, σ=0.05); lower=0.0, upper=1.0)]), HalfNormal{Float64}(μ=1.0), DistributionsAD.TuringScalMvNormal{Vector{Float64}, Float64}(m=[-1.0, -1.0], σ=0.1), 2), n = 30), NamedTuple(), ConditionContext((σ_AR = 0.0,), DynamicPPL.DefaultContext()))
              \n\n\n\n\n\n

              In this note, we are going to treat \\(R_t\\) as varying every two days. The reason for this is to 1) reduce the effective number of parameters, and 2) showcase the BroadcastLatentModel wrapper.

              In EpiAware we set this behaviour by wrapping a LatentModel in a BroadcastLatentModel. This allows us to set the broadcasting period and type. In this case we broadcast each latent process value over \\(2\\) days in a RepeatBlock.

              \n\n
              twod_ar = BroadcastLatentModel(ar, 2, RepeatBlock())
              \n
              BroadcastLatentModel{AR{Product{Continuous, Truncated{Normal{Float64}, Continuous, Float64, Float64, Float64}, Vector{Truncated{Normal{Float64}, Continuous, Float64, Float64, Float64}}}, HalfNormal{Float64}, DistributionsAD.TuringScalMvNormal{Vector{Float64}, Float64}, Int64}, Int64, RepeatBlock}(AR{Product{Continuous, Truncated{Normal{Float64}, Continuous, Float64, Float64, Float64}, Vector{Truncated{Normal{Float64}, Continuous, Float64, Float64, Float64}}}, HalfNormal{Float64}, DistributionsAD.TuringScalMvNormal{Vector{Float64}, Float64}, Int64}(Distributions.Product{Distributions.Continuous, Distributions.Truncated{Distributions.Normal{Float64}, Distributions.Continuous, Float64, Float64, Float64}, Vector{Distributions.Truncated{Distributions.Normal{Float64}, Distributions.Continuous, Float64, Float64, Float64}}}(v=Truncated{Normal{Float64}, Continuous, Float64, Float64, Float64}[Truncated(Distributions.Normal{Float64}(μ=0.8, σ=0.05); lower=0.0, upper=1.0), Truncated(Distributions.Normal{Float64}(μ=0.05, σ=0.05); lower=0.0, upper=1.0)]), HalfNormal{Float64}(μ=1.0), DistributionsAD.TuringScalMvNormal{Vector{Float64}, Float64}(m=[-1.0, -1.0], σ=0.1), 2), 2, RepeatBlock())
              \n\n\n\n\n\n

              The Renewal model as an EpiModel type

              EpiAware has an EpiModel type system which we use to set the behaviour of the latent infection model. In this case we want to implement a renewal model.

              To construct an EpiModel we need to supply some fixed data for the model contained in an EpiData object. The EpiData constructor performs double interval censoring to convert our continuous estimate of the generation interval into a discretized version \\(g_t\\). We also implement right truncation, the default is rounding the 99th percentile of the generation interval distribution, but this can be controlled using the keyword D_gen.

              \n\n
              truth_GI = Gamma(6.5, 0.62)
              \n
              Distributions.Gamma{Float64}(α=6.5, θ=0.62)
              \n\n
              model_data = EpiData(gen_distribution = truth_GI)
              \n
              EpiData{Float64, typeof(exp)}([0.026663134095601056, 0.14059778064943784, 0.2502660305615846, 0.24789569560506844, 0.1731751163417783, 0.09635404000022223, 0.04573437575216367, 0.019313826994143808], 8, exp)
              \n\n\n\n\n\n

              The user also needs to specify a prior for the log incidence at time zero, \\(\\log I_0\\). The initial history of latent infections \\(I_{-1}, I_{-2},\\dots\\) is constructed as

              $$I_t = e^{rt} I_0,\\qquad t = 0, -1, -2,...$$

              Where the exponential growth rate \\(r\\) is determined by the initial reproductive number \\(R_1\\) via the solution to the implicit equation,

              $$R_1 = 1 \\Big{/} \\sum_{t\\geq 1} e^{-rt} g_t$$

              \n\n
              log_I0_prior = Normal(log(1.0), 1.0)
              \n
              Distributions.Normal{Float64}(μ=0.0, σ=1.0)
              \n\n
              epi = RenewalWithPopulation(model_data, log_I0_prior, 1e8)
              \n
              RenewalWithPopulation{Normal{Float64}}(EpiData{Float64, typeof(exp)}([0.026663134095601056, 0.14059778064943784, 0.2502660305615846, 0.24789569560506844, 0.1731751163417783, 0.09635404000022223, 0.04573437575216367, 0.019313826994143808], 8, exp), Distributions.Normal{Float64}(μ=0.0, σ=1.0), 1.0e8)
              \n\n\n

              NB: We don't implement a background infection rate in this model.

              \n\n\n
              Turing model interface

              As mentioned above, we can use this instance of the Renewal latent infection model to construct a TuringModel which implements the probabilistic behaviour determined by epi.

              We do this with the constructor function generate_latent_infs which combines epi with a provided \\(\\log R_t\\) time series.

              Here we choose an example where \\(R_t\\) decreases from \\(R_t = 3\\) to \\(R_t = 0.5\\) over the course of 30 days.

              \n\n
              R_t_fixed = [0.5 + 2.5 / (1 + exp(t - 15)) for t in 1:30]
              \n
              30-element Vector{Float64}:\n 2.9999979211799306\n 2.9999943491892553\n 2.9999846395634946\n 2.99995824644538\n 2.9998865053282437\n 2.9996915135600344\n 2.999161624673834\n ⋮\n 0.500113494671756\n 0.5000417535546202\n 0.5000153604365055\n 0.5000056508107448\n 0.5000020788200692\n 0.5000007647555673
              \n\n
              latent_inf_mdl = generate_latent_infs(epi, log.(R_t_fixed))
              \n
              Model{typeof(generate_latent_infs), (:epi_model, :_Rt), (), (), Tuple{RenewalWithPopulation{Normal{Float64}}, Vector{Float64}}, Tuple{}, DefaultContext}(EpiAware.EpiAwareBase.generate_latent_infs, (epi_model = RenewalWithPopulation{Normal{Float64}}(EpiData{Float64, typeof(exp)}([0.026663134095601056, 0.14059778064943784, 0.2502660305615846, 0.24789569560506844, 0.1731751163417783, 0.09635404000022223, 0.04573437575216367, 0.019313826994143808], 8, exp), Distributions.Normal{Float64}(μ=0.0, σ=1.0), 1.0e8), _Rt = [1.0986115957278464, 1.098610405062754, 1.0986071685094998, 1.0985983707197156, 1.0985744563952262, 1.098509454567543, 1.0983327911702674, 1.097852790994088, 1.09654964358037, 1.0930193012626002  …  -0.6808598639891831, -0.6886022683659516, -0.6914718340845708, -0.6925303979295329, -0.6929202169746165, -0.6930636769372295, -0.6931164601588107, -0.6931358790023187, -0.6931430229284499, -0.6931456510499804]), NamedTuple(), DefaultContext())
              \n\n\n\n\n\n

              Negative Binomial Observations as an ObservationModel type

              In Mishra et al latent infections were assumed to occur on their observation day with negative binomial errors, this motivates using the serial interval (the time between onset of symptoms of a primary and secondary case) rather than generation interval distribution (the time between infection time of a primary and secondary case).

              Observation models are set in EpiAware as concrete subtypes of an ObservationModel. The Negative binomial error model without observation delays is set with a NegativeBinomialError struct. In Mishra et al the overdispersion parameter \\(\\phi\\) sets the relationship between the mean and variance of the negative binomial errors,

              $$\\text{var} = \\text{mean} + {\\text{mean}^2 \\over \\phi}.$$

              In EpiAware, we default to a prior on \\(\\sqrt{1/\\phi}\\) because this quantity has the dimensions of a standard deviation and, therefore, is easier to reason on a priori beliefs.

              \n\n
              obs = NegativeBinomialError(cluster_factor_prior = HalfNormal(0.15))
              \n
              NegativeBinomialError{HalfNormal{Float64}}(HalfNormal{Float64}(μ=0.15))
              \n\n\n
              Turing model interface

              We can construct a NegativeBinomialError model implementation as a TuringModel using generate_observations

              Turing uses missing arguments to indicate variables that are to be sampled. We use this to observe a forward model that samples observations, conditional on an underlying expected observation time series.

              \n\n\n

              First, we set an artificial expected cases curve.

              \n\n
              expected_cases = [1000 * exp(-(t - 15)^2 / (2 * 4)) for t in 1:30]
              \n
              30-element Vector{Float64}:\n 2.289734845645553e-8\n 6.691586091292782e-7\n 1.5229979744712628e-5\n 0.0002699578503363014\n 0.003726653172078671\n 0.04006529739295107\n 0.33546262790251186\n ⋮\n 0.003726653172078671\n 0.0002699578503363014\n 1.5229979744712628e-5\n 6.691586091292782e-7\n 2.289734845645553e-8\n 6.101936677605324e-10
              \n\n
              obs_mdl = generate_observations(obs, missing, expected_cases)
              \n
              Model{typeof(generate_observations), (:obs_model, :y_t, :Y_t), (), (:y_t,), Tuple{NegativeBinomialError{HalfNormal{Float64}}, Missing, Vector{Float64}}, Tuple{}, DefaultContext}(EpiAware.EpiAwareBase.generate_observations, (obs_model = NegativeBinomialError{HalfNormal{Float64}}(HalfNormal{Float64}(μ=0.15)), y_t = missing, Y_t = [2.289734845645553e-8, 6.691586091292782e-7, 1.5229979744712628e-5, 0.0002699578503363014, 0.003726653172078671, 0.04006529739295107, 0.33546262790251186, 2.187491118182885, 11.108996538242305, 43.93693362340742  …  11.108996538242305, 2.187491118182885, 0.33546262790251186, 0.04006529739295107, 0.003726653172078671, 0.0002699578503363014, 1.5229979744712628e-5, 6.691586091292782e-7, 2.289734845645553e-8, 6.101936677605324e-10]), NamedTuple(), DefaultContext())
              \n\n\n\n\n\n

              A reverse observation model, which samples the underlying latent infections conditional on observations would require a prior on the latent infections. This is the purpose of composing multiple models; as we'll see below the latent infection and latent \\(R_t\\) models are informative priors on the latent infection time series underlying the observations.

              \n\n\n

              Composing models into an EpiProblem

              As mentioned above, each module of the overall epidemiological model we are interested in is a TuringModel in its own right. In this section, we compose the individual models into the full epidemiological model using the EpiProblem struct.

              The constructor for an EpiProblem requires:

              The tspan set the range of the time index for the models.

              \n\n
              epi_prob = EpiProblem(epi_model = epi,\n    latent_model = twod_ar,\n    observation_model = obs,\n    tspan = (45, 80))
              \n
              EpiProblem{RenewalWithPopulation{Normal{Float64}}, BroadcastLatentModel{AR{Product{Continuous, Truncated{Normal{Float64}, Continuous, Float64, Float64, Float64}, Vector{Truncated{Normal{Float64}, Continuous, Float64, Float64, Float64}}}, HalfNormal{Float64}, DistributionsAD.TuringScalMvNormal{Vector{Float64}, Float64}, Int64}, Int64, RepeatBlock}, NegativeBinomialError{HalfNormal{Float64}}}(RenewalWithPopulation{Normal{Float64}}(EpiData{Float64, typeof(exp)}([0.026663134095601056, 0.14059778064943784, 0.2502660305615846, 0.24789569560506844, 0.1731751163417783, 0.09635404000022223, 0.04573437575216367, 0.019313826994143808], 8, exp), Distributions.Normal{Float64}(μ=0.0, σ=1.0), 1.0e8), BroadcastLatentModel{AR{Product{Continuous, Truncated{Normal{Float64}, Continuous, Float64, Float64, Float64}, Vector{Truncated{Normal{Float64}, Continuous, Float64, Float64, Float64}}}, HalfNormal{Float64}, DistributionsAD.TuringScalMvNormal{Vector{Float64}, Float64}, Int64}, Int64, RepeatBlock}(AR{Product{Continuous, Truncated{Normal{Float64}, Continuous, Float64, Float64, Float64}, Vector{Truncated{Normal{Float64}, Continuous, Float64, Float64, Float64}}}, HalfNormal{Float64}, DistributionsAD.TuringScalMvNormal{Vector{Float64}, Float64}, Int64}(Distributions.Product{Distributions.Continuous, Distributions.Truncated{Distributions.Normal{Float64}, Distributions.Continuous, Float64, Float64, Float64}, Vector{Distributions.Truncated{Distributions.Normal{Float64}, Distributions.Continuous, Float64, Float64, Float64}}}(v=Truncated{Normal{Float64}, Continuous, Float64, Float64, Float64}[Truncated(Distributions.Normal{Float64}(μ=0.8, σ=0.05); lower=0.0, upper=1.0), Truncated(Distributions.Normal{Float64}(μ=0.05, σ=0.05); lower=0.0, upper=1.0)]), HalfNormal{Float64}(μ=1.0), DistributionsAD.TuringScalMvNormal{Vector{Float64}, Float64}(m=[-1.0, -1.0], σ=0.1), 2), 2, RepeatBlock()), NegativeBinomialError{HalfNormal{Float64}}(HalfNormal{Float64}(μ=0.15)), (45, 80))
              \n\n","category":"page"},{"location":"showcase/replications/mishra-2020/#Inference-Methods","page":"On the derivation of the renewal equation from an age-dependent branching process: an epidemic modelling perspective","title":"Inference Methods","text":"","category":"section"},{"location":"showcase/replications/mishra-2020/","page":"On the derivation of the renewal equation from an age-dependent branching process: an epidemic modelling perspective","title":"On the derivation of the renewal equation from an age-dependent branching process: an epidemic modelling perspective","text":"
              \n

              We make inferences on the unobserved quantities, such as \\(R_t\\) by sampling from the model conditioned on the observed data. We generate the posterior samples using the No U-Turns (NUTS) sampler.

              To make NUTS more robust we provide manypathfinder, which is built on pathfinder variational inference from Pathfinder.jl. manypathfinder runs nruns pathfinder processes on the inference problem and returns the pathfinder run with maximum estimated ELBO.

              The composition of doing variational inference as a pre-sampler step which gets passed to NUTS initialisation is defined using the EpiMethod struct, where a sequence of pre-sampler steps can be be defined.

              EpiMethod also allows the specification of NUTS parameters, such as type of automatic differentiation, type of parallelism and number of parallel chains to sample.

              \n\n
              num_threads = min(10, Threads.nthreads())
              \n
              1
              \n\n
              inference_method = EpiMethod(\n    pre_sampler_steps = [ManyPathfinder(nruns = 4, maxiters = 100)],\n    sampler = NUTSampler(adtype = AutoReverseDiff(),\n        ndraws = 2000,\n        nchains = num_threads,\n        mcmc_parallel = MCMCThreads())\n)
              \n
              EpiMethod{ManyPathfinder, NUTSampler{AutoReverseDiff{false}, MCMCThreads, UnionAll}}(ManyPathfinder[ManyPathfinder(10, 4, 100, 100)], NUTSampler{AutoReverseDiff{false}, MCMCThreads, UnionAll}(0.8, AutoReverseDiff(), MCMCThreads(), 1, 10, 1000.0, 0.0, 2000, AdvancedHMC.DiagEuclideanMetric))
              \n\n","category":"page"},{"location":"showcase/replications/mishra-2020/#Inference-and-analysis","page":"On the derivation of the renewal equation from an age-dependent branching process: an epidemic modelling perspective","title":"Inference and analysis","text":"","category":"section"},{"location":"showcase/replications/mishra-2020/","page":"On the derivation of the renewal equation from an age-dependent branching process: an epidemic modelling perspective","title":"On the derivation of the renewal equation from an age-dependent branching process: an epidemic modelling perspective","text":"
              \n

              In the background of this note (see hidden top cell and short R script in this directory), we load daily reported cases from South Korea from Jan-July 2020 which were gathered using covidregionaldata from ECDC data archives.

              We supply the data as a NamedTuple with the y_t field containing the observed data, shortened to fit the chosen tspan of epi_prob.

              \n\n
              south_korea_data = (y_t = daily_cases[epi_prob.tspan[1]:epi_prob.tspan[2]],\n    dates = dates[epi_prob.tspan[1]:epi_prob.tspan[2]])
              \n
              (y_t = [0, 0, 0, 1, 1, 1, 15, 34, 75, 190  …  131, 242, 114, 110, 107, 76, 74, 84, 93, 152], dates = [Date(\"2020-02-13\"), Date(\"2020-02-14\"), Date(\"2020-02-15\"), Date(\"2020-02-16\"), Date(\"2020-02-17\"), Date(\"2020-02-18\"), Date(\"2020-02-19\"), Date(\"2020-02-20\"), Date(\"2020-02-21\"), Date(\"2020-02-22\")  …  Date(\"2020-03-10\"), Date(\"2020-03-11\"), Date(\"2020-03-12\"), Date(\"2020-03-13\"), Date(\"2020-03-14\"), Date(\"2020-03-15\"), Date(\"2020-03-16\"), Date(\"2020-03-17\"), Date(\"2020-03-18\"), Date(\"2020-03-19\")])
              \n\n\n

              Sampling with apply_method

              The apply_method function combines the elements above:

              And returns a collection of results:

              \n\n
              inference_results = apply_method(epi_prob,\n    inference_method,\n    south_korea_data\n)
              \n
              EpiAwareObservables(Model{typeof(generate_epiaware), (:y_t, :time_steps, :epi_model), (:latent_model, :observation_model), (), Tuple{Vector{Int64}, Int64, RenewalWithPopulation{Normal{Float64}}}, Tuple{BroadcastLatentModel{AR{Product{Continuous, Truncated{Normal{Float64}, Continuous, Float64, Float64, Float64}, Vector{Truncated{Normal{Float64}, Continuous, Float64, Float64, Float64}}}, HalfNormal{Float64}, DistributionsAD.TuringScalMvNormal{Vector{Float64}, Float64}, Int64}, Int64, RepeatBlock}, NegativeBinomialError{HalfNormal{Float64}}}, DefaultContext}(EpiAware.EpiAwareBase.generate_epiaware, (y_t = [0, 0, 0, 1, 1, 1, 15, 34, 75, 190  …  131, 242, 114, 110, 107, 76, 74, 84, 93, 152], time_steps = 36, epi_model = RenewalWithPopulation{Normal{Float64}}(EpiData{Float64, typeof(exp)}([0.026663134095601056, 0.14059778064943784, 0.2502660305615846, 0.24789569560506844, 0.1731751163417783, 0.09635404000022223, 0.04573437575216367, 0.019313826994143808], 8, exp), Distributions.Normal{Float64}(μ=0.0, σ=1.0), 1.0e8)), (latent_model = BroadcastLatentModel{AR{Product{Continuous, Truncated{Normal{Float64}, Continuous, Float64, Float64, Float64}, Vector{Truncated{Normal{Float64}, Continuous, Float64, Float64, Float64}}}, HalfNormal{Float64}, DistributionsAD.TuringScalMvNormal{Vector{Float64}, Float64}, Int64}, Int64, RepeatBlock}(AR{Product{Continuous, Truncated{Normal{Float64}, Continuous, Float64, Float64, Float64}, Vector{Truncated{Normal{Float64}, Continuous, Float64, Float64, Float64}}}, HalfNormal{Float64}, DistributionsAD.TuringScalMvNormal{Vector{Float64}, Float64}, Int64}(Distributions.Product{Distributions.Continuous, Distributions.Truncated{Distributions.Normal{Float64}, Distributions.Continuous, Float64, Float64, Float64}, Vector{Distributions.Truncated{Distributions.Normal{Float64}, Distributions.Continuous, Float64, Float64, Float64}}}(v=Truncated{Normal{Float64}, Continuous, Float64, Float64, Float64}[Truncated(Distributions.Normal{Float64}(μ=0.8, σ=0.05); lower=0.0, upper=1.0), Truncated(Distributions.Normal{Float64}(μ=0.05, σ=0.05); lower=0.0, upper=1.0)]), HalfNormal{Float64}(μ=1.0), DistributionsAD.TuringScalMvNormal{Vector{Float64}, Float64}(m=[-1.0, -1.0], σ=0.1), 2), 2, RepeatBlock()), observation_model = NegativeBinomialError{HalfNormal{Float64}}(HalfNormal{Float64}(μ=0.15))), DefaultContext()), nothing, MCMC chain (2000×35×1 Array{Float64, 3}), @NamedTuple{generated_y_t::Vector{Int64}, I_t::Vector{Float64}, Z_t::Vector{Float64}, process_aux::@NamedTuple{σ_AR::Float64, ar_init::Vector{Float64}, damp_AR::Vector{Float64}, sq_cluster_factor::Float64}}[(generated_y_t = [0, 0, 0, 1, 1, 1, 15, 34, 75, 190  …  131, 242, 114, 110, 107, 76, 74, 84, 93, 152], I_t = [0.6302189734369976, 0.4774713968245689, 0.3905291507562299, 0.3022359509208115, 0.9922833853995451, 0.813228204790894, 21.106447028610603, 46.10331357944557, 53.33687089383859, 152.24222960039674  …  197.5819007248144, 173.94553409919794, 136.98722629438038, 111.65633481799061, 125.31743099837803, 99.6995783777211, 78.81882944289, 68.09834544453484, 113.75830423055085, 99.6034860166183], Z_t = [-1.0832047855152138, -1.0832047855152138, -1.0146262702530706, -1.0146262702530706, 0.418711014559223, 0.418711014559223, 3.6849734508145495, 3.6849734508145495, 2.414227285537577, 2.414227285537577  …  -0.8921461057175676, -0.8921461057175676, -0.9481069026492762, -0.9481069026492762, -0.6086302626701813, -0.6086302626701813, -0.6492378533259052, -0.6492378533259052, 0.0048214101954354716, 0.0048214101954354716], process_aux = (σ_AR = 1.5841436659699561, ar_init = [-1.0832047855152138, -1.0146262702530706], damp_AR = [0.7640084446616473, 0.06809055715841618], sq_cluster_factor = 0.079180832239541)); (generated_y_t = [0, 0, 0, 1, 1, 1, 15, 34, 75, 190  …  131, 242, 114, 110, 107, 76, 74, 84, 93, 152], I_t = [0.9054036333499285, 0.7298094574188798, 0.5567385913041931, 0.4503846504021242, 2.230213896626074, 1.9065600991663039, 17.881558039189844, 32.4744970077826, 51.89540975761122, 128.44184641355815  …  178.21457047327442, 153.92366069174773, 150.53268696146284, 118.86938255651403, 120.72629891594556, 96.25096518758762, 111.96747397950845, 95.52634405260403, 165.56194047256344, 157.2302637345635], Z_t = [-0.8898357447217325, -0.8898357447217325, -0.9467061642702784, -0.9467061642702784, 0.8678971922522976, 0.8678971922522976, 2.9833461455222965, 2.9833461455222965, 2.4248084414242914, 2.4248084414242914  …  -1.108402692341453, -1.108402692341453, -0.9535543249686977, -0.9535543249686977, -0.6756561197376965, -0.6756561197376965, -0.3264624005485029, -0.3264624005485029, 0.33979129660429197, 0.33979129660429197], process_aux = (σ_AR = 2.006219571534054, ar_init = [-0.8898357447217325, -0.9467061642702784], damp_AR = [0.7477859993710714, 0.07099853573426045], sq_cluster_factor = 0.10824590568528863)); … ; (generated_y_t = [0, 0, 0, 1, 1, 1, 15, 34, 75, 190  …  131, 242, 114, 110, 107, 76, 74, 84, 93, 152], I_t = [1.2739313505255094, 0.9284479089848867, 0.8675168996177901, 0.6575416056195217, 1.7933463862437304, 1.4831973604222313, 18.312506724736963, 28.3160889159895, 82.39544494211103, 215.99113564106977  …  153.63601628462584, 135.00614788819811, 154.28236495292967, 124.1945925971968, 128.01665725054332, 106.31031490775568, 78.72349016967804, 70.33397592850444, 155.20469776895922, 138.04015530663935], Z_t = [-1.1712194264050033, -1.1712194264050033, -0.9365858749109013, -0.9365858749109013, 0.31385097788297855, 0.31385097788297855, 2.8525497842836396, 2.8525497842836396, 2.927661598221874, 2.927661598221874  …  -1.0354808546735808, -1.0354808546735808, -0.7278311981768211, -0.7278311981768211, -0.47094674087799177, -0.47094674087799177, -0.6315540092573445, -0.6315540092573445, 0.28437585348657035, 0.28437585348657035], process_aux = (σ_AR = 1.638797767408246, ar_init = [-1.1712194264050033, -0.9365858749109013], damp_AR = [0.7615374108450998, 0.061451939399942826], sq_cluster_factor = 0.1010913711477206)); (generated_y_t = [0, 0, 0, 1, 1, 1, 15, 34, 75, 190  …  131, 242, 114, 110, 107, 76, 74, 84, 93, 152], I_t = [0.36557026373911194, 0.28537577652833657, 0.24465754806075726, 0.19332007790512695, 0.5784430227066278, 0.4831367513694791, 23.986389990707373, 74.85371802000027, 40.67406402063849, 127.27792831196787  …  200.46755591770244, 177.25464086769261, 169.4193439834972, 139.64155100487525, 117.50767176549644, 98.4990070786369, 75.57177784500391, 64.52735423543758, 200.2979491781433, 173.46136967899554], Z_t = [-0.9990885088367124, -0.9990885088367124, -0.9097637407764456, -0.9097637407764456, 0.41166688293517095, 0.41166688293517095, 4.320290495933675, 4.320290495933675, 1.963418480789977, 1.963418480789977  …  -0.8273355767471939, -0.8273355767471939, -0.7012007179628654, -0.7012007179628654, -0.6810786163999226, -0.6810786163999226, -0.7819315466370461, -0.7819315466370461, 0.5240376203663384, 0.5240376203663384], process_aux = (σ_AR = 2.0368151186594696, ar_init = [-0.9990885088367124, -0.9097637407764456], damp_AR = [0.7551398290101086, 0.07370704512817201], sq_cluster_factor = 0.12321894564496723));;])
              \n\n\n

              Results and Predictive plotting

              We can spaghetti plot generated case data from the version of the model which hasn't conditioned on case data using posterior parameters inferred from the version conditioned on observed data. This is known as posterior predictive checking, and is a useful diagnostic tool for Bayesian inference (see here).

              Because we are using synthetic data we can also plot the model predictions for the unobserved infections and check that (at least in this example) we were able to capture some unobserved/latent variables in the process accurate.

              We find that the EpiAware model recovers the main finding in Mishra et al; that the \\(R_t\\) in South Korea peaked at a very high value (\\(R_t \\sim 10\\) at peak) before rapidly dropping below 1 in early March 2020.

              Note that, in reality, the peak \\(R_t\\) found here and in _Mishra et al) is unrealistically high, this might be due to a combination of:

              In a future note, we'll demonstrate having a time-varying ascertainment rate.

              \n\n\n\n\n\n

              Parameter inference

              We can interrogate the sampled chains directly from the samples field of the inference_results object.

              \n\n\n\n\n","category":"page"},{"location":"showcase/replications/mishra-2020/","page":"On the derivation of the renewal equation from an age-dependent branching process: an epidemic modelling perspective","title":"On the derivation of the renewal equation from an age-dependent branching process: an epidemic modelling perspective","text":"EditURL = \"https://github.com/CDCgov/Rt-without-renewal/blob/main/docs/src/showcase/replications/mishra-2020/index.jl\"","category":"page"},{"location":"lib/EpiAwareBase/public/#Public-Documentation","page":"Public API","title":"Public Documentation","text":"","category":"section"},{"location":"lib/EpiAwareBase/public/","page":"Public API","title":"Public API","text":"Documentation for EpiAwareBae.jl's public interface.","category":"page"},{"location":"lib/EpiAwareBase/public/","page":"Public API","title":"Public API","text":"See the Internals section of the manual for internal package docs covering all submodules.","category":"page"},{"location":"lib/EpiAwareBase/public/#Contents","page":"Public API","title":"Contents","text":"","category":"section"},{"location":"lib/EpiAwareBase/public/","page":"Public API","title":"Public API","text":"Pages = [\"public.md\"]\nDepth = 2:2","category":"page"},{"location":"lib/EpiAwareBase/public/#Index","page":"Public API","title":"Index","text":"","category":"section"},{"location":"lib/EpiAwareBase/public/","page":"Public API","title":"Public API","text":"Pages = [\"public.md\"]","category":"page"},{"location":"lib/EpiAwareBase/public/#Public-API","page":"Public API","title":"Public API","text":"","category":"section"},{"location":"lib/EpiAwareBase/public/","page":"Public API","title":"Public API","text":"Modules = [EpiAware.EpiAwareBase]\nPrivate = false","category":"page"},{"location":"lib/EpiAwareBase/public/#EpiAware.EpiAwareBase","page":"Public API","title":"EpiAware.EpiAwareBase","text":"Module for defining abstract epidemiological types.\n\n\n\n\n\n","category":"module"},{"location":"lib/EpiAwareBase/public/#EpiAware.EpiAwareBase.AbstractBroadcastRule","page":"Public API","title":"EpiAware.EpiAwareBase.AbstractBroadcastRule","text":"abstract type AbstractBroadcastRule\n\nAn abstract type representing a broadcast rule.\n\n\n\nFields\n\n\n\n\n\n","category":"type"},{"location":"lib/EpiAwareBase/public/#EpiAware.EpiAwareBase.AbstractEpiMethod","page":"Public API","title":"EpiAware.EpiAwareBase.AbstractEpiMethod","text":"abstract type AbstractEpiMethod\n\nAbstract supertype for all EpiAware inference/generative modelling methods.\n\n\n\nFields\n\n\n\n\n\n","category":"type"},{"location":"lib/EpiAwareBase/public/#EpiAware.EpiAwareBase.AbstractEpiModel","page":"Public API","title":"EpiAware.EpiAwareBase.AbstractEpiModel","text":"abstract type AbstractEpiModel <: AbstractModel\n\nThe abstract supertype for all structs that define a model for generating unobserved/latent infections.\n\n\n\nFields\n\n\n\n\n\n","category":"type"},{"location":"lib/EpiAwareBase/public/#EpiAware.EpiAwareBase.AbstractEpiOptMethod","page":"Public API","title":"EpiAware.EpiAwareBase.AbstractEpiOptMethod","text":"abstract type AbstractEpiOptMethod <: AbstractEpiMethod\n\nAbstract supertype for infence/generative methods that are based on optimization, e.g. MAP estimation or variational inference.\n\n\n\nFields\n\n\n\n\n\n","category":"type"},{"location":"lib/EpiAwareBase/public/#EpiAware.EpiAwareBase.AbstractEpiProblem","page":"Public API","title":"EpiAware.EpiAwareBase.AbstractEpiProblem","text":"abstract type AbstractEpiProblem\n\nAbstract supertype for all EpiAware problems.\n\n\n\nFields\n\n\n\n\n\n","category":"type"},{"location":"lib/EpiAwareBase/public/#EpiAware.EpiAwareBase.AbstractEpiSamplingMethod","page":"Public API","title":"EpiAware.EpiAwareBase.AbstractEpiSamplingMethod","text":"abstract type AbstractEpiSamplingMethod <: AbstractEpiMethod\n\nAbstract supertype for infence/generative methods that are based on sampling from the posterior distribution, e.g. NUTS.\n\n\n\nFields\n\n\n\n\n\n","category":"type"},{"location":"lib/EpiAwareBase/public/#EpiAware.EpiAwareBase.AbstractLatentModel","page":"Public API","title":"EpiAware.EpiAwareBase.AbstractLatentModel","text":"abstract type AbstractLatentModel <: AbstractModel\n\nThe abstract supertype for all structs that define a model for generating a latent process used in EpiAware models.\n\n\n\nFields\n\n\n\n\n\n","category":"type"},{"location":"lib/EpiAwareBase/public/#EpiAware.EpiAwareBase.AbstractObservationModel","page":"Public API","title":"EpiAware.EpiAwareBase.AbstractObservationModel","text":"abstract type AbstractObservationModel <: AbstractModel\n\nA type representing an abstract observation model that is a subtype of AbstractModel.\n\n\n\nFields\n\n\n\n\n\n","category":"type"},{"location":"lib/EpiAwareBase/public/#EpiAware.EpiAwareBase.AbstractTuringEpiModel","page":"Public API","title":"EpiAware.EpiAwareBase.AbstractTuringEpiModel","text":"abstract type AbstractTuringEpiModel <: AbstractEpiModel\n\nA abstract type representing a Turing-based epidemiological model.\n\n\n\nFields\n\n\n\n\n\n","category":"type"},{"location":"lib/EpiAwareBase/public/#EpiAware.EpiAwareBase.AbstractTuringIntercept","page":"Public API","title":"EpiAware.EpiAwareBase.AbstractTuringIntercept","text":"abstract type AbstractTuringIntercept <: AbstractTuringLatentModel\n\nA abstract type used to define the common interface for intercept models.\n\n\n\nFields\n\n\n\n\n\n","category":"type"},{"location":"lib/EpiAwareBase/public/#EpiAware.EpiAwareBase.AbstractTuringLatentModel","page":"Public API","title":"EpiAware.EpiAwareBase.AbstractTuringLatentModel","text":"abstract type AbstractTuringLatentModel <: AbstractLatentModel\n\nA abstract type representing a Turing-based Latent model.\n\n\n\nFields\n\n\n\n\n\n","category":"type"},{"location":"lib/EpiAwareBase/public/#EpiAware.EpiAwareBase.AbstractTuringObservationErrorModel","page":"Public API","title":"EpiAware.EpiAwareBase.AbstractTuringObservationErrorModel","text":"abstract type AbstractTuringObservationErrorModel <: AbstractTuringObservationModel\n\nThe abstract supertype for all structs that defines a Turing-based model for generating observation errors.\n\n\n\nFields\n\n\n\n\n\n","category":"type"},{"location":"lib/EpiAwareBase/public/#EpiAware.EpiAwareBase.AbstractTuringObservationModel","page":"Public API","title":"EpiAware.EpiAwareBase.AbstractTuringObservationModel","text":"abstract type AbstractTuringObservationModel <: AbstractObservationModel\n\nA abstract type representing a Turing-based observation model.\n\n\n\nFields\n\n\n\n\n\n","category":"type"},{"location":"lib/EpiAwareBase/public/#EpiAware.EpiAwareBase.AbstractTuringRenewal","page":"Public API","title":"EpiAware.EpiAwareBase.AbstractTuringRenewal","text":"abstract type AbstractTuringRenewal <: AbstractTuringEpiModel\n\nAbstract type for all Turing-based Renewal infection generating models.\n\n\n\nFields\n\n\n\n\n\n","category":"type"},{"location":"lib/EpiAwareBase/public/#EpiAware.EpiAwareBase.EpiAwareObservables","page":"Public API","title":"EpiAware.EpiAwareBase.EpiAwareObservables","text":"struct EpiAwareObservables\n\nThe EpiAwareObservables struct represents the observables used in the EpiAware model.\n\nFields\n\nmodel: The model used for the observables.\ndata: The data used for the observables.\nsamples: Samples from the posterior distribution.\ngenerated: The generated observables.\n\n\n\nFields\n\nmodel::Any\ndata::Any\nsamples::Any\ngenerated::Any\n\n\n\n\n\n","category":"type"},{"location":"lib/EpiAwareBase/public/#EpiAware.EpiAwareBase.EpiMethod","page":"Public API","title":"EpiAware.EpiAwareBase.EpiMethod","text":"struct EpiMethod{O<:AbstractEpiOptMethod, S<:AbstractEpiSamplingMethod} <: AbstractEpiMethod\n\nEpiMethod represents a method for performing EpiAware inference and/or generative modelling, which combines a sequence of optimization steps to pass initialisation information to a sampler method.\n\n\n\nFields\n\npre_sampler_steps::Vector{O} where O<:AbstractEpiOptMethod: Pre-sampler optimization steps.\nsampler::AbstractEpiSamplingMethod: Sampler method.\n\n\n\n\n\n","category":"type"},{"location":"lib/EpiAwareBase/public/#EpiAware.EpiAwareBase.EpiProblem","page":"Public API","title":"EpiAware.EpiAwareBase.EpiProblem","text":"struct EpiProblem{E<:AbstractEpiModel, L<:AbstractLatentModel, O<:AbstractObservationModel} <: AbstractEpiProblem\n\nDefines an inference/generative modelling problem for case data.\n\nEpiProblem wraps the underlying components of an epidemiological model:\n\nepi_model: An epidemiological model for unobserved infections.\nlatent_model: A latent model for underlying latent process.\nobservation_model: An observation model for observed cases.\n\nAlong with a tspan tuple for the time span of the case data.\n\n\n\nFields\n\nepi_model::AbstractEpiModel: Epidemiological model for unobserved infections.\nlatent_model::AbstractLatentModel: Latent model for underlying latent process.\nobservation_model::AbstractObservationModel: Observation model for observed cases.\ntspan::Tuple{Int64, Int64}: Time span for either inference or generative modelling of case time series.\n\n\n\n\n\n","category":"type"},{"location":"lib/EpiAwareBase/public/#EpiAware.EpiAwareBase._apply_method","page":"Public API","title":"EpiAware.EpiAwareBase._apply_method","text":"_apply_method(\n model::AbstractEpiModel,\n method::AbstractEpiMethod;\n ...\n)\n_apply_method(\n model::AbstractEpiModel,\n method::AbstractEpiMethod,\n prev_result;\n kwargs...\n)\n\n\nApply the inference/generative method method to the AbstractEpiModel object mdl.\n\nArguments\n\nmodel::AbstractEpiModel: The model to apply the method to.\nmethod::AbstractEpiMethod: The epidemiological method to apply.\nprev_result: The previous result of the method.\nkwargs: Additional keyword arguments passed to the method.\n\nReturns\n\nnothing: If no concrete implementation is defined for the given method.\n\n\n\n\n\n","category":"function"},{"location":"lib/EpiAwareBase/public/#EpiAware.EpiAwareBase.apply_method-Tuple{Any, Any, Any}","page":"Public API","title":"EpiAware.EpiAwareBase.apply_method","text":"apply_method(\n model,\n method,\n data;\n kwargs...\n) -> EpiAwareObservables\n\n\nWrap the _apply_method function by calling it with the given model, method, data, and optional keyword arguments (kwargs). The resulting solution is then passed to the generated_observables function, along with the model and input data, to compute the generated observables.\n\nArguments\n\nmodel: The model to apply the method to.\nmethod: The method to apply to the model.\ndata: The data to pass to the apply_method function.\nkwargs: Optional keyword arguments to pass to the apply_method function.\n\nReturns\n\nThe generated observables computed from the solution.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiAwareBase/public/#EpiAware.EpiAwareBase.apply_method-Tuple{Any, Any}","page":"Public API","title":"EpiAware.EpiAwareBase.apply_method","text":"apply_method(\n model,\n method;\n kwargs...\n) -> EpiAwareObservables\n\n\nCalls wrap_apply_method setting the data argument to nothing.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiAwareBase/public/#EpiAware.EpiAwareBase.apply_method-Tuple{EpiProblem, AbstractEpiMethod, Any}","page":"Public API","title":"EpiAware.EpiAwareBase.apply_method","text":"apply_method(\n epiproblem::EpiProblem,\n method::AbstractEpiMethod,\n data;\n fix_parameters,\n condition_parameters,\n kwargs...\n) -> EpiAwareObservables\n\n\nRun the EpiAware algorithm to estimate the parameters of an epidemiological model.\n\nArguments\n\nepiproblem::EpiProblem: An EpiProblem object specifying the epidemiological problem.\nmethod::EpiMethod: An EpiMethod object specifying the inference method.\ndata: The observed data used for inference.\n\nKeyword Arguments\n\nfix_parameters::NamedTuple: A NamedTuple of fixed parameters for the model.\ncondition_parameters::NamedTuple: A NamedTuple of conditioned parameters for the model.\nkwargs...: Additional keyword arguments passed to the inference methods.\n\nReturns\n\nA NamedTuple with a samples field which is the output of applying methods and a model field with the model used. Optionally, a gens field with the generated quantities from the model if that makes sense with the inference method.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiAwareBase/public/#EpiAware.EpiAwareBase.broadcast_n-Tuple{AbstractBroadcastRule, Any, Any, Any}","page":"Public API","title":"EpiAware.EpiAwareBase.broadcast_n","text":"broadcast_n(\n broadcast_rule::AbstractBroadcastRule,\n latent,\n n,\n period\n)\n\n\nThis function is used to define the behavior of broadcasting for a specific type of AbstractBroadcastRule.\n\nThe broadcast_n function returns the length of the latent periods to generate using the given broadcast_rule. Which model of broadcasting to be implemented is set by the type of broadcast_rule. If no implemention is defined for the given broadcast_rule, then EpiAware will return a warning and return nothing.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiAwareBase/public/#EpiAware.EpiAwareBase.broadcast_rule-Tuple{AbstractBroadcastRule, Any, Any}","page":"Public API","title":"EpiAware.EpiAwareBase.broadcast_rule","text":"broadcast_rule(\n broadcast_rule::AbstractBroadcastRule,\n n,\n period\n)\n\n\nThis function is used to define the behavior of broadcasting for a specific type of AbstractBroadcastRule.\n\nThe broadcast_rule function implements a model of broadcasting a latent process. Which model of broadcasting to be implemented is set by the type of broadcast_rule. If no implemention is defined for the given broadcast_rule, then EpiAware will return a warning and return nothing.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiAwareBase/public/#EpiAware.EpiAwareBase.condition_model-Tuple{Any, Any, Any}","page":"Public API","title":"EpiAware.EpiAwareBase.condition_model","text":"condition_model(\n model,\n fix_parameters,\n condition_parameters\n) -> Any\n\n\nCondition a model on fixed (i.e to a value) and conditioned (i.e to data) parameters.\n\nReturns\n\nmodel: The conditioned model.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiAwareBase/public/#EpiAware.EpiAwareBase.generate_epiaware-Tuple{Any, Any, AbstractEpiModel, AbstractLatentModel, AbstractObservationModel}","page":"Public API","title":"EpiAware.EpiAwareBase.generate_epiaware","text":"generate_epiaware(\n y_t,\n time_step,\n epi_model::AbstractEpiModel,\n latent_model::AbstractLatentModel,\n observation_model::AbstractObservationModel\n)\n\n\nCreate an epi-aware model using the specified epimodel, latentmodel, and observation_model.\n\nArguments\n\ny_t: The observed data.\ntime_steps: The time steps.\nepi_model: An abstract epi model.\nlatent_model: An abstract latent model.\nobservation_model: An abstract observation model.\n\nReturns\n\nnothing\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiAwareBase/public/#EpiAware.EpiAwareBase.generate_epiaware-Tuple{EpiProblem, Any}","page":"Public API","title":"EpiAware.EpiAwareBase.generate_epiaware","text":"generate_epiaware(epiproblem::EpiProblem, data) -> Any\n\n\nGenerate an epi-aware model given an EpiProblem and data.\n\nArguments\n\nepiproblem: Epi problem specification.\ndata: Observed data.\n\nReturns\n\nA tuple containing the generated quantities of the epi-aware model.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiAwareBase/public/#EpiAware.EpiAwareBase.generate_latent-Tuple{AbstractLatentModel, Any}","page":"Public API","title":"EpiAware.EpiAwareBase.generate_latent","text":"generate_latent(latent_model::AbstractLatentModel, n) -> Any\n\n\nConstructor function for a latent process path Z_t of length n.\n\nThe generate_latent function implements a model of generating a latent process. Which model for generating the latent process infections is implemented is set by the type of latent_model. If no implemention is defined for the type of latent_model, then EpiAware will pass a warning and return nothing.\n\nInterface to Turing.jl probablilistic programming language (PPL)\n\nApart from the no implementation fallback method, the generate_latent implementation function should return a constructor function for a DynamicPPL.Model object. Sample paths of Z_t are generated quantities of the constructed model. Priors for model parameters are fields of epi_model.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiAwareBase/public/#EpiAware.EpiAwareBase.generate_latent_infs-Tuple{AbstractEpiModel, Any}","page":"Public API","title":"EpiAware.EpiAwareBase.generate_latent_infs","text":"generate_latent_infs(\n epi_model::AbstractEpiModel,\n Z_t\n) -> Any\n\n\nConstructor function for unobserved/latent infections based on the type of epi_model <: AbstractEpimodel and a latent process path Z_t.\n\nThe generate_latent_infs function implements a model of generating unobserved/latent infections conditional on a latent process. Which model of generating unobserved/latent infections to be implemented is set by the type of epi_model. If no implemention is defined for the given epi_model, then EpiAware will return a warning and return nothing.\n\nInterface to Turing.jl probablilistic programming language (PPL)\n\nApart from the no implementation fallback method, the generate_latent_infs implementation function returns a constructor function for a DynamicPPL.Model object where the unobserved/latent infections are a generated quantity. Priors for model parameters are fields of epi_model.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiAwareBase/public/#EpiAware.EpiAwareBase.generate_observations-Tuple{AbstractObservationModel, Any, Any}","page":"Public API","title":"EpiAware.EpiAwareBase.generate_observations","text":"generate_observations(\n obs_model::AbstractObservationModel,\n y_t,\n Y_t\n) -> Any\n\n\nConstructor function for generating observations based on the given observation model.\n\nThe generate_observations function implements a model of generating observations based on the given observation model. Which model of generating observations to be implemented is set by the type of obs_model. If no implemention is defined for the given obs_model, then EpiAware will return a warning and return nothing.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiAwareBase/public/#EpiAware.EpiAwareBase.generated_observables-Tuple{Any, Any, Any}","page":"Public API","title":"EpiAware.EpiAwareBase.generated_observables","text":"generated_observables(\n model,\n data,\n solution\n) -> EpiAwareObservables\n\n\nGenerate observables from a given model and solution and return them as a EpiAwareObservables struct.\n\nArguments\n\nmodel: The model used for generating observables.\ndata: The data used for generating observables.\nsolution: The solution used for generating observables.\n\nReturns\n\nAn instance of EpiAwareObservables struct with the provided model, data, solution, and the generated observables if specified\n\n\n\n\n\n","category":"method"},{"location":"getting-started/explainers/#Explainers","page":"Overview","title":"Explainers","text":"","category":"section"},{"location":"getting-started/explainers/","page":"Overview","title":"Overview","text":"This section contains a series of explainers that provide a detailed overview of the EpiAware platform and its features. These explainers are designed to help you understand the platform and its capabilities, and to provide you with the information you need to get started using EpiAware. See the sidebar for the list of explainers.","category":"page"},{"location":"lib/EpiObsModels/internals/#Internal-Documentation","page":"Internal API","title":"Internal Documentation","text":"","category":"section"},{"location":"lib/EpiObsModels/internals/","page":"Internal API","title":"Internal API","text":"Documentation for EpiObsModels.jl's internal interface.","category":"page"},{"location":"lib/EpiObsModels/internals/#Contents","page":"Internal API","title":"Contents","text":"","category":"section"},{"location":"lib/EpiObsModels/internals/","page":"Internal API","title":"Internal API","text":"Pages = [\"internals.md\"]\nDepth = 2:2","category":"page"},{"location":"lib/EpiObsModels/internals/#Index","page":"Internal API","title":"Index","text":"","category":"section"},{"location":"lib/EpiObsModels/internals/","page":"Internal API","title":"Internal API","text":"Pages = [\"internals.md\"]","category":"page"},{"location":"lib/EpiObsModels/internals/#Internal-API","page":"Internal API","title":"Internal API","text":"","category":"section"},{"location":"lib/EpiObsModels/internals/","page":"Internal API","title":"Internal API","text":"Modules = [EpiAware.EpiObsModels]\nPublic = false","category":"page"},{"location":"lib/EpiObsModels/internals/#EpiAware.EpiAwareBase.generate_observations-Tuple{AbstractTuringObservationErrorModel, Any, Any}","page":"Internal API","title":"EpiAware.EpiAwareBase.generate_observations","text":"generate_observations(\n obs_model::AbstractTuringObservationErrorModel,\n y_t,\n Y_t\n) -> Any\n\n\nGenerates observations from an observation error model. It provides support for missing values in observations (y_t), and missing values at the beginning of the expected observations (Y_t). It also pads the expected observations with a small value (1e-6) to mitigate potential numerical issues.\n\nIt dispatches to the observation_error function to generate the observation error distribution which uses priors generated by generate_observation_error_priors submodel. For most observation error models specific implementations of observation_error and generate_observation_error_priors are required but a specific implementation of generate_observations is not required.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiObsModels/internals/#EpiAware.EpiAwareBase.generate_observations-Tuple{Ascertainment, Any, Any}","page":"Internal API","title":"EpiAware.EpiAwareBase.generate_observations","text":"generate_observations(\n obs_model::Ascertainment,\n y_t,\n Y_t\n) -> Any\n\n\nGenerates observations based on the LatentDelay observation model.\n\nArguments\n\nobs_model::Ascertainment: The Ascertainment model.\ny_t: The current state of the observations.\nY_t` : The expected observations.\n\nReturns\n\ny_t: The updated observations.\nexpected_aux: Additional expected observation-related variables.\nobs_aux: Additional observation-related variables.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiObsModels/internals/#EpiAware.EpiAwareBase.generate_observations-Tuple{LatentDelay, Any, Any}","page":"Internal API","title":"EpiAware.EpiAwareBase.generate_observations","text":"generate_observations(\n obs_model::LatentDelay,\n y_t,\n Y_t\n) -> Any\n\n\nGenerates observations based on the LatentDelay observation model.\n\nArguments\n\nobs_model::LatentDelay: The LatentDelay observation model.\ny_t: The current observations.\nI_t: The current infection indicator.\n\nReturns\n\ny_t: The updated observations.\nobs_aux: Additional observation-related variables.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiObsModels/internals/#EpiAware.EpiAwareBase.generate_observations-Tuple{StackObservationModels, NamedTuple, AbstractVector}","page":"Internal API","title":"EpiAware.EpiAwareBase.generate_observations","text":"generate_observations(\n obs_model::StackObservationModels,\n y_t::NamedTuple,\n Y_t::AbstractVector\n) -> Any\n\n\nGenerate observations from a stack of observation models. Maps Y_t to a NamedTuple of the same length as y_t assuming a 1 to many mapping.\n\nArguments\n\nobs_model::StackObservationModels: The stack of observation models.\ny_t::NamedTuple: The observed values.\nY_t::AbstractVector: The expected values.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiObsModels/internals/#EpiAware.EpiAwareBase.generate_observations-Tuple{StackObservationModels, NamedTuple, NamedTuple}","page":"Internal API","title":"EpiAware.EpiAwareBase.generate_observations","text":"generate_observations(\n obs_model::StackObservationModels,\n y_t::NamedTuple,\n Y_t::NamedTuple\n) -> Any\n\n\nGenerate observations from a stack of observation models. Assumes a 1 to 1 mapping between y_t and Y_t.\n\nArguments\n\nobs_model::StackObservationModels: The stack of observation models.\ny_t::NamedTuple: The observed values.\nY_t::NamedTuple: The expected values.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiObsModels/internals/#EpiAware.EpiObsModels.NegativeBinomialMeanClust-Tuple{Any, Any}","page":"Internal API","title":"EpiAware.EpiObsModels.NegativeBinomialMeanClust","text":"NegativeBinomialMeanClust(\n μ,\n α\n) -> Union{Distributions.DiscreteUniform, Distributions.NegativeBinomial}\n\n\nCompute the mean-cluster factor negative binomial distribution.\n\nArguments\n\nμ: The mean of the distribution.\nα: The clustering factor parameter.\n\nReturns\n\nA NegativeBinomial distribution object.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiObsModels/internals/#EpiAware.EpiObsModels.generate_observation_kernel-Tuple{Any, Any}","page":"Internal API","title":"EpiAware.EpiObsModels.generate_observation_kernel","text":"generate_observation_kernel(\n delay_int,\n time_horizon;\n partial\n) -> Any\n\n\nGenerate an observation kernel matrix based on the given delay interval and time horizon.\n\nArguments\n\ndelay_int::Vector{Float64}: The delay PMF vector.\ntime_horizon::Int: The number of time steps of the observation period.\npartial::Bool: Whether to generate a partial observation kernel matrix.\n\nReturns\n\nK::SparseMatrixCSC{Float64, Int}: The observation kernel matrix.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiInference/internals/#Internal-Documentation","page":"Internal API","title":"Internal Documentation","text":"","category":"section"},{"location":"lib/EpiInference/internals/","page":"Internal API","title":"Internal API","text":"Documentation for EpInference.jl's internal interface.","category":"page"},{"location":"lib/EpiInference/internals/#Contents","page":"Internal API","title":"Contents","text":"","category":"section"},{"location":"lib/EpiInference/internals/","page":"Internal API","title":"Internal API","text":"Pages = [\"internals.md\"]\nDepth = 2:2","category":"page"},{"location":"lib/EpiInference/internals/#Index","page":"Internal API","title":"Index","text":"","category":"section"},{"location":"lib/EpiInference/internals/","page":"Internal API","title":"Internal API","text":"Pages = [\"internals.md\"]","category":"page"},{"location":"lib/EpiInference/internals/#Internal-API","page":"Internal API","title":"Internal API","text":"","category":"section"},{"location":"lib/EpiInference/internals/","page":"Internal API","title":"Internal API","text":"Modules = [EpiAware.EpiInference]\nPublic = false","category":"page"},{"location":"lib/EpiInference/internals/#EpiAware.EpiAwareBase._apply_method","page":"Internal API","title":"EpiAware.EpiAwareBase._apply_method","text":"_apply_method(\n model::DynamicPPL.Model,\n method::NUTSampler;\n ...\n) -> Any\n_apply_method(\n model::DynamicPPL.Model,\n method::NUTSampler,\n prev_result;\n kwargs...\n) -> Any\n\n\nApply NUTS sampling to a DynamicPPL.Model object with prev_result representing any initial results to use for sampler initialisation.\n\n\n\n\n\n","category":"function"},{"location":"lib/EpiInference/internals/#EpiAware.EpiAwareBase._apply_method-2","page":"Internal API","title":"EpiAware.EpiAwareBase._apply_method","text":"_apply_method(\n model::DynamicPPL.Model,\n method::ManyPathfinder;\n ...\n) -> Any\n_apply_method(\n model::DynamicPPL.Model,\n method::ManyPathfinder,\n prev_result;\n kwargs...\n) -> Any\n\n\nApply a ManyPathfinder method to a DynamicPPL.Model object.\n\nIf prev_result is a vector of real numbers, then the ManyPathfinder method is applied with the initial values set to prev_result. Otherwise, the ManyPathfinder method is run with default initial values generated.\n\n\n\n\n\n","category":"function"},{"location":"lib/EpiInference/internals/#EpiAware.EpiInference._apply_nuts-Tuple{Any, Any, Any}","page":"Internal API","title":"EpiAware.EpiInference._apply_nuts","text":"_apply_nuts(model, method, prev_result; kwargs...) -> Any\n\n\nNo initialisation NUTS.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiInference/internals/#EpiAware.EpiInference._apply_nuts-Tuple{Any, Any, Pathfinder.PathfinderResult}","page":"Internal API","title":"EpiAware.EpiInference._apply_nuts","text":"_apply_nuts(\n model,\n method,\n prev_result::Pathfinder.PathfinderResult;\n kwargs...\n) -> Any\n\n\nInitialise NUTS with initial parameters from a Pathfinder result.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiInference/internals/#EpiAware.EpiInference._continue_manypathfinder!-Tuple{Any, DynamicPPL.Model}","page":"Internal API","title":"EpiAware.EpiInference._continue_manypathfinder!","text":"_continue_manypathfinder!(\n pfs,\n mdl::DynamicPPL.Model;\n max_tries,\n nruns,\n kwargs...\n)\n\n\nContinue running the pathfinder algorithm until a pathfinder succeeds or the maximum number of tries is reached.\n\nArguments\n\npfs: An array of pathfinder objects.\nmdl::DynamicPPL.Model: The model to perform inference on.\nmax_tries: The maximum number of tries to run the pathfinder algorithm. Default is Inf.\nnruns: The number of times to run the pathfinder function.\nkwargs...: Additional keyword arguments passed to pathfinder.\n\nReturns\n\npfs: The updated array of pathfinder objects.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiInference/internals/#EpiAware.EpiInference._get_best_elbo_pathfinder-Tuple{Any}","page":"Internal API","title":"EpiAware.EpiInference._get_best_elbo_pathfinder","text":"_get_best_elbo_pathfinder(pfs) -> Any\n\n\nSelects the pathfinder with the highest ELBO estimate from a list of pathfinders.\n\nArguments\n\npfs: A list of pathfinders results or Symbol values indicating failure.\n\nReturns\n\nThe pathfinder with the highest ELBO estimate.\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiInference/internals/#EpiAware.EpiInference._run_manypathfinder-Tuple{DynamicPPL.Model}","page":"Internal API","title":"EpiAware.EpiInference._run_manypathfinder","text":"_run_manypathfinder(mdl::DynamicPPL.Model; nruns, kwargs...)\n\n\nRun pathfinder multiple times and store the results in an array. Fails safely.\n\nArguments\n\nmdl::DynamicPPL.Model: The Turing model to be used for inference.\nnruns: The number of times to run the pathfinder function.\nkwargs...: Additional keyword arguments passed to pathfinder.\n\nReturns\n\nAn array of PathfinderResult objects or Symbol values indicating success or failure.\n\n\n\n\n\n","category":"method"},{"location":"getting-started/explainers/modelling-infections/#Modelling-infections","page":"Modelling infections","title":"Modelling infections","text":"","category":"section"},{"location":"developer/contributing/#Contributing","page":"Contributing","title":"Contributing","text":"","category":"section"},{"location":"developer/contributing/","page":"Contributing","title":"Contributing","text":"This page details the some of the guidelines that should be followed when contributing to this package. It is adapted from Documenter.jl.","category":"page"},{"location":"developer/contributing/#Branches","page":"Contributing","title":"Branches","text":"","category":"section"},{"location":"developer/contributing/","page":"Contributing","title":"Contributing","text":"release-* branches are used for tagged minor versions of this package. This follows the same approach used in the main Julia repository, albeit on a much more modest scale.","category":"page"},{"location":"developer/contributing/","page":"Contributing","title":"Contributing","text":"Please open pull requests against the master branch rather than any of the release-* branches whenever possible.","category":"page"},{"location":"developer/contributing/#Backports","page":"Contributing","title":"Backports","text":"","category":"section"},{"location":"developer/contributing/","page":"Contributing","title":"Contributing","text":"Bug fixes are backported to the release-* branches using git cherry-pick -x by a EpiAware member and will become available in point releases of that particular minor version of the package.","category":"page"},{"location":"developer/contributing/","page":"Contributing","title":"Contributing","text":"Feel free to nominate commits that should be backported by opening an issue. Requests for new point releases to be tagged in METADATA.jl can also be made in the same way.","category":"page"},{"location":"developer/contributing/#release-*-branches","page":"Contributing","title":"release-* branches","text":"","category":"section"},{"location":"developer/contributing/","page":"Contributing","title":"Contributing","text":"Each new minor version x.y.0 gets a branch called release-x.y (a protected branch).\nNew versions are usually tagged only from the release-x.y branches.\nFor patch releases, changes get backported to the release-x.y branch via a single PR with the standard name \"Backports for x.y.z\" and label \"Type: Backport\". The PR message links to all the PRs that are providing commits to the backport. The PR gets merged as a merge commit (i.e. not squashed).\nThe old release-* branches may be removed once they have outlived their usefulness.\nPatch version milestones are used to keep track of which PRs get backported etc.","category":"page"},{"location":"developer/contributing/#Style-Guide","page":"Contributing","title":"Style Guide","text":"","category":"section"},{"location":"developer/contributing/","page":"Contributing","title":"Contributing","text":"Follow the style of the surrounding text when making changes. When adding new features please try to stick to the following points whenever applicable. This project follows the SciML style guide.","category":"page"},{"location":"developer/contributing/#Tests","page":"Contributing","title":"Tests","text":"","category":"section"},{"location":"developer/contributing/#Unit-tests","page":"Contributing","title":"Unit tests","text":"","category":"section"},{"location":"developer/contributing/","page":"Contributing","title":"Contributing","text":"As is conventional for Julia packages, unit tests are located at test/*.jl with the entrypoint test/runtests.jl.","category":"page"},{"location":"developer/contributing/#End-to-end-testing","page":"Contributing","title":"End to end testing","text":"","category":"section"},{"location":"developer/contributing/","page":"Contributing","title":"Contributing","text":"Tests that build example package docs from source and inspect the results (end to end tests) are located in /test/examples. The main entry points are test/examples/make.jl for building and test/examples/test.jl for doing some basic checks on the generated outputs.","category":"page"},{"location":"lib/EpiObsModels/#EpiObsModels.jl","page":"Overview","title":"EpiObsModels.jl","text":"","category":"section"},{"location":"lib/EpiObsModels/","page":"Overview","title":"Overview","text":"This package provides observation models for the EpiAware ecosystem.","category":"page"},{"location":"lib/EpiObsModels/#API","page":"Overview","title":"API","text":"","category":"section"},{"location":"lib/EpiObsModels/","page":"Overview","title":"Overview","text":"Pages = [\"lib/EpiObsModels/public.md\", \"lib/EpiObsModels/internals.md\"]","category":"page"},{"location":"developer/checklist/#Checklists","page":"Release checklist","title":"Checklists","text":"","category":"section"},{"location":"developer/checklist/","page":"Release checklist","title":"Release checklist","text":"The purpose of this page is to collate a series of checklists for commonly performed changes to the source code of EpiAware. It has been adapted from Documenter.jl.","category":"page"},{"location":"developer/checklist/","page":"Release checklist","title":"Release checklist","text":"In each case, copy the checklist into the description of the pull request.","category":"page"},{"location":"developer/checklist/#Making-a-release","page":"Release checklist","title":"Making a release","text":"","category":"section"},{"location":"developer/checklist/","page":"Release checklist","title":"Release checklist","text":"In preparation for a release, use the following checklist. These steps should be performed on a branch with an open pull request, either for a topic branch, or for a new branch release-1.y.z (\"Release version 1.y.z\") if multiple changes have accumulated on the master branch since the last release.","category":"page"},{"location":"developer/checklist/","page":"Release checklist","title":"Release checklist","text":"## Pre-release\n\n - [ ] Change the version number in `Project.toml`\n * If the release is breaking, increment MAJOR\n * If the release adds a new user-visible feature, increment MINOR\n * Otherwise (bug-fixes, documentation improvements), increment PATCH\n - [ ] Update `CHANGELOG.md`, following the existing style (in particular, make sure that the change log for this version has the correct version number and date).\n - [ ] Run `make changelog`, to make sure that all the issue references in `CHANGELOG.md` are up to date.\n - [ ] Check that the commit messages in this PR do not contain `[ci skip]`\n - [ ] Run https://github.com/JuliaDocs/Documenter.jl/actions/workflows/regression-tests.yml\n using a `workflow_dispatch` trigger to check for any changes that broke extensions.\n\n## The release\n\n - [ ] After merging the pull request, tag the release. There are two options for this:\n\n 1. [Comment `[at]JuliaRegistrator register` on the GitHub commit.](https://github.com/JuliaRegistries/Registrator.jl#via-the-github-app)\n 2. Use [JuliaHub's package registration feature](https://help.juliahub.com/juliahub/stable/contribute/#registrator) to trigger the registration.\n\n Either of those should automatically publish a new version to the Julia registry.\n - Once registered, the `TagBot.yml` workflow should create a tag, and rebuild the documentation for this tag.\n - These steps can take quite a bit of time (1 hour or more), so don't be surprised if the new documentation takes a while to appear.","category":"page"},{"location":"lib/EpiAwareBase/#EpiAwareBase.jl","page":"Overview","title":"EpiAwareBase.jl","text":"","category":"section"},{"location":"lib/EpiAwareBase/","page":"Overview","title":"Overview","text":"This package provides the core functionality for the EpiAware ecosystem. It is a dependency of all other EpiAware packages.","category":"page"},{"location":"lib/EpiAwareBase/#API","page":"Overview","title":"API","text":"","category":"section"},{"location":"lib/EpiAwareBase/","page":"Overview","title":"Overview","text":"Pages = [\"lib/EpiAwareBase/public.md\", \"lib/EpiAwareBase/internals.md\"]","category":"page"},{"location":"developer/#developer","page":"Overview","title":"Developer documentation","text":"","category":"section"},{"location":"developer/","page":"Overview","title":"Overview","text":"Welcome to the EpiAware developer documentation! This section is designed to help you get started with developing the package.","category":"page"},{"location":"lib/EpiAwareUtils/public/#Public-Documentation","page":"Public API","title":"Public Documentation","text":"","category":"section"},{"location":"lib/EpiAwareUtils/public/","page":"Public API","title":"Public API","text":"Documentation for EpiAwareBae.jl's public interface.","category":"page"},{"location":"lib/EpiAwareUtils/public/","page":"Public API","title":"Public API","text":"See the Internals section of the manual for internal package docs covering all submodules.","category":"page"},{"location":"lib/EpiAwareUtils/public/#Contents","page":"Public API","title":"Contents","text":"","category":"section"},{"location":"lib/EpiAwareUtils/public/","page":"Public API","title":"Public API","text":"Pages = [\"public.md\"]\nDepth = 2:2","category":"page"},{"location":"lib/EpiAwareUtils/public/#Index","page":"Public API","title":"Index","text":"","category":"section"},{"location":"lib/EpiAwareUtils/public/","page":"Public API","title":"Public API","text":"Pages = [\"public.md\"]","category":"page"},{"location":"lib/EpiAwareUtils/public/#Public-API","page":"Public API","title":"Public API","text":"","category":"section"},{"location":"lib/EpiAwareUtils/public/","page":"Public API","title":"Public API","text":"Modules = [EpiAware.EpiAwareUtils]\nPrivate = false","category":"page"},{"location":"lib/EpiAwareUtils/public/#EpiAware.EpiAwareUtils","page":"Public API","title":"EpiAware.EpiAwareUtils","text":"Module for defining utility functions.\n\n\n\n\n\n","category":"module"},{"location":"lib/EpiAwareUtils/public/#EpiAware.EpiAwareUtils.DirectSample","page":"Public API","title":"EpiAware.EpiAwareUtils.DirectSample","text":"struct DirectSample <: AbstractEpiSamplingMethod\n\nSample directly from a Turing model.\n\n\n\nFields\n\nn_samples::Union{Nothing, Int64}: Number of samples from a model. If an integer is provided, the model is sampled n_samples times using Turing.Prior() returning an MCMChains. Chain object. If nothing, the model is sampled once returning a NamedTuple object of the sampled random variables along with generated quantities\n\n\n\n\n\n","category":"type"},{"location":"lib/EpiAwareUtils/public/#EpiAware.EpiAwareUtils.HalfNormal","page":"Public API","title":"EpiAware.EpiAwareUtils.HalfNormal","text":"struct HalfNormal{T<:Real} <: Distributions.Distribution{Distributions.Univariate, Distributions.Continuous}\n\nCreate a half-normal prior distribution with the specified mean.\n\nArguments:\n\nμ: The mean of the half-normal distribution.\n\nReturns:\n\nA HalfNormal distribution with the specified mean.\n\nExamples:\n\nusing EpiAware, Distributions\n\nhn = HalfNormal(1.0)\n# output\nEpiAware.EpiAwareUtils.HalfNormal{Float64}(μ=1.0)\n\nfilter out all the values that are less than 0\n\nrand(hn)\n# output\n0.4508533245229199\n\ncdf(hn, 2)\n# output\n0.8894596502772643\n\nquantile(hn, 0.5)\n# output\n0.8453475393951495\n\nlogpdf(hn, 2)\n# output\n-3.1111166111445083\n\nmean(hn)\n# output\n1.0\n\nvar(hn)\n# output\n0.5707963267948966\n\n\n\nFields\n\nμ::Real\n\n\n\n\n\n","category":"type"},{"location":"lib/EpiAwareUtils/public/#EpiAware.EpiAwareUtils.censored_pmf-Tuple{Distributions.Distribution, Val{:single_censored}}","page":"Public API","title":"EpiAware.EpiAwareUtils.censored_pmf","text":"censored_pmf(\n dist::Distributions.Distribution,\n ::Val{:single_censored};\n primary_approximation_point,\n Δd,\n D\n)\n\n\nCreate a discrete probability mass function (PMF) from a given distribution, assuming that the primary event happens at primary_approximation_point * Δd within an intial censoring interval. Common single-censoring approximations are primary_approximation_point = 0 (left-hand approximation), primary_approximation_point = 1 (right-hand) and primary_approximation_point = 0.5 (midpoint).\n\nArguments\n\ndist: The distribution from which to create the PMF.\n::Val{:single_censored}: A dummy argument to dispatch to this method. The purpose of the Val\n\ntype argument is that to use single-censored approximation is an active decision.\n\nprimary_approximation_point: A approximation point for the primary time in its censoring interval.\n\nDefault is 0.5 for midpoint approximation.\n\nΔd: The step size for discretizing the domain. Default is 1.0.\nD: The upper bound of the domain. Must be greater than Δd.\n\nReturns\n\nA vector representing the PMF.\n\nRaises:\n\nAssertionError if the minimum value of dist is negative.\nAssertionError if Δd is not positive.\nAssertionError if D is not greater than Δd.\n\nExamples\n\nusing Distributions\nusing EpiAware.EpiAwareUtils\n\ndist = Exponential(1.0)\n\ncensored_pmf(dist, Val(:single_censored); D = 10) |>\n p -> round.(p, digits=3)\n\n# output\n10-element Vector{Float64}:\n 0.393\n 0.383\n 0.141\n 0.052\n 0.019\n 0.007\n 0.003\n 0.001\n 0.0\n 0.0\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiAwareUtils/public/#EpiAware.EpiAwareUtils.censored_pmf-Tuple{Distributions.Distribution}","page":"Public API","title":"EpiAware.EpiAwareUtils.censored_pmf","text":"censored_pmf(dist::Distributions.Distribution; Δd, D) -> Any\n\n\nCreate a discrete probability mass function (PMF) from a given distribution, assuming a uniform distribution over primary event times with censoring intervals of width Δd for both primary and secondary events. The CDF for the time from the left edge of the interval containing the primary event to the secondary event is created by direct numerical integration of the convolution of the CDF of dist with the uniform density on [0,Δd), the discrete PMF for double censored delays is then found using simple differencing on the CDF.\n\nArguments\n\ndist: The distribution from which to create the PMF.\nΔd: The step size for discretizing the domain. Default is 1.0.\nD: The upper bound of the domain. Must be greater than Δd. Default D = nothing\n\nindicates that the distribution should be truncated at its 99th percentile rounded to nearest multiple of Δd.\n\nReturns\n\nA vector representing the PMF.\n\nRaises\n\nAssertionError if the minimum value of dist is negative.\nAssertionError if Δd is not positive.\nAssertionError if D is shorter than Δd.\nAssertionError if D is not a multiple of Δd.\n\nExamples\n\nusing Distributions\nusing EpiAware.EpiAwareUtils\n\ndist = Exponential(1.0)\n\ncensored_pmf(dist; D = 10) |>\n p -> round.(p, digits=3)\n\n# output\n10-element Vector{Float64}:\n 0.368\n 0.4\n 0.147\n 0.054\n 0.02\n 0.007\n 0.003\n 0.001\n 0.0\n 0.0\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiAwareUtils/public/#EpiAware.EpiAwareUtils.get_param_array-Tuple{MCMCChains.Chains}","page":"Public API","title":"EpiAware.EpiAwareUtils.get_param_array","text":"get_param_array(chn::MCMCChains.Chains) -> Any\n\n\nExtract a parameter array from a Chains object chn that matches the shape of number of sample and chain pairs in chn.\n\nArguments\n\nchn::Chains: The Chains object containing the MCMC samples.\n\nReturns\n\nparam_array: An array of parameter samples, where each element corresponds to a single\n\nMCMC sample as a NamedTuple.\n\nExample\n\nSampling from a simple model which has both scalar and vector quantity random variables across 4 chains.\n\nusing Turing, MCMCChains, EpiAware\n\n@model function testmodel()\n y ~ Normal()\nend\nmdl = testmodel()\nchn = sample(mdl, Prior(), MCMCSerial(), 2, 1, progress=false)\n\nA = get_param_array(chn)\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiAwareUtils/public/#EpiAware.EpiAwareUtils.prefix_submodel-Tuple{AbstractModel, Function, String, Vararg{Any}}","page":"Public API","title":"EpiAware.EpiAwareUtils.prefix_submodel","text":"prefix_submodel(\n model::AbstractModel,\n fn::Function,\n prefix::String,\n kwargs...\n) -> Any\n\n\nGenerate a submodel with an optional prefix. A lightweight wrapper around the @submodel macro from DynamicPPL.jl.\n\nArguments\n\nmodel::AbstractModel: The model to be used.\nfn::Function: The Turing @model function to be applied to the model.\nprefix::String: The prefix to be used. If the prefix is an empty string, the submodel is created without a prefix.\n\nReturns\n\nsubmodel: The returns from the submodel are passed through.\n\nExamples\n\nusing EpiAware, DynamicPPL\n\nsubmodel = prefix_submodel(FixedIntercept(0.1), generate_latent, string(1), 2)\nsubmodel\n# output\nModel{typeof(prefix_submodel), (:model, :fn, :prefix, Symbol(\"#splat#kwargs\")), (), (), Tuple{FixedIntercept{Float64}, typeof(generate_latent), String, Tuple{Int64}}, Tuple{}, DefaultContext}(EpiAware.EpiAwareUtils.prefix_submodel, (model = FixedIntercept{Float64}(0.1), fn = EpiAware.EpiAwareBase.generate_latent, prefix = \"1\", var\"#splat#kwargs\" = (2,)), NamedTuple(), DefaultContext())\n\nWe can now draw a sample from the submodel.\n\nrand(submodel)\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiAwareUtils/public/#EpiAware.EpiAwareUtils.scan-Union{Tuple{F}, Tuple{F, Any, Any}} where F<:AbstractModel","page":"Public API","title":"EpiAware.EpiAwareUtils.scan","text":"scan(f::AbstractModel, init, xs) -> Tuple{Any, Any}\n\n\nApply f to each element of xs and accumulate the results.\n\nf must be a callable on a sub-type of AbstractModel.\n\nDesign note\n\nscan is being restricted to AbstractModel sub-types to ensure: 1. That compiler specialization is activated 2. Also avoids potential compiler overhead from specialisation on f<: Function.\n\nArguments\n\nf: A callable/functor that takes two arguments, carry and x, and returns a new carry and a result y.\ninit: The initial value for the carry variable.\nxs: An iterable collection of elements.\n\nReturns\n\nys: An array containing the results of applying f to each element of xs.\ncarry: The final value of the carry variable after processing all elements of xs.\n\nExamples\n\n```jldoctest using EpiAware\n\nstruct Adder <: EpiAwareBase.AbstractModel end function (a::Adder)(carry, x) carry + x, carry + x end\n\nscan(Adder(), 0, 1:5) #output ([1, 3, 6, 10, 15], 15)\n\n\n\n\n\n","category":"method"},{"location":"lib/EpiAwareUtils/public/#EpiAware.EpiAwareUtils.spread_draws-Tuple{MCMCChains.Chains}","page":"Public API","title":"EpiAware.EpiAwareUtils.spread_draws","text":"spread_draws(chn::MCMCChains.Chains) -> DataFrames.DataFrame\n\n\nspread_draws(chn::Chains)\n\nConverts a Chains object into a DataFrame in tidybayes format.\n\nArguments\n\nchn::Chains: The Chains object to be converted.\n\nReturns\n\ndf::DataFrame: The converted DataFrame.\n\n\n\n\n\n","category":"method"},{"location":"release-notes/","page":"Release notes","title":"Release notes","text":"EditURL = \"https://github.com/JuliaDocs/Documenter.jl/blob/master/CHANGELOG.md\"","category":"page"},{"location":"release-notes/#Release-notes","page":"Release notes","title":"Release notes","text":"","category":"section"},{"location":"release-notes/","page":"Release notes","title":"Release notes","text":"The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.","category":"page"},{"location":"release-notes/#Unreleased","page":"Release notes","title":"Unreleased","text":"","category":"section"},{"location":"release-notes/#Added","page":"Release notes","title":"Added","text":"","category":"section"},{"location":"release-notes/#Changed","page":"Release notes","title":"Changed","text":"","category":"section"},{"location":"release-notes/#Fixed","page":"Release notes","title":"Fixed","text":"","category":"section"},{"location":"getting-started/#getting-started","page":"Overview","title":"Getting started","text":"","category":"section"},{"location":"getting-started/","page":"Overview","title":"Overview","text":"Note that this section of the documentation is still under construction. Please see replications for the most up-to-date information. Please feel free to contribute to the documentation by submitting a pull request.","category":"page"},{"location":"getting-started/","page":"Overview","title":"Overview","text":"Welcome to the EpiAware documentation! This section is designed to help you get started with the package. It includes a frequently asked questions (FAQ) section, a series of explainers that provide a detailed overview of the platform and its features, and tutorials that will help you get started with EpiAware for specific tasks. See the sidebar for the list of topics.","category":"page"},{"location":"getting-started/explainers/observation-models/#Observation-models","page":"Observation models","title":"Observation models","text":"","category":"section"},{"location":"showcase/#showcase","page":"Overview","title":"EpiAware Showcase","text":"","category":"section"},{"location":"showcase/","page":"Overview","title":"Overview","text":"Here we showcase the capabilities of EpiAware in action. If you have a showcase you would like to add, please submit a pull request.","category":"page"}] } diff --git a/dev/showcase/index.html b/dev/showcase/index.html index ac8ed19cc..90b79b262 100644 --- a/dev/showcase/index.html +++ b/dev/showcase/index.html @@ -1,2 +1,2 @@ -Overview · EpiAware.jl

              EpiAware Showcase

              Here we showcase the capabilities of EpiAware in action. If you have a showcase you would like to add, please submit a pull request.

              +Overview · EpiAware.jl

              EpiAware Showcase

              Here we showcase the capabilities of EpiAware in action. If you have a showcase you would like to add, please submit a pull request.

              diff --git a/dev/showcase/replications/mishra-2020/index.html b/dev/showcase/replications/mishra-2020/index.html index 67ec50549..21c06f897 100644 --- a/dev/showcase/replications/mishra-2020/index.html +++ b/dev/showcase/replications/mishra-2020/index.html @@ -74,7 +74,7 @@

              We can sample from this model, which is useful for model diagnostic and prior predictive checking.

              - +

              And we can sample from this model with some parameters conditioned, for example with \(\sigma = 0\). In this case the AR process is an initial perturbation model with return to baseline.

              @@ -83,7 +83,7 @@

              Model{typeof(generate_latent), (:latent_model, :n), (), (), Tuple{AR{Product{Continuous, Truncated{Normal{Float64}, Continuous, Float64, Float64, Float64}, Vector{Truncated{Normal{Float64}, Continuous, Float64, Float64, Float64}}}, HalfNormal{Float64}, DistributionsAD.TuringScalMvNormal{Vector{Float64}, Float64}, Int64}, Int64}, Tuple{}, ConditionContext{@NamedTuple{σ_AR::Float64}, DefaultContext}}(EpiAware.EpiAwareBase.generate_latent, (latent_model = AR{Product{Continuous, Truncated{Normal{Float64}, Continuous, Float64, Float64, Float64}, Vector{Truncated{Normal{Float64}, Continuous, Float64, Float64, Float64}}}, HalfNormal{Float64}, DistributionsAD.TuringScalMvNormal{Vector{Float64}, Float64}, Int64}(Distributions.Product{Distributions.Continuous, Distributions.Truncated{Distributions.Normal{Float64}, Distributions.Continuous, Float64, Float64, Float64}, Vector{Distributions.Truncated{Distributions.Normal{Float64}, Distributions.Continuous, Float64, Float64, Float64}}}(v=Truncated{Normal{Float64}, Continuous, Float64, Float64, Float64}[Truncated(Distributions.Normal{Float64}(μ=0.8, σ=0.05); lower=0.0, upper=1.0), Truncated(Distributions.Normal{Float64}(μ=0.05, σ=0.05); lower=0.0, upper=1.0)]), HalfNormal{Float64}(μ=1.0), DistributionsAD.TuringScalMvNormal{Vector{Float64}, Float64}(m=[-1.0, -1.0], σ=0.1), 2), n = 30), NamedTuple(), ConditionContext((σ_AR = 0.0,), DynamicPPL.DefaultContext())) - +

              In this note, we are going to treat \(R_t\) as varying every two days. The reason for this is to 1) reduce the effective number of parameters, and 2) showcase the BroadcastLatentModel wrapper.

              In EpiAware we set this behaviour by wrapping a LatentModel in a BroadcastLatentModel. This allows us to set the broadcasting period and type. In this case we broadcast each latent process value over \(2\) days in a RepeatBlock.

              @@ -92,7 +92,7 @@

              BroadcastLatentModel{AR{Product{Continuous, Truncated{Normal{Float64}, Continuous, Float64, Float64, Float64}, Vector{Truncated{Normal{Float64}, Continuous, Float64, Float64, Float64}}}, HalfNormal{Float64}, DistributionsAD.TuringScalMvNormal{Vector{Float64}, Float64}, Int64}, Int64, RepeatBlock}(AR{Product{Continuous, Truncated{Normal{Float64}, Continuous, Float64, Float64, Float64}, Vector{Truncated{Normal{Float64}, Continuous, Float64, Float64, Float64}}}, HalfNormal{Float64}, DistributionsAD.TuringScalMvNormal{Vector{Float64}, Float64}, Int64}(Distributions.Product{Distributions.Continuous, Distributions.Truncated{Distributions.Normal{Float64}, Distributions.Continuous, Float64, Float64, Float64}, Vector{Distributions.Truncated{Distributions.Normal{Float64}, Distributions.Continuous, Float64, Float64, Float64}}}(v=Truncated{Normal{Float64}, Continuous, Float64, Float64, Float64}[Truncated(Distributions.Normal{Float64}(μ=0.8, σ=0.05); lower=0.0, upper=1.0), Truncated(Distributions.Normal{Float64}(μ=0.05, σ=0.05); lower=0.0, upper=1.0)]), HalfNormal{Float64}(μ=1.0), DistributionsAD.TuringScalMvNormal{Vector{Float64}, Float64}(m=[-1.0, -1.0], σ=0.1), 2), 2, RepeatBlock()) - +

              The Renewal model as an EpiModel type

              EpiAware has an EpiModel type system which we use to set the behaviour of the latent infection model. In this case we want to implement a renewal model.

              To construct an EpiModel we need to supply some fixed data for the model contained in an EpiData object. The EpiData constructor performs double interval censoring to convert our continuous estimate of the generation interval into a discretized version \(g_t\). We also implement right truncation, the default is rounding the 99th percentile of the generation interval distribution, but this can be controlled using the keyword D_gen.

              @@ -104,7 +104,7 @@

              EpiData{Float64, typeof(exp)}([0.026663134095601056, 0.14059778064943784, 0.2502660305615846, 0.24789569560506844, 0.1731751163417783, 0.09635404000022223, 0.04573437575216367, 0.019313826994143808], 8, exp) - +

              The user also needs to specify a prior for the log incidence at time zero, \(\log I_0\). The initial history of latent infections \(I_{-1}, I_{-2},\dots\) is constructed as

              $$I_t = e^{rt} I_0,\qquad t = 0, -1, -2,...$$

              Where the exponential growth rate \(r\) is determined by the initial reproductive number \(R_1\) via the solution to the implicit equation,

              $$R_1 = 1 \Big{/} \sum_{t\geq 1} e^{-rt} g_t$$

              @@ -142,7 +142,7 @@

              Model{typeof(generate_latent_infs), (:epi_model, :_Rt), (), (), Tuple{RenewalWithPopulation{Normal{Float64}}, Vector{Float64}}, Tuple{}, DefaultContext}(EpiAware.EpiAwareBase.generate_latent_infs, (epi_model = RenewalWithPopulation{Normal{Float64}}(EpiData{Float64, typeof(exp)}([0.026663134095601056, 0.14059778064943784, 0.2502660305615846, 0.24789569560506844, 0.1731751163417783, 0.09635404000022223, 0.04573437575216367, 0.019313826994143808], 8, exp), Distributions.Normal{Float64}(μ=0.0, σ=1.0), 1.0e8), _Rt = [1.0986115957278464, 1.098610405062754, 1.0986071685094998, 1.0985983707197156, 1.0985744563952262, 1.098509454567543, 1.0983327911702674, 1.097852790994088, 1.09654964358037, 1.0930193012626002 … -0.6808598639891831, -0.6886022683659516, -0.6914718340845708, -0.6925303979295329, -0.6929202169746165, -0.6930636769372295, -0.6931164601588107, -0.6931358790023187, -0.6931430229284499, -0.6931456510499804]), NamedTuple(), DefaultContext()) - +

              Negative Binomial Observations as an ObservationModel type

              In Mishra et al latent infections were assumed to occur on their observation day with negative binomial errors, this motivates using the serial interval (the time between onset of symptoms of a primary and secondary case) rather than generation interval distribution (the time between infection time of a primary and secondary case).

              Observation models are set in EpiAware as concrete subtypes of an ObservationModel. The Negative binomial error model without observation delays is set with a NegativeBinomialError struct. In Mishra et al the overdispersion parameter \(\phi\) sets the relationship between the mean and variance of the negative binomial errors,

              $$\text{var} = \text{mean} + {\text{mean}^2 \over \phi}.$$

              In EpiAware, we default to a prior on \(\sqrt{1/\phi}\) because this quantity has the dimensions of a standard deviation and, therefore, is easier to reason on a priori beliefs.

              @@ -177,7 +177,7 @@

              Model{typeof(generate_observations), (:obs_model, :y_t, :Y_t), (), (:y_t,), Tuple{NegativeBinomialError{HalfNormal{Float64}}, Missing, Vector{Float64}}, Tuple{}, DefaultContext}(EpiAware.EpiAwareBase.generate_observations, (obs_model = NegativeBinomialError{HalfNormal{Float64}}(HalfNormal{Float64}(μ=0.15)), y_t = missing, Y_t = [2.289734845645553e-8, 6.691586091292782e-7, 1.5229979744712628e-5, 0.0002699578503363014, 0.003726653172078671, 0.04006529739295107, 0.33546262790251186, 2.187491118182885, 11.108996538242305, 43.93693362340742 … 11.108996538242305, 2.187491118182885, 0.33546262790251186, 0.04006529739295107, 0.003726653172078671, 0.0002699578503363014, 1.5229979744712628e-5, 6.691586091292782e-7, 2.289734845645553e-8, 6.101936677605324e-10]), NamedTuple(), DefaultContext()) - +

              A reverse observation model, which samples the underlying latent infections conditional on observations would require a prior on the latent infections. This is the purpose of composing multiple models; as we'll see below the latent infection and latent \(R_t\) models are informative priors on the latent infection time series underlying the observations.

              @@ -232,6 +232,6 @@

              Parameter inference

              We can interrogate the sampled chains directly from the samples field of the inference_results object.

              - + -
              +