Exercises


The following packages are required for this practical:

library(dplyr)
library(magrittr)
library(mice)
library(ggplot2)
library(DAAG)

The data sets elastic1 and elastic2 from the package DAAG were obtained using the same apparatus, including the same rubber band, as the data frame elasticband.

  1. Using a different symbol and/or a different color, plot the data from the two data frames elastic1 and elastic2 on the same graph. Do the two sets of results appear consistent?

  1. For each of the data sets elastic1 and elastic2, determine the regression of distance on stretch. In each case determine:

Compare the two sets of results. What is the key difference between the two sets of data?


  1. Study the residual vs leverage plots for both models. Hint use plot() on the fitted object

  1. Use the robust regression function rlm() from the MASS package to fit lines to the data in elastic1 and elastic2. Compare the results with those from use of lm():

  1. Use the elastic2 variable stretch to obtain predictions on the model fitted on elastic1.

  1. Now make a scatterplot to investigate similarity between plot the predicted values against the observed values for elastic2

The mammalsleep dataset is part of mice. It contains the Allison and Cicchetti (1976) data for mammalian species. To learn more about this data, type

?mammalsleep
## starting httpd help server ... done

  1. Fit and inspect a model where brw is modeled from bw

  1. Now fit and inspect a model where brw is predicted from both bw and species

  1. Can you find a model that improves the \(R^2\) in modeling brw?

  1. Inspect the diagnostic plots for the model obtained in exercise 12. What issues can you detect?

End of Practical.