# [SciPy-User] calculate predicted values from regression + confidence intervall

Mon Oct 17 04:59:06 CDT 2011

```Hello Josef
Hello others,

I am not sure if that is what I really want.
I just want to calculate a new predicted value
using my regression equation and a variance
(prediction intervall is statistically correct
expression) for the new predicted value.

I calculated my regression already in R and want to
use the results in python manually (without a
python-R interface).

The R Coefficients are as follows:
Estimate Std. Error t value Pr(>|t|)
(Intercept)  -9.00068    1.15351  -7.803 8.26e-12 ***
Variable X1  1.87119    0.23341   8.017  2.95e-12 ***
Variable X2  0.39193    0.07312   5.360  5.92e-07 ***
Variable X3  0.27870    0.09561   2.915  0.00445 **

Can I use these results to manually calculate
a predicted value of Y with a give set of new Xs? like
X1 = 200
X2 = 150
X3 = 5

I can easily calculate the predicted Y as
Y = -9 + 200*1.87 + 150*0.39 + 5*0.28

but how can I get the prediction interval?
I am not sure if your approach is the one I need
for that (with my given input) and if yes
how to use it?

/Johannes

>
> Message: 2
> Date: Fri, 14 Oct 2011 18:54:23 -0400
> From: josef.pktd@gmail.com
> Subject: Re: [SciPy-User] calculate predicted values from regression +
> 	confidence intervall
> To: SciPy Users List <scipy-user@scipy.org>
> Message-ID:
> Content-Type: text/plain; charset=ISO-8859-1
>
> On Fri, Oct 14, 2011 at 7:51 AM, Johannes Radinger <JRadinger@gmx.at>
> wrote:
> > Hello,
> >
> > I did a statistical regression analysis (linear regression) in R which
> > has following parameters:
> >
> > Y = X1 + X2
> >
> > from the R-analysis I can get the intercept and slopes for the
> independent variables so that I get:
> >
> > Y = Intercept + slope1*X1 + slope2*X2
> >
> > Now I want to use that in Scipy to calculate new predicted Y values.
> > Generally that is not a problem. I use the new X1 and X2 as input and
> > the slopes and intercept are predefined. So I can easily calculate Y
> new.
> >
> > Now my question arises:
> > How can I calculate a kind of uncertainty (e.g. a confidence intervall)
> for
> > the new Y? What do I have to extract from R and how do I have to use
> > the extracted parameters in scipy to calculate such things?
> > Is that generally possible?
>
> Better sandbox then nothing:
>
> https://github.com/statsmodels/statsmodels/blob/master/scikits/statsmodels/sandbox/regression/predstd.py#L28
>
> This is my version for scikits.statsmodels.OLS (and maybe WLS)
>
> usage example
> https://github.com/statsmodels/statsmodels/blob/master/scikits/statsmodels/examples/tut_ols.py
>
> Josef
>
> >
> > Thank you very much
> > Johannes
> > --
> > NEU: FreePhone - 0ct/min Handyspartarif mit Geld-zur?ck-Garantie!
> > Jetzt informieren: http://www.gmx.net/de/go/freephone
> > _______________________________________________
> > SciPy-User mailing list
> > SciPy-User@scipy.org
> > http://mail.scipy.org/mailman/listinfo/scipy-user
> >
>
>
> ------------------------------
>
> _______________________________________________
> SciPy-User mailing list
> SciPy-User@scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>
>
> End of SciPy-User Digest, Vol 98, Issue 22
> ******************************************

--
NEU: FreePhone - 0ct/min Handyspartarif mit Geld-zurück-Garantie!
Jetzt informieren: http://www.gmx.net/de/go/freephone
```