Dear Stata Experts,
I would like to graph cluster-specific regression lines after estimating a 2-level model using the mixed command. I am using data where individuals are clustered within countries (from the International Social Survey Programme).
I have followed the example at https://grodri.github.io/multilevel/lang2. The code below works nicely with the snijders data where students are clustered within schools.

However, when I do this with my data, the graph I get looks like scribbles (see below). I think this may be an issue with sorting the data properly before graphing, but I haven't been able to fix it. Does anyone have any suggestions?
Thanks,
Jeremy

I would like to graph cluster-specific regression lines after estimating a 2-level model using the mixed command. I am using data where individuals are clustered within countries (from the International Social Survey Programme).
I have followed the example at https://grodri.github.io/multilevel/lang2. The code below works nicely with the snijders data where students are clustered within schools.
Code:
use https://grodri.github.io/datasets/snijders, clear sum iq_verb gen iqvc = iq_verb - r(mean) mixed langpost iqvc || schoolnr: iqvc, mle covariance(unstructured) predict yhat2, fitted sort schoolnr iqvc line yhat2 iqvc, connect(ascending)
However, when I do this with my data, the graph I get looks like scribbles (see below). I think this may be an issue with sorting the data properly before graphing, but I haven't been able to fix it. Does anyone have any suggestions?
Thanks,
Jeremy
Code:
center tgid_7ns, gen(tgid_7ns_c) mixed jobsat c.tgid_7ns_c $personalcontrolsfv $jobcontrolsfv $countrycontrolsfv || country: c.tgid_7ns_c if analysis==1 & woman==1, stddev capture drop prjobsat predict prjobsat if e(sample), fitted sort country tgid_7ns_c line prjobsat tgid_7ns_c if e(sample), connect(ascending)
Comment