[SciPy-User] lmfit: confidence intervals issue

Antonino Ingargiola tritemio at gmail.com
Fri Jun 20 16:37:01 EDT 2014


Hi Matt,

I reply inline...

On Wed, Jun 18, 2014 at 8:19 PM, Matt Newville <newville at cars.uchicago.edu>
wrote:
[cut]

> I haven't tried your example, but it's possible that the development
> version on github.com fixes this -- there was a similar problem with
>  conf_interval() failing when calling brentq() that was fixed relatively
> recently (slow devel cycle),  but I'm not certain that the fix there will
> work here.
>

Indeed, upgrading to the latest version solved the error. Now I get the CI
in both cases.

I would guess that the essential problem is related to the fact that your
> also getting NaNs from the covariance matrix.  Again, without actually
> trying your problem, I believe that this is probably related to your use of
>
>      pos_range = (x - offset) >= 0
>
> to select the data range for which y!=0.   This could make the fit
> insensitive to small changes (ie, well below 1) to offset, making it hard
> to compute the partial derivative for it.  This could, in turn, make the
> covariance matrix hard to get (which is what you are seeing).    Without
> finite, numerical values for stderr from the covariance matrix, it's hard
> for conf_interval() to make good guesses about what range of values to
> search around.
>
>
Thanks for the explanation, now I understand much better the problem. I
have a model function with a discontinuity in the origin (i.e. exp(-x - x0)
for x > x0 else 0). If I sample it with a step dx, I will always have a
problem when x0 changes less than dx. Is there any known trick I can use to
avoid this problem?


> In short, it's a challenge to  have variables that are used essentially as
> integers.  Still, even if it doesn't work well, it shouldn't be failing
> this way.
>

Yes, but now I'm curious. How did you get around the problem? Are the
confidence interval still accurate in this case? I assume that if the CI
for the offset (x0) is < dx they don't make to much sense, is it right?

Thanks,
Antonio
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20140620/d7a1dbfc/attachment.html>


More information about the SciPy-User mailing list