This R markdown file shows the data cleaning process as well as the process used to generate first order, interaction model and higher order models. It also shows the assumptions checks performed. However, the main elaboration on what each step means is in the report in PDF format.
car_dataset <- read.csv('Car details.csv')
#Remove rows with NA (221 rows)
car_dataset <- car_dataset[complete.cases(car_dataset), ]
#Remove the 'kmpl' / 'km per kg' for the mileage column
car_dataset$mileage = as.numeric(gsub("[^0-9.<>]", "", car_dataset$mileage))
#Remove Zero value mileage rows (17 rows)
car_dataset = car_dataset[car_dataset$mileage!=0, ]
#Remove the 'CC' for the engine column
car_dataset$engine = as.numeric(gsub("[^0-9.<>]", "", car_dataset$engine))
#Remove the 'bhp' for the max_power column
car_dataset$max_power = as.numeric(gsub("[^0-9.<>]", "", car_dataset$max_power))
#break the torque column into torque_nm and torque_rpm columns
for (i in 1:nrow(car_dataset)){
if(grepl('(kgm@ rpm)',car_dataset$torque[i])){
car_dataset$torque_nm[i] <-as.numeric(strsplit(car_dataset$torque[i], "[@]")[[1]][1])*9.80665 #covert from kgm to nm
car_dataset$torque_rpm[i] <-as.numeric(gsub("[^0-9.<>]", "",strsplit(car_dataset$torque[i], "@|-|~")[[1]][2]))
}
else if (grepl('kgm at',tolower(car_dataset$torque[i])))
{
car_dataset$torque_nm[i] <- as.numeric(gsub("[^0-9.<>]", "",strsplit(car_dataset$torque[i], "[at]")[[1]][1]))*9.80665
car_dataset$torque_rpm[i] <- as.numeric(gsub("[^0-9.<>]", "",strsplit(car_dataset$torque[i], c("at|-|~"))[[1]][2]))
}
else if (grepl('nm at',tolower(car_dataset$torque[i])))
{
car_dataset$torque_nm[i] <- as.numeric(gsub("[^0-9.<>]", "",strsplit(car_dataset$torque[i], "[at]")[[1]][1]))
car_dataset$torque_rpm[i] <- as.numeric(gsub("[^0-9.<>]", "",strsplit(car_dataset$torque[i], c("at|-|~"))[[1]][2]))
}
else if (grepl(' / ',car_dataset$torque[i]))
{
car_dataset$torque_nm[i] <- as.numeric(gsub("[^0-9.<>]", "",strsplit(car_dataset$torque[i], " / ")[[1]][1]))
car_dataset$torque_rpm[i] <- as.numeric(gsub("[^0-9.<>]", "",strsplit(car_dataset$torque[i], c(" / "))[[1]][2]))
}
else if (grepl('kgm@',car_dataset$torque[i]))
{
car_dataset$torque_nm[i] <- as.numeric(gsub("[^0-9.<>]", "",strsplit(car_dataset$torque[i], "[@]|\\(")[[1]][1]))*9.80665
car_dataset$torque_rpm[i] <- as.numeric(gsub("[^0-9.<>]", "",strsplit(car_dataset$torque[i], c("@|-|~"))[[1]][2]))
}
else
{
car_dataset$torque_nm[i] <- as.numeric(gsub("[^0-9.<>]", "",strsplit(car_dataset$torque[i], "[@]|\\(")[[1]][1]))
car_dataset$torque_rpm[i] <- as.numeric(gsub("[^0-9.<>]", "",strsplit(car_dataset$torque[i], c("@|-|~"))[[1]][2]))
}
}
#Remove rows with NA in torque_rpm (35 rows)
car_dataset <- car_dataset[complete.cases(car_dataset$torque_rpm), ]
library(mctest)
firstordermodel<-lm(selling_price~year+km_driven+factor(fuel)+factor(seller_type)+factor(transmission)+factor(owner)+mileage+engine+max_power+seats+torque_rpm, data=car_dataset)
imcdiag(firstordermodel, method="VIF")
##
## Call:
## imcdiag(mod = firstordermodel, method = "VIF")
##
##
## VIF Multicollinearity Diagnostics
##
## VIF detection
## year 2.0953 0
## km_driven 1.4386 0
## factor(fuel)Diesel 40.2806 1
## factor(fuel)LPG 1.6951 0
## factor(fuel)Petrol 39.1833 1
## factor(seller_type)Individual 1.4686 0
## factor(seller_type)Trustmark Dealer 1.2542 0
## factor(transmission)Manual 1.6409 0
## factor(owner)Fourth & Above Owner 1.1005 0
## factor(owner)Second Owner 1.2754 0
## factor(owner)Test Drive Car 1.0109 0
## factor(owner)Third Owner 1.1996 0
## mileage 3.0548 0
## engine 5.5554 0
## max_power 3.2619 0
## seats 2.3255 0
## torque_rpm 4.2029 0
##
## Multicollinearity may be due to factor(fuel)Diesel factor(fuel)Petrol regressors
##
## 1 --> COLLINEARITY is detected by the test
## 0 --> COLLINEARITY is not detected by the test
##
## ===================================
summary(firstordermodel)
##
## Call:
## lm(formula = selling_price ~ year + km_driven + factor(fuel) +
## factor(seller_type) + factor(transmission) + factor(owner) +
## mileage + engine + max_power + seats + torque_rpm, data = car_dataset)
##
## Residuals:
## Min 1Q Median 3Q Max
## -2194974 -189249 13230 162870 4367716
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -6.430e+07 3.756e+06 -17.118 < 2e-16 ***
## year 3.209e+04 1.879e+03 17.077 < 2e-16 ***
## km_driven -9.418e-01 1.057e-01 -8.913 < 2e-16 ***
## factor(fuel)Diesel -2.152e+05 6.381e+04 -3.373 0.000748 ***
## factor(fuel)LPG 2.399e+05 9.791e+04 2.450 0.014316 *
## factor(fuel)Petrol -1.571e+03 6.307e+04 -0.025 0.980130
## factor(seller_type)Individual -2.732e+05 1.615e+04 -16.912 < 2e-16 ***
## factor(seller_type)Trustmark Dealer -3.343e+05 3.286e+04 -10.173 < 2e-16 ***
## factor(transmission)Manual -4.278e+05 1.924e+04 -22.233 < 2e-16 ***
## factor(owner)Fourth & Above Owner 5.248e+03 3.731e+04 0.141 0.888142
## factor(owner)Second Owner -4.322e+04 1.296e+04 -3.335 0.000858 ***
## factor(owner)Test Drive Car 1.984e+06 1.997e+05 9.934 < 2e-16 ***
## factor(owner)Third Owner -1.363e+04 2.231e+04 -0.611 0.541258
## mileage 1.692e+04 2.219e+03 7.624 2.75e-14 ***
## engine 1.294e+02 2.346e+01 5.515 3.59e-08 ***
## max_power 1.225e+04 2.570e+02 47.646 < 2e-16 ***
## seats -3.813e+04 7.955e+03 -4.793 1.67e-06 ***
## torque_rpm -1.207e+02 9.021e+00 -13.380 < 2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 443900 on 7837 degrees of freedom
## Multiple R-squared: 0.6821, Adjusted R-squared: 0.6814
## F-statistic: 989.2 on 17 and 7837 DF, p-value: < 2.2e-16
aprs =ols_step_best_subset(firstordermodel, details=TRUE)
cp<-c(aprs$cp)
AIC<-c(aprs$aic)
AdjustedR<-c(aprs$adjr)
cbind(AdjustedR,cp,AIC)
## AdjustedR cp AIC
## [1,] 0.5463546 3331.20899 229355.4
## [2,] 0.6102392 1757.25232 228164.2
## [3,] 0.6430044 950.58254 227475.4
## [4,] 0.6607986 511.94464 227075.8
## [5,] 0.6657138 388.65051 226965.1
## [6,] 0.6695501 295.14547 226875.5
## [7,] 0.6743263 178.52764 226762.1
## [8,] 0.6768440 115.50213 226704.1
## [9,] 0.6799655 39.68024 226628.9
## [10,] 0.6805224 26.97430 226616.2
## [11,] 0.6814156 6.00000 226595.2
par(mfrow=c(2,2)) # split the plotting panel into a 2 x 2 grid
plot(aprs$cp,type = "o",pch=10, xlab="Number of Variables",ylab= "Cp")
plot(aprs$aic,type = "o",pch=10, xlab="Number of Variables",ylab= "AIC")
plot(aprs$adjr,type = "o",pch=10, xlab="Number of Variables",ylab= "Adjusted R^2")
best.subset<-regsubsets(selling_price~year+km_driven+factor(fuel)+factor(seller_type)+factor(transmission)+factor(owner)+mileage+engine+max_power+seats+torque_rpm, data=car_dataset, nv=11 )
reg.summary = summary(best.subset)
summary(best.subset)
## Subset selection object
## Call: regsubsets.formula(selling_price ~ year + km_driven + factor(fuel) +
## factor(seller_type) + factor(transmission) + factor(owner) +
## mileage + engine + max_power + seats + torque_rpm, data = car_dataset,
## nv = 11)
## 17 Variables (and intercept)
## Forced in Forced out
## year FALSE FALSE
## km_driven FALSE FALSE
## factor(fuel)Diesel FALSE FALSE
## factor(fuel)LPG FALSE FALSE
## factor(fuel)Petrol FALSE FALSE
## factor(seller_type)Individual FALSE FALSE
## factor(seller_type)Trustmark Dealer FALSE FALSE
## factor(transmission)Manual FALSE FALSE
## factor(owner)Fourth & Above Owner FALSE FALSE
## factor(owner)Second Owner FALSE FALSE
## factor(owner)Test Drive Car FALSE FALSE
## factor(owner)Third Owner FALSE FALSE
## mileage FALSE FALSE
## engine FALSE FALSE
## max_power FALSE FALSE
## seats FALSE FALSE
## torque_rpm FALSE FALSE
## 1 subsets of each size up to 11
## Selection Algorithm: exhaustive
## year km_driven factor(fuel)Diesel factor(fuel)LPG factor(fuel)Petrol
## 1 ( 1 ) " " " " " " " " " "
## 2 ( 1 ) "*" " " " " " " " "
## 3 ( 1 ) "*" " " " " " " " "
## 4 ( 1 ) "*" " " " " " " " "
## 5 ( 1 ) "*" " " " " " " " "
## 6 ( 1 ) "*" " " " " " " " "
## 7 ( 1 ) "*" "*" " " " " " "
## 8 ( 1 ) "*" "*" " " " " " "
## 9 ( 1 ) "*" "*" " " " " " "
## 10 ( 1 ) "*" "*" "*" " " " "
## 11 ( 1 ) "*" "*" "*" " " " "
## factor(seller_type)Individual factor(seller_type)Trustmark Dealer
## 1 ( 1 ) " " " "
## 2 ( 1 ) " " " "
## 3 ( 1 ) " " " "
## 4 ( 1 ) "*" " "
## 5 ( 1 ) "*" "*"
## 6 ( 1 ) "*" "*"
## 7 ( 1 ) "*" "*"
## 8 ( 1 ) "*" "*"
## 9 ( 1 ) "*" "*"
## 10 ( 1 ) "*" "*"
## 11 ( 1 ) "*" "*"
## factor(transmission)Manual factor(owner)Fourth & Above Owner
## 1 ( 1 ) " " " "
## 2 ( 1 ) " " " "
## 3 ( 1 ) "*" " "
## 4 ( 1 ) "*" " "
## 5 ( 1 ) "*" " "
## 6 ( 1 ) "*" " "
## 7 ( 1 ) "*" " "
## 8 ( 1 ) "*" " "
## 9 ( 1 ) "*" " "
## 10 ( 1 ) "*" " "
## 11 ( 1 ) "*" " "
## factor(owner)Second Owner factor(owner)Test Drive Car
## 1 ( 1 ) " " " "
## 2 ( 1 ) " " " "
## 3 ( 1 ) " " " "
## 4 ( 1 ) " " " "
## 5 ( 1 ) " " " "
## 6 ( 1 ) " " "*"
## 7 ( 1 ) " " " "
## 8 ( 1 ) " " "*"
## 9 ( 1 ) " " "*"
## 10 ( 1 ) " " "*"
## 11 ( 1 ) " " "*"
## factor(owner)Third Owner mileage engine max_power seats torque_rpm
## 1 ( 1 ) " " " " " " "*" " " " "
## 2 ( 1 ) " " " " " " "*" " " " "
## 3 ( 1 ) " " " " " " "*" " " " "
## 4 ( 1 ) " " " " " " "*" " " " "
## 5 ( 1 ) " " " " " " "*" " " " "
## 6 ( 1 ) " " " " " " "*" " " " "
## 7 ( 1 ) " " " " " " "*" " " "*"
## 8 ( 1 ) " " " " " " "*" " " "*"
## 9 ( 1 ) " " " " " " "*" "*" "*"
## 10 ( 1 ) " " "*" " " "*" " " "*"
## 11 ( 1 ) " " "*" "*" "*" " " "*"
rsquare<-c(reg.summary$rsq)
cp<-c(reg.summary$cp)
AdjustedR<-c(reg.summary$adjr2)
RMSE<-c(reg.summary$rss)
BIC<-c(reg.summary$bic)
cbind(rsquare,cp,BIC,RMSE,AdjustedR)
## rsquare cp BIC RMSE AdjustedR
## [1,] 0.5464124 3331.20899 -6191.965 2.203705e+15 0.5463546
## [2,] 0.6103384 1757.25232 -7376.248 1.893128e+15 0.6102392
## [3,] 0.6431408 950.58254 -8058.025 1.733761e+15 0.6430044
## [4,] 0.6544121 674.71311 -8301.157 1.679001e+15 0.6542360
## [5,] 0.6610145 513.94464 -8443.710 1.646924e+15 0.6607986
## [6,] 0.6655708 403.61864 -8541.036 1.624787e+15 0.6653151
## [7,] 0.6698752 299.50357 -8633.824 1.603875e+15 0.6695807
## [8,] 0.6742847 192.79794 -8730.481 1.582452e+15 0.6739526
## [9,] 0.6767009 135.23129 -8779.999 1.570713e+15 0.6763300
## [10,] 0.6797097 63.05667 -8844.475 1.556095e+15 0.6793013
## [11,] 0.6803057 50.36254 -8850.137 1.553200e+15 0.6798573
par(mfrow=c(3,2)) # split the plotting panel into a 3 x 2 grid
plot(reg.summary$cp,type = "o",pch=10, xlab="Number of Variables",ylab= "Cp")
plot(reg.summary$bic,type = "o",pch=10, xlab="Number of Variables",ylab= "BIC")
plot(reg.summary$rsq,type = "o",pch=10, xlab="Number of Variables",ylab= "R^2")
plot(reg.summary$rss,type = "o",pch=10, xlab="Number of Variables",ylab= "RMSE")
plot(reg.summary$adjr2,type = "o",pch=10, xlab="Number of Variables",ylab= "Adjusted R^2")
# F test on seats
reduced_model = lm(selling_price~year+km_driven+factor(fuel)+factor(seller_type)+factor(transmission)+factor(owner)+mileage+engine+max_power+torque_rpm, data=car_dataset)
anova(reduced_model, firstordermodel)
intmodel = lm(selling_price~(year+km_driven+factor(fuel)+factor(seller_type)+factor(transmission)+factor(owner)+mileage+engine+max_power+seats+torque_rpm)^2, data=car_dataset)
# Took out insignifant terms
reducedint = lm(selling_price~year+km_driven+factor(fuel)+factor(seller_type)+factor(transmission)+factor(owner)+mileage+engine+max_power+seats+torque_rpm + year*km_driven + year*factor(seller_type) + year*factor(transmission) + year*mileage + year*engine + year*max_power + year*torque_rpm + km_driven*factor(seller_type) + km_driven*factor(transmission) + km_driven*max_power + factor(fuel)*factor(transmission) + factor(fuel)*factor(owner) + factor(seller_type)*factor(transmission) + factor(seller_type)*factor(owner) + factor(seller_type)*mileage + factor(seller_type)*engine +factor(seller_type)*max_power + factor(transmission)*factor(owner) + factor(transmission)*mileage + factor(transmission)*engine + factor(transmission)*max_power + factor(transmission)*seats + factor(transmission)*torque_rpm + factor(owner)*mileage + factor(owner)*engine + factor(owner)*torque_rpm + mileage*engine + mileage*max_power + engine*max_power + engine*torque_rpm + max_power*seats + max_power*torque_rpm, data=car_dataset)
# took out interaction between factor owner and torque rpm
reducedint2 = lm(selling_price~year+km_driven+factor(fuel)+factor(seller_type)+factor(transmission)+factor(owner)+mileage+engine+max_power+seats+torque_rpm + year*km_driven + year*factor(seller_type) + year*factor(transmission) + year*mileage + year*engine + year*max_power + year*torque_rpm + km_driven*factor(seller_type) + km_driven*factor(transmission) + km_driven*max_power + factor(fuel)*factor(transmission) + factor(fuel)*factor(owner) + factor(seller_type)*factor(transmission) + factor(seller_type)*factor(owner) + factor(seller_type)*mileage + factor(seller_type)*engine +factor(seller_type)*max_power + factor(transmission)*factor(owner) + factor(transmission)*mileage + factor(transmission)*engine + factor(transmission)*max_power + factor(transmission)*seats + factor(transmission)*torque_rpm + factor(owner)*mileage + factor(owner)*engine + mileage*engine + mileage*max_power + engine*max_power + engine*torque_rpm + max_power*seats + max_power*torque_rpm, data=car_dataset)
summary(reducedint2)
##
## Call:
## lm(formula = selling_price ~ year + km_driven + factor(fuel) +
## factor(seller_type) + factor(transmission) + factor(owner) +
## mileage + engine + max_power + seats + torque_rpm + year *
## km_driven + year * factor(seller_type) + year * factor(transmission) +
## year * mileage + year * engine + year * max_power + year *
## torque_rpm + km_driven * factor(seller_type) + km_driven *
## factor(transmission) + km_driven * max_power + factor(fuel) *
## factor(transmission) + factor(fuel) * factor(owner) + factor(seller_type) *
## factor(transmission) + factor(seller_type) * factor(owner) +
## factor(seller_type) * mileage + factor(seller_type) * engine +
## factor(seller_type) * max_power + factor(transmission) *
## factor(owner) + factor(transmission) * mileage + factor(transmission) *
## engine + factor(transmission) * max_power + factor(transmission) *
## seats + factor(transmission) * torque_rpm + factor(owner) *
## mileage + factor(owner) * engine + mileage * engine + mileage *
## max_power + engine * max_power + engine * torque_rpm + max_power *
## seats + max_power * torque_rpm, data = car_dataset)
##
## Residuals:
## Min 1Q Median 3Q Max
## -2823325 -82100 -3035 81121 2124031
##
## Coefficients: (11 not defined because of singularities)
## Estimate
## (Intercept) -4.410e+07
## year 2.043e+04
## km_driven 2.099e+02
## factor(fuel)Diesel 4.621e+05
## factor(fuel)LPG -3.421e+04
## factor(fuel)Petrol -6.874e+04
## factor(seller_type)Individual 5.169e+07
## factor(seller_type)Trustmark Dealer 4.170e+07
## factor(transmission)Manual 9.040e+07
## factor(owner)Fourth & Above Owner 6.515e+05
## factor(owner)Second Owner 4.965e+04
## factor(owner)Test Drive Car 3.817e+07
## factor(owner)Third Owner 6.300e+05
## mileage -3.408e+06
## engine 1.869e+04
## max_power -2.664e+06
## seats 1.073e+05
## torque_rpm 2.099e+04
## year:km_driven -1.065e-01
## year:factor(seller_type)Individual -2.539e+04
## year:factor(seller_type)Trustmark Dealer -2.114e+04
## year:factor(transmission)Manual -4.400e+04
## year:mileage 1.709e+03
## year:engine -9.416e+00
## year:max_power 1.335e+03
## year:torque_rpm -1.029e+01
## km_driven:factor(seller_type)Individual 1.755e+00
## km_driven:factor(seller_type)Trustmark Dealer 3.866e+00
## km_driven:factor(transmission)Manual 3.210e+00
## km_driven:max_power -8.784e-03
## factor(fuel)Diesel:factor(transmission)Manual -4.418e+05
## factor(fuel)LPG:factor(transmission)Manual NA
## factor(fuel)Petrol:factor(transmission)Manual NA
## factor(fuel)Diesel:factor(owner)Fourth & Above Owner 1.540e+05
## factor(fuel)LPG:factor(owner)Fourth & Above Owner 6.880e+03
## factor(fuel)Petrol:factor(owner)Fourth & Above Owner 2.126e+04
## factor(fuel)Diesel:factor(owner)Second Owner 3.694e+04
## factor(fuel)LPG:factor(owner)Second Owner -3.817e+04
## factor(fuel)Petrol:factor(owner)Second Owner 3.949e+04
## factor(fuel)Diesel:factor(owner)Test Drive Car 1.360e+07
## factor(fuel)LPG:factor(owner)Test Drive Car NA
## factor(fuel)Petrol:factor(owner)Test Drive Car NA
## factor(fuel)Diesel:factor(owner)Third Owner 1.156e+04
## factor(fuel)LPG:factor(owner)Third Owner -1.054e+05
## factor(fuel)Petrol:factor(owner)Third Owner 9.407e+03
## factor(seller_type)Individual:factor(transmission)Manual 2.746e+04
## factor(seller_type)Trustmark Dealer:factor(transmission)Manual 2.399e+05
## factor(seller_type)Individual:factor(owner)Fourth & Above Owner NA
## factor(seller_type)Trustmark Dealer:factor(owner)Fourth & Above Owner NA
## factor(seller_type)Individual:factor(owner)Second Owner -4.810e+04
## factor(seller_type)Trustmark Dealer:factor(owner)Second Owner -4.833e+05
## factor(seller_type)Individual:factor(owner)Test Drive Car NA
## factor(seller_type)Trustmark Dealer:factor(owner)Test Drive Car NA
## factor(seller_type)Individual:factor(owner)Third Owner -2.314e+05
## factor(seller_type)Trustmark Dealer:factor(owner)Third Owner NA
## factor(seller_type)Individual:mileage -1.343e+04
## factor(seller_type)Trustmark Dealer:mileage 7.107e+03
## factor(seller_type)Individual:engine 1.630e+02
## factor(seller_type)Trustmark Dealer:engine 5.313e+02
## factor(seller_type)Individual:max_power -6.796e+03
## factor(seller_type)Trustmark Dealer:max_power -3.118e+03
## factor(transmission)Manual:factor(owner)Fourth & Above Owner -3.295e+05
## factor(transmission)Manual:factor(owner)Second Owner -8.297e+04
## factor(transmission)Manual:factor(owner)Test Drive Car NA
## factor(transmission)Manual:factor(owner)Third Owner -3.364e+05
## factor(transmission)Manual:mileage -1.735e+04
## factor(transmission)Manual:engine 5.098e+02
## factor(transmission)Manual:max_power -1.450e+04
## factor(transmission)Manual:seats -3.607e+04
## factor(transmission)Manual:torque_rpm -1.685e+02
## factor(owner)Fourth & Above Owner:mileage -1.446e+04
## factor(owner)Second Owner:mileage 1.648e+03
## factor(owner)Test Drive Car:mileage -2.331e+06
## factor(owner)Third Owner:mileage -2.785e+03
## factor(owner)Fourth & Above Owner:engine -1.385e+02
## factor(owner)Second Owner:engine -3.141e+00
## factor(owner)Test Drive Car:engine NA
## factor(owner)Third Owner:engine -3.611e+01
## mileage:engine -1.241e+01
## mileage:max_power 1.789e+02
## engine:max_power 1.768e+00
## engine:torque_rpm -1.366e-01
## max_power:seats -6.986e+02
## max_power:torque_rpm 1.027e+00
## Std. Error
## (Intercept) 2.214e+07
## year 1.103e+04
## km_driven 2.986e+01
## factor(fuel)Diesel 5.626e+04
## factor(fuel)LPG 7.184e+04
## factor(fuel)Petrol 4.315e+04
## factor(seller_type)Individual 7.825e+06
## factor(seller_type)Trustmark Dealer 4.224e+07
## factor(transmission)Manual 9.854e+06
## factor(owner)Fourth & Above Owner 3.419e+05
## factor(owner)Second Owner 1.273e+05
## factor(owner)Test Drive Car 3.504e+06
## factor(owner)Third Owner 2.714e+05
## mileage 6.072e+05
## engine 6.493e+03
## max_power 8.616e+04
## seats 2.682e+04
## torque_rpm 1.818e+03
## year:km_driven 1.483e-02
## year:factor(seller_type)Individual 3.890e+03
## year:factor(seller_type)Trustmark Dealer 2.093e+04
## year:factor(transmission)Manual 4.913e+03
## year:mileage 3.011e+02
## year:engine 3.227e+00
## year:max_power 4.287e+01
## year:torque_rpm 9.012e-01
## km_driven:factor(seller_type)Individual 3.231e-01
## km_driven:factor(seller_type)Trustmark Dealer 1.805e+00
## km_driven:factor(transmission)Manual 3.580e-01
## km_driven:max_power 2.035e-03
## factor(fuel)Diesel:factor(transmission)Manual 4.060e+04
## factor(fuel)LPG:factor(transmission)Manual NA
## factor(fuel)Petrol:factor(transmission)Manual NA
## factor(fuel)Diesel:factor(owner)Fourth & Above Owner 2.501e+05
## factor(fuel)LPG:factor(owner)Fourth & Above Owner 3.444e+05
## factor(fuel)Petrol:factor(owner)Fourth & Above Owner 2.441e+05
## factor(fuel)Diesel:factor(owner)Second Owner 7.421e+04
## factor(fuel)LPG:factor(owner)Second Owner 1.178e+05
## factor(fuel)Petrol:factor(owner)Second Owner 7.539e+04
## factor(fuel)Diesel:factor(owner)Test Drive Car 1.525e+06
## factor(fuel)LPG:factor(owner)Test Drive Car NA
## factor(fuel)Petrol:factor(owner)Test Drive Car NA
## factor(fuel)Diesel:factor(owner)Third Owner 1.747e+05
## factor(fuel)LPG:factor(owner)Third Owner 2.129e+05
## factor(fuel)Petrol:factor(owner)Third Owner 1.747e+05
## factor(seller_type)Individual:factor(transmission)Manual 2.644e+04
## factor(seller_type)Trustmark Dealer:factor(transmission)Manual 5.978e+04
## factor(seller_type)Individual:factor(owner)Fourth & Above Owner NA
## factor(seller_type)Trustmark Dealer:factor(owner)Fourth & Above Owner NA
## factor(seller_type)Individual:factor(owner)Second Owner 2.946e+04
## factor(seller_type)Trustmark Dealer:factor(owner)Second Owner 1.202e+05
## factor(seller_type)Individual:factor(owner)Test Drive Car NA
## factor(seller_type)Trustmark Dealer:factor(owner)Test Drive Car NA
## factor(seller_type)Individual:factor(owner)Third Owner 1.217e+05
## factor(seller_type)Trustmark Dealer:factor(owner)Third Owner NA
## factor(seller_type)Individual:mileage 2.814e+03
## factor(seller_type)Trustmark Dealer:mileage 9.664e+03
## factor(seller_type)Individual:engine 3.696e+01
## factor(seller_type)Trustmark Dealer:engine 1.146e+02
## factor(seller_type)Individual:max_power 4.551e+02
## factor(seller_type)Trustmark Dealer:max_power 2.187e+03
## factor(transmission)Manual:factor(owner)Fourth & Above Owner 1.034e+05
## factor(transmission)Manual:factor(owner)Second Owner 2.943e+04
## factor(transmission)Manual:factor(owner)Test Drive Car NA
## factor(transmission)Manual:factor(owner)Third Owner 6.542e+04
## factor(transmission)Manual:mileage 4.772e+03
## factor(transmission)Manual:engine 5.478e+01
## factor(transmission)Manual:max_power 5.400e+02
## factor(transmission)Manual:seats 1.954e+04
## factor(transmission)Manual:torque_rpm 1.716e+01
## factor(owner)Fourth & Above Owner:mileage 8.909e+03
## factor(owner)Second Owner:mileage 2.797e+03
## factor(owner)Test Drive Car:mileage 2.247e+05
## factor(owner)Third Owner:mileage 5.190e+03
## factor(owner)Fourth & Above Owner:engine 7.174e+01
## factor(owner)Second Owner:engine 2.554e+01
## factor(owner)Test Drive Car:engine NA
## factor(owner)Third Owner:engine 4.335e+01
## mileage:engine 3.368e+00
## mileage:max_power 3.758e+01
## engine:max_power 2.815e-01
## engine:torque_rpm 1.609e-02
## max_power:seats 1.321e+02
## max_power:torque_rpm 2.174e-01
## t value
## (Intercept) -1.992
## year 1.852
## km_driven 7.031
## factor(fuel)Diesel 8.213
## factor(fuel)LPG -0.476
## factor(fuel)Petrol -1.593
## factor(seller_type)Individual 6.606
## factor(seller_type)Trustmark Dealer 0.987
## factor(transmission)Manual 9.174
## factor(owner)Fourth & Above Owner 1.906
## factor(owner)Second Owner 0.390
## factor(owner)Test Drive Car 10.893
## factor(owner)Third Owner 2.321
## mileage -5.613
## engine 2.879
## max_power -30.922
## seats 4.001
## torque_rpm 11.547
## year:km_driven -7.181
## year:factor(seller_type)Individual -6.526
## year:factor(seller_type)Trustmark Dealer -1.010
## year:factor(transmission)Manual -8.955
## year:mileage 5.677
## year:engine -2.918
## year:max_power 31.130
## year:torque_rpm -11.418
## km_driven:factor(seller_type)Individual 5.432
## km_driven:factor(seller_type)Trustmark Dealer 2.142
## km_driven:factor(transmission)Manual 8.968
## km_driven:max_power -4.317
## factor(fuel)Diesel:factor(transmission)Manual -10.880
## factor(fuel)LPG:factor(transmission)Manual NA
## factor(fuel)Petrol:factor(transmission)Manual NA
## factor(fuel)Diesel:factor(owner)Fourth & Above Owner 0.615
## factor(fuel)LPG:factor(owner)Fourth & Above Owner 0.020
## factor(fuel)Petrol:factor(owner)Fourth & Above Owner 0.087
## factor(fuel)Diesel:factor(owner)Second Owner 0.498
## factor(fuel)LPG:factor(owner)Second Owner -0.324
## factor(fuel)Petrol:factor(owner)Second Owner 0.524
## factor(fuel)Diesel:factor(owner)Test Drive Car 8.918
## factor(fuel)LPG:factor(owner)Test Drive Car NA
## factor(fuel)Petrol:factor(owner)Test Drive Car NA
## factor(fuel)Diesel:factor(owner)Third Owner 0.066
## factor(fuel)LPG:factor(owner)Third Owner -0.495
## factor(fuel)Petrol:factor(owner)Third Owner 0.054
## factor(seller_type)Individual:factor(transmission)Manual 1.038
## factor(seller_type)Trustmark Dealer:factor(transmission)Manual 4.013
## factor(seller_type)Individual:factor(owner)Fourth & Above Owner NA
## factor(seller_type)Trustmark Dealer:factor(owner)Fourth & Above Owner NA
## factor(seller_type)Individual:factor(owner)Second Owner -1.633
## factor(seller_type)Trustmark Dealer:factor(owner)Second Owner -4.021
## factor(seller_type)Individual:factor(owner)Test Drive Car NA
## factor(seller_type)Trustmark Dealer:factor(owner)Test Drive Car NA
## factor(seller_type)Individual:factor(owner)Third Owner -1.902
## factor(seller_type)Trustmark Dealer:factor(owner)Third Owner NA
## factor(seller_type)Individual:mileage -4.775
## factor(seller_type)Trustmark Dealer:mileage 0.735
## factor(seller_type)Individual:engine 4.409
## factor(seller_type)Trustmark Dealer:engine 4.637
## factor(seller_type)Individual:max_power -14.934
## factor(seller_type)Trustmark Dealer:max_power -1.426
## factor(transmission)Manual:factor(owner)Fourth & Above Owner -3.187
## factor(transmission)Manual:factor(owner)Second Owner -2.819
## factor(transmission)Manual:factor(owner)Test Drive Car NA
## factor(transmission)Manual:factor(owner)Third Owner -5.141
## factor(transmission)Manual:mileage -3.635
## factor(transmission)Manual:engine 9.307
## factor(transmission)Manual:max_power -26.858
## factor(transmission)Manual:seats -1.846
## factor(transmission)Manual:torque_rpm -9.814
## factor(owner)Fourth & Above Owner:mileage -1.623
## factor(owner)Second Owner:mileage 0.589
## factor(owner)Test Drive Car:mileage -10.376
## factor(owner)Third Owner:mileage -0.537
## factor(owner)Fourth & Above Owner:engine -1.930
## factor(owner)Second Owner:engine -0.123
## factor(owner)Test Drive Car:engine NA
## factor(owner)Third Owner:engine -0.833
## mileage:engine -3.684
## mileage:max_power 4.761
## engine:max_power 6.281
## engine:torque_rpm -8.492
## max_power:seats -5.287
## max_power:torque_rpm 4.722
## Pr(>|t|)
## (Intercept) 0.046412
## year 0.064011
## km_driven 2.22e-12
## factor(fuel)Diesel 2.50e-16
## factor(fuel)LPG 0.633916
## factor(fuel)Petrol 0.111183
## factor(seller_type)Individual 4.21e-11
## factor(seller_type)Trustmark Dealer 0.323559
## factor(transmission)Manual < 2e-16
## factor(owner)Fourth & Above Owner 0.056738
## factor(owner)Second Owner 0.696527
## factor(owner)Test Drive Car < 2e-16
## factor(owner)Third Owner 0.020287
## mileage 2.05e-08
## engine 0.004005
## max_power < 2e-16
## seats 6.37e-05
## torque_rpm < 2e-16
## year:km_driven 7.54e-13
## year:factor(seller_type)Individual 7.18e-11
## year:factor(seller_type)Trustmark Dealer 0.312619
## year:factor(transmission)Manual < 2e-16
## year:mileage 1.42e-08
## year:engine 0.003531
## year:max_power < 2e-16
## year:torque_rpm < 2e-16
## km_driven:factor(seller_type)Individual 5.75e-08
## km_driven:factor(seller_type)Trustmark Dealer 0.032220
## km_driven:factor(transmission)Manual < 2e-16
## km_driven:max_power 1.60e-05
## factor(fuel)Diesel:factor(transmission)Manual < 2e-16
## factor(fuel)LPG:factor(transmission)Manual NA
## factor(fuel)Petrol:factor(transmission)Manual NA
## factor(fuel)Diesel:factor(owner)Fourth & Above Owner 0.538269
## factor(fuel)LPG:factor(owner)Fourth & Above Owner 0.984062
## factor(fuel)Petrol:factor(owner)Fourth & Above Owner 0.930614
## factor(fuel)Diesel:factor(owner)Second Owner 0.618620
## factor(fuel)LPG:factor(owner)Second Owner 0.745973
## factor(fuel)Petrol:factor(owner)Second Owner 0.600422
## factor(fuel)Diesel:factor(owner)Test Drive Car < 2e-16
## factor(fuel)LPG:factor(owner)Test Drive Car NA
## factor(fuel)Petrol:factor(owner)Test Drive Car NA
## factor(fuel)Diesel:factor(owner)Third Owner 0.947250
## factor(fuel)LPG:factor(owner)Third Owner 0.620524
## factor(fuel)Petrol:factor(owner)Third Owner 0.957061
## factor(seller_type)Individual:factor(transmission)Manual 0.299166
## factor(seller_type)Trustmark Dealer:factor(transmission)Manual 6.04e-05
## factor(seller_type)Individual:factor(owner)Fourth & Above Owner NA
## factor(seller_type)Trustmark Dealer:factor(owner)Fourth & Above Owner NA
## factor(seller_type)Individual:factor(owner)Second Owner 0.102540
## factor(seller_type)Trustmark Dealer:factor(owner)Second Owner 5.85e-05
## factor(seller_type)Individual:factor(owner)Test Drive Car NA
## factor(seller_type)Trustmark Dealer:factor(owner)Test Drive Car NA
## factor(seller_type)Individual:factor(owner)Third Owner 0.057189
## factor(seller_type)Trustmark Dealer:factor(owner)Third Owner NA
## factor(seller_type)Individual:mileage 1.83e-06
## factor(seller_type)Trustmark Dealer:mileage 0.462135
## factor(seller_type)Individual:engine 1.05e-05
## factor(seller_type)Trustmark Dealer:engine 3.59e-06
## factor(seller_type)Individual:max_power < 2e-16
## factor(seller_type)Trustmark Dealer:max_power 0.154007
## factor(transmission)Manual:factor(owner)Fourth & Above Owner 0.001445
## factor(transmission)Manual:factor(owner)Second Owner 0.004829
## factor(transmission)Manual:factor(owner)Test Drive Car NA
## factor(transmission)Manual:factor(owner)Third Owner 2.80e-07
## factor(transmission)Manual:mileage 0.000279
## factor(transmission)Manual:engine < 2e-16
## factor(transmission)Manual:max_power < 2e-16
## factor(transmission)Manual:seats 0.064863
## factor(transmission)Manual:torque_rpm < 2e-16
## factor(owner)Fourth & Above Owner:mileage 0.104547
## factor(owner)Second Owner:mileage 0.555839
## factor(owner)Test Drive Car:mileage < 2e-16
## factor(owner)Third Owner:mileage 0.591576
## factor(owner)Fourth & Above Owner:engine 0.053590
## factor(owner)Second Owner:engine 0.902132
## factor(owner)Test Drive Car:engine NA
## factor(owner)Third Owner:engine 0.404819
## mileage:engine 0.000231
## mileage:max_power 1.96e-06
## engine:max_power 3.54e-10
## engine:torque_rpm < 2e-16
## max_power:seats 1.28e-07
## max_power:torque_rpm 2.38e-06
##
## (Intercept) *
## year .
## km_driven ***
## factor(fuel)Diesel ***
## factor(fuel)LPG
## factor(fuel)Petrol
## factor(seller_type)Individual ***
## factor(seller_type)Trustmark Dealer
## factor(transmission)Manual ***
## factor(owner)Fourth & Above Owner .
## factor(owner)Second Owner
## factor(owner)Test Drive Car ***
## factor(owner)Third Owner *
## mileage ***
## engine **
## max_power ***
## seats ***
## torque_rpm ***
## year:km_driven ***
## year:factor(seller_type)Individual ***
## year:factor(seller_type)Trustmark Dealer
## year:factor(transmission)Manual ***
## year:mileage ***
## year:engine **
## year:max_power ***
## year:torque_rpm ***
## km_driven:factor(seller_type)Individual ***
## km_driven:factor(seller_type)Trustmark Dealer *
## km_driven:factor(transmission)Manual ***
## km_driven:max_power ***
## factor(fuel)Diesel:factor(transmission)Manual ***
## factor(fuel)LPG:factor(transmission)Manual
## factor(fuel)Petrol:factor(transmission)Manual
## factor(fuel)Diesel:factor(owner)Fourth & Above Owner
## factor(fuel)LPG:factor(owner)Fourth & Above Owner
## factor(fuel)Petrol:factor(owner)Fourth & Above Owner
## factor(fuel)Diesel:factor(owner)Second Owner
## factor(fuel)LPG:factor(owner)Second Owner
## factor(fuel)Petrol:factor(owner)Second Owner
## factor(fuel)Diesel:factor(owner)Test Drive Car ***
## factor(fuel)LPG:factor(owner)Test Drive Car
## factor(fuel)Petrol:factor(owner)Test Drive Car
## factor(fuel)Diesel:factor(owner)Third Owner
## factor(fuel)LPG:factor(owner)Third Owner
## factor(fuel)Petrol:factor(owner)Third Owner
## factor(seller_type)Individual:factor(transmission)Manual
## factor(seller_type)Trustmark Dealer:factor(transmission)Manual ***
## factor(seller_type)Individual:factor(owner)Fourth & Above Owner
## factor(seller_type)Trustmark Dealer:factor(owner)Fourth & Above Owner
## factor(seller_type)Individual:factor(owner)Second Owner
## factor(seller_type)Trustmark Dealer:factor(owner)Second Owner ***
## factor(seller_type)Individual:factor(owner)Test Drive Car
## factor(seller_type)Trustmark Dealer:factor(owner)Test Drive Car
## factor(seller_type)Individual:factor(owner)Third Owner .
## factor(seller_type)Trustmark Dealer:factor(owner)Third Owner
## factor(seller_type)Individual:mileage ***
## factor(seller_type)Trustmark Dealer:mileage
## factor(seller_type)Individual:engine ***
## factor(seller_type)Trustmark Dealer:engine ***
## factor(seller_type)Individual:max_power ***
## factor(seller_type)Trustmark Dealer:max_power
## factor(transmission)Manual:factor(owner)Fourth & Above Owner **
## factor(transmission)Manual:factor(owner)Second Owner **
## factor(transmission)Manual:factor(owner)Test Drive Car
## factor(transmission)Manual:factor(owner)Third Owner ***
## factor(transmission)Manual:mileage ***
## factor(transmission)Manual:engine ***
## factor(transmission)Manual:max_power ***
## factor(transmission)Manual:seats .
## factor(transmission)Manual:torque_rpm ***
## factor(owner)Fourth & Above Owner:mileage
## factor(owner)Second Owner:mileage
## factor(owner)Test Drive Car:mileage ***
## factor(owner)Third Owner:mileage
## factor(owner)Fourth & Above Owner:engine .
## factor(owner)Second Owner:engine
## factor(owner)Test Drive Car:engine
## factor(owner)Third Owner:engine
## mileage:engine ***
## mileage:max_power ***
## engine:max_power ***
## engine:torque_rpm ***
## max_power:seats ***
## max_power:torque_rpm ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 237900 on 7782 degrees of freedom
## Multiple R-squared: 0.9093, Adjusted R-squared: 0.9085
## F-statistic: 1084 on 72 and 7782 DF, p-value: < 2.2e-16
reducedint3 = lm(log(selling_price)~year+km_driven+factor(fuel)+factor(seller_type)+factor(transmission)+factor(owner)+mileage+engine+max_power+seats+torque_rpm + year*km_driven + year*factor(seller_type) + year*factor(transmission) + year*mileage + year*engine + year*max_power + year*torque_rpm + km_driven*factor(seller_type) + km_driven*factor(transmission) + km_driven*max_power + factor(fuel)*factor(transmission) + factor(fuel)*factor(owner) + factor(seller_type)*factor(transmission) + factor(seller_type)*factor(owner) + factor(seller_type)*mileage + factor(seller_type)*engine +factor(seller_type)*max_power + factor(transmission)*factor(owner) + factor(transmission)*mileage + factor(transmission)*engine + factor(transmission)*max_power + factor(transmission)*seats + factor(transmission)*torque_rpm + factor(owner)*mileage + factor(owner)*engine + mileage*engine + mileage*max_power + engine*max_power + engine*torque_rpm + max_power*seats + max_power*torque_rpm, data=car_dataset)
anova(reducedint2, reducedint)
summary(reducedint2)
##
## Call:
## lm(formula = selling_price ~ year + km_driven + factor(fuel) +
## factor(seller_type) + factor(transmission) + factor(owner) +
## mileage + engine + max_power + seats + torque_rpm + year *
## km_driven + year * factor(seller_type) + year * factor(transmission) +
## year * mileage + year * engine + year * max_power + year *
## torque_rpm + km_driven * factor(seller_type) + km_driven *
## factor(transmission) + km_driven * max_power + factor(fuel) *
## factor(transmission) + factor(fuel) * factor(owner) + factor(seller_type) *
## factor(transmission) + factor(seller_type) * factor(owner) +
## factor(seller_type) * mileage + factor(seller_type) * engine +
## factor(seller_type) * max_power + factor(transmission) *
## factor(owner) + factor(transmission) * mileage + factor(transmission) *
## engine + factor(transmission) * max_power + factor(transmission) *
## seats + factor(transmission) * torque_rpm + factor(owner) *
## mileage + factor(owner) * engine + mileage * engine + mileage *
## max_power + engine * max_power + engine * torque_rpm + max_power *
## seats + max_power * torque_rpm, data = car_dataset)
##
## Residuals:
## Min 1Q Median 3Q Max
## -2823325 -82100 -3035 81121 2124031
##
## Coefficients: (11 not defined because of singularities)
## Estimate
## (Intercept) -4.410e+07
## year 2.043e+04
## km_driven 2.099e+02
## factor(fuel)Diesel 4.621e+05
## factor(fuel)LPG -3.421e+04
## factor(fuel)Petrol -6.874e+04
## factor(seller_type)Individual 5.169e+07
## factor(seller_type)Trustmark Dealer 4.170e+07
## factor(transmission)Manual 9.040e+07
## factor(owner)Fourth & Above Owner 6.515e+05
## factor(owner)Second Owner 4.965e+04
## factor(owner)Test Drive Car 3.817e+07
## factor(owner)Third Owner 6.300e+05
## mileage -3.408e+06
## engine 1.869e+04
## max_power -2.664e+06
## seats 1.073e+05
## torque_rpm 2.099e+04
## year:km_driven -1.065e-01
## year:factor(seller_type)Individual -2.539e+04
## year:factor(seller_type)Trustmark Dealer -2.114e+04
## year:factor(transmission)Manual -4.400e+04
## year:mileage 1.709e+03
## year:engine -9.416e+00
## year:max_power 1.335e+03
## year:torque_rpm -1.029e+01
## km_driven:factor(seller_type)Individual 1.755e+00
## km_driven:factor(seller_type)Trustmark Dealer 3.866e+00
## km_driven:factor(transmission)Manual 3.210e+00
## km_driven:max_power -8.784e-03
## factor(fuel)Diesel:factor(transmission)Manual -4.418e+05
## factor(fuel)LPG:factor(transmission)Manual NA
## factor(fuel)Petrol:factor(transmission)Manual NA
## factor(fuel)Diesel:factor(owner)Fourth & Above Owner 1.540e+05
## factor(fuel)LPG:factor(owner)Fourth & Above Owner 6.880e+03
## factor(fuel)Petrol:factor(owner)Fourth & Above Owner 2.126e+04
## factor(fuel)Diesel:factor(owner)Second Owner 3.694e+04
## factor(fuel)LPG:factor(owner)Second Owner -3.817e+04
## factor(fuel)Petrol:factor(owner)Second Owner 3.949e+04
## factor(fuel)Diesel:factor(owner)Test Drive Car 1.360e+07
## factor(fuel)LPG:factor(owner)Test Drive Car NA
## factor(fuel)Petrol:factor(owner)Test Drive Car NA
## factor(fuel)Diesel:factor(owner)Third Owner 1.156e+04
## factor(fuel)LPG:factor(owner)Third Owner -1.054e+05
## factor(fuel)Petrol:factor(owner)Third Owner 9.407e+03
## factor(seller_type)Individual:factor(transmission)Manual 2.746e+04
## factor(seller_type)Trustmark Dealer:factor(transmission)Manual 2.399e+05
## factor(seller_type)Individual:factor(owner)Fourth & Above Owner NA
## factor(seller_type)Trustmark Dealer:factor(owner)Fourth & Above Owner NA
## factor(seller_type)Individual:factor(owner)Second Owner -4.810e+04
## factor(seller_type)Trustmark Dealer:factor(owner)Second Owner -4.833e+05
## factor(seller_type)Individual:factor(owner)Test Drive Car NA
## factor(seller_type)Trustmark Dealer:factor(owner)Test Drive Car NA
## factor(seller_type)Individual:factor(owner)Third Owner -2.314e+05
## factor(seller_type)Trustmark Dealer:factor(owner)Third Owner NA
## factor(seller_type)Individual:mileage -1.343e+04
## factor(seller_type)Trustmark Dealer:mileage 7.107e+03
## factor(seller_type)Individual:engine 1.630e+02
## factor(seller_type)Trustmark Dealer:engine 5.313e+02
## factor(seller_type)Individual:max_power -6.796e+03
## factor(seller_type)Trustmark Dealer:max_power -3.118e+03
## factor(transmission)Manual:factor(owner)Fourth & Above Owner -3.295e+05
## factor(transmission)Manual:factor(owner)Second Owner -8.297e+04
## factor(transmission)Manual:factor(owner)Test Drive Car NA
## factor(transmission)Manual:factor(owner)Third Owner -3.364e+05
## factor(transmission)Manual:mileage -1.735e+04
## factor(transmission)Manual:engine 5.098e+02
## factor(transmission)Manual:max_power -1.450e+04
## factor(transmission)Manual:seats -3.607e+04
## factor(transmission)Manual:torque_rpm -1.685e+02
## factor(owner)Fourth & Above Owner:mileage -1.446e+04
## factor(owner)Second Owner:mileage 1.648e+03
## factor(owner)Test Drive Car:mileage -2.331e+06
## factor(owner)Third Owner:mileage -2.785e+03
## factor(owner)Fourth & Above Owner:engine -1.385e+02
## factor(owner)Second Owner:engine -3.141e+00
## factor(owner)Test Drive Car:engine NA
## factor(owner)Third Owner:engine -3.611e+01
## mileage:engine -1.241e+01
## mileage:max_power 1.789e+02
## engine:max_power 1.768e+00
## engine:torque_rpm -1.366e-01
## max_power:seats -6.986e+02
## max_power:torque_rpm 1.027e+00
## Std. Error
## (Intercept) 2.214e+07
## year 1.103e+04
## km_driven 2.986e+01
## factor(fuel)Diesel 5.626e+04
## factor(fuel)LPG 7.184e+04
## factor(fuel)Petrol 4.315e+04
## factor(seller_type)Individual 7.825e+06
## factor(seller_type)Trustmark Dealer 4.224e+07
## factor(transmission)Manual 9.854e+06
## factor(owner)Fourth & Above Owner 3.419e+05
## factor(owner)Second Owner 1.273e+05
## factor(owner)Test Drive Car 3.504e+06
## factor(owner)Third Owner 2.714e+05
## mileage 6.072e+05
## engine 6.493e+03
## max_power 8.616e+04
## seats 2.682e+04
## torque_rpm 1.818e+03
## year:km_driven 1.483e-02
## year:factor(seller_type)Individual 3.890e+03
## year:factor(seller_type)Trustmark Dealer 2.093e+04
## year:factor(transmission)Manual 4.913e+03
## year:mileage 3.011e+02
## year:engine 3.227e+00
## year:max_power 4.287e+01
## year:torque_rpm 9.012e-01
## km_driven:factor(seller_type)Individual 3.231e-01
## km_driven:factor(seller_type)Trustmark Dealer 1.805e+00
## km_driven:factor(transmission)Manual 3.580e-01
## km_driven:max_power 2.035e-03
## factor(fuel)Diesel:factor(transmission)Manual 4.060e+04
## factor(fuel)LPG:factor(transmission)Manual NA
## factor(fuel)Petrol:factor(transmission)Manual NA
## factor(fuel)Diesel:factor(owner)Fourth & Above Owner 2.501e+05
## factor(fuel)LPG:factor(owner)Fourth & Above Owner 3.444e+05
## factor(fuel)Petrol:factor(owner)Fourth & Above Owner 2.441e+05
## factor(fuel)Diesel:factor(owner)Second Owner 7.421e+04
## factor(fuel)LPG:factor(owner)Second Owner 1.178e+05
## factor(fuel)Petrol:factor(owner)Second Owner 7.539e+04
## factor(fuel)Diesel:factor(owner)Test Drive Car 1.525e+06
## factor(fuel)LPG:factor(owner)Test Drive Car NA
## factor(fuel)Petrol:factor(owner)Test Drive Car NA
## factor(fuel)Diesel:factor(owner)Third Owner 1.747e+05
## factor(fuel)LPG:factor(owner)Third Owner 2.129e+05
## factor(fuel)Petrol:factor(owner)Third Owner 1.747e+05
## factor(seller_type)Individual:factor(transmission)Manual 2.644e+04
## factor(seller_type)Trustmark Dealer:factor(transmission)Manual 5.978e+04
## factor(seller_type)Individual:factor(owner)Fourth & Above Owner NA
## factor(seller_type)Trustmark Dealer:factor(owner)Fourth & Above Owner NA
## factor(seller_type)Individual:factor(owner)Second Owner 2.946e+04
## factor(seller_type)Trustmark Dealer:factor(owner)Second Owner 1.202e+05
## factor(seller_type)Individual:factor(owner)Test Drive Car NA
## factor(seller_type)Trustmark Dealer:factor(owner)Test Drive Car NA
## factor(seller_type)Individual:factor(owner)Third Owner 1.217e+05
## factor(seller_type)Trustmark Dealer:factor(owner)Third Owner NA
## factor(seller_type)Individual:mileage 2.814e+03
## factor(seller_type)Trustmark Dealer:mileage 9.664e+03
## factor(seller_type)Individual:engine 3.696e+01
## factor(seller_type)Trustmark Dealer:engine 1.146e+02
## factor(seller_type)Individual:max_power 4.551e+02
## factor(seller_type)Trustmark Dealer:max_power 2.187e+03
## factor(transmission)Manual:factor(owner)Fourth & Above Owner 1.034e+05
## factor(transmission)Manual:factor(owner)Second Owner 2.943e+04
## factor(transmission)Manual:factor(owner)Test Drive Car NA
## factor(transmission)Manual:factor(owner)Third Owner 6.542e+04
## factor(transmission)Manual:mileage 4.772e+03
## factor(transmission)Manual:engine 5.478e+01
## factor(transmission)Manual:max_power 5.400e+02
## factor(transmission)Manual:seats 1.954e+04
## factor(transmission)Manual:torque_rpm 1.716e+01
## factor(owner)Fourth & Above Owner:mileage 8.909e+03
## factor(owner)Second Owner:mileage 2.797e+03
## factor(owner)Test Drive Car:mileage 2.247e+05
## factor(owner)Third Owner:mileage 5.190e+03
## factor(owner)Fourth & Above Owner:engine 7.174e+01
## factor(owner)Second Owner:engine 2.554e+01
## factor(owner)Test Drive Car:engine NA
## factor(owner)Third Owner:engine 4.335e+01
## mileage:engine 3.368e+00
## mileage:max_power 3.758e+01
## engine:max_power 2.815e-01
## engine:torque_rpm 1.609e-02
## max_power:seats 1.321e+02
## max_power:torque_rpm 2.174e-01
## t value
## (Intercept) -1.992
## year 1.852
## km_driven 7.031
## factor(fuel)Diesel 8.213
## factor(fuel)LPG -0.476
## factor(fuel)Petrol -1.593
## factor(seller_type)Individual 6.606
## factor(seller_type)Trustmark Dealer 0.987
## factor(transmission)Manual 9.174
## factor(owner)Fourth & Above Owner 1.906
## factor(owner)Second Owner 0.390
## factor(owner)Test Drive Car 10.893
## factor(owner)Third Owner 2.321
## mileage -5.613
## engine 2.879
## max_power -30.922
## seats 4.001
## torque_rpm 11.547
## year:km_driven -7.181
## year:factor(seller_type)Individual -6.526
## year:factor(seller_type)Trustmark Dealer -1.010
## year:factor(transmission)Manual -8.955
## year:mileage 5.677
## year:engine -2.918
## year:max_power 31.130
## year:torque_rpm -11.418
## km_driven:factor(seller_type)Individual 5.432
## km_driven:factor(seller_type)Trustmark Dealer 2.142
## km_driven:factor(transmission)Manual 8.968
## km_driven:max_power -4.317
## factor(fuel)Diesel:factor(transmission)Manual -10.880
## factor(fuel)LPG:factor(transmission)Manual NA
## factor(fuel)Petrol:factor(transmission)Manual NA
## factor(fuel)Diesel:factor(owner)Fourth & Above Owner 0.615
## factor(fuel)LPG:factor(owner)Fourth & Above Owner 0.020
## factor(fuel)Petrol:factor(owner)Fourth & Above Owner 0.087
## factor(fuel)Diesel:factor(owner)Second Owner 0.498
## factor(fuel)LPG:factor(owner)Second Owner -0.324
## factor(fuel)Petrol:factor(owner)Second Owner 0.524
## factor(fuel)Diesel:factor(owner)Test Drive Car 8.918
## factor(fuel)LPG:factor(owner)Test Drive Car NA
## factor(fuel)Petrol:factor(owner)Test Drive Car NA
## factor(fuel)Diesel:factor(owner)Third Owner 0.066
## factor(fuel)LPG:factor(owner)Third Owner -0.495
## factor(fuel)Petrol:factor(owner)Third Owner 0.054
## factor(seller_type)Individual:factor(transmission)Manual 1.038
## factor(seller_type)Trustmark Dealer:factor(transmission)Manual 4.013
## factor(seller_type)Individual:factor(owner)Fourth & Above Owner NA
## factor(seller_type)Trustmark Dealer:factor(owner)Fourth & Above Owner NA
## factor(seller_type)Individual:factor(owner)Second Owner -1.633
## factor(seller_type)Trustmark Dealer:factor(owner)Second Owner -4.021
## factor(seller_type)Individual:factor(owner)Test Drive Car NA
## factor(seller_type)Trustmark Dealer:factor(owner)Test Drive Car NA
## factor(seller_type)Individual:factor(owner)Third Owner -1.902
## factor(seller_type)Trustmark Dealer:factor(owner)Third Owner NA
## factor(seller_type)Individual:mileage -4.775
## factor(seller_type)Trustmark Dealer:mileage 0.735
## factor(seller_type)Individual:engine 4.409
## factor(seller_type)Trustmark Dealer:engine 4.637
## factor(seller_type)Individual:max_power -14.934
## factor(seller_type)Trustmark Dealer:max_power -1.426
## factor(transmission)Manual:factor(owner)Fourth & Above Owner -3.187
## factor(transmission)Manual:factor(owner)Second Owner -2.819
## factor(transmission)Manual:factor(owner)Test Drive Car NA
## factor(transmission)Manual:factor(owner)Third Owner -5.141
## factor(transmission)Manual:mileage -3.635
## factor(transmission)Manual:engine 9.307
## factor(transmission)Manual:max_power -26.858
## factor(transmission)Manual:seats -1.846
## factor(transmission)Manual:torque_rpm -9.814
## factor(owner)Fourth & Above Owner:mileage -1.623
## factor(owner)Second Owner:mileage 0.589
## factor(owner)Test Drive Car:mileage -10.376
## factor(owner)Third Owner:mileage -0.537
## factor(owner)Fourth & Above Owner:engine -1.930
## factor(owner)Second Owner:engine -0.123
## factor(owner)Test Drive Car:engine NA
## factor(owner)Third Owner:engine -0.833
## mileage:engine -3.684
## mileage:max_power 4.761
## engine:max_power 6.281
## engine:torque_rpm -8.492
## max_power:seats -5.287
## max_power:torque_rpm 4.722
## Pr(>|t|)
## (Intercept) 0.046412
## year 0.064011
## km_driven 2.22e-12
## factor(fuel)Diesel 2.50e-16
## factor(fuel)LPG 0.633916
## factor(fuel)Petrol 0.111183
## factor(seller_type)Individual 4.21e-11
## factor(seller_type)Trustmark Dealer 0.323559
## factor(transmission)Manual < 2e-16
## factor(owner)Fourth & Above Owner 0.056738
## factor(owner)Second Owner 0.696527
## factor(owner)Test Drive Car < 2e-16
## factor(owner)Third Owner 0.020287
## mileage 2.05e-08
## engine 0.004005
## max_power < 2e-16
## seats 6.37e-05
## torque_rpm < 2e-16
## year:km_driven 7.54e-13
## year:factor(seller_type)Individual 7.18e-11
## year:factor(seller_type)Trustmark Dealer 0.312619
## year:factor(transmission)Manual < 2e-16
## year:mileage 1.42e-08
## year:engine 0.003531
## year:max_power < 2e-16
## year:torque_rpm < 2e-16
## km_driven:factor(seller_type)Individual 5.75e-08
## km_driven:factor(seller_type)Trustmark Dealer 0.032220
## km_driven:factor(transmission)Manual < 2e-16
## km_driven:max_power 1.60e-05
## factor(fuel)Diesel:factor(transmission)Manual < 2e-16
## factor(fuel)LPG:factor(transmission)Manual NA
## factor(fuel)Petrol:factor(transmission)Manual NA
## factor(fuel)Diesel:factor(owner)Fourth & Above Owner 0.538269
## factor(fuel)LPG:factor(owner)Fourth & Above Owner 0.984062
## factor(fuel)Petrol:factor(owner)Fourth & Above Owner 0.930614
## factor(fuel)Diesel:factor(owner)Second Owner 0.618620
## factor(fuel)LPG:factor(owner)Second Owner 0.745973
## factor(fuel)Petrol:factor(owner)Second Owner 0.600422
## factor(fuel)Diesel:factor(owner)Test Drive Car < 2e-16
## factor(fuel)LPG:factor(owner)Test Drive Car NA
## factor(fuel)Petrol:factor(owner)Test Drive Car NA
## factor(fuel)Diesel:factor(owner)Third Owner 0.947250
## factor(fuel)LPG:factor(owner)Third Owner 0.620524
## factor(fuel)Petrol:factor(owner)Third Owner 0.957061
## factor(seller_type)Individual:factor(transmission)Manual 0.299166
## factor(seller_type)Trustmark Dealer:factor(transmission)Manual 6.04e-05
## factor(seller_type)Individual:factor(owner)Fourth & Above Owner NA
## factor(seller_type)Trustmark Dealer:factor(owner)Fourth & Above Owner NA
## factor(seller_type)Individual:factor(owner)Second Owner 0.102540
## factor(seller_type)Trustmark Dealer:factor(owner)Second Owner 5.85e-05
## factor(seller_type)Individual:factor(owner)Test Drive Car NA
## factor(seller_type)Trustmark Dealer:factor(owner)Test Drive Car NA
## factor(seller_type)Individual:factor(owner)Third Owner 0.057189
## factor(seller_type)Trustmark Dealer:factor(owner)Third Owner NA
## factor(seller_type)Individual:mileage 1.83e-06
## factor(seller_type)Trustmark Dealer:mileage 0.462135
## factor(seller_type)Individual:engine 1.05e-05
## factor(seller_type)Trustmark Dealer:engine 3.59e-06
## factor(seller_type)Individual:max_power < 2e-16
## factor(seller_type)Trustmark Dealer:max_power 0.154007
## factor(transmission)Manual:factor(owner)Fourth & Above Owner 0.001445
## factor(transmission)Manual:factor(owner)Second Owner 0.004829
## factor(transmission)Manual:factor(owner)Test Drive Car NA
## factor(transmission)Manual:factor(owner)Third Owner 2.80e-07
## factor(transmission)Manual:mileage 0.000279
## factor(transmission)Manual:engine < 2e-16
## factor(transmission)Manual:max_power < 2e-16
## factor(transmission)Manual:seats 0.064863
## factor(transmission)Manual:torque_rpm < 2e-16
## factor(owner)Fourth & Above Owner:mileage 0.104547
## factor(owner)Second Owner:mileage 0.555839
## factor(owner)Test Drive Car:mileage < 2e-16
## factor(owner)Third Owner:mileage 0.591576
## factor(owner)Fourth & Above Owner:engine 0.053590
## factor(owner)Second Owner:engine 0.902132
## factor(owner)Test Drive Car:engine NA
## factor(owner)Third Owner:engine 0.404819
## mileage:engine 0.000231
## mileage:max_power 1.96e-06
## engine:max_power 3.54e-10
## engine:torque_rpm < 2e-16
## max_power:seats 1.28e-07
## max_power:torque_rpm 2.38e-06
##
## (Intercept) *
## year .
## km_driven ***
## factor(fuel)Diesel ***
## factor(fuel)LPG
## factor(fuel)Petrol
## factor(seller_type)Individual ***
## factor(seller_type)Trustmark Dealer
## factor(transmission)Manual ***
## factor(owner)Fourth & Above Owner .
## factor(owner)Second Owner
## factor(owner)Test Drive Car ***
## factor(owner)Third Owner *
## mileage ***
## engine **
## max_power ***
## seats ***
## torque_rpm ***
## year:km_driven ***
## year:factor(seller_type)Individual ***
## year:factor(seller_type)Trustmark Dealer
## year:factor(transmission)Manual ***
## year:mileage ***
## year:engine **
## year:max_power ***
## year:torque_rpm ***
## km_driven:factor(seller_type)Individual ***
## km_driven:factor(seller_type)Trustmark Dealer *
## km_driven:factor(transmission)Manual ***
## km_driven:max_power ***
## factor(fuel)Diesel:factor(transmission)Manual ***
## factor(fuel)LPG:factor(transmission)Manual
## factor(fuel)Petrol:factor(transmission)Manual
## factor(fuel)Diesel:factor(owner)Fourth & Above Owner
## factor(fuel)LPG:factor(owner)Fourth & Above Owner
## factor(fuel)Petrol:factor(owner)Fourth & Above Owner
## factor(fuel)Diesel:factor(owner)Second Owner
## factor(fuel)LPG:factor(owner)Second Owner
## factor(fuel)Petrol:factor(owner)Second Owner
## factor(fuel)Diesel:factor(owner)Test Drive Car ***
## factor(fuel)LPG:factor(owner)Test Drive Car
## factor(fuel)Petrol:factor(owner)Test Drive Car
## factor(fuel)Diesel:factor(owner)Third Owner
## factor(fuel)LPG:factor(owner)Third Owner
## factor(fuel)Petrol:factor(owner)Third Owner
## factor(seller_type)Individual:factor(transmission)Manual
## factor(seller_type)Trustmark Dealer:factor(transmission)Manual ***
## factor(seller_type)Individual:factor(owner)Fourth & Above Owner
## factor(seller_type)Trustmark Dealer:factor(owner)Fourth & Above Owner
## factor(seller_type)Individual:factor(owner)Second Owner
## factor(seller_type)Trustmark Dealer:factor(owner)Second Owner ***
## factor(seller_type)Individual:factor(owner)Test Drive Car
## factor(seller_type)Trustmark Dealer:factor(owner)Test Drive Car
## factor(seller_type)Individual:factor(owner)Third Owner .
## factor(seller_type)Trustmark Dealer:factor(owner)Third Owner
## factor(seller_type)Individual:mileage ***
## factor(seller_type)Trustmark Dealer:mileage
## factor(seller_type)Individual:engine ***
## factor(seller_type)Trustmark Dealer:engine ***
## factor(seller_type)Individual:max_power ***
## factor(seller_type)Trustmark Dealer:max_power
## factor(transmission)Manual:factor(owner)Fourth & Above Owner **
## factor(transmission)Manual:factor(owner)Second Owner **
## factor(transmission)Manual:factor(owner)Test Drive Car
## factor(transmission)Manual:factor(owner)Third Owner ***
## factor(transmission)Manual:mileage ***
## factor(transmission)Manual:engine ***
## factor(transmission)Manual:max_power ***
## factor(transmission)Manual:seats .
## factor(transmission)Manual:torque_rpm ***
## factor(owner)Fourth & Above Owner:mileage
## factor(owner)Second Owner:mileage
## factor(owner)Test Drive Car:mileage ***
## factor(owner)Third Owner:mileage
## factor(owner)Fourth & Above Owner:engine .
## factor(owner)Second Owner:engine
## factor(owner)Test Drive Car:engine
## factor(owner)Third Owner:engine
## mileage:engine ***
## mileage:max_power ***
## engine:max_power ***
## engine:torque_rpm ***
## max_power:seats ***
## max_power:torque_rpm ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 237900 on 7782 degrees of freedom
## Multiple R-squared: 0.9093, Adjusted R-squared: 0.9085
## F-statistic: 1084 on 72 and 7782 DF, p-value: < 2.2e-16
reducedint2_quad = lm(selling_price~year+km_driven+factor(fuel)+factor(seller_type)+factor(transmission)+factor(owner)+mileage+engine+I(engine^2)+max_power+I(max_power^2)+seats+torque_rpm + year*km_driven + year*factor(seller_type) + year*factor(transmission) + year*mileage + year*engine + year*max_power + year*torque_rpm + km_driven*factor(seller_type) + km_driven*factor(transmission) + km_driven*max_power + factor(fuel)*factor(transmission) + factor(fuel)*factor(owner) + factor(seller_type)*factor(transmission) + factor(seller_type)*factor(owner) + factor(seller_type)*mileage + factor(seller_type)*engine +factor(seller_type)*max_power + factor(transmission)*factor(owner) + factor(transmission)*mileage + factor(transmission)*engine + factor(transmission)*max_power + factor(transmission)*seats + factor(transmission)*torque_rpm + factor(owner)*mileage + factor(owner)*engine + mileage*engine + mileage*max_power + engine*max_power + engine*torque_rpm + max_power*seats + max_power*torque_rpm, data=car_dataset)
summary(reducedint2_quad)
##
## Call:
## lm(formula = selling_price ~ year + km_driven + factor(fuel) +
## factor(seller_type) + factor(transmission) + factor(owner) +
## mileage + engine + I(engine^2) + max_power + I(max_power^2) +
## seats + torque_rpm + year * km_driven + year * factor(seller_type) +
## year * factor(transmission) + year * mileage + year * engine +
## year * max_power + year * torque_rpm + km_driven * factor(seller_type) +
## km_driven * factor(transmission) + km_driven * max_power +
## factor(fuel) * factor(transmission) + factor(fuel) * factor(owner) +
## factor(seller_type) * factor(transmission) + factor(seller_type) *
## factor(owner) + factor(seller_type) * mileage + factor(seller_type) *
## engine + factor(seller_type) * max_power + factor(transmission) *
## factor(owner) + factor(transmission) * mileage + factor(transmission) *
## engine + factor(transmission) * max_power + factor(transmission) *
## seats + factor(transmission) * torque_rpm + factor(owner) *
## mileage + factor(owner) * engine + mileage * engine + mileage *
## max_power + engine * max_power + engine * torque_rpm + max_power *
## seats + max_power * torque_rpm, data = car_dataset)
##
## Residuals:
## Min 1Q Median 3Q Max
## -2785325 -82344 -2261 79920 2142333
##
## Coefficients: (11 not defined because of singularities)
## Estimate
## (Intercept) -5.463e+07
## year 2.539e+04
## km_driven 2.212e+02
## factor(fuel)Diesel 4.473e+05
## factor(fuel)LPG -3.152e+04
## factor(fuel)Petrol -5.578e+04
## factor(seller_type)Individual 5.326e+07
## factor(seller_type)Trustmark Dealer 3.558e+07
## factor(transmission)Manual 8.760e+07
## factor(owner)Fourth & Above Owner 6.678e+05
## factor(owner)Second Owner 5.399e+04
## factor(owner)Test Drive Car 3.856e+07
## factor(owner)Third Owner 6.089e+05
## mileage -2.955e+06
## engine 1.870e+04
## I(engine^2) -1.781e-01
## max_power -2.714e+06
## I(max_power^2) -1.784e+01
## seats 1.532e+05
## torque_rpm 2.344e+04
## year:km_driven -1.121e-01
## year:factor(seller_type)Individual -2.620e+04
## year:factor(seller_type)Trustmark Dealer -1.820e+04
## year:factor(transmission)Manual -4.256e+04
## year:mileage 1.488e+03
## year:engine -9.143e+00
## year:max_power 1.358e+03
## year:torque_rpm -1.150e+01
## km_driven:factor(seller_type)Individual 1.663e+00
## km_driven:factor(seller_type)Trustmark Dealer 4.353e+00
## km_driven:factor(transmission)Manual 3.200e+00
## km_driven:max_power -8.463e-03
## factor(fuel)Diesel:factor(transmission)Manual -4.386e+05
## factor(fuel)LPG:factor(transmission)Manual NA
## factor(fuel)Petrol:factor(transmission)Manual NA
## factor(fuel)Diesel:factor(owner)Fourth & Above Owner 1.446e+05
## factor(fuel)LPG:factor(owner)Fourth & Above Owner -4.798e+02
## factor(fuel)Petrol:factor(owner)Fourth & Above Owner 8.112e+03
## factor(fuel)Diesel:factor(owner)Second Owner 4.660e+04
## factor(fuel)LPG:factor(owner)Second Owner -2.366e+04
## factor(fuel)Petrol:factor(owner)Second Owner 4.465e+04
## factor(fuel)Diesel:factor(owner)Test Drive Car 1.375e+07
## factor(fuel)LPG:factor(owner)Test Drive Car NA
## factor(fuel)Petrol:factor(owner)Test Drive Car NA
## factor(fuel)Diesel:factor(owner)Third Owner 1.842e+04
## factor(fuel)LPG:factor(owner)Third Owner -8.707e+04
## factor(fuel)Petrol:factor(owner)Third Owner 1.339e+04
## factor(seller_type)Individual:factor(transmission)Manual 2.052e+04
## factor(seller_type)Trustmark Dealer:factor(transmission)Manual 2.213e+05
## factor(seller_type)Individual:factor(owner)Fourth & Above Owner NA
## factor(seller_type)Trustmark Dealer:factor(owner)Fourth & Above Owner NA
## factor(seller_type)Individual:factor(owner)Second Owner -5.021e+04
## factor(seller_type)Trustmark Dealer:factor(owner)Second Owner -4.914e+05
## factor(seller_type)Individual:factor(owner)Test Drive Car NA
## factor(seller_type)Trustmark Dealer:factor(owner)Test Drive Car NA
## factor(seller_type)Individual:factor(owner)Third Owner -2.289e+05
## factor(seller_type)Trustmark Dealer:factor(owner)Third Owner NA
## factor(seller_type)Individual:mileage -1.166e+04
## factor(seller_type)Trustmark Dealer:mileage 1.296e+04
## factor(seller_type)Individual:engine 1.861e+02
## factor(seller_type)Trustmark Dealer:engine 5.169e+02
## factor(seller_type)Individual:max_power -6.839e+03
## factor(seller_type)Trustmark Dealer:max_power -1.929e+03
## factor(transmission)Manual:factor(owner)Fourth & Above Owner -3.513e+05
## factor(transmission)Manual:factor(owner)Second Owner -8.739e+04
## factor(transmission)Manual:factor(owner)Test Drive Car NA
## factor(transmission)Manual:factor(owner)Third Owner -3.432e+05
## factor(transmission)Manual:mileage -1.739e+04
## factor(transmission)Manual:engine 6.451e+02
## factor(transmission)Manual:max_power -1.635e+04
## factor(transmission)Manual:seats -5.708e+04
## factor(transmission)Manual:torque_rpm -1.666e+02
## factor(owner)Fourth & Above Owner:mileage -1.364e+04
## factor(owner)Second Owner:mileage 1.726e+03
## factor(owner)Test Drive Car:mileage -2.356e+06
## factor(owner)Third Owner:mileage -1.896e+03
## factor(owner)Fourth & Above Owner:engine -1.385e+02
## factor(owner)Second Owner:engine -8.887e+00
## factor(owner)Test Drive Car:engine NA
## factor(owner)Third Owner:engine -3.444e+01
## mileage:engine -2.785e+01
## mileage:max_power 3.217e+02
## engine:max_power 4.970e+00
## engine:torque_rpm -1.782e-01
## max_power:seats -1.011e+03
## max_power:torque_rpm 1.427e+00
## Std. Error
## (Intercept) 2.226e+07
## year 1.108e+04
## km_driven 2.987e+01
## factor(fuel)Diesel 5.616e+04
## factor(fuel)LPG 7.167e+04
## factor(fuel)Petrol 4.324e+04
## factor(seller_type)Individual 7.810e+06
## factor(seller_type)Trustmark Dealer 4.213e+07
## factor(transmission)Manual 9.888e+06
## factor(owner)Fourth & Above Owner 3.410e+05
## factor(owner)Second Owner 1.270e+05
## factor(owner)Test Drive Car 3.495e+06
## factor(owner)Third Owner 2.706e+05
## mileage 6.097e+05
## engine 6.476e+03
## I(engine^2) 3.014e-02
## max_power 8.625e+04
## I(max_power^2) 4.142e+00
## seats 2.842e+04
## torque_rpm 1.863e+03
## year:km_driven 1.483e-02
## year:factor(seller_type)Individual 3.883e+03
## year:factor(seller_type)Trustmark Dealer 2.088e+04
## year:factor(transmission)Manual 4.932e+03
## year:mileage 3.023e+02
## year:engine 3.218e+00
## year:max_power 4.292e+01
## year:torque_rpm 9.233e-01
## km_driven:factor(seller_type)Individual 3.226e-01
## km_driven:factor(seller_type)Trustmark Dealer 1.802e+00
## km_driven:factor(transmission)Manual 3.574e-01
## km_driven:max_power 2.032e-03
## factor(fuel)Diesel:factor(transmission)Manual 4.049e+04
## factor(fuel)LPG:factor(transmission)Manual NA
## factor(fuel)Petrol:factor(transmission)Manual NA
## factor(fuel)Diesel:factor(owner)Fourth & Above Owner 2.495e+05
## factor(fuel)LPG:factor(owner)Fourth & Above Owner 3.434e+05
## factor(fuel)Petrol:factor(owner)Fourth & Above Owner 2.435e+05
## factor(fuel)Diesel:factor(owner)Second Owner 7.403e+04
## factor(fuel)LPG:factor(owner)Second Owner 1.175e+05
## factor(fuel)Petrol:factor(owner)Second Owner 7.519e+04
## factor(fuel)Diesel:factor(owner)Test Drive Car 1.521e+06
## factor(fuel)LPG:factor(owner)Test Drive Car NA
## factor(fuel)Petrol:factor(owner)Test Drive Car NA
## factor(fuel)Diesel:factor(owner)Third Owner 1.742e+05
## factor(fuel)LPG:factor(owner)Third Owner 2.123e+05
## factor(fuel)Petrol:factor(owner)Third Owner 1.742e+05
## factor(seller_type)Individual:factor(transmission)Manual 2.639e+04
## factor(seller_type)Trustmark Dealer:factor(transmission)Manual 5.970e+04
## factor(seller_type)Individual:factor(owner)Fourth & Above Owner NA
## factor(seller_type)Trustmark Dealer:factor(owner)Fourth & Above Owner NA
## factor(seller_type)Individual:factor(owner)Second Owner 2.938e+04
## factor(seller_type)Trustmark Dealer:factor(owner)Second Owner 1.199e+05
## factor(seller_type)Individual:factor(owner)Test Drive Car NA
## factor(seller_type)Trustmark Dealer:factor(owner)Test Drive Car NA
## factor(seller_type)Individual:factor(owner)Third Owner 1.213e+05
## factor(seller_type)Trustmark Dealer:factor(owner)Third Owner NA
## factor(seller_type)Individual:mileage 2.851e+03
## factor(seller_type)Trustmark Dealer:mileage 9.676e+03
## factor(seller_type)Individual:engine 3.701e+01
## factor(seller_type)Trustmark Dealer:engine 1.143e+02
## factor(seller_type)Individual:max_power 4.571e+02
## factor(seller_type)Trustmark Dealer:max_power 2.189e+03
## factor(transmission)Manual:factor(owner)Fourth & Above Owner 1.032e+05
## factor(transmission)Manual:factor(owner)Second Owner 2.935e+04
## factor(transmission)Manual:factor(owner)Test Drive Car NA
## factor(transmission)Manual:factor(owner)Third Owner 6.524e+04
## factor(transmission)Manual:mileage 4.775e+03
## factor(transmission)Manual:engine 6.412e+01
## factor(transmission)Manual:max_power 7.254e+02
## factor(transmission)Manual:seats 2.022e+04
## factor(transmission)Manual:torque_rpm 1.712e+01
## factor(owner)Fourth & Above Owner:mileage 8.886e+03
## factor(owner)Second Owner:mileage 2.790e+03
## factor(owner)Test Drive Car:mileage 2.241e+05
## factor(owner)Third Owner:mileage 5.179e+03
## factor(owner)Fourth & Above Owner:engine 7.158e+01
## factor(owner)Second Owner:engine 2.548e+01
## factor(owner)Test Drive Car:engine NA
## factor(owner)Third Owner:engine 4.323e+01
## mileage:engine 4.095e+00
## mileage:max_power 4.317e+01
## engine:max_power 5.593e-01
## engine:torque_rpm 1.761e-02
## max_power:seats 1.430e+02
## max_power:torque_rpm 2.277e-01
## t value
## (Intercept) -2.454
## year 2.291
## km_driven 7.408
## factor(fuel)Diesel 7.966
## factor(fuel)LPG -0.440
## factor(fuel)Petrol -1.290
## factor(seller_type)Individual 6.820
## factor(seller_type)Trustmark Dealer 0.845
## factor(transmission)Manual 8.859
## factor(owner)Fourth & Above Owner 1.959
## factor(owner)Second Owner 0.425
## factor(owner)Test Drive Car 11.034
## factor(owner)Third Owner 2.250
## mileage -4.847
## engine 2.888
## I(engine^2) -5.908
## max_power -31.467
## I(max_power^2) -4.308
## seats 5.392
## torque_rpm 12.584
## year:km_driven -7.557
## year:factor(seller_type)Individual -6.746
## year:factor(seller_type)Trustmark Dealer -0.872
## year:factor(transmission)Manual -8.629
## year:mileage 4.924
## year:engine -2.842
## year:max_power 31.644
## year:torque_rpm -12.455
## km_driven:factor(seller_type)Individual 5.155
## km_driven:factor(seller_type)Trustmark Dealer 2.416
## km_driven:factor(transmission)Manual 8.954
## km_driven:max_power -4.164
## factor(fuel)Diesel:factor(transmission)Manual -10.830
## factor(fuel)LPG:factor(transmission)Manual NA
## factor(fuel)Petrol:factor(transmission)Manual NA
## factor(fuel)Diesel:factor(owner)Fourth & Above Owner 0.580
## factor(fuel)LPG:factor(owner)Fourth & Above Owner -0.001
## factor(fuel)Petrol:factor(owner)Fourth & Above Owner 0.033
## factor(fuel)Diesel:factor(owner)Second Owner 0.630
## factor(fuel)LPG:factor(owner)Second Owner -0.201
## factor(fuel)Petrol:factor(owner)Second Owner 0.594
## factor(fuel)Diesel:factor(owner)Test Drive Car 9.042
## factor(fuel)LPG:factor(owner)Test Drive Car NA
## factor(fuel)Petrol:factor(owner)Test Drive Car NA
## factor(fuel)Diesel:factor(owner)Third Owner 0.106
## factor(fuel)LPG:factor(owner)Third Owner -0.410
## factor(fuel)Petrol:factor(owner)Third Owner 0.077
## factor(seller_type)Individual:factor(transmission)Manual 0.778
## factor(seller_type)Trustmark Dealer:factor(transmission)Manual 3.708
## factor(seller_type)Individual:factor(owner)Fourth & Above Owner NA
## factor(seller_type)Trustmark Dealer:factor(owner)Fourth & Above Owner NA
## factor(seller_type)Individual:factor(owner)Second Owner -1.709
## factor(seller_type)Trustmark Dealer:factor(owner)Second Owner -4.098
## factor(seller_type)Individual:factor(owner)Test Drive Car NA
## factor(seller_type)Trustmark Dealer:factor(owner)Test Drive Car NA
## factor(seller_type)Individual:factor(owner)Third Owner -1.887
## factor(seller_type)Trustmark Dealer:factor(owner)Third Owner NA
## factor(seller_type)Individual:mileage -4.090
## factor(seller_type)Trustmark Dealer:mileage 1.339
## factor(seller_type)Individual:engine 5.029
## factor(seller_type)Trustmark Dealer:engine 4.523
## factor(seller_type)Individual:max_power -14.961
## factor(seller_type)Trustmark Dealer:max_power -0.881
## factor(transmission)Manual:factor(owner)Fourth & Above Owner -3.405
## factor(transmission)Manual:factor(owner)Second Owner -2.977
## factor(transmission)Manual:factor(owner)Test Drive Car NA
## factor(transmission)Manual:factor(owner)Third Owner -5.260
## factor(transmission)Manual:mileage -3.643
## factor(transmission)Manual:engine 10.061
## factor(transmission)Manual:max_power -22.540
## factor(transmission)Manual:seats -2.822
## factor(transmission)Manual:torque_rpm -9.731
## factor(owner)Fourth & Above Owner:mileage -1.535
## factor(owner)Second Owner:mileage 0.619
## factor(owner)Test Drive Car:mileage -10.514
## factor(owner)Third Owner:mileage -0.366
## factor(owner)Fourth & Above Owner:engine -1.935
## factor(owner)Second Owner:engine -0.349
## factor(owner)Test Drive Car:engine NA
## factor(owner)Third Owner:engine -0.797
## mileage:engine -6.801
## mileage:max_power 7.451
## engine:max_power 8.886
## engine:torque_rpm -10.119
## max_power:seats -7.072
## max_power:torque_rpm 6.267
## Pr(>|t|)
## (Intercept) 0.014142
## year 0.022005
## km_driven 1.42e-13
## factor(fuel)Diesel 1.87e-15
## factor(fuel)LPG 0.660149
## factor(fuel)Petrol 0.197030
## factor(seller_type)Individual 9.77e-12
## factor(seller_type)Trustmark Dealer 0.398372
## factor(transmission)Manual < 2e-16
## factor(owner)Fourth & Above Owner 0.050185
## factor(owner)Second Owner 0.670704
## factor(owner)Test Drive Car < 2e-16
## factor(owner)Third Owner 0.024474
## mileage 1.28e-06
## engine 0.003888
## I(engine^2) 3.61e-09
## max_power < 2e-16
## I(max_power^2) 1.67e-05
## seats 7.18e-08
## torque_rpm < 2e-16
## year:km_driven 4.59e-14
## year:factor(seller_type)Individual 1.63e-11
## year:factor(seller_type)Trustmark Dealer 0.383234
## year:factor(transmission)Manual < 2e-16
## year:mileage 8.66e-07
## year:engine 0.004500
## year:max_power < 2e-16
## year:torque_rpm < 2e-16
## km_driven:factor(seller_type)Individual 2.59e-07
## km_driven:factor(seller_type)Trustmark Dealer 0.015697
## km_driven:factor(transmission)Manual < 2e-16
## km_driven:max_power 3.16e-05
## factor(fuel)Diesel:factor(transmission)Manual < 2e-16
## factor(fuel)LPG:factor(transmission)Manual NA
## factor(fuel)Petrol:factor(transmission)Manual NA
## factor(fuel)Diesel:factor(owner)Fourth & Above Owner 0.562234
## factor(fuel)LPG:factor(owner)Fourth & Above Owner 0.998885
## factor(fuel)Petrol:factor(owner)Fourth & Above Owner 0.973424
## factor(fuel)Diesel:factor(owner)Second Owner 0.529023
## factor(fuel)LPG:factor(owner)Second Owner 0.840518
## factor(fuel)Petrol:factor(owner)Second Owner 0.552587
## factor(fuel)Diesel:factor(owner)Test Drive Car < 2e-16
## factor(fuel)LPG:factor(owner)Test Drive Car NA
## factor(fuel)Petrol:factor(owner)Test Drive Car NA
## factor(fuel)Diesel:factor(owner)Third Owner 0.915766
## factor(fuel)LPG:factor(owner)Third Owner 0.681795
## factor(fuel)Petrol:factor(owner)Third Owner 0.938724
## factor(seller_type)Individual:factor(transmission)Manual 0.436880
## factor(seller_type)Trustmark Dealer:factor(transmission)Manual 0.000210
## factor(seller_type)Individual:factor(owner)Fourth & Above Owner NA
## factor(seller_type)Trustmark Dealer:factor(owner)Fourth & Above Owner NA
## factor(seller_type)Individual:factor(owner)Second Owner 0.087470
## factor(seller_type)Trustmark Dealer:factor(owner)Second Owner 4.21e-05
## factor(seller_type)Individual:factor(owner)Test Drive Car NA
## factor(seller_type)Trustmark Dealer:factor(owner)Test Drive Car NA
## factor(seller_type)Individual:factor(owner)Third Owner 0.059190
## factor(seller_type)Trustmark Dealer:factor(owner)Third Owner NA
## factor(seller_type)Individual:mileage 4.35e-05
## factor(seller_type)Trustmark Dealer:mileage 0.180597
## factor(seller_type)Individual:engine 5.05e-07
## factor(seller_type)Trustmark Dealer:engine 6.19e-06
## factor(seller_type)Individual:max_power < 2e-16
## factor(seller_type)Trustmark Dealer:max_power 0.378198
## factor(transmission)Manual:factor(owner)Fourth & Above Owner 0.000665
## factor(transmission)Manual:factor(owner)Second Owner 0.002919
## factor(transmission)Manual:factor(owner)Test Drive Car NA
## factor(transmission)Manual:factor(owner)Third Owner 1.48e-07
## factor(transmission)Manual:mileage 0.000272
## factor(transmission)Manual:engine < 2e-16
## factor(transmission)Manual:max_power < 2e-16
## factor(transmission)Manual:seats 0.004778
## factor(transmission)Manual:torque_rpm < 2e-16
## factor(owner)Fourth & Above Owner:mileage 0.124944
## factor(owner)Second Owner:mileage 0.536081
## factor(owner)Test Drive Car:mileage < 2e-16
## factor(owner)Third Owner:mileage 0.714288
## factor(owner)Fourth & Above Owner:engine 0.052977
## factor(owner)Second Owner:engine 0.727305
## factor(owner)Test Drive Car:engine NA
## factor(owner)Third Owner:engine 0.425578
## mileage:engine 1.12e-11
## mileage:max_power 1.02e-13
## engine:max_power < 2e-16
## engine:torque_rpm < 2e-16
## max_power:seats 1.66e-12
## max_power:torque_rpm 3.87e-10
##
## (Intercept) *
## year *
## km_driven ***
## factor(fuel)Diesel ***
## factor(fuel)LPG
## factor(fuel)Petrol
## factor(seller_type)Individual ***
## factor(seller_type)Trustmark Dealer
## factor(transmission)Manual ***
## factor(owner)Fourth & Above Owner .
## factor(owner)Second Owner
## factor(owner)Test Drive Car ***
## factor(owner)Third Owner *
## mileage ***
## engine **
## I(engine^2) ***
## max_power ***
## I(max_power^2) ***
## seats ***
## torque_rpm ***
## year:km_driven ***
## year:factor(seller_type)Individual ***
## year:factor(seller_type)Trustmark Dealer
## year:factor(transmission)Manual ***
## year:mileage ***
## year:engine **
## year:max_power ***
## year:torque_rpm ***
## km_driven:factor(seller_type)Individual ***
## km_driven:factor(seller_type)Trustmark Dealer *
## km_driven:factor(transmission)Manual ***
## km_driven:max_power ***
## factor(fuel)Diesel:factor(transmission)Manual ***
## factor(fuel)LPG:factor(transmission)Manual
## factor(fuel)Petrol:factor(transmission)Manual
## factor(fuel)Diesel:factor(owner)Fourth & Above Owner
## factor(fuel)LPG:factor(owner)Fourth & Above Owner
## factor(fuel)Petrol:factor(owner)Fourth & Above Owner
## factor(fuel)Diesel:factor(owner)Second Owner
## factor(fuel)LPG:factor(owner)Second Owner
## factor(fuel)Petrol:factor(owner)Second Owner
## factor(fuel)Diesel:factor(owner)Test Drive Car ***
## factor(fuel)LPG:factor(owner)Test Drive Car
## factor(fuel)Petrol:factor(owner)Test Drive Car
## factor(fuel)Diesel:factor(owner)Third Owner
## factor(fuel)LPG:factor(owner)Third Owner
## factor(fuel)Petrol:factor(owner)Third Owner
## factor(seller_type)Individual:factor(transmission)Manual
## factor(seller_type)Trustmark Dealer:factor(transmission)Manual ***
## factor(seller_type)Individual:factor(owner)Fourth & Above Owner
## factor(seller_type)Trustmark Dealer:factor(owner)Fourth & Above Owner
## factor(seller_type)Individual:factor(owner)Second Owner .
## factor(seller_type)Trustmark Dealer:factor(owner)Second Owner ***
## factor(seller_type)Individual:factor(owner)Test Drive Car
## factor(seller_type)Trustmark Dealer:factor(owner)Test Drive Car
## factor(seller_type)Individual:factor(owner)Third Owner .
## factor(seller_type)Trustmark Dealer:factor(owner)Third Owner
## factor(seller_type)Individual:mileage ***
## factor(seller_type)Trustmark Dealer:mileage
## factor(seller_type)Individual:engine ***
## factor(seller_type)Trustmark Dealer:engine ***
## factor(seller_type)Individual:max_power ***
## factor(seller_type)Trustmark Dealer:max_power
## factor(transmission)Manual:factor(owner)Fourth & Above Owner ***
## factor(transmission)Manual:factor(owner)Second Owner **
## factor(transmission)Manual:factor(owner)Test Drive Car
## factor(transmission)Manual:factor(owner)Third Owner ***
## factor(transmission)Manual:mileage ***
## factor(transmission)Manual:engine ***
## factor(transmission)Manual:max_power ***
## factor(transmission)Manual:seats **
## factor(transmission)Manual:torque_rpm ***
## factor(owner)Fourth & Above Owner:mileage
## factor(owner)Second Owner:mileage
## factor(owner)Test Drive Car:mileage ***
## factor(owner)Third Owner:mileage
## factor(owner)Fourth & Above Owner:engine .
## factor(owner)Second Owner:engine
## factor(owner)Test Drive Car:engine
## factor(owner)Third Owner:engine
## mileage:engine ***
## mileage:max_power ***
## engine:max_power ***
## engine:torque_rpm ***
## max_power:seats ***
## max_power:torque_rpm ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 237300 on 7780 degrees of freedom
## Multiple R-squared: 0.9099, Adjusted R-squared: 0.909
## F-statistic: 1061 on 74 and 7780 DF, p-value: < 2.2e-16
ggplot(reducedint2, aes(x=.fitted, y=.resid)) +
geom_point() + geom_smooth()+
geom_hline(yintercept = 0)
## `geom_smooth()` using method = 'gam' and formula 'y ~ s(x, bs = "cs")'
Box-Cox is used mainly to solve the Nonnormallity and Heteroscedasticity, but it somehow helps to solve the Linearality as well.
library(MASS)
##
## Attaching package: 'MASS'
## The following object is masked from 'package:olsrr':
##
## cement
## The following object is masked from 'package:dplyr':
##
## select
bc=boxcox(reducedint2,lambda=seq(-8,8))
bestlambda=bc$x[which(bc$y==max(bc$y))]
bestlambda
## [1] 0.08080808
bcmodel=lm((((selling_price^0.08080808)-1)/0.08080808) ~ year+km_driven+factor(fuel)+factor(seller_type)+factor(transmission)+factor(owner)+mileage+engine+max_power+seats+torque_rpm + year*km_driven + year*factor(seller_type) + year*factor(transmission) + year*mileage + year*engine + year*max_power + year*torque_rpm + km_driven*factor(seller_type) + km_driven*factor(transmission) + km_driven*max_power + factor(fuel)*factor(transmission) + factor(fuel)*factor(owner) + factor(seller_type)*factor(transmission) + factor(seller_type)*factor(owner) + factor(seller_type)*mileage + factor(seller_type)*engine +factor(seller_type)*max_power + factor(transmission)*factor(owner) + factor(transmission)*mileage + factor(transmission)*engine + factor(transmission)*max_power + factor(transmission)*seats + factor(transmission)*torque_rpm + factor(owner)*mileage + factor(owner)*engine + mileage*engine + mileage*max_power + engine*max_power + engine*torque_rpm + max_power*seats + max_power*torque_rpm, data=car_dataset)
summary(bcmodel)
##
## Call:
## lm(formula = (((selling_price^0.08080808) - 1)/0.08080808) ~
## year + km_driven + factor(fuel) + factor(seller_type) + factor(transmission) +
## factor(owner) + mileage + engine + max_power + seats +
## torque_rpm + year * km_driven + year * factor(seller_type) +
## year * factor(transmission) + year * mileage + year *
## engine + year * max_power + year * torque_rpm + km_driven *
## factor(seller_type) + km_driven * factor(transmission) +
## km_driven * max_power + factor(fuel) * factor(transmission) +
## factor(fuel) * factor(owner) + factor(seller_type) *
## factor(transmission) + factor(seller_type) * factor(owner) +
## factor(seller_type) * mileage + factor(seller_type) *
## engine + factor(seller_type) * max_power + factor(transmission) *
## factor(owner) + factor(transmission) * mileage + factor(transmission) *
## engine + factor(transmission) * max_power + factor(transmission) *
## seats + factor(transmission) * torque_rpm + factor(owner) *
## mileage + factor(owner) * engine + mileage * engine +
## mileage * max_power + engine * max_power + engine * torque_rpm +
## max_power * seats + max_power * torque_rpm, data = car_dataset)
##
## Residuals:
## Min 1Q Median 3Q Max
## -4.1559 -0.4235 0.0429 0.4736 3.9419
##
## Coefficients: (11 not defined because of singularities)
## Estimate
## (Intercept) -2.339e+02
## year 1.247e-01
## km_driven 8.509e-04
## factor(fuel)Diesel 1.023e+00
## factor(fuel)LPG 3.672e-01
## factor(fuel)Petrol -5.083e-02
## factor(seller_type)Individual 3.861e+01
## factor(seller_type)Trustmark Dealer -3.320e+02
## factor(transmission)Manual -5.458e+01
## factor(owner)Fourth & Above Owner 1.023e+00
## factor(owner)Second Owner -1.496e+00
## factor(owner)Test Drive Car 2.636e+01
## factor(owner)Third Owner -5.416e-01
## mileage -6.835e+00
## engine -1.291e-02
## max_power -3.889e+00
## seats -4.750e-02
## torque_rpm 3.093e-02
## year:km_driven -4.267e-07
## year:factor(seller_type)Individual -1.921e-02
## year:factor(seller_type)Trustmark Dealer 1.634e-01
## year:factor(transmission)Manual 2.653e-02
## year:mileage 3.426e-03
## year:engine 7.753e-06
## year:max_power 1.951e-03
## year:torque_rpm -1.532e-05
## km_driven:factor(seller_type)Individual -2.078e-07
## km_driven:factor(seller_type)Trustmark Dealer 1.197e-05
## km_driven:factor(transmission)Manual 6.145e-06
## km_driven:max_power 1.043e-08
## factor(fuel)Diesel:factor(transmission)Manual -7.271e-01
## factor(fuel)LPG:factor(transmission)Manual NA
## factor(fuel)Petrol:factor(transmission)Manual NA
## factor(fuel)Diesel:factor(owner)Fourth & Above Owner 5.831e-02
## factor(fuel)LPG:factor(owner)Fourth & Above Owner 3.624e-01
## factor(fuel)Petrol:factor(owner)Fourth & Above Owner -3.819e-01
## factor(fuel)Diesel:factor(owner)Second Owner 3.172e-01
## factor(fuel)LPG:factor(owner)Second Owner 4.490e-01
## factor(fuel)Petrol:factor(owner)Second Owner 4.780e-01
## factor(fuel)Diesel:factor(owner)Test Drive Car 9.165e+00
## factor(fuel)LPG:factor(owner)Test Drive Car NA
## factor(fuel)Petrol:factor(owner)Test Drive Car NA
## factor(fuel)Diesel:factor(owner)Third Owner -5.669e-02
## factor(fuel)LPG:factor(owner)Third Owner 8.735e-02
## factor(fuel)Petrol:factor(owner)Third Owner 1.615e-02
## factor(seller_type)Individual:factor(transmission)Manual 9.977e-02
## factor(seller_type)Trustmark Dealer:factor(transmission)Manual 4.715e-01
## factor(seller_type)Individual:factor(owner)Fourth & Above Owner NA
## factor(seller_type)Trustmark Dealer:factor(owner)Fourth & Above Owner NA
## factor(seller_type)Individual:factor(owner)Second Owner -1.838e-01
## factor(seller_type)Trustmark Dealer:factor(owner)Second Owner -8.695e-01
## factor(seller_type)Individual:factor(owner)Test Drive Car NA
## factor(seller_type)Trustmark Dealer:factor(owner)Test Drive Car NA
## factor(seller_type)Individual:factor(owner)Third Owner -3.750e-01
## factor(seller_type)Trustmark Dealer:factor(owner)Third Owner NA
## factor(seller_type)Individual:mileage -4.302e-03
## factor(seller_type)Trustmark Dealer:mileage -1.388e-03
## factor(seller_type)Individual:engine 1.854e-04
## factor(seller_type)Trustmark Dealer:engine 1.163e-03
## factor(seller_type)Individual:max_power -3.075e-03
## factor(seller_type)Trustmark Dealer:max_power 3.717e-03
## factor(transmission)Manual:factor(owner)Fourth & Above Owner -5.437e-01
## factor(transmission)Manual:factor(owner)Second Owner -1.384e-01
## factor(transmission)Manual:factor(owner)Test Drive Car NA
## factor(transmission)Manual:factor(owner)Third Owner -1.014e-01
## factor(transmission)Manual:mileage 1.892e-02
## factor(transmission)Manual:engine -1.881e-04
## factor(transmission)Manual:max_power -5.096e-03
## factor(transmission)Manual:seats 2.472e-01
## factor(transmission)Manual:torque_rpm -7.899e-05
## factor(owner)Fourth & Above Owner:mileage -1.741e-02
## factor(owner)Second Owner:mileage 3.983e-02
## factor(owner)Test Drive Car:mileage -1.581e+00
## factor(owner)Third Owner:mileage 2.099e-02
## factor(owner)Fourth & Above Owner:engine -3.205e-04
## factor(owner)Second Owner:engine 3.379e-04
## factor(owner)Test Drive Car:engine NA
## factor(owner)Third Owner:engine 2.424e-04
## mileage:engine -4.060e-05
## mileage:max_power 7.413e-05
## engine:max_power -8.540e-06
## engine:torque_rpm -4.786e-07
## max_power:seats -6.348e-04
## max_power:torque_rpm 6.805e-06
## Std. Error
## (Intercept) 7.146e+01
## year 3.560e-02
## km_driven 9.638e-05
## factor(fuel)Diesel 1.816e-01
## factor(fuel)LPG 2.319e-01
## factor(fuel)Petrol 1.393e-01
## factor(seller_type)Individual 2.526e+01
## factor(seller_type)Trustmark Dealer 1.363e+02
## factor(transmission)Manual 3.181e+01
## factor(owner)Fourth & Above Owner 1.104e+00
## factor(owner)Second Owner 4.109e-01
## factor(owner)Test Drive Car 1.131e+01
## factor(owner)Third Owner 8.759e-01
## mileage 1.960e+00
## engine 2.096e-02
## max_power 2.781e-01
## seats 8.656e-02
## torque_rpm 5.868e-03
## year:km_driven 4.787e-08
## year:factor(seller_type)Individual 1.256e-02
## year:factor(seller_type)Trustmark Dealer 6.756e-02
## year:factor(transmission)Manual 1.586e-02
## year:mileage 9.718e-04
## year:engine 1.041e-05
## year:max_power 1.384e-04
## year:torque_rpm 2.909e-06
## km_driven:factor(seller_type)Individual 1.043e-06
## km_driven:factor(seller_type)Trustmark Dealer 5.825e-06
## km_driven:factor(transmission)Manual 1.155e-06
## km_driven:max_power 6.567e-09
## factor(fuel)Diesel:factor(transmission)Manual 1.311e-01
## factor(fuel)LPG:factor(transmission)Manual NA
## factor(fuel)Petrol:factor(transmission)Manual NA
## factor(fuel)Diesel:factor(owner)Fourth & Above Owner 8.074e-01
## factor(fuel)LPG:factor(owner)Fourth & Above Owner 1.112e+00
## factor(fuel)Petrol:factor(owner)Fourth & Above Owner 7.880e-01
## factor(fuel)Diesel:factor(owner)Second Owner 2.395e-01
## factor(fuel)LPG:factor(owner)Second Owner 3.804e-01
## factor(fuel)Petrol:factor(owner)Second Owner 2.434e-01
## factor(fuel)Diesel:factor(owner)Test Drive Car 4.923e+00
## factor(fuel)LPG:factor(owner)Test Drive Car NA
## factor(fuel)Petrol:factor(owner)Test Drive Car NA
## factor(fuel)Diesel:factor(owner)Third Owner 5.638e-01
## factor(fuel)LPG:factor(owner)Third Owner 6.873e-01
## factor(fuel)Petrol:factor(owner)Third Owner 5.639e-01
## factor(seller_type)Individual:factor(transmission)Manual 8.536e-02
## factor(seller_type)Trustmark Dealer:factor(transmission)Manual 1.930e-01
## factor(seller_type)Individual:factor(owner)Fourth & Above Owner NA
## factor(seller_type)Trustmark Dealer:factor(owner)Fourth & Above Owner NA
## factor(seller_type)Individual:factor(owner)Second Owner 9.509e-02
## factor(seller_type)Trustmark Dealer:factor(owner)Second Owner 3.880e-01
## factor(seller_type)Individual:factor(owner)Test Drive Car NA
## factor(seller_type)Trustmark Dealer:factor(owner)Test Drive Car NA
## factor(seller_type)Individual:factor(owner)Third Owner 3.927e-01
## factor(seller_type)Trustmark Dealer:factor(owner)Third Owner NA
## factor(seller_type)Individual:mileage 9.082e-03
## factor(seller_type)Trustmark Dealer:mileage 3.119e-02
## factor(seller_type)Individual:engine 1.193e-04
## factor(seller_type)Trustmark Dealer:engine 3.698e-04
## factor(seller_type)Individual:max_power 1.469e-03
## factor(seller_type)Trustmark Dealer:max_power 7.059e-03
## factor(transmission)Manual:factor(owner)Fourth & Above Owner 3.338e-01
## factor(transmission)Manual:factor(owner)Second Owner 9.500e-02
## factor(transmission)Manual:factor(owner)Test Drive Car NA
## factor(transmission)Manual:factor(owner)Third Owner 2.112e-01
## factor(transmission)Manual:mileage 1.540e-02
## factor(transmission)Manual:engine 1.768e-04
## factor(transmission)Manual:max_power 1.743e-03
## factor(transmission)Manual:seats 6.306e-02
## factor(transmission)Manual:torque_rpm 5.540e-05
## factor(owner)Fourth & Above Owner:mileage 2.876e-02
## factor(owner)Second Owner:mileage 9.030e-03
## factor(owner)Test Drive Car:mileage 7.252e-01
## factor(owner)Third Owner:mileage 1.675e-02
## factor(owner)Fourth & Above Owner:engine 2.316e-04
## factor(owner)Second Owner:engine 8.244e-05
## factor(owner)Test Drive Car:engine NA
## factor(owner)Third Owner:engine 1.399e-04
## mileage:engine 1.087e-05
## mileage:max_power 1.213e-04
## engine:max_power 9.088e-07
## engine:torque_rpm 5.193e-08
## max_power:seats 4.265e-04
## max_power:torque_rpm 7.018e-07
## t value
## (Intercept) -3.274
## year 3.502
## km_driven 8.829
## factor(fuel)Diesel 5.631
## factor(fuel)LPG 1.584
## factor(fuel)Petrol -0.365
## factor(seller_type)Individual 1.528
## factor(seller_type)Trustmark Dealer -2.435
## factor(transmission)Manual -1.716
## factor(owner)Fourth & Above Owner 0.927
## factor(owner)Second Owner -3.641
## factor(owner)Test Drive Car 2.331
## factor(owner)Third Owner -0.618
## mileage -3.488
## engine -0.616
## max_power -13.985
## seats -0.549
## torque_rpm 5.272
## year:km_driven -8.915
## year:factor(seller_type)Individual -1.529
## year:factor(seller_type)Trustmark Dealer 2.419
## year:factor(transmission)Manual 1.673
## year:mileage 3.525
## year:engine 0.744
## year:max_power 14.101
## year:torque_rpm -5.267
## km_driven:factor(seller_type)Individual -0.199
## km_driven:factor(seller_type)Trustmark Dealer 2.054
## km_driven:factor(transmission)Manual 5.318
## km_driven:max_power 1.587
## factor(fuel)Diesel:factor(transmission)Manual -5.548
## factor(fuel)LPG:factor(transmission)Manual NA
## factor(fuel)Petrol:factor(transmission)Manual NA
## factor(fuel)Diesel:factor(owner)Fourth & Above Owner 0.072
## factor(fuel)LPG:factor(owner)Fourth & Above Owner 0.326
## factor(fuel)Petrol:factor(owner)Fourth & Above Owner -0.485
## factor(fuel)Diesel:factor(owner)Second Owner 1.324
## factor(fuel)LPG:factor(owner)Second Owner 1.181
## factor(fuel)Petrol:factor(owner)Second Owner 1.964
## factor(fuel)Diesel:factor(owner)Test Drive Car 1.862
## factor(fuel)LPG:factor(owner)Test Drive Car NA
## factor(fuel)Petrol:factor(owner)Test Drive Car NA
## factor(fuel)Diesel:factor(owner)Third Owner -0.101
## factor(fuel)LPG:factor(owner)Third Owner 0.127
## factor(fuel)Petrol:factor(owner)Third Owner 0.029
## factor(seller_type)Individual:factor(transmission)Manual 1.169
## factor(seller_type)Trustmark Dealer:factor(transmission)Manual 2.444
## factor(seller_type)Individual:factor(owner)Fourth & Above Owner NA
## factor(seller_type)Trustmark Dealer:factor(owner)Fourth & Above Owner NA
## factor(seller_type)Individual:factor(owner)Second Owner -1.933
## factor(seller_type)Trustmark Dealer:factor(owner)Second Owner -2.241
## factor(seller_type)Individual:factor(owner)Test Drive Car NA
## factor(seller_type)Trustmark Dealer:factor(owner)Test Drive Car NA
## factor(seller_type)Individual:factor(owner)Third Owner -0.955
## factor(seller_type)Trustmark Dealer:factor(owner)Third Owner NA
## factor(seller_type)Individual:mileage -0.474
## factor(seller_type)Trustmark Dealer:mileage -0.044
## factor(seller_type)Individual:engine 1.554
## factor(seller_type)Trustmark Dealer:engine 3.145
## factor(seller_type)Individual:max_power -2.093
## factor(seller_type)Trustmark Dealer:max_power 0.527
## factor(transmission)Manual:factor(owner)Fourth & Above Owner -1.629
## factor(transmission)Manual:factor(owner)Second Owner -1.457
## factor(transmission)Manual:factor(owner)Test Drive Car NA
## factor(transmission)Manual:factor(owner)Third Owner -0.480
## factor(transmission)Manual:mileage 1.228
## factor(transmission)Manual:engine -1.064
## factor(transmission)Manual:max_power -2.924
## factor(transmission)Manual:seats 3.920
## factor(transmission)Manual:torque_rpm -1.426
## factor(owner)Fourth & Above Owner:mileage -0.605
## factor(owner)Second Owner:mileage 4.411
## factor(owner)Test Drive Car:mileage -2.180
## factor(owner)Third Owner:mileage 1.253
## factor(owner)Fourth & Above Owner:engine -1.384
## factor(owner)Second Owner:engine 4.099
## factor(owner)Test Drive Car:engine NA
## factor(owner)Third Owner:engine 1.733
## mileage:engine -3.734
## mileage:max_power 0.611
## engine:max_power -9.397
## engine:torque_rpm -9.217
## max_power:seats -1.488
## max_power:torque_rpm 9.696
## Pr(>|t|)
## (Intercept) 0.001066
## year 0.000464
## km_driven < 2e-16
## factor(fuel)Diesel 1.85e-08
## factor(fuel)LPG 0.113330
## factor(fuel)Petrol 0.715175
## factor(seller_type)Individual 0.126430
## factor(seller_type)Trustmark Dealer 0.014909
## factor(transmission)Manual 0.086184
## factor(owner)Fourth & Above Owner 0.353980
## factor(owner)Second Owner 0.000273
## factor(owner)Test Drive Car 0.019803
## factor(owner)Third Owner 0.536369
## mileage 0.000490
## engine 0.537916
## max_power < 2e-16
## seats 0.583167
## torque_rpm 1.39e-07
## year:km_driven < 2e-16
## year:factor(seller_type)Individual 0.126194
## year:factor(seller_type)Trustmark Dealer 0.015590
## year:factor(transmission)Manual 0.094398
## year:mileage 0.000425
## year:engine 0.456639
## year:max_power < 2e-16
## year:torque_rpm 1.43e-07
## km_driven:factor(seller_type)Individual 0.842102
## km_driven:factor(seller_type)Trustmark Dealer 0.039967
## km_driven:factor(transmission)Manual 1.08e-07
## km_driven:max_power 0.112443
## factor(fuel)Diesel:factor(transmission)Manual 2.99e-08
## factor(fuel)LPG:factor(transmission)Manual NA
## factor(fuel)Petrol:factor(transmission)Manual NA
## factor(fuel)Diesel:factor(owner)Fourth & Above Owner 0.942433
## factor(fuel)LPG:factor(owner)Fourth & Above Owner 0.744427
## factor(fuel)Petrol:factor(owner)Fourth & Above Owner 0.627948
## factor(fuel)Diesel:factor(owner)Second Owner 0.185463
## factor(fuel)LPG:factor(owner)Second Owner 0.237821
## factor(fuel)Petrol:factor(owner)Second Owner 0.049531
## factor(fuel)Diesel:factor(owner)Test Drive Car 0.062679
## factor(fuel)LPG:factor(owner)Test Drive Car NA
## factor(fuel)Petrol:factor(owner)Test Drive Car NA
## factor(fuel)Diesel:factor(owner)Third Owner 0.919904
## factor(fuel)LPG:factor(owner)Third Owner 0.898880
## factor(fuel)Petrol:factor(owner)Third Owner 0.977158
## factor(seller_type)Individual:factor(transmission)Manual 0.242486
## factor(seller_type)Trustmark Dealer:factor(transmission)Manual 0.014567
## factor(seller_type)Individual:factor(owner)Fourth & Above Owner NA
## factor(seller_type)Trustmark Dealer:factor(owner)Fourth & Above Owner NA
## factor(seller_type)Individual:factor(owner)Second Owner 0.053250
## factor(seller_type)Trustmark Dealer:factor(owner)Second Owner 0.025045
## factor(seller_type)Individual:factor(owner)Test Drive Car NA
## factor(seller_type)Trustmark Dealer:factor(owner)Test Drive Car NA
## factor(seller_type)Individual:factor(owner)Third Owner 0.339623
## factor(seller_type)Trustmark Dealer:factor(owner)Third Owner NA
## factor(seller_type)Individual:mileage 0.635760
## factor(seller_type)Trustmark Dealer:mileage 0.964515
## factor(seller_type)Individual:engine 0.120193
## factor(seller_type)Trustmark Dealer:engine 0.001670
## factor(seller_type)Individual:max_power 0.036364
## factor(seller_type)Trustmark Dealer:max_power 0.598540
## factor(transmission)Manual:factor(owner)Fourth & Above Owner 0.103385
## factor(transmission)Manual:factor(owner)Second Owner 0.145192
## factor(transmission)Manual:factor(owner)Test Drive Car NA
## factor(transmission)Manual:factor(owner)Third Owner 0.631176
## factor(transmission)Manual:mileage 0.219350
## factor(transmission)Manual:engine 0.287528
## factor(transmission)Manual:max_power 0.003468
## factor(transmission)Manual:seats 8.93e-05
## factor(transmission)Manual:torque_rpm 0.153979
## factor(owner)Fourth & Above Owner:mileage 0.544968
## factor(owner)Second Owner:mileage 1.04e-05
## factor(owner)Test Drive Car:mileage 0.029254
## factor(owner)Third Owner:mileage 0.210154
## factor(owner)Fourth & Above Owner:engine 0.166440
## factor(owner)Second Owner:engine 4.19e-05
## factor(owner)Test Drive Car:engine NA
## factor(owner)Third Owner:engine 0.083201
## mileage:engine 0.000190
## mileage:max_power 0.541189
## engine:max_power < 2e-16
## engine:torque_rpm < 2e-16
## max_power:seats 0.136685
## max_power:torque_rpm < 2e-16
##
## (Intercept) **
## year ***
## km_driven ***
## factor(fuel)Diesel ***
## factor(fuel)LPG
## factor(fuel)Petrol
## factor(seller_type)Individual
## factor(seller_type)Trustmark Dealer *
## factor(transmission)Manual .
## factor(owner)Fourth & Above Owner
## factor(owner)Second Owner ***
## factor(owner)Test Drive Car *
## factor(owner)Third Owner
## mileage ***
## engine
## max_power ***
## seats
## torque_rpm ***
## year:km_driven ***
## year:factor(seller_type)Individual
## year:factor(seller_type)Trustmark Dealer *
## year:factor(transmission)Manual .
## year:mileage ***
## year:engine
## year:max_power ***
## year:torque_rpm ***
## km_driven:factor(seller_type)Individual
## km_driven:factor(seller_type)Trustmark Dealer *
## km_driven:factor(transmission)Manual ***
## km_driven:max_power
## factor(fuel)Diesel:factor(transmission)Manual ***
## factor(fuel)LPG:factor(transmission)Manual
## factor(fuel)Petrol:factor(transmission)Manual
## factor(fuel)Diesel:factor(owner)Fourth & Above Owner
## factor(fuel)LPG:factor(owner)Fourth & Above Owner
## factor(fuel)Petrol:factor(owner)Fourth & Above Owner
## factor(fuel)Diesel:factor(owner)Second Owner
## factor(fuel)LPG:factor(owner)Second Owner
## factor(fuel)Petrol:factor(owner)Second Owner *
## factor(fuel)Diesel:factor(owner)Test Drive Car .
## factor(fuel)LPG:factor(owner)Test Drive Car
## factor(fuel)Petrol:factor(owner)Test Drive Car
## factor(fuel)Diesel:factor(owner)Third Owner
## factor(fuel)LPG:factor(owner)Third Owner
## factor(fuel)Petrol:factor(owner)Third Owner
## factor(seller_type)Individual:factor(transmission)Manual
## factor(seller_type)Trustmark Dealer:factor(transmission)Manual *
## factor(seller_type)Individual:factor(owner)Fourth & Above Owner
## factor(seller_type)Trustmark Dealer:factor(owner)Fourth & Above Owner
## factor(seller_type)Individual:factor(owner)Second Owner .
## factor(seller_type)Trustmark Dealer:factor(owner)Second Owner *
## factor(seller_type)Individual:factor(owner)Test Drive Car
## factor(seller_type)Trustmark Dealer:factor(owner)Test Drive Car
## factor(seller_type)Individual:factor(owner)Third Owner
## factor(seller_type)Trustmark Dealer:factor(owner)Third Owner
## factor(seller_type)Individual:mileage
## factor(seller_type)Trustmark Dealer:mileage
## factor(seller_type)Individual:engine
## factor(seller_type)Trustmark Dealer:engine **
## factor(seller_type)Individual:max_power *
## factor(seller_type)Trustmark Dealer:max_power
## factor(transmission)Manual:factor(owner)Fourth & Above Owner
## factor(transmission)Manual:factor(owner)Second Owner
## factor(transmission)Manual:factor(owner)Test Drive Car
## factor(transmission)Manual:factor(owner)Third Owner
## factor(transmission)Manual:mileage
## factor(transmission)Manual:engine
## factor(transmission)Manual:max_power **
## factor(transmission)Manual:seats ***
## factor(transmission)Manual:torque_rpm
## factor(owner)Fourth & Above Owner:mileage
## factor(owner)Second Owner:mileage ***
## factor(owner)Test Drive Car:mileage *
## factor(owner)Third Owner:mileage
## factor(owner)Fourth & Above Owner:engine
## factor(owner)Second Owner:engine ***
## factor(owner)Test Drive Car:engine
## factor(owner)Third Owner:engine .
## mileage:engine ***
## mileage:max_power
## engine:max_power ***
## engine:torque_rpm ***
## max_power:seats
## max_power:torque_rpm ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.768 on 7782 degrees of freedom
## Multiple R-squared: 0.895, Adjusted R-squared: 0.894
## F-statistic: 921 on 72 and 7782 DF, p-value: < 2.2e-16
library(ggplot2)
ggplot(bcmodel, aes(x=.fitted, y=.resid)) +
geom_point() + geom_smooth()+
geom_hline(yintercept = 0)
## `geom_smooth()` using method = 'gam' and formula 'y ~ s(x, bs = "cs")'
# Cooks distance for outliers
car_dataset[cooks.distance(reducedint2)>1,]
plot(reducedint2,pch=18,col="red",which=c(4))
lev=hatvalues(reducedint2)
outlier3p = lev[lev>(3*28/7855)]
#print(outlier3p)
library(MASS)
bc=boxcox(reducedint2,lambda=seq(-8,8))
bestlambda=bc$x[which(bc$y==max(bc$y))]
bestlambda
## [1] 0.08080808
bcmodel=lm((((selling_price^0.08080808)-1)/0.08080808) ~ year+km_driven+factor(fuel)+factor(seller_type)+factor(transmission)+factor(owner)+mileage+engine+max_power+seats+torque_rpm + year*km_driven + year*factor(seller_type) + year*factor(transmission) + year*mileage + year*engine + year*max_power + year*torque_rpm + km_driven*factor(seller_type) + km_driven*factor(transmission) + km_driven*max_power + factor(fuel)*factor(transmission) + factor(fuel)*factor(owner) + factor(seller_type)*factor(transmission) + factor(seller_type)*factor(owner) + factor(seller_type)*mileage + factor(seller_type)*engine +factor(seller_type)*max_power + factor(transmission)*factor(owner) + factor(transmission)*mileage + factor(transmission)*engine + factor(transmission)*max_power + factor(transmission)*seats + factor(transmission)*torque_rpm + factor(owner)*mileage + factor(owner)*engine + mileage*engine + mileage*max_power + engine*max_power + engine*torque_rpm + max_power*seats + max_power*torque_rpm, data=car_dataset)
summary(bcmodel)
##
## Call:
## lm(formula = (((selling_price^0.08080808) - 1)/0.08080808) ~
## year + km_driven + factor(fuel) + factor(seller_type) + factor(transmission) +
## factor(owner) + mileage + engine + max_power + seats +
## torque_rpm + year * km_driven + year * factor(seller_type) +
## year * factor(transmission) + year * mileage + year *
## engine + year * max_power + year * torque_rpm + km_driven *
## factor(seller_type) + km_driven * factor(transmission) +
## km_driven * max_power + factor(fuel) * factor(transmission) +
## factor(fuel) * factor(owner) + factor(seller_type) *
## factor(transmission) + factor(seller_type) * factor(owner) +
## factor(seller_type) * mileage + factor(seller_type) *
## engine + factor(seller_type) * max_power + factor(transmission) *
## factor(owner) + factor(transmission) * mileage + factor(transmission) *
## engine + factor(transmission) * max_power + factor(transmission) *
## seats + factor(transmission) * torque_rpm + factor(owner) *
## mileage + factor(owner) * engine + mileage * engine +
## mileage * max_power + engine * max_power + engine * torque_rpm +
## max_power * seats + max_power * torque_rpm, data = car_dataset)
##
## Residuals:
## Min 1Q Median 3Q Max
## -4.1559 -0.4235 0.0429 0.4736 3.9419
##
## Coefficients: (11 not defined because of singularities)
## Estimate
## (Intercept) -2.339e+02
## year 1.247e-01
## km_driven 8.509e-04
## factor(fuel)Diesel 1.023e+00
## factor(fuel)LPG 3.672e-01
## factor(fuel)Petrol -5.083e-02
## factor(seller_type)Individual 3.861e+01
## factor(seller_type)Trustmark Dealer -3.320e+02
## factor(transmission)Manual -5.458e+01
## factor(owner)Fourth & Above Owner 1.023e+00
## factor(owner)Second Owner -1.496e+00
## factor(owner)Test Drive Car 2.636e+01
## factor(owner)Third Owner -5.416e-01
## mileage -6.835e+00
## engine -1.291e-02
## max_power -3.889e+00
## seats -4.750e-02
## torque_rpm 3.093e-02
## year:km_driven -4.267e-07
## year:factor(seller_type)Individual -1.921e-02
## year:factor(seller_type)Trustmark Dealer 1.634e-01
## year:factor(transmission)Manual 2.653e-02
## year:mileage 3.426e-03
## year:engine 7.753e-06
## year:max_power 1.951e-03
## year:torque_rpm -1.532e-05
## km_driven:factor(seller_type)Individual -2.078e-07
## km_driven:factor(seller_type)Trustmark Dealer 1.197e-05
## km_driven:factor(transmission)Manual 6.145e-06
## km_driven:max_power 1.043e-08
## factor(fuel)Diesel:factor(transmission)Manual -7.271e-01
## factor(fuel)LPG:factor(transmission)Manual NA
## factor(fuel)Petrol:factor(transmission)Manual NA
## factor(fuel)Diesel:factor(owner)Fourth & Above Owner 5.831e-02
## factor(fuel)LPG:factor(owner)Fourth & Above Owner 3.624e-01
## factor(fuel)Petrol:factor(owner)Fourth & Above Owner -3.819e-01
## factor(fuel)Diesel:factor(owner)Second Owner 3.172e-01
## factor(fuel)LPG:factor(owner)Second Owner 4.490e-01
## factor(fuel)Petrol:factor(owner)Second Owner 4.780e-01
## factor(fuel)Diesel:factor(owner)Test Drive Car 9.165e+00
## factor(fuel)LPG:factor(owner)Test Drive Car NA
## factor(fuel)Petrol:factor(owner)Test Drive Car NA
## factor(fuel)Diesel:factor(owner)Third Owner -5.669e-02
## factor(fuel)LPG:factor(owner)Third Owner 8.735e-02
## factor(fuel)Petrol:factor(owner)Third Owner 1.615e-02
## factor(seller_type)Individual:factor(transmission)Manual 9.977e-02
## factor(seller_type)Trustmark Dealer:factor(transmission)Manual 4.715e-01
## factor(seller_type)Individual:factor(owner)Fourth & Above Owner NA
## factor(seller_type)Trustmark Dealer:factor(owner)Fourth & Above Owner NA
## factor(seller_type)Individual:factor(owner)Second Owner -1.838e-01
## factor(seller_type)Trustmark Dealer:factor(owner)Second Owner -8.695e-01
## factor(seller_type)Individual:factor(owner)Test Drive Car NA
## factor(seller_type)Trustmark Dealer:factor(owner)Test Drive Car NA
## factor(seller_type)Individual:factor(owner)Third Owner -3.750e-01
## factor(seller_type)Trustmark Dealer:factor(owner)Third Owner NA
## factor(seller_type)Individual:mileage -4.302e-03
## factor(seller_type)Trustmark Dealer:mileage -1.388e-03
## factor(seller_type)Individual:engine 1.854e-04
## factor(seller_type)Trustmark Dealer:engine 1.163e-03
## factor(seller_type)Individual:max_power -3.075e-03
## factor(seller_type)Trustmark Dealer:max_power 3.717e-03
## factor(transmission)Manual:factor(owner)Fourth & Above Owner -5.437e-01
## factor(transmission)Manual:factor(owner)Second Owner -1.384e-01
## factor(transmission)Manual:factor(owner)Test Drive Car NA
## factor(transmission)Manual:factor(owner)Third Owner -1.014e-01
## factor(transmission)Manual:mileage 1.892e-02
## factor(transmission)Manual:engine -1.881e-04
## factor(transmission)Manual:max_power -5.096e-03
## factor(transmission)Manual:seats 2.472e-01
## factor(transmission)Manual:torque_rpm -7.899e-05
## factor(owner)Fourth & Above Owner:mileage -1.741e-02
## factor(owner)Second Owner:mileage 3.983e-02
## factor(owner)Test Drive Car:mileage -1.581e+00
## factor(owner)Third Owner:mileage 2.099e-02
## factor(owner)Fourth & Above Owner:engine -3.205e-04
## factor(owner)Second Owner:engine 3.379e-04
## factor(owner)Test Drive Car:engine NA
## factor(owner)Third Owner:engine 2.424e-04
## mileage:engine -4.060e-05
## mileage:max_power 7.413e-05
## engine:max_power -8.540e-06
## engine:torque_rpm -4.786e-07
## max_power:seats -6.348e-04
## max_power:torque_rpm 6.805e-06
## Std. Error
## (Intercept) 7.146e+01
## year 3.560e-02
## km_driven 9.638e-05
## factor(fuel)Diesel 1.816e-01
## factor(fuel)LPG 2.319e-01
## factor(fuel)Petrol 1.393e-01
## factor(seller_type)Individual 2.526e+01
## factor(seller_type)Trustmark Dealer 1.363e+02
## factor(transmission)Manual 3.181e+01
## factor(owner)Fourth & Above Owner 1.104e+00
## factor(owner)Second Owner 4.109e-01
## factor(owner)Test Drive Car 1.131e+01
## factor(owner)Third Owner 8.759e-01
## mileage 1.960e+00
## engine 2.096e-02
## max_power 2.781e-01
## seats 8.656e-02
## torque_rpm 5.868e-03
## year:km_driven 4.787e-08
## year:factor(seller_type)Individual 1.256e-02
## year:factor(seller_type)Trustmark Dealer 6.756e-02
## year:factor(transmission)Manual 1.586e-02
## year:mileage 9.718e-04
## year:engine 1.041e-05
## year:max_power 1.384e-04
## year:torque_rpm 2.909e-06
## km_driven:factor(seller_type)Individual 1.043e-06
## km_driven:factor(seller_type)Trustmark Dealer 5.825e-06
## km_driven:factor(transmission)Manual 1.155e-06
## km_driven:max_power 6.567e-09
## factor(fuel)Diesel:factor(transmission)Manual 1.311e-01
## factor(fuel)LPG:factor(transmission)Manual NA
## factor(fuel)Petrol:factor(transmission)Manual NA
## factor(fuel)Diesel:factor(owner)Fourth & Above Owner 8.074e-01
## factor(fuel)LPG:factor(owner)Fourth & Above Owner 1.112e+00
## factor(fuel)Petrol:factor(owner)Fourth & Above Owner 7.880e-01
## factor(fuel)Diesel:factor(owner)Second Owner 2.395e-01
## factor(fuel)LPG:factor(owner)Second Owner 3.804e-01
## factor(fuel)Petrol:factor(owner)Second Owner 2.434e-01
## factor(fuel)Diesel:factor(owner)Test Drive Car 4.923e+00
## factor(fuel)LPG:factor(owner)Test Drive Car NA
## factor(fuel)Petrol:factor(owner)Test Drive Car NA
## factor(fuel)Diesel:factor(owner)Third Owner 5.638e-01
## factor(fuel)LPG:factor(owner)Third Owner 6.873e-01
## factor(fuel)Petrol:factor(owner)Third Owner 5.639e-01
## factor(seller_type)Individual:factor(transmission)Manual 8.536e-02
## factor(seller_type)Trustmark Dealer:factor(transmission)Manual 1.930e-01
## factor(seller_type)Individual:factor(owner)Fourth & Above Owner NA
## factor(seller_type)Trustmark Dealer:factor(owner)Fourth & Above Owner NA
## factor(seller_type)Individual:factor(owner)Second Owner 9.509e-02
## factor(seller_type)Trustmark Dealer:factor(owner)Second Owner 3.880e-01
## factor(seller_type)Individual:factor(owner)Test Drive Car NA
## factor(seller_type)Trustmark Dealer:factor(owner)Test Drive Car NA
## factor(seller_type)Individual:factor(owner)Third Owner 3.927e-01
## factor(seller_type)Trustmark Dealer:factor(owner)Third Owner NA
## factor(seller_type)Individual:mileage 9.082e-03
## factor(seller_type)Trustmark Dealer:mileage 3.119e-02
## factor(seller_type)Individual:engine 1.193e-04
## factor(seller_type)Trustmark Dealer:engine 3.698e-04
## factor(seller_type)Individual:max_power 1.469e-03
## factor(seller_type)Trustmark Dealer:max_power 7.059e-03
## factor(transmission)Manual:factor(owner)Fourth & Above Owner 3.338e-01
## factor(transmission)Manual:factor(owner)Second Owner 9.500e-02
## factor(transmission)Manual:factor(owner)Test Drive Car NA
## factor(transmission)Manual:factor(owner)Third Owner 2.112e-01
## factor(transmission)Manual:mileage 1.540e-02
## factor(transmission)Manual:engine 1.768e-04
## factor(transmission)Manual:max_power 1.743e-03
## factor(transmission)Manual:seats 6.306e-02
## factor(transmission)Manual:torque_rpm 5.540e-05
## factor(owner)Fourth & Above Owner:mileage 2.876e-02
## factor(owner)Second Owner:mileage 9.030e-03
## factor(owner)Test Drive Car:mileage 7.252e-01
## factor(owner)Third Owner:mileage 1.675e-02
## factor(owner)Fourth & Above Owner:engine 2.316e-04
## factor(owner)Second Owner:engine 8.244e-05
## factor(owner)Test Drive Car:engine NA
## factor(owner)Third Owner:engine 1.399e-04
## mileage:engine 1.087e-05
## mileage:max_power 1.213e-04
## engine:max_power 9.088e-07
## engine:torque_rpm 5.193e-08
## max_power:seats 4.265e-04
## max_power:torque_rpm 7.018e-07
## t value
## (Intercept) -3.274
## year 3.502
## km_driven 8.829
## factor(fuel)Diesel 5.631
## factor(fuel)LPG 1.584
## factor(fuel)Petrol -0.365
## factor(seller_type)Individual 1.528
## factor(seller_type)Trustmark Dealer -2.435
## factor(transmission)Manual -1.716
## factor(owner)Fourth & Above Owner 0.927
## factor(owner)Second Owner -3.641
## factor(owner)Test Drive Car 2.331
## factor(owner)Third Owner -0.618
## mileage -3.488
## engine -0.616
## max_power -13.985
## seats -0.549
## torque_rpm 5.272
## year:km_driven -8.915
## year:factor(seller_type)Individual -1.529
## year:factor(seller_type)Trustmark Dealer 2.419
## year:factor(transmission)Manual 1.673
## year:mileage 3.525
## year:engine 0.744
## year:max_power 14.101
## year:torque_rpm -5.267
## km_driven:factor(seller_type)Individual -0.199
## km_driven:factor(seller_type)Trustmark Dealer 2.054
## km_driven:factor(transmission)Manual 5.318
## km_driven:max_power 1.587
## factor(fuel)Diesel:factor(transmission)Manual -5.548
## factor(fuel)LPG:factor(transmission)Manual NA
## factor(fuel)Petrol:factor(transmission)Manual NA
## factor(fuel)Diesel:factor(owner)Fourth & Above Owner 0.072
## factor(fuel)LPG:factor(owner)Fourth & Above Owner 0.326
## factor(fuel)Petrol:factor(owner)Fourth & Above Owner -0.485
## factor(fuel)Diesel:factor(owner)Second Owner 1.324
## factor(fuel)LPG:factor(owner)Second Owner 1.181
## factor(fuel)Petrol:factor(owner)Second Owner 1.964
## factor(fuel)Diesel:factor(owner)Test Drive Car 1.862
## factor(fuel)LPG:factor(owner)Test Drive Car NA
## factor(fuel)Petrol:factor(owner)Test Drive Car NA
## factor(fuel)Diesel:factor(owner)Third Owner -0.101
## factor(fuel)LPG:factor(owner)Third Owner 0.127
## factor(fuel)Petrol:factor(owner)Third Owner 0.029
## factor(seller_type)Individual:factor(transmission)Manual 1.169
## factor(seller_type)Trustmark Dealer:factor(transmission)Manual 2.444
## factor(seller_type)Individual:factor(owner)Fourth & Above Owner NA
## factor(seller_type)Trustmark Dealer:factor(owner)Fourth & Above Owner NA
## factor(seller_type)Individual:factor(owner)Second Owner -1.933
## factor(seller_type)Trustmark Dealer:factor(owner)Second Owner -2.241
## factor(seller_type)Individual:factor(owner)Test Drive Car NA
## factor(seller_type)Trustmark Dealer:factor(owner)Test Drive Car NA
## factor(seller_type)Individual:factor(owner)Third Owner -0.955
## factor(seller_type)Trustmark Dealer:factor(owner)Third Owner NA
## factor(seller_type)Individual:mileage -0.474
## factor(seller_type)Trustmark Dealer:mileage -0.044
## factor(seller_type)Individual:engine 1.554
## factor(seller_type)Trustmark Dealer:engine 3.145
## factor(seller_type)Individual:max_power -2.093
## factor(seller_type)Trustmark Dealer:max_power 0.527
## factor(transmission)Manual:factor(owner)Fourth & Above Owner -1.629
## factor(transmission)Manual:factor(owner)Second Owner -1.457
## factor(transmission)Manual:factor(owner)Test Drive Car NA
## factor(transmission)Manual:factor(owner)Third Owner -0.480
## factor(transmission)Manual:mileage 1.228
## factor(transmission)Manual:engine -1.064
## factor(transmission)Manual:max_power -2.924
## factor(transmission)Manual:seats 3.920
## factor(transmission)Manual:torque_rpm -1.426
## factor(owner)Fourth & Above Owner:mileage -0.605
## factor(owner)Second Owner:mileage 4.411
## factor(owner)Test Drive Car:mileage -2.180
## factor(owner)Third Owner:mileage 1.253
## factor(owner)Fourth & Above Owner:engine -1.384
## factor(owner)Second Owner:engine 4.099
## factor(owner)Test Drive Car:engine NA
## factor(owner)Third Owner:engine 1.733
## mileage:engine -3.734
## mileage:max_power 0.611
## engine:max_power -9.397
## engine:torque_rpm -9.217
## max_power:seats -1.488
## max_power:torque_rpm 9.696
## Pr(>|t|)
## (Intercept) 0.001066
## year 0.000464
## km_driven < 2e-16
## factor(fuel)Diesel 1.85e-08
## factor(fuel)LPG 0.113330
## factor(fuel)Petrol 0.715175
## factor(seller_type)Individual 0.126430
## factor(seller_type)Trustmark Dealer 0.014909
## factor(transmission)Manual 0.086184
## factor(owner)Fourth & Above Owner 0.353980
## factor(owner)Second Owner 0.000273
## factor(owner)Test Drive Car 0.019803
## factor(owner)Third Owner 0.536369
## mileage 0.000490
## engine 0.537916
## max_power < 2e-16
## seats 0.583167
## torque_rpm 1.39e-07
## year:km_driven < 2e-16
## year:factor(seller_type)Individual 0.126194
## year:factor(seller_type)Trustmark Dealer 0.015590
## year:factor(transmission)Manual 0.094398
## year:mileage 0.000425
## year:engine 0.456639
## year:max_power < 2e-16
## year:torque_rpm 1.43e-07
## km_driven:factor(seller_type)Individual 0.842102
## km_driven:factor(seller_type)Trustmark Dealer 0.039967
## km_driven:factor(transmission)Manual 1.08e-07
## km_driven:max_power 0.112443
## factor(fuel)Diesel:factor(transmission)Manual 2.99e-08
## factor(fuel)LPG:factor(transmission)Manual NA
## factor(fuel)Petrol:factor(transmission)Manual NA
## factor(fuel)Diesel:factor(owner)Fourth & Above Owner 0.942433
## factor(fuel)LPG:factor(owner)Fourth & Above Owner 0.744427
## factor(fuel)Petrol:factor(owner)Fourth & Above Owner 0.627948
## factor(fuel)Diesel:factor(owner)Second Owner 0.185463
## factor(fuel)LPG:factor(owner)Second Owner 0.237821
## factor(fuel)Petrol:factor(owner)Second Owner 0.049531
## factor(fuel)Diesel:factor(owner)Test Drive Car 0.062679
## factor(fuel)LPG:factor(owner)Test Drive Car NA
## factor(fuel)Petrol:factor(owner)Test Drive Car NA
## factor(fuel)Diesel:factor(owner)Third Owner 0.919904
## factor(fuel)LPG:factor(owner)Third Owner 0.898880
## factor(fuel)Petrol:factor(owner)Third Owner 0.977158
## factor(seller_type)Individual:factor(transmission)Manual 0.242486
## factor(seller_type)Trustmark Dealer:factor(transmission)Manual 0.014567
## factor(seller_type)Individual:factor(owner)Fourth & Above Owner NA
## factor(seller_type)Trustmark Dealer:factor(owner)Fourth & Above Owner NA
## factor(seller_type)Individual:factor(owner)Second Owner 0.053250
## factor(seller_type)Trustmark Dealer:factor(owner)Second Owner 0.025045
## factor(seller_type)Individual:factor(owner)Test Drive Car NA
## factor(seller_type)Trustmark Dealer:factor(owner)Test Drive Car NA
## factor(seller_type)Individual:factor(owner)Third Owner 0.339623
## factor(seller_type)Trustmark Dealer:factor(owner)Third Owner NA
## factor(seller_type)Individual:mileage 0.635760
## factor(seller_type)Trustmark Dealer:mileage 0.964515
## factor(seller_type)Individual:engine 0.120193
## factor(seller_type)Trustmark Dealer:engine 0.001670
## factor(seller_type)Individual:max_power 0.036364
## factor(seller_type)Trustmark Dealer:max_power 0.598540
## factor(transmission)Manual:factor(owner)Fourth & Above Owner 0.103385
## factor(transmission)Manual:factor(owner)Second Owner 0.145192
## factor(transmission)Manual:factor(owner)Test Drive Car NA
## factor(transmission)Manual:factor(owner)Third Owner 0.631176
## factor(transmission)Manual:mileage 0.219350
## factor(transmission)Manual:engine 0.287528
## factor(transmission)Manual:max_power 0.003468
## factor(transmission)Manual:seats 8.93e-05
## factor(transmission)Manual:torque_rpm 0.153979
## factor(owner)Fourth & Above Owner:mileage 0.544968
## factor(owner)Second Owner:mileage 1.04e-05
## factor(owner)Test Drive Car:mileage 0.029254
## factor(owner)Third Owner:mileage 0.210154
## factor(owner)Fourth & Above Owner:engine 0.166440
## factor(owner)Second Owner:engine 4.19e-05
## factor(owner)Test Drive Car:engine NA
## factor(owner)Third Owner:engine 0.083201
## mileage:engine 0.000190
## mileage:max_power 0.541189
## engine:max_power < 2e-16
## engine:torque_rpm < 2e-16
## max_power:seats 0.136685
## max_power:torque_rpm < 2e-16
##
## (Intercept) **
## year ***
## km_driven ***
## factor(fuel)Diesel ***
## factor(fuel)LPG
## factor(fuel)Petrol
## factor(seller_type)Individual
## factor(seller_type)Trustmark Dealer *
## factor(transmission)Manual .
## factor(owner)Fourth & Above Owner
## factor(owner)Second Owner ***
## factor(owner)Test Drive Car *
## factor(owner)Third Owner
## mileage ***
## engine
## max_power ***
## seats
## torque_rpm ***
## year:km_driven ***
## year:factor(seller_type)Individual
## year:factor(seller_type)Trustmark Dealer *
## year:factor(transmission)Manual .
## year:mileage ***
## year:engine
## year:max_power ***
## year:torque_rpm ***
## km_driven:factor(seller_type)Individual
## km_driven:factor(seller_type)Trustmark Dealer *
## km_driven:factor(transmission)Manual ***
## km_driven:max_power
## factor(fuel)Diesel:factor(transmission)Manual ***
## factor(fuel)LPG:factor(transmission)Manual
## factor(fuel)Petrol:factor(transmission)Manual
## factor(fuel)Diesel:factor(owner)Fourth & Above Owner
## factor(fuel)LPG:factor(owner)Fourth & Above Owner
## factor(fuel)Petrol:factor(owner)Fourth & Above Owner
## factor(fuel)Diesel:factor(owner)Second Owner
## factor(fuel)LPG:factor(owner)Second Owner
## factor(fuel)Petrol:factor(owner)Second Owner *
## factor(fuel)Diesel:factor(owner)Test Drive Car .
## factor(fuel)LPG:factor(owner)Test Drive Car
## factor(fuel)Petrol:factor(owner)Test Drive Car
## factor(fuel)Diesel:factor(owner)Third Owner
## factor(fuel)LPG:factor(owner)Third Owner
## factor(fuel)Petrol:factor(owner)Third Owner
## factor(seller_type)Individual:factor(transmission)Manual
## factor(seller_type)Trustmark Dealer:factor(transmission)Manual *
## factor(seller_type)Individual:factor(owner)Fourth & Above Owner
## factor(seller_type)Trustmark Dealer:factor(owner)Fourth & Above Owner
## factor(seller_type)Individual:factor(owner)Second Owner .
## factor(seller_type)Trustmark Dealer:factor(owner)Second Owner *
## factor(seller_type)Individual:factor(owner)Test Drive Car
## factor(seller_type)Trustmark Dealer:factor(owner)Test Drive Car
## factor(seller_type)Individual:factor(owner)Third Owner
## factor(seller_type)Trustmark Dealer:factor(owner)Third Owner
## factor(seller_type)Individual:mileage
## factor(seller_type)Trustmark Dealer:mileage
## factor(seller_type)Individual:engine
## factor(seller_type)Trustmark Dealer:engine **
## factor(seller_type)Individual:max_power *
## factor(seller_type)Trustmark Dealer:max_power
## factor(transmission)Manual:factor(owner)Fourth & Above Owner
## factor(transmission)Manual:factor(owner)Second Owner
## factor(transmission)Manual:factor(owner)Test Drive Car
## factor(transmission)Manual:factor(owner)Third Owner
## factor(transmission)Manual:mileage
## factor(transmission)Manual:engine
## factor(transmission)Manual:max_power **
## factor(transmission)Manual:seats ***
## factor(transmission)Manual:torque_rpm
## factor(owner)Fourth & Above Owner:mileage
## factor(owner)Second Owner:mileage ***
## factor(owner)Test Drive Car:mileage *
## factor(owner)Third Owner:mileage
## factor(owner)Fourth & Above Owner:engine
## factor(owner)Second Owner:engine ***
## factor(owner)Test Drive Car:engine
## factor(owner)Third Owner:engine .
## mileage:engine ***
## mileage:max_power
## engine:max_power ***
## engine:torque_rpm ***
## max_power:seats
## max_power:torque_rpm ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.768 on 7782 degrees of freedom
## Multiple R-squared: 0.895, Adjusted R-squared: 0.894
## F-statistic: 921 on 72 and 7782 DF, p-value: < 2.2e-16
library(lmtest)
## Loading required package: zoo
##
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
##
## as.Date, as.Date.numeric
bptest(firstordermodel)
##
## studentized Breusch-Pagan test
##
## data: firstordermodel
## BP = 2413.8, df = 17, p-value < 2.2e-16
bptest(reducedint2)
##
## studentized Breusch-Pagan test
##
## data: reducedint2
## BP = 3000.7, df = 72, p-value < 2.2e-16
bptest(reducedint3)
##
## studentized Breusch-Pagan test
##
## data: reducedint3
## BP = 1040.6, df = 72, p-value < 2.2e-16
bptest(bcmodel)
##
## studentized Breusch-Pagan test
##
## data: bcmodel
## BP = 1014.3, df = 72, p-value < 2.2e-16
Residual Plot
#residual vs fitted data plot for the finalintermodel model
ggplot(bcmodel, aes(x=.fitted, y=.resid)) +
geom_point() +geom_smooth()+
geom_hline(yintercept = 0)
## `geom_smooth()` using method = 'gam' and formula 'y ~ s(x, bs = "cs")'
#a scale location plot
ggplot(bcmodel, aes(x=.fitted, y=sqrt(abs(.stdresid)))) +
geom_point() +
geom_hline(yintercept = 0) +
geom_smooth()+
ggtitle("Scale-Location plot : Standardized Residual vs Fitted values")
## `geom_smooth()` using method = 'gam' and formula 'y ~ s(x, bs = "cs")'
## Warning: Removed 3 rows containing non-finite values (stat_smooth).
## Warning: Removed 3 rows containing missing values (geom_point).
ks.test(x=residuals(bcmodel),y='pnorm',alternative='two.sided')
## Warning in ks.test.default(x = residuals(bcmodel), y = "pnorm", alternative =
## "two.sided"): ties should not be present for the Kolmogorov-Smirnov test
##
## Asymptotic one-sample Kolmogorov-Smirnov test
##
## data: residuals(bcmodel)
## D = 0.090496, p-value < 2.2e-16
## alternative hypothesis: two-sided
#Testing for Normality again
shapiro.test(residuals(bcmodel)[0:5000])
##
## Shapiro-Wilk normality test
##
## data: residuals(bcmodel)[0:5000]
## W = 0.98689, p-value < 2.2e-16
After the shapiro test, the p-value(0.9545) is much higher than 0.05, which confirms that the residuals are normally distributed.
Histogram for residuals
library(ggplot2)
qplot(residuals(bcmodel),
geom="histogram",
binwidth = 0.5,
main = "Histogram of residuals",
xlab = "residuals", color="red",
fill=I("blue"))
The outputs show that the residual data is a normal distribution (from histogram).
Normal Q-Q plot
#normal QQ plot
ggplot(car_dataset, aes(sample=bcmodel$residuals)) +
stat_qq() +
stat_qq_line()
Q-Q plot compute the slope and intercept of the line connecting the points at specified quartiles of the theoretical and sample distributions. The outputs show that the residual data has normal distribution from Q-Q plot because the points are closed to the the diagonal reference line between -2 and 2 in X.