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

Christian K. ckkart@hoc....
Sun Oct 23 16:18:10 CDT 2011


Am 21.10.11 02:03, schrieb josef.pktd@gmail.com:
> On Thu, Oct 20, 2011 at 5:15 PM, Robert Kern <robert.kern@gmail.com> wrote:
>> On Thu, Oct 20, 2011 at 21:50, Christian K. <ckkart@hoc.net> wrote:
>>> Am 20.10.11 16:12, schrieb josef.pktd@gmail.com:
>>>> On Thu, Oct 20, 2011 at 5:11 AM, Christian K. <ckkart@hoc.net> wrote:
>>>>>  <josef.pktd <at> gmail.com> writes:
>>>>>>> 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.
>>>>>
>>>>> Ok, but then I do not understand how to follow your indications for the
>>>>> prediction interval:
>>>>>
>>>>>>> distributed with mean y = Y = X*beta, and var(y) = X' * cov_beta * X +
>>>>>>> var_u_estimate (dot products for appropriate shapes)
>>>>>
>>>>> X in my case is [X,Y] and cov_beta has a shape of 3x3, since there are 3
>>>>> paramters.
>>>>> Sorry for my ignorance on statistics, I really apppreaciate your help.
>>>>
>>>> I'm attaching a complete example for the linear in parameters case,
>>>> including the comparison with statsmodels.
>>>
>>> Ok, I got it, thank you very much. As I understood, this works for OLS
>>> (only?).
> 
> It's OLS only, it can be adapted to other estimators like non-linear
> least squares, or to weighted least squares.
> 
> I never looked at the details of odr, so I'm no  help there.
> 
> Josef
> 
> 
>>> What about if I get the covariance matrix from a 2D odr/leastsq
>>> fit from scipy.odr ? I noticed, that the covariance matrices differ by a
>>> constant (large) factor.
>>
>> ODRPACK will scale the covariance matrix by the Chi^2 score of the
>> residuals (i.e. divide the residuals by the error bars, square, sum,
>> divide by nobs-nparams), IIRC. This accounts for misestimation of the
>> error bars. If the error bars were correctly estimated, the Chi^2
>> score will be ~1. If the error bars were too small compared to the
>> residuals, then the Chi^2 score will be high, and thus increase the
>> estimated variance, etc. This may or may not be what you want,
>> especially when comparing it with other tools, but it's what ODRPACK
>> computes, so it's what scipy.odr returns.

I see. While playng with the errors of both the inputs and outputs of
odr I noticed, that the covariance matrix does depend on the input
errors even when specifying fit_type=2 == least squares. Is that to be
expected?

Anyway, thank you both for your valuable inputs.

Christian




More information about the SciPy-User mailing list