load("kruiser.RData") View(kruiser) options(scipen = 999) initialmodel<-with(kruiser,lm(Price ~ Mileage + Cylinder + Sound + Leather)) summary(initialmodel) library(lm.beta) initialmodel<-lm.beta(initialmodel) summary(initialmodel) initialmodel2<-with(kruiser,lm(Price ~ Mileage + Liter + Sound + Leather)) summary(initialmodel2) initialmodel3<-with(kruiser,lm(Price ~ Mileage + Cylinder + Liter + Sound + Leather)) summary(initialmodel3) # Useful link: https://www.stat.berkeley.edu/~s133/factors.html kruiser$Cylinder<-as.factor(kruiser$Cylinder) str(kruiser) initialmodel4<-with(kruiser,lm(Price ~ Mileage + Cylinder + Sound + Leather)) summary(initialmodel4) # We finished here. Nevertheless it is worthwile to run the following lines improvedmodel<-with(kruiser,lm(Price ~ Mileage + Cylinder + Sound + Make+ Mileage:Cylinder)) summary(improvedmodel) kruiser$Priceestimated<-predict(improvedmodel,kruiser) kruiser$Priceestimated2<-fitted(improvedmodel) View(kruiser) plot(kruiser$Price,kruiser$Priceestimated)