Dear Statalists,
I am trying to plot a figure after a difference-in-difference regression. The DID regression is as below.
reg dependent i.year treatment treatment*post var1 var2
After the regression, I want to plot a figure with two lines.
Line 1 = mean(dependent) - _b[var1]*mean(var1) - _b[var2]*mean(var2), for treatment group through years.
Line 2 = mean(dependent) - _b[var1]*mean(var1) - _b[var2]*mean(var2), for nontreatment group through years.
These are actually "the mean of dependent variables" minus "the factors impacted by var1 and var2" for both treated and untreated groups through years. So, I tried the code as follows.
egen depedent1=mean(depedent1) - _b[var1]*mean(var1) - _b[var2]*mean(var2), by(year), if treatment==1
egen depedent2=mean(depedent1) - _b[var1]*mean(var1) - _b[var2]*mean(var2), by(year), if treatment==0
Unfortunately, Stata reports "varlist not allowed". May I have your advice on how can I work on this?
Thanks a lot,
Chenli
I am trying to plot a figure after a difference-in-difference regression. The DID regression is as below.
reg dependent i.year treatment treatment*post var1 var2
After the regression, I want to plot a figure with two lines.
Line 1 = mean(dependent) - _b[var1]*mean(var1) - _b[var2]*mean(var2), for treatment group through years.
Line 2 = mean(dependent) - _b[var1]*mean(var1) - _b[var2]*mean(var2), for nontreatment group through years.
These are actually "the mean of dependent variables" minus "the factors impacted by var1 and var2" for both treated and untreated groups through years. So, I tried the code as follows.
egen depedent1=mean(depedent1) - _b[var1]*mean(var1) - _b[var2]*mean(var2), by(year), if treatment==1
egen depedent2=mean(depedent1) - _b[var1]*mean(var1) - _b[var2]*mean(var2), by(year), if treatment==0
Unfortunately, Stata reports "varlist not allowed". May I have your advice on how can I work on this?
Thanks a lot,
Chenli
Comment