|
5 | 5 | "cell_type": "markdown", |
6 | 6 | "metadata": {}, |
7 | 7 | "source": [ |
8 | | - "# Example Interrupted Time Series (ITS) with `pymc` models\n", |
| 8 | + "# Bayesian Interrupted Time Series\n", |
9 | 9 | "\n", |
10 | | - "Interrupted Time Series (ITS) analysis is a powerful approach for estimating the causal impact of an intervention or treatment when you have a single time series of observations. The key idea is to compare what actually happened after the intervention to what would have happened in the absence of the intervention (the \"counterfactual\"). To do this, we train a statistical model on the pre-intervention data (when no treatment has occurred) and then use this model to forecast the expected outcomes into the post-intervention period. The difference between the observed outcomes and these model-based counterfactual predictions provides an estimate of the causal effect of the intervention, along with a measure of uncertainty if using a Bayesian approach.\n", |
11 | | - "\n", |
12 | | - "This notebook shows an example of using interrupted time series, where we do not have untreated control units of a similar nature to the treated unit and we just have a single time series of observations and the predictor variables are simply time and month. So the only real way to estimate the counterfactual is by training a model on the pre-intervention data and then using this model to forecast the expected outcomes into the post-intervention period." |
| 10 | + "Interrupted Time Series (ITS) analysis is a powerful approach for estimating the causal impact of an intervention or treatment when you have a single time series of observations. The key idea is to compare what actually happened after the intervention to what would have happened in the absence of the intervention (the \"counterfactual\"). To do this, we train a statistical model on the pre-intervention data (when no treatment has occurred) and then use this model to forecast the expected outcomes into the post-intervention period as-if treatment had not occurred. The difference between the observed outcomes and these model-based counterfactual predictions provides an estimate of the causal effect of the intervention, along with a measure of uncertainty if using a Bayesian approach." |
13 | 11 | ] |
14 | 12 | }, |
15 | 13 | { |
16 | 14 | "cell_type": "markdown", |
17 | 15 | "metadata": {}, |
18 | 16 | "source": [ |
19 | | - "## What do we mean by \"causal impact\" in Interrupted Time Series?\n", |
20 | | - "\n", |
21 | | - "In the context of interrupted time series (ITS) analysis, especially when using Bayesian models, the term **causal impact** refers to the estimated effect of an intervention or event on an outcome of interest.\n", |
| 17 | + "## What do we mean by _causal impact_ in Interrupted Time Series?\n", |
22 | 18 | "\n", |
23 | | - "### Instantaneous and Cumulative Bayesian Causal Effects\n", |
| 19 | + "In the context of interrupted time series analysis, the term **causal impact** refers to the estimated effect of an intervention or event on an outcome of interest. We can break this down into two components which tell us different aspects of the intervention's effect:\n", |
24 | 20 | "\n", |
25 | 21 | "- The **Instantaneous Bayesian Causal Effect** at each time point is the difference between the observed outcome and the model's posterior predictive distribution for the counterfactual (i.e., what would have happened without the intervention). This is not just a single number, but a full probability distribution that reflects our uncertainty.\n", |
26 | 22 | "- The **Cumulative Bayesian Causal Impact** is the sum of these instantaneous effects over the post-intervention period, again represented as a distribution.\n", |
27 | 23 | "\n", |
28 | | - "### Mathematical expression\n", |
29 | 24 | "Let $y_t$ be the observed outcome at time $t$ (after the intervention), and $\\tilde{y}_t$ be the model's counterfactual prediction for the same time point. Then:\n", |
30 | 25 | "- **Instantaneous effect:** $\\Delta_t = y_t - \\tilde{y}_t$\n", |
31 | 26 | "- **Cumulative effect (up to time $T$):** $C_T = \\sum_{t=1}^T \\Delta_t$\n", |
|
45 | 40 | "cell_type": "markdown", |
46 | 41 | "metadata": {}, |
47 | 42 | "source": [ |
48 | | - "## Interrupted Time Series (ITS) Example" |
| 43 | + "## Interrupted Time Series example" |
49 | 44 | ] |
50 | 45 | }, |
51 | 46 | { |
|
538 | 533 | "name": "python", |
539 | 534 | "nbconvert_exporter": "python", |
540 | 535 | "pygments_lexer": "ipython3", |
541 | | - "version": "3.11.9" |
| 536 | + "version": "3.13.2" |
542 | 537 | }, |
543 | 538 | "orig_nbformat": 4, |
544 | 539 | "vscode": { |
|
0 commit comments