[SciPy-user] scipy.optimize.leastsq and covariance matrix meaning
Bruce Southey
bsouthey at gmail.com
Mon Nov 10 12:37:06 EST 2008
massimo sandal wrote:
> Bruce Southey wrote:
>> massimo sandal wrote:
>>> massimo sandal wrote:
>>>
>>>> I'll try to sketch up a script reproducing the core of the problem
>>>> with actual data.
>>> Here it is. Can anyone give it a look to help me understand if and
>>> how to make sense of the covariance matrix?
>>>
>>> m.
>> There is some problem with your model with respect to your data.
>> Looking at the plot of x and y, the relationship is linear with a
>> correlation of 0.86. There is no hint of a non-linear relationship
>> although a spline or similar local polynomial method could give a
>> nicer fit. I do not know what you would expect to see from your
>> function but you should also plot the expected model using typical
>> values of your parameters.
>>
>> I would suggest you explore fitting polynomial models first (could
>> only get a linear term for x in what you provided) and splines before
>> doing nonlinear models.
>
> The kind of things I am fitting is a single molecule force
> spectroscopy force curve: see for example
> http://www.jpk.com/unfolding-of-individual-titin-i27-octamer-i91-8.media.f229c5303ada22eb0a4ebe759457750av2.gif
>
>
> and I am fitting peaks using the worm-like chain equation (actually,
> in the script I use the inverse valus of the parameters) that you can
> find here:
> http://en.wikipedia.org/wiki/Worm-like_chain
>
> with results looking like that:
> http://www.jpk.com/titin-force-extension-profile.media.37bc90d1dbd105742098ed8317385a48v1.gif
>
> http://biology.plosjournals.org/perlserv/?request=slideshow&type=figure&doi=10.1371/journal.pbio.0060006&id=93367
>
>
> The model is non-linear because the physics underlying the data is
> non-linear. I am not "choosing" the equation*, I am applying that
> equation to find parameters from the curve.
>
> What I have pasted is just the section of a much larger data plot. The
> section can seem almost linear, but the non-linear fit on that section
> fits perfectly also the remaining sections -as expected.
> Fitting the whole peak or only the last portion of it does not change
> significantly the fit or the output parameters.
>
> The whole software I am working on is Hooke, available at
> http://code.google.com/p/hooke , in case anyone is interested.
>
> m.
>
> *strictly speaking the are subtly different models to choose from
> indeed (WLC, FJC, etc.), but WLC is the simpler and more widespread
> and is enough for what I mean to do
>
> _______________________________________________
> SciPy-user mailing list
> SciPy-user at scipy.org
> http://projects.scipy.org/mailman/listinfo/scipy-user
>
What are the actual parameters that you think you are trying to estimate
here?
What is y and x relative to the equation? In particular is y=F*P or just
F or P?
Your parameter therm is a constant so I would first compute Y/therm
before doing anything else or just ignore it.
Also, you probably need to rescale both x and y because these are either
very small or very large. Perhaps even standardize x to mean 0 and
variance 1. However, you do need to be very careful here. Getting
nonlinear models to converge to 'correct' parameters is often an art
than a science.
However, I still don't think you have the data to estimate this function
as there are no clear 'high' and 'low' points. I also don't think this
model will describe the patterns provided by the links (not even clear
how your data relates to these images).
Bruce
More information about the SciPy-User
mailing list