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

josef.pktd@gmai... josef.pktd@gmai...
Wed Oct 19 06:51:56 CDT 2011

```On Wed, Oct 19, 2011 at 3:17 AM, Christian K. <ckkart@hoc.net> wrote:
> Hi Joseph,
>
> <josef.pktd <at> gmail.com> writes:
>>
>> Roughly (I would need to check the details):
>> the parameter estimate is from a multivariate normal distribution,
>> your y is a linear transformation, so the prediction should be normal
>> distributed with mean y = Y = X*beta, and var(y) = X' * cov_beta * X +
>> var_u_estimate (dot products for appropriate shapes)
>
> Does this hold also for nonlinear models? I would need to calculate prediction
> intervals for something like
>
> f(X,Y) = a1-a2*log(X)+a3/Y (inverse power/Arrhenius model from accelerated
> reliability testing)

your f(X,Y) is still linear in the parameters, a1, a2, a3. So the
linear version still applies.

For the general non-linear model where f(x, params) is non-linear in
the parameters, it would hold only locally, as a linear approximation,
with y = jac * beta, where the gradient/jacobian jac replaces x in the
linear model in the covariance calculation.
I haven't looked at it in detail yet, but I think some statistical
packages might return this.
The problem is that the local linear approximation might not be very
good if you are interested in larger deviations, for example
confidence intervals, and the standard deviation is large relative to
the curvature.

The same problem shows up for all non-linear transformation using this
Delta method in statistics
http://en.wikipedia.org/wiki/Delta_method

There are ways to improve the approximation, but it's only simple in
special cases. Most things that I have seen for the general nonlinear
case in terms of higher order approximation looked too complicated for
my taste.

I guess, in statsmodels  I will add the Delta method and bootstrap,
and let the users decide if the approximation is good enough in their
case, using the Delta method is much faster.

Josef

>
> Currently I am using a Monte Carllo approach to get the prediction intervals.
>
> Best regards, Christian K.
>
>
>
>
> _______________________________________________
> SciPy-User mailing list
> SciPy-User@scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>
```