* Chapter 3: Model Diagnostics using Stata . * Note: this syntax is based on Model 3.1, because models with * heterogeneous error variance structures cannot be fitted using the xtmixed command. * Fit Model 3.1 . xi: xtmixed weight i.treatment*i.sex litsize, || litter:, covariance(identity) variance *********************************************************. * Plot conditional raw residuals in each treatment group . *********************************************************. predict resid, resid * Histograms. twoway (histogram resid), by(treatment) * Q-Q plots. qnorm resid if treatment == "Control" qnorm resid if treatment == "High" qnorm resid if treatment == "Low" ***********************************************************************************. * Test residuals for normality in each treatment group using the Shapiro-Wilk test . ***********************************************************************************. gsort +treatment by treatment: swilk resid *****************************************************************************************. * Plot conditional raw residuals vs. conditional predicted values in each treatment group. *****************************************************************************************. predict fitted, fitted twoway (scatter resid fitted), by(treatment) *********************************************************. * Plot standardized residuals for each litter * (note: studentized residuals are currently unavailable). *********************************************************. predict stresid, rstandard graph box stresid, medtype(line) over(litter) * NOTE: Influence diagnostics are currently unavailable in Stata (Release 9.2).