* Chapter 4: Model Diagnostics using Stata . * Fit Model 4.2 (final model) using REML estimation . xtmixed mathgain mathkind sex minority ses || schoolid: || classid:, variance *******************************************************. * Save EBLUPs of random effects and generate Q-Q plots . *******************************************************. * Random classroom effects. predict cl_eblups, reffects level(classid) qnorm cl_eblups predict sc_eblups, reffects level(schoolid) qnorm sc_eblups *************************************************************************. * Plot conditional raw residuals at student level to check for normality . *************************************************************************. predict resid, resid qnorm resid ******************************************************************. * Plot conditional raw residuals vs. conditional predicted values, * and add the fit of a Loess smoother. ******************************************************************. predict fitted, fitted twoway (scatter resid fitted) (lowess resid fitted)