1
$\begingroup$

If I have a linear model and want to use predict() to predict the mean and confidence interval of multiple ($m$) new observations of a given x-value ($x_h$), how do I account for the $m$ in the formula for the $s$ of the predicted mean?
$$ {\rm MSE}(\frac 1 m + \frac 1 n + \frac{(x_h - \bar x)^2}{S_{xx}}) $$

Is it the weight argument? Or do I have to include the desired $x_h$ $m$ times in the newdata?

$\endgroup$

1 Answer 1

2
$\begingroup$

The weights argument will work -- just set it equal to $m$ in your formula. It will not work to put multiple instances of $x_h$ in newdata -- you'll just get several copies of the same interval.

Another approach is to use pred.var = summary(mod)$sigma^2 / m where mod is your model and m is your value of $m$. The reason this works is that pred.var is used to set the variance of future observations; by default it is assumed to be the same as in the data ($\sigma^2$, estimated by $MSE$). By pretending it is $\sigma^2/m$ (estimated as $MSE/m$), you are using the variance of the average of $m$ predictions and will produce the correct result.

$\endgroup$
5
  • $\begingroup$ The documentation states: "This can be a multiple of res.var, the estimated value of σ^2". Does that mean that res.var is the same as summary(mod)$sigma^2? $\endgroup$
    – Kevin M
    Commented May 14, 2015 at 22:56
  • $\begingroup$ If weights will work, do you want to consider changing the top part of your answer for others' future reference? $\endgroup$
    – Kevin M
    Commented May 14, 2015 at 23:02
  • $\begingroup$ Yes, that is what it means. res.var is a variable internal to predict.lm that is equal to that value. $\endgroup$
    – Russ Lenth
    Commented May 14, 2015 at 23:02
  • $\begingroup$ @KevinM: Took me a while, but I made the change. $\endgroup$
    – Russ Lenth
    Commented May 15, 2015 at 17:42
  • $\begingroup$ Looks great! I can't upvote on this site yet. $\endgroup$
    – Kevin M
    Commented May 15, 2015 at 18:12

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.