0
$\begingroup$

I'm fitting a linear regression model in R. Initially, I included only a dummy coded dichotomous variable as a predictor. Thus, the values of the predictor are X0 (set to 0) and X1 (set to 1). Thus, I know the regression coefficient indicates the expected mean difference between X0 and X1.

However, I then used the predict function to get the estimated values for my participants. I then calculated the estimated values across X0 and X1 and surprisingly found that the mean is different that what was indicated by the regression coefficient. Why? Moreover, I'm now wondering what the predict function is useful for?

$\endgroup$
  • $\begingroup$ With a single factor as a predictor, you can remove the intercept from the model and get the mean for each factor level as its coefficient. Something like summary(lm(y~-1 + x)). $\endgroup$ – assumednormal Sep 26 '17 at 16:19
  • $\begingroup$ Related to the question of what the predict function is useful for, what would be the advantage of getting predicted values and confidence intervals when that information is already provided in the regression summary? $\endgroup$ – user166625 Sep 26 '17 at 16:55
  • $\begingroup$ Please edit the title. I think you're missing a verb before "size". $\endgroup$ – Kodiologist Sep 26 '17 at 19:06
1
$\begingroup$

If your regression equation is:

$$\hat{y} = \hat{\beta}_0 + \hat{\beta}_1x$$

The predict function will give you $\hat{y}$ given the $x$ you input.

The $\hat{y}$ will include information from the intercept $\hat{\beta}_0$ and from the coefficient, $\hat{\beta}_1$.

| cite | improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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