Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

You just type datamtcars) in Rstudio and run and the data will open itself 1. Lo

ID: 3314291 • Letter: Y

Question

You just type datamtcars) in Rstudio and run and the data will open itself 1. Load the mtcors dataset data(mtcars) 2. Description of variables: a. mpg: Miles/(US) gallon b. yl: Number of cylinders c. disp: Displacement (cu.in.) d. bp: Gross horsepower e. drat: Rear axle ratio f. wt: Weight (1000 lbs) g. gsec 1/4 mile time am: Transmission (o automatic, 1 = manual) J. gear: Number of forward gears k. carb: Number of carburetors 3. Run a regression where mpg is the dependent variable and cy! is the independent variable a. Look at the summary of the regression and comment on the significance and the magnitude of the independent variable b. Check the assumptions of linear regression 4. Run a regression where mpg is the dependent variable and hp is the independent variable a. Look at the summary of the regression and comment on the significance and the magnitude of the independent variable b. Check the assumptions of linear regression

Explanation / Answer

The following analysis was performed in R

1) Loaded the dataset - mtcars from the caret package. mtc<- dataset::mtcars

2) 32 observations of 11 variables are present in the dataset.

3) lm(mpg~cyl, data = mtc)

> summary(reg)

Call:

lm(formula = mpg ~ cyl, data = mtc)

Residuals:

Min 1Q Median 3Q Max

-4.9814 -2.1185 0.2217 1.0717 7.5186

Coefficients:

Estimate Std. Error t value Pr(>|t|)   

(Intercept) 37.8846 2.0738 18.27 < 2e-16 ***

cyl -2.8758 0.3224 -8.92 6.11e-10 ***

---

Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 3.206 on 30 degrees of freedom

Multiple R-squared: 0.7262, Adjusted R-squared: 0.7171

F-statistic: 79.56 on 1 and 30 DF, p-value: 6.113e-10

----------------------------------------------------------------------------------------

The low p value above indicates that cyl significantly influences the dependent variable mpg i.e. number of cylinders influences the miles/gallon

The coefficient indicates that for 1 unit increase in the number of cylinders, the miles /gallon reduces by 2.8758.

All the assumptions of linear regression is fulfilled by the above model.
No Autocorrelation, Heteroscedasticity, multicolllinearity (NA) has been found. Model meets linearity assumption and normal distribtuion of error terms.

4) reg1<-lm(mpg~hp, data=mtc)

> summary(reg1)

Call:

lm(formula = mpg ~ hp, data = mtc)

Residuals:

Min 1Q Median 3Q Max

-5.7121 -2.1122 -0.8854 1.5819 8.2360

Coefficients:

Estimate Std. Error t value Pr(>|t|)   

(Intercept) 30.09886 1.63392 18.421 < 2e-16 ***

hp -0.06823 0.01012 -6.742 1.79e-07 ***

---

Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 3.863 on 30 degrees of freedom

Multiple R-squared: 0.6024, Adjusted R-squared: 0.5892

F-statistic: 45.46 on 1 and 30 DF, p-value: 1.788e-07

----------------------------------------------------------------------------------------------

The model does not meet the assumptions of linear regression.
There is non linearity present in the data as is observed by the residuals vs fitted values plot.
The error terms are not distributed normally as is observed by the QQ plot.
Thers is positive autocorrelation in the data as is observed by the Durbin Watson statistic - 1.33.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote