require{car} library(car) attitude attach(attitude) Y=rating X1=complaints X2=privileges X3=learning X4=raises X5=critical X6=advance #attitude #Simple linear regression RM1=lm(Y~X1) Yhat1=fitted(RM1) plot(X1,Y) abline(RM1,col="blue") segments(X1,Yhat1,X1,Y,col="red") anova(RM1) RM2=lm(Y~X2) Yhat2=fitted(RM2) plot(X2,Y) abline(RM2,col="blue") segments(X2,Yhat2,X2,Y,col="red") anova(RM2) RM3=lm(Y~X3) Yhat3=fitted(RM3) plot(X3,Y) abline(RM3,col="blue") segments(X3,Yhat3,X3,Y,col="red") anova(RM3) RM4=lm(Y~X4) Yhat4=fitted(RM4) plot(X4,Y) abline(RM4,col="blue") segments(X4,Yhat4,X4,Y,col="red") anova(RM4) RM5=lm(Y~X5) Yhat5=fitted(RM5) plot(X5,Y) abline(RM5,col="blue") segments(X5,Yhat5,X5,Y,col="red") anova(RM5) RM6=lm(Y~X6) Yhat6=fitted(RM6) plot(X6,Y) abline(RM6,col="blue") segments(X6,Yhat6,X6,Y,col="red") anova(RM6) # Multipule regression full model # Reduced modle marginal FM=lm(Y~X1+X2+X3+X4+X5+X6) summary(FM) Anova(FM) drop1(FM) step(FM,direction="backward") RM13=lm(Y~X1+X3) anova(RM13,FM)