Load the sample data.
weight
contains data from a longitudinal study, where 20 subjects are randomly assigned to 4 exercise programs, and their weight loss is recorded over six 2-week time periods. This is simulated data.
Store the data in a table. Define Subject
and Program
as categorical variables.
Fit a linear mixed-effects model where the initial weight, type of program, week, and the interaction between the week and type of program are the fixed effects. The intercept and week vary by subject.
Plot the histogram of the raw residuals.
Plot the residuals versus the fitted values.
There is no obvious pattern, so there are no immediate signs of heteroscedasticity.
Create the normal probability plot of residuals.
Data appears to be normal.
Find the observation number for the data that appears to be an outlier to the right of the plot.
Create a box plot of the raw, Pearson, and standardized residuals.
All three box plots point out the outlier on the right tail of the distribution. The box plots of raw and Pearson residuals also point out a second possible outlier on the left tail. Find the corresponding observation number.
Plot the raw residuals versus lagged residuals.
There is no obvious pattern in the graph. The residuals do not appear to be correlated.