O'Reilly logo

Introduction to R for Business Intelligence by Jay Gendron

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

Refining data for simple linear regression

As discussed earlier, there may be times when your diagnostic plots indicate that the data does not meet all the assumptions specified by the LINE approach (Linearity, Independence, Normality, and Equal variance).

Consider the following simple dataset. Run a SLR and generate its diagnostic plots:

x0 <- c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10) 
y0 <- c(1.00, 1.41, 1.73, 2.00, 2.24, 
        2.45, 2.65, 2.83, 3.00, 3.16) 
fit0 <- lm(y0 ~ x0) 
 
par(mfrow = c(1, 3)) 
plot(x0, y0, pch = 19, main = "Linearity?"); abline(fit0) 
hist(fit0$residuals, main = "Normality?", col = "gray") 
plot(fit0$fitted.values, fit0$residuals,  
     main = "Equal Variance?", pch = 19); abline(h = 0) 

The diagnostic plots generated are as follows:

The first plot ...

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