Skip to content

Commit

Permalink
revise overview
Browse files Browse the repository at this point in the history
  • Loading branch information
rfl-urbaniak committed Oct 18, 2024
1 parent 7b92c91 commit 21826b7
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions docs/source/dynamical_multi.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
},
{
"cell_type": "code",
"execution_count": 75,
"execution_count": 1,
"metadata": {
"ExecuteTime": {
"end_time": "2023-07-18T18:46:29.292774Z",
Expand Down Expand Up @@ -93,13 +93,13 @@
"source": [
"## Overview: Composing Hierarchical Bayesian Models with ODEs\n",
"\n",
"In our previous tutorial on causal reasoning with continuous time dynamical systems we showed how embedding differential equation solvers in ChiRho allows us to do the following: (i) fit dynamical systems parameters using Pyro's support for variational inference and (ii) reason about (uncertain) interventions representing various policy decisions. In this tutorial we expand on that early epidemiological example by composing the same simple susceptible, infected, recovered (SIR) model with hierarchical priors over dynamical systems parameters for each of several distinct geographic location. The key insight here is that the same Bayesian modeling motifs for pooling statistical information between distinct stratum in standard Bayesian multilevel regression modeling (TODO: cite Gelman's book) can be used when the regression equations are swapped out with mechanistic models in the form of differential equations.\n",
"In our previous tutorial on causal reasoning with continuous time dynamical systems we showed how embedding differential equation solvers in ChiRho allows us to do the following: (i) fit dynamical systems parameters using Pyro's support for variational inference and (ii) reason about (uncertain) interventions representing various policy decisions. In this tutorial we expand on that early epidemiological example by composing the same simple susceptible, infected, recovered (SIR) model with hierarchical priors over dynamical systems parameters for each of several distinct geographic location (we will use three locations in our running example). The key insight here is that the same Bayesian modeling motifs for pooling statistical information between distinct strata in standard Bayesian multilevel regression modeling (see Chapter 5 of Gelman, A., Carlin, J. B., Stern, H. S., & Rubin, D. B. (1995). *Bayesian data analysis*. Chapman and Hall/CRC with subsequent editions and improvements) can be used when the regression equations are swapped out with mechanistic models in the form of differential equations.\n",
"\n",
"### Background: \n",
"### Background: causal reasoning in dynamical systems\n",
"\n",
"If you haven't read the preliminary tutorial on causal reasoning with continuous time dynamical systems, we recommend doing so first beforing continuing. In that tutorial you'll find a short description of how we represent causal interventions in dynamical systems, as well as all of the details behind the SIR model used in this expanded tutorial.\n",
"\n",
"### Model Description:\n",
"### Modelling assumptions:\n",
"\n",
"In this example, we again explore the SIR (Susceptible, Infected, Recovered) compartmental model, a fundamental model in epidemiology. Here, the variables of interest are:\n",
"\n",
Expand All @@ -109,11 +109,18 @@
"\n",
"- $R(t)$: the number of recovered individuals at time $t$.\n",
"\n",
"These compartments interact through a set of ordinary differential equations that describe the rate at which individuals move from being susceptible to infected, and from infected to recovered.\n",
"These compartments interact through a set of ordinary differential equations that describe the rate at which individuals move from being susceptible to infected, and from infected to recovered. \n",
"\n",
"Unlike in the previous tutorial, where $S$, $I$, and $R$ are real-valued functions of time, in this tutorial these variables will be vector-valued functions of time where each element corresponds to the number of people susceptible, infected, and recovered in a particular stratum. In this example, each stratum refers to an individual town.\n",
"Unlike in the previous tutorial, where $S$, $I$, and $R$ are real-valued functions of time, in this tutorial these variables will be vector-valued functions of time where each element corresponds to the number of people susceptible, infected, and recovered in a particular stratum. In this example, each stratum refers to an individual town. We will assume the interactions between compartments within each of the towns are guided by the same equations with potentially somewhat different parameters, coming from (respectively) the same common distributions. \n",
"\n",
"Just as in the previous tutorial, we define the differential equation model as a `pyro.nn.PyroModule` as follows, where the `forward` method is a function from state `X` to the time derivative of the state, `dX`. Fortunately, we can use the exact same implementation for the stratified example here, taking advantage of PyTorch's tensor broadcasting semantics."
"We will also assume that parameters come from distributions representing our uncertainty about them, and that observations come from Poisson distributions centered around predicted trajectories. In practice, this will be achieved by composing the ODE core with Bayesian elements in a step-wise fashion as described below."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Causal probabilistic program"
]
},
{
Expand Down Expand Up @@ -1126,7 +1133,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": "new-pyro",
"language": "python",
"name": "python3"
},
Expand Down

0 comments on commit 21826b7

Please sign in to comment.