Dear Statalist,
I am using Stata 17 and am analysing an interaction effect of how the relationship between length of time spent in one's neighbourhood is associated with one's mental health depending on how attached one is to their neighbourhood. Mental health is a continuous variable, time in the neighbourhood is continuous and attachment is a 3-category categorical variable. The data is 4 waves of panel data.
I have been creating a marginsplot showing the average marginal effects of the impact of time spent in the neighbourhood at three levels of attachment, with 95% confidence intervals around the estimates.
I get this marginsplot as a result:
However, I was wondering if it is possible to plot both the 95% confidence intervals and the 90% confidence for these average marginal effects on the same marginsplot? Below is an example from an article that seems to do this. It shows average marginal effects of having had COVID-19 on trust in strangers depending on their perceived economic condition (an interaction effect). The thin/thick vertical bars are 95/90% CIs.
However, I can't seem to find anyway of doing this myself. When specifying the
in calculating margins it only allows me to set one at a time. I have seen that you can do this using coefplot e.g.,
However, I can't seem to be able to do something similar using marginsplot.
I did find a way of plotting average marginal effects using coefplot:
But again, I can't seem to find a way of getting both the 90% and 95% confidence intervals on to the same plot.
Any help would be much appreciated.
Best wishes,
James
I am using Stata 17 and am analysing an interaction effect of how the relationship between length of time spent in one's neighbourhood is associated with one's mental health depending on how attached one is to their neighbourhood. Mental health is a continuous variable, time in the neighbourhood is continuous and attachment is a 3-category categorical variable. The data is 4 waves of panel data.
Code:
xtreg mental c.time_in_neighbourhood##i.nei_attachment, fe
Code:
margins, dydx(time_in_neighbourhood) at(nei_attachment=(1 2 3)) level(95) marginsplot, recast(scatter) yline(0, lwidth(vthin))
However, I was wondering if it is possible to plot both the 95% confidence intervals and the 90% confidence for these average marginal effects on the same marginsplot? Below is an example from an article that seems to do this. It shows average marginal effects of having had COVID-19 on trust in strangers depending on their perceived economic condition (an interaction effect). The thin/thick vertical bars are 95/90% CIs.
However, I can't seem to find anyway of doing this myself. When specifying the
Code:
level(95)
Code:
coefplot, levels(99.9 99 95)
I did find a way of plotting average marginal effects using coefplot:
Code:
xtreg mental c.time_in_neighbourhood##i.nei_attachment, fe margins, dydx(time_in_neighbourhood) at(nei_attachment=(1 2 3)) level(95) post coefplot, xline(0) xtitle(Average marginal effects)
Any help would be much appreciated.
Best wishes,
James
Comment