









Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!










library(MASS) library(ISLR) names(Boston)
attach(Boston)
lm.fit=lm(medv~lstat ,data=Boston) lm.fit
names(lm.fit)
coef(lm.fit)
confint(lm.fit)
predict(lm.fit,data.frame(lstat=c( 5 , 10 , 15 )),interval ="confidence")
predict(lm.fit,data.frame(lstat=c( 5 , 10 , 15 )),interval ="prediction")
plot(lstat ,medv) abline(lm.fit) abline(lm.fit,lwd= 3 ,col="red")
plot(lstat ,medv ,pch="+") plot( 1 : 20 , 1 : 20 ,pch= 1 : 20 ) # These are the values for pch
par(mfrow=c( 2 , 2 )) plot(lm.fit)
plot(predict(lm.fit), rstudent (lm.fit))
plot(hatvalues (lm.fit)) which.max(hatvalues (lm.fit))
MULTIPLE LINEAR REGRESSION lm.fit=lm(medv~lstat+age ,data=Boston) summary(lm.fit)
lm.fit1=lm(medv~.-age,data=Boston) summary(lm.fit1)
Interaction term
summary(lm(medv~lstat*age,data=Boston))
Non-linear Transformations of the Predictors
lm.fit2=lm(medv~lstat+I(lstat^ 2 )) summary(lm.fit2)
lm.fit5=lm(medv~poly(lstat , 5 )) summary(lm.fit5)
summary(lm(medv~log(rm),data=Boston))
Qualitative Predictor
fix(Carseats) names(Carseats)
lm.fit=lm(Sales~.+Income:Advertising +Price:Age,data=Carseats) summary(lm.fit)