Hi, I am having a problem with the csdid command, it will work for years but not for age:
My dataset:
Option 1: By year:
Outcome:
Option 2: By age:
Outcome:
Surely, I should be getting the same result, irrespective of whether I use age or year in this example. I need to run it by year for my dataset but it always drops all the observations and errors.
All help is greatly appreciated, many thanks in advance!
My dataset:
id | year | age | treatment_age | treatment_year | Outcome |
5 | 1989 | 43 | 0 | ||
5 | 1991 | 45 | 53 | 1999 | 0 |
5 | 1993 | 47 | 53 | 1999 | 0 |
5 | 1995 | 49 | 53 | 1999 | 0 |
5 | 1997 | 51 | 53 | 1999 | 0 |
5 | 1999 | 53 | 53 | 1999 | 1 |
5 | 2001 | 55 | 53 | 1999 | 0 |
5 | 2003 | 57 | 53 | 1999 | 0 |
6 | 1989 | 42 | 1 | ||
6 | 1991 | 44 | 50 | 1997 | 0 |
6 | 1993 | 46 | 50 | 1997 | 1 |
6 | 1995 | 48 | 50 | 1997 | 0 |
6 | 1997 | 50 | 50 | 1997 | 1 |
6 | 1999 | 52 | 50 | 1997 | 1 |
6 | 2001 | 54 | 50 | 1997 | 1 |
6 | 2003 | 56 | 50 | 1997 | 0 |
Code:
csdid Outcome if id == 5 | id == 6, [ivar(id)] time(year) gvar(treatment_year) agg(event)
Code:
No never treated observations found. Using Not yet treated data ...xxxxxxxxx Difference-in-difference with Multiple Time Periods Number of obs = 8 Outcome model : regression adjustment Treatment model: none ------------------------------------------------------------------------------ | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- Pre_avg | 0 (omitted) Post_avg | 1 . . . . . Tm4 | 1 . . . . . Tm2 | -1 . . . . . Tp0 | 1 . . . . . ------------------------------------------------------------------------------ Control: Not yet Treated
Option 2: By age:
Code:
csdid Outcome if id == 5 | id == 6, [ivar(id)] time(age) gvar(treatment_age) agg(event)
Code:
No never treated observations found. Using Not yet treated data xxxxxxxxxxxxxxxxxxxxxxxxxx mean(): 3301 subscript invalid aggte(): - function returned error makerif2(): - function returned error <istmt>: - function returned error
All help is greatly appreciated, many thanks in advance!
Comment