[SciPy-User] How to fit data with errorbars

josef.pktd at gmail.com josef.pktd at gmail.com
Tue Feb 16 23:36:53 EST 2010


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.

(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.)

Josef

>
> -- Nathaniel
> _______________________________________________
> SciPy-User mailing list
> SciPy-User at scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>



More information about the SciPy-User mailing list