Vous êtes sur la page 1sur 5

pdfcrowd.com PRO version Are you a developer?

Try out the HTML to PDF API


Project
Project Summary- In the data set mtcars there are 11 variables, 7(mpg=Miles/gallon, cyl=no.of
cylinders,disp=displacement,hp=grosshorsepower, drat=Rear axle ratio,wt=weight,qsec=1/4 mile time) of them are
quantitative varibles and 4(vs=V/s, am=transmission,gear=no.of forward gears,carb=no.ofcarburetors) of them are
qualititative variables. We will find and predict the relation between the variable mpg(Resonse variable) and the other
predictors variables including am (transmission mode)variable which is a categorical variable also. We will use the forward
going adjusted R2 method and also will discover if interaction variable can also improve the model. Besides looking at the
adjusted R2 method in the forward going techniques, We will also consider the p values of the prediction varibales.And
after evaluting the models we found that most optimized model has adjusted R2 value as 81.51.And all predictor variables
has their p values less than the 0.05 which is also less than the significance level. Also after setting the model we have
checked the normalization of residuals for the fitted model and that also is quite good and normal with less
skewedness.And which transmission system(am=1 or 0)is better for mpg can not be answered. Because At lower weights
2.62 manual transmission is better(am=1) is 1 mpg higher than automatic transmisssion at same weight 2.62 but at heavy
weight 5.42, am=1 has negative mpg compared to am=0(automatic transmission). So after styding further the model we
found out it can not be answered that which am(transmission system) is better for mpg becuase few other predictors are
also responsible in this case such as wt(weight)
data(mtcars)
Going ahead with a forward selection-adjusted R2 method also applying interactive variables later in the models
a=lm(mpg~am,data=mtcars)
b=lm(mpg~wt+am,data=mtcars)
c=lm(mpg~wt+am+cyl,data=mtcars)
d=lm(mpg~wt+am+cyl+disp,data=mtcars)
d=lm(mpg~wt+am+cyl+hp,data=mtcars)
pdfcrowd.com PRO version Are you a developer? Try out the HTML to PDF API
e=lm(mpg~wt+am+cyl+hp+drat,data=mtcars)
f=lm(mpg~wt+am+cyl+hp+qsec,data=mtcars)
g=lm(mpg~wt+am+cyl+hp+gear,data=mtcars)
h=lm(mpg~wt+am+cyl+hp+qsec+carb,data=mtcars)
h=lm(mpg~wt+am+am*wt,data=mtcars)
summary(h)
##
## Call:
## lm(formula = mpg ~ wt + am + am * wt, data = mtcars)
##
## Residuals:
## Min 1Q Median 3Q Max
## -3.600 -1.545 -0.533 0.901 6.091
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 31.416 3.020 10.40 4.0e-11 ***
## wt -3.786 0.786 -4.82 4.6e-05 ***
## am 14.878 4.264 3.49 0.0016 **
## wt:am -5.298 1.445 -3.67 0.0010 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 2.59 on 28 degrees of freedom
## Multiple R-squared: 0.833, Adjusted R-squared: 0.815
## F-statistic: 46.6 on 3 and 28 DF, p-value: 5.21e-11
pdfcrowd.com PRO version Are you a developer? Try out the HTML to PDF API
SO after conducting and setting up different models a,b,c,d,e,f,g,h we observed Adjusted R2 in all te models and also the p
values for the predictors and we found out after using as an interactive variable in model H R2 adjusted R2 and p values of
predictors make the best model.SO h is the model we will set up as the best fit model now finding out mpg for different
transmission systems
31.4161-3.759*2.62+14.8784-5.2984*2.62
## [1] 22.56
31.4161-3.759*2.62
## [1] 21.57
Here manual transmission system(am=1) has higher mpg. Lets take an aother example for little higher weight of 5.42
31.4161-3.759*5.42+14.8784-5.2984*5.42
## [1] -2.797
31.4161-3.759*5.42
## [1] 11.04
Here manual transmission has (am=1)negative mpg and automatic (am=0) has higher mpg. So on the basis of just am=0 or
1 this question can not be answered. now doing some exploratory anaysis of our model
pdfcrowd.com PRO version Are you a developer? Try out the HTML to PDF API
plot(density(residuals(h)))
oldpar <- par(mfrow = c(2, 2))
pdfcrowd.com PRO version Are you a developer? Try out the HTML to PDF API
plot(h)

Vous aimerez peut-être aussi