O'Reilly logo

R Graph Essentials by David Alexander Lillis

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Including a regression line and residuals

In the Creating scatterplots and line plots section in Chapter 1, Base Graphics in R – One Step at a Time, we saw how to use the abline() command and the lm() command to include a regression line in your graph. Now, we will take this idea a little further. The following regression uses a datafile in which a sample of 10 people rated a film by awarding scores out of 100. These people then viewed the film a second time 1 month later and again awarded scores. We wish to use a regression model to see how well the first rating scores predicted the second rating.

In an OLS regression with one predictor, we fit a model of the following form:

Yi  =  β0  +  β1 Xi  + ei

In this form, β0 is the intercept, β1 is the slope, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required