[SciPy-User] How to fit data with errorbars

Skipper Seabold jsseabold at gmail.com
Tue Feb 16 23:44:59 EST 2010


On Tue, Feb 16, 2010 at 11:36 PM,  <josef.pktd at gmail.com> wrote:
> On Tue, Feb 16, 2010 at 11:18 PM, Nathaniel Smith <njs at pobox.com> wrote:
>> On Tue, Feb 16, 2010 at 7:48 PM,  <josef.pktd at gmail.com> wrote:
>>> I didn't realize that it is a problem linear in parameters if the
>>> objective is to fit a polynomial.
>>
>> I dunno, I'm just going off a quick glance at the documentation for
>> "polyfit", which the OP wanted to use in the first place :-).
>>
>>> Essentially the same calculations are done in statsmodels.WLS  plus
>>> you get additional results and test statistics.
>>>
>>> something like
>>>
>>> wls_results = scikits.statsmodels.WLS(Y, np.vander(X,2), weights=1/stddevs)
>>> wls_results.params
>>> wls_results.bse
>>> wls_results.fittedvalues
>>>
>>> example in statsmodels\examples\tut_ols_wls.py
>>
>> Yeah, using real statistics code is always a better idea when
>> available. (Actually, I would use R for this. Don't tell anyone!)
>
> But it's more fun trying to figure out how to do it in python than how
> to do it in R or rpy.
>

Exactly.

> (But maybe not so much if I have to figure out both for doing the
> validation tests. I've seen that your incremental_ls also uses R only
> for validation and not for the heavy duty stuff.)
>

But this lets you be on both sides and try to convince people that R
isn't fun and you know by experience ;)



More information about the SciPy-User mailing list