# st: calculating the confidence intervals for the difference in predicted values

 From stata user To statalist@hsphsun2.harvard.edu Subject st: calculating the confidence intervals for the difference in predicted values Date Mon, 19 Oct 2009 00:19:27 -0700

```Dear Statalist:

I have a question on how to calculate confidence intervals for the
difference between two predicted values.

Say I have a liner regression model: Y=a+bX+e, and I obtained an
estimate of the coefficients a_bar and b_bar (where b_bar can be a
matrix of coefficents). Then I used the model to make one in-sample
prediction Y_in and one out-of-sample prediction Y_out, and I want to
calculate the standard error of the difference btw the two predicted
values, i.e., Var(Y_in-Y_out).

I think I can rewrite the difference as Y_in-Y_out=b_bar*(X_in-X_out),
and then Var(Y_in-Y_out)=(X_in-X_out)*e(V)*(X_in-X_out)'. But I have
no idea how to implement it in Stata.

Also, what if I want to find Var(Y_in/Y_out)?--i.e. now we want to
estimate the variance of a nonlinear function of the two predicted
values.

Can anyone help? Any suggestions would be appreciated!

Thanks!
Ken.
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```