Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
asjadnaqvi committed Sep 30, 2021
1 parent 838461b commit cb5be42
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
Binary file added assets/images/twfe1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 15 additions & 5 deletions docs/theory and code/06_twfe.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ $$ y_{it} = \alpha_{i} + \alpha_t + \beta D_{it} + \epsilon_{it} $$
Let us generate a simple 2x2 example in Stata. First step define the panel structure. Since it is a 2x2, we just need two units and two time periods:

```r

clear
local units = 2
local start = 1
Expand All @@ -96,7 +95,6 @@ egen t = seq(), f(`start') t(`end')
sort id t
xtset id t
lab var id "Panel variable"
lab var t "Time variable"
```
Expand All @@ -107,10 +105,22 @@ Next we define the treatment group and a generic TWFE model without adding any v
gen D = id==2 & t==2
gen btrue = cond(D==1, 2, 0)
gen Y = id + 3*t + btrue*D
```
gen Y = id + 3*t + btrue*D
According to the last line, the treatment effect should have an impact of 3 units on Y in the post group. We can check this by plotting the data:
```r
twoway ///
(connected Y t if id==1) ///
(connected Y t if id==2) ///
, ///
legend(order(1 "id=1" 2 "id=2")) ///
xlabel(1 2) ylabel(4(1)10)
```
According to the last line, the treatment effect should have an impact of 2 units on Y in the post group.
which gives us:
[](../../assets/images/twfe.png)
<img src="../../assets/images/twfe.png" height="400" title="TWFE">

0 comments on commit cb5be42

Please sign in to comment.