0
$\begingroup$

Here is what I did:

1) I divided the mtcars dataset into a training set (80%) and a validation set (20%).

2) I built a simple linear model predicting mileage (mpg) based on displacement (disp).

3) I built a multi-linear model predicting mileage (mpg) based on displacement, horsepower and weight (disp + hp + wt).

Here is the R code I used:

set.seed(123) 
trainingRowIndex <- sample(1:nrow(mtcars), 0.8*nrow(mtcars))
trainingSet <- mtcars[trainingRowIndex, ]
validationSet  <- mtcars[-trainingRowIndex, ]
# Build simple linear model (disp only)
lmMtcars <- lm(mpg ~ disp, data=trainingSet) 
summary (lmMtcars)
# Build multi-linear model (disp + hp + wt)
mlmMtcars <- lm(mpg ~ disp + hp + wt , data=trainingSet)
summary (mlmMtcars)

In the simple linear model, the disp has a p-value of 2.33e-07 (basically meaning that it is a good predictor). However, in the multi-linear model, disp has a p-value of 0.87220 (meaning that it is not a good predictor). I would expect disp to be a rather good predictor for mgp as there is a strong (negative) correlation between the two (=-0.8475514).

Why is the disp p-value not significant in the case of the multi-linear model? Is there something wrong with my code or do I miss something here?

Thanks,

$\endgroup$
2
  • 1
    $\begingroup$ Yes, you are missing something. This is not a programming issue. Please read some regression textbook or consult your statistics teacher. $\endgroup$
    – Roland
    Commented Jul 10, 2018 at 20:53
  • $\begingroup$ p-value is not an indicator of how well the variable predicts. See Roland's comment. $\endgroup$ Commented Jul 10, 2018 at 20:54

1 Answer 1

0
$\begingroup$

The p-values in multiple linear regression are conditional tests, they measure the effect of the given term above and beyond the effect of all the other terms in the model. So displacement has a significant effect (being a good predictor is beyond just being significant) when it is in the model by itself, but in the multiple model you are asking about the contribution of displacement above and beyond the relationship with horsepower and weight. Since horsepower and weight contain much of the same information that displacement does you get a different estimate and a different p-value.

What if you had displacement measured in cubic centimeters and displacement measured in cubic inches. Either one would be meaningful by itself, but using both of them would be redundant, neither would contribute anything above and beyond what the other one does, you would only need one of the 2.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.