Mtcars Dataset Analysis in R
Mtcars Dataset Analysis in R
Mtcars Dataset Analysis in R
Use the “mtcars” data set under “car” package for analysis.
Build an Econometric Model on that you have confidence that it can be used for prediction purpose. In
the process of building the model the following issues are expected to be addressed.
Before analysis
Estimation Stage
1. Linearity
2. Normality
3. Free from Autocorrelation
4. Absence of Multicollinearity
5. Homoscedastic error variance
Finally, give the best fitted model that fulfills all the requirements.
Note: Give the R codes that you used to analyze data in the Report
Data File
The data was extracted from the 1974 Motor Trend US magazine, and comprises fuel
consumption and 10 aspects of automobile design and performance for 32 automobiles
(1973–74 models).
A data frame with 32 observations on 11 variables.
[, 1] mpg Miles/(US) gallon
[, 2] cyl Number of cylinders
[, 3] disp Displacement (cu.in.)
[, 4] hp Gross horsepower
[, 5] drat Rear axle ratio
[, 6] wt Weight (1000 lbs)
[, 7] qsec 1/4 mile time
[, 8] vs V/S
[, 9] am Transmission (0 = automatic, 1 = manual)
[,10] gear Number of forward gears
[,11] carb Number of carburetors
Descriptive Analysis
Box Plot
boxplot(mpg~cyl,data=mtcars, main="Car Milage Data", xlab="Number of
Cylinders", ylab="Miles Per Gallon")
Matrix Plot
pairs(~mpg+disp+drat+wt,data=mtcars)
Correlation Analysis
cor(a)
Regression Diagnostic
Normality
a. Graphical
qqPlot(fit, main="QQ Plot")
b. Test of Hypothesis
res<-residuals(fit) # to get the residuals from the estimated model
shapiro.test(res)
Heteroscedasticity
a. Graphical
spreadLevelPlot(fit)# plot studentized residuals vs. fitted values
b. Test of Hypothesis
Multicolinearity
vif(fit) # variance inflation factors
sqrt(vif(fit)) > 2 # problem?
Autocorrelation
durbinWatsonTest(fit)