Dear smartest listers,
I would like to plot the mean y against each value of x, separately for the 4 cases (g=0,h=0), (g=0,h=1), (g=1,h=0), and (h=1,h=1).
So I started with the following code:
Now I would like to add also a sort of "confidence interval" (although I am plotting means rather than regression coefficients) that would allow to see whether the lines are significantly different or whether their confidence intervals overlap. IFF I remember my statistics correctly, I should get 95% confidence intervals by adding to each curve a shaded area covering on each side of the line two standard deviations, or would you do this differently?
For that purpose, I ran another separate collapse with
instead of
to save for each g, h and x value also the standard deviation of y.
But now I am unsure how to complement the above code to include also those 4 shaded areas.
Would anyone know?
Thank you so much!
PM
I would like to plot the mean y against each value of x, separately for the 4 cases (g=0,h=0), (g=0,h=1), (g=1,h=0), and (h=1,h=1).
So I started with the following code:
Code:
collapse (mean) y, by(g h x) sort g h x save graphdata, replace use graphdata, replace gen y1 = y if g==0 & h==0 gen y2 = y if g==0 & h==1 gen y3 = y if g==1 & h==0 gen y4 = y if g==1 & h==1 twoway (line y1 x) (line y2 x) (line y3 x) (line y4 x) -
For that purpose, I ran another separate collapse with
Code:
(sd)
Code:
(mean)
But now I am unsure how to complement the above code to include also those 4 shaded areas.
Would anyone know?
Thank you so much!
PM
Comment