Update: the above syntax worked perfectly.. For example:
For those interested, the syntax to achieve this is:
Code: Select all
xi: runmlwin satlife cons ///
incgm agegm female i.genhlth2 socact socmeet ///
discuss i.feelinc2 ptnr children i.optim temp ///
i.likely ///
gdp06_cent gdpXlik2 gdpXlik3 gdpXlik4, ///
level2(cntry: cons) ///
level1(id: cons, weightvar(cweight))
cap drop hat_gdp06xlik4
gen hat_gdp06xlik4 = _b[cons]*cons + _b[_Ilikely_4]*_Ilikely_4 + _b[gdp06_cent]*gdp06_cent + _b[gdpXlik4]*gdpXlik4
twoway (connected hat_gdp06xlik4 gdp06_cent if lik4 == 0) ///
(connected hat_gdp06xlik4 gdp06_cent if lik4 == 1), ///
ytitle(Predicted life satisfaction) ///
xtitle(National GDP (PPPs, 2006; centred)) ///
title(Interaction plot) ///
subtitle(job insecurity x GDP (PPPs)) ///
caption(Weighted to control for population size and sample design, size(small)) ///
note(Source: European Social Survey (2006); Eurostat (2006)) ///
legend(order(1 "lik4 = 0" 2 "lik4 = 1") position(7) ring(0)) ///
scheme(s1color) xsize(6) aspectratio(.8)
While I'm here.. I have a follow-up question:
Is there any way of plotting the above graph with confidence intervals?
My guess is that this would involve using 'generate' to extract the standard errors of the parameters
of interest, then calculating confidence intervals (y_hat +/- 1.96 SE_hat), and finally plotting these
in Stata – probably using a combination of 'line' and 'rarea' graphs. For example, in the graph below
I've plotted the original graph (above) with shaded areas to represent 0.5 above and 0.5 below the
predicted lines.
What I need, therefore, is to be able to save the (predicted) standard errors from a model (for a
specified set of parameters) so I can calculate the variables "upper" and lower". Any thoughts/advice
on how to do this would be gratefully received.
Thanks!
Ewan
--