|
366 | 366 | {
|
367 | 367 | "data": {
|
368 | 368 | "application/vnd.jupyter.widget-view+json": {
|
369 |
| - "model_id": "157d55ed720c45048f1f3b9ec64f1633", |
| 369 | + "model_id": "ab6182fae8c348fdb460e76b3a00ff6f", |
370 | 370 | "version_major": 2,
|
371 | 371 | "version_minor": 0
|
372 | 372 | },
|
|
543 | 543 | {
|
544 | 544 | "data": {
|
545 | 545 | "application/vnd.jupyter.widget-view+json": {
|
546 |
| - "model_id": "e55e1b5eec744b3ab83eb01ce5cd778c", |
| 546 | + "model_id": "7101d2c9f94d47d6932c76fa1d2bd42f", |
547 | 547 | "version_major": 2,
|
548 | 548 | "version_minor": 0
|
549 | 549 | },
|
|
568 | 568 | "name": "stderr",
|
569 | 569 | "output_type": "stream",
|
570 | 570 | "text": [
|
571 |
| - "Sampling 4 chains for 1_000 tune and 1_000 draw iterations (4_000 + 4_000 draws total) took 1 seconds.\n", |
| 571 | + "Sampling 4 chains for 1_000 tune and 1_000 draw iterations (4_000 + 4_000 draws total) took 2 seconds.\n", |
572 | 572 | "Sampling: [beta, sigma, y_hat]\n",
|
573 | 573 | "Sampling: [y_hat]\n",
|
574 | 574 | "Sampling: [y_hat]\n",
|
|
712 | 712 | {
|
713 | 713 | "data": {
|
714 | 714 | "application/vnd.jupyter.widget-view+json": {
|
715 |
| - "model_id": "2765ee0006c8440983f9dcfa938bea5c", |
| 715 | + "model_id": "3ee5408d908741fd91fc55eb5e783aab", |
716 | 716 | "version_major": 2,
|
717 | 717 | "version_minor": 0
|
718 | 718 | },
|
|
737 | 737 | "name": "stderr",
|
738 | 738 | "output_type": "stream",
|
739 | 739 | "text": [
|
740 |
| - "Sampling 4 chains for 1_000 tune and 1_000 draw iterations (4_000 + 4_000 draws total) took 1 seconds.\n", |
| 740 | + "Sampling 4 chains for 1_000 tune and 1_000 draw iterations (4_000 + 4_000 draws total) took 2 seconds.\n", |
741 | 741 | "Sampling: [beta, sigma, y_hat]\n",
|
742 | 742 | "Sampling: [y_hat]\n",
|
743 | 743 | "Sampling: [y_hat]\n",
|
|
831 | 831 | "source": [
|
832 | 832 | "## Analysis 4 - Two way fixed effects\n",
|
833 | 833 | "\n",
|
834 |
| - "Finally, we can evaluate difference in difference model in its two-way fixed effects (TWFE) formulation. \n", |
| 834 | + "Finally, we can evaluate the difference in difference model in its two-way fixed effects (TWFE) formulation. The two-way fixed effects model is widely used in econometrics for causal inference in panel data settings. It accounts for both unit-specific effects (e.g., differences between districts) and time-specific effects (e.g., shocks or trends affecting all units simultaneously). \n", |
835 | 835 | "\n",
|
836 |
| - "This is similar to the previous model in that the `district:post_treatment` interaction term still gives you a treatment indicator variable and the assiated coefficient $\\beta_{\\Delta}$ is the causal effect of the intervention.\n", |
| 836 | + "The TWFE model is equivalent to the classic 2$\\times$2 DiD model (Model 1) - but only in the situation of two groups and two time periods. Outside of this special case the approach is not equivalent and can potentially have some problems {cite:p}`imai2021twfepanel`. Readers should proceed with caution when using the TWFE model outside of the 2$\\times$2 case - see {cite:t}`kropko2018two`.\n", |
837 | 837 | "\n",
|
838 |
| - "But it is different in that there is no _linear_ `year` term, instead we have a categorical `year` variable. This means that the model can capture any temporal trends in the data. These can be thought of as capturing time based schocks that affect all units.\n", |
| 838 | + "The TWFE approach similar to the previous model in that the `district:post_treatment` interaction term still gives you a treatment indicator variable and the assiated coefficient $\\beta_{\\Delta}$ is the causal effect of the intervention. But it is different in that there is no _linear_ `year` term, instead we have a _categorical_ `year` variable. This means that the model can capture any temporal trends in the data. These can be thought of as capturing time based schocks that affect all units.\n", |
839 | 839 | "\n",
|
840 | 840 | "The equation for the expected values is:\n",
|
841 | 841 | "\n",
|
|
851 | 851 | "* $\\alpha$ is a scalar intercept term.\n",
|
852 | 852 | "* $\\alpha[district_i]$ is a vector of fixed effects for each district. There are only 2 districts, so this is a vector of length 2. The $district_i$ indexes the element of $\\alpha$ that corresponds to the district of the $i^{th}$ observation.\n",
|
853 | 853 | "* $\\beta[year_i]$ is a vector of fixed effects for each year. There are 6 years, so this is a vector of length 6. The $year_i$ indexes the element of $\\beta$ that corresponds to the year of the $i^{th}$ observation.\n",
|
854 |
| - "* $\\Delta$ is a scalar representing the treatment effect, which is the same as the coefficient of the `district:post_treatment` interaction term.\n" |
| 854 | + "* $\\Delta$ is a scalar representing the treatment effect, which is the same as the coefficient of the `district:post_treatment` interaction term." |
855 | 855 | ]
|
856 | 856 | },
|
857 | 857 | {
|
|
875 | 875 | {
|
876 | 876 | "data": {
|
877 | 877 | "application/vnd.jupyter.widget-view+json": {
|
878 |
| - "model_id": "dd5a6855e8034f63961ddd55c6e23e13", |
| 878 | + "model_id": "f7899527e56140b29f209c86dd346b38", |
879 | 879 | "version_major": 2,
|
880 | 880 | "version_minor": 0
|
881 | 881 | },
|
|
0 commit comments