I am trying to use the estat ptrends command to check the parallel trends assumption in a Diff-in-Diff research design. I tried following the instructions here:
Here is a dataex.
Earnings is my outcome variable,
DiD is the treatment variable, which is an interaction between treatment_time*treated_neighborhood. It takes the value of 1 if the observation lives in a treated neighborhood and received treatment after the policy is implemented.
treated_neighborhood takes the value of one if the neighborhood received policy treatment, and 0 otherwise.
Finally, treatment_time takes the value of 1 if the month falls after the treatment occurred, and 0 otherwise, based on the month variable.
```
dataex earnings DiD treated_neighborhood treatment_time month
----------------------- copy starting from the next line -----------------------
[CODE]
* Example generated by -dataex-. For more info, type help dataex
clear
input float(earnings DiD treated_neighborhood treatment_time)
437 0 0 0 -6274
322 0 0 0 -6298
554 0 0 0 -6287
246 0 0 0 -6291
331 0 0 0 -6356
109 0 0 0 -6312
```
The code above works well with no errors, however, when I run estat ptrends or estat granger to include dummies as if treatment had occurred in the past, I receive the following error:
"estat ptrend requires at least two pre-intervention time periods"
Here is how I coded the treatment_time variable:
```
gen treatment_time = (month>=ym(2007, 9) & !missing(month))
```
Here is a dataex.
Earnings is my outcome variable,
DiD is the treatment variable, which is an interaction between treatment_time*treated_neighborhood. It takes the value of 1 if the observation lives in a treated neighborhood and received treatment after the policy is implemented.
treated_neighborhood takes the value of one if the neighborhood received policy treatment, and 0 otherwise.
Finally, treatment_time takes the value of 1 if the month falls after the treatment occurred, and 0 otherwise, based on the month variable.
```
dataex earnings DiD treated_neighborhood treatment_time month
----------------------- copy starting from the next line -----------------------
[CODE]
* Example generated by -dataex-. For more info, type help dataex
clear
input float(earnings DiD treated_neighborhood treatment_time)
437 0 0 0 -6274
322 0 0 0 -6298
554 0 0 0 -6287
246 0 0 0 -6291
331 0 0 0 -6356
109 0 0 0 -6312
```
The code above works well with no errors, however, when I run estat ptrends or estat granger to include dummies as if treatment had occurred in the past, I receive the following error:
"estat ptrend requires at least two pre-intervention time periods"
Here is how I coded the treatment_time variable:
```
gen treatment_time = (month>=ym(2007, 9) & !missing(month))
```