from the following, you may need to answer: 1. the value of correlation coefficient? 2. it is significant? 3. what is the regression model here? 4. it is significant? 5. what is the confidence interval for this regression coefficient? comments for the graphs?

cor.test(mtcars$mpg, mtcars$disp)
## 
##  Pearson's product-moment correlation
## 
## data:  mtcars$mpg and mtcars$disp
## t = -8.7472, df = 30, p-value = 9.38e-10
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.9233594 -0.7081376
## sample estimates:
##        cor 
## -0.8475514
fit<- lm(mpg ~ disp, data = mtcars)
fit
## 
## Call:
## lm(formula = mpg ~ disp, data = mtcars)
## 
## Coefficients:
## (Intercept)         disp  
##    29.59985     -0.04122
summary(fit)
## 
## Call:
## lm(formula = mpg ~ disp, data = mtcars)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -4.8922 -2.2022 -0.9631  1.6272  7.2305 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 29.599855   1.229720  24.070  < 2e-16 ***
## disp        -0.041215   0.004712  -8.747 9.38e-10 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 3.251 on 30 degrees of freedom
## Multiple R-squared:  0.7183, Adjusted R-squared:  0.709 
## F-statistic: 76.51 on 1 and 30 DF,  p-value: 9.38e-10
confint(fit)
##                   2.5 %      97.5 %
## (Intercept) 27.08843246 32.11127705
## disp        -0.05083797 -0.03159227
op<- par(mfrow = c(2, 2))
plot(fit)

par(op)

it there any problem for the following multiple linear regression?

fit<- lm(mpg ~ disp + hp + drat + wt + qsec, data = mtcars)
summary(fit)
## 
## Call:
## lm(formula = mpg ~ disp + hp + drat + wt + qsec, data = mtcars)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -3.5404 -1.6701 -0.4264  1.1320  5.4996 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)   
## (Intercept) 16.53357   10.96423   1.508  0.14362   
## disp         0.00872    0.01119   0.779  0.44281   
## hp          -0.02060    0.01528  -1.348  0.18936   
## drat         2.01578    1.30946   1.539  0.13579   
## wt          -4.38546    1.24343  -3.527  0.00158 **
## qsec         0.64015    0.45934   1.394  0.17523   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.558 on 26 degrees of freedom
## Multiple R-squared:  0.8489, Adjusted R-squared:  0.8199 
## F-statistic: 29.22 on 5 and 26 DF,  p-value: 6.892e-10
library(car)
## 载入需要的程辑包:carData
vif(fit)
##     disp       hp     drat       wt     qsec 
## 9.110869 5.201833 2.322343 7.012686 3.191939

for the following, which model is better?

fit1<- lm(mpg ~ disp + hp + drat + qsec, data = mtcars)
fit2<- lm(mpg ~ disp + hp + wt + qsec, data = mtcars)
AIC(fit1, fit2)
##      df      AIC
## fit1  6 168.7896
## fit2  6 159.0696

write down the final model from the following output.

library(MASS)
fit<- lm(mpg ~ disp + hp + drat + wt + qsec, data = mtcars)
stepAIC(fit, direction = "backward")
## Start:  AIC=65.47
## mpg ~ disp + hp + drat + wt + qsec
## 
##        Df Sum of Sq    RSS    AIC
## - disp  1     3.974 174.10 64.205
## <none>              170.13 65.466
## - hp    1    11.886 182.01 65.627
## - qsec  1    12.708 182.84 65.772
## - drat  1    15.506 185.63 66.258
## - wt    1    81.394 251.52 75.978
## 
## Step:  AIC=64.21
## mpg ~ hp + drat + wt + qsec
## 
##        Df Sum of Sq    RSS    AIC
## - hp    1     9.418 183.52 63.891
## - qsec  1     9.578 183.68 63.919
## <none>              174.10 64.205
## - drat  1    11.956 186.06 64.331
## - wt    1   113.882 287.99 78.310
## 
## Step:  AIC=63.89
## mpg ~ drat + wt + qsec
## 
##        Df Sum of Sq    RSS    AIC
## <none>              183.52 63.891
## - drat  1    11.942 195.46 63.908
## - qsec  1    85.720 269.24 74.156
## - wt    1   275.686 459.21 91.241
## 
## Call:
## lm(formula = mpg ~ drat + wt + qsec, data = mtcars)
## 
## Coefficients:
## (Intercept)         drat           wt         qsec  
##     11.3945       1.6561      -4.3978       0.9462