I have longitudinal data on several countries, looking at GDP and CO2 Emissions. In ggplot2, it is easy to make the software do something HLM-ish by plotting relationships separately for every country:
ggplot(dat, aes(x=CO2.Emissions, y=GDP, color=as.factor(Country))) + geom_point(shape=20) + geom_smooth(method=lm) + theme(legend.position="none") + scale_y_log10(name="Log10(GDP)") + scale_x_log10(name="Log10(CO2 Emissions)")
However, this is not a true plot of a multilevel model. I would love to do something LIKE this but visualizing results from a multilevel model. Specifically, the model is:
lmer(GDP ~ 1 + CO2.Emissions + (1 + CO2.Emissions | Country), data=dat )
This generates a random slope and intercept for each country. QUESTION: can I plot these and get something similar to (and as aesthetically pleasing as) the ggplot above? I want to visualize the relationships as depicted in the model, which ggplot2 is not doing.
Any help is appreciated!