Gerrit Gort
Load the BodyWeight data from the nlme package.
Make a plot of weight against Time.
Fit a linear regression model to examine the relationship of time with Weight.
Extract the regression coefficients and the anova table.
Calculate the residual variance of the fitted model.
Make some diagnostic plots using standardized residuals.
Make a QQ-plot of the standardized residuals.
Use simulation to get some feeling for the size of deviations to be expected in QQ-plots, if data are normally distributed: draw repeatedly 25 observations from a standard normal distribution and make QQ-plots.
BodyWeight <- BodyWeight[with(BodyWeight,order(Rat,-Time)),]
BWf <- BodyWeight[!duplicated(BodyWeight$Rat),]
Plot the final weight for each diet.
Test the effect of diet on final weight.
Reparameterize the model and test if diet 1, 2, and/or 3 differ significantly from diet 4.
Make a plot of weight against time, where you can differentiate between the diets.
Fit an ancova model that includes a linear effect for time and an effect of diet.
Test if time and diet have a significant relationship with weight.
Optional: make a new data.frame with initial and final weight of the rats. Test if initial weight has a relationship with final weight.
Make a plot of weight against time, identify the effect of individuals rats.
Fit a model with rat as a random effect. Test if the improvement of fit is significant compared to a model without random rat effect.
Fit a model with a random slope for rats. Test the improvement of fit of this model.