Exercises
Practice the following exercises to revise the concepts learned thus far:
By far, the best way to become comfortable and learn the in-and-outs of applied regression analysis is to actually carry out regression analyses. To this end, you can use some of the many datasets that are included in R. To get a full listing of the datasets in the datasets package, execute the following:
> help(package="datasets")
There are hundreds of more datasets spread across the other several thousand R packages. Even better, load your own datasets, and attempt to model them.
Examine and plot the data set
pressure
, which describes the relationship between the vapor pressure of mercury and temperature. What assumption of linear regression does this violate? Attempt to model this using linear regression by usingtemperature
squared as a predictor, like this:> lm(pressure ~ I(temperature^2), data=pressure)
Compare the fit between the model that uses the non-squared
temperature
and this one. Explore...