On Fri, May 14, 2010 at 3:01 PM, Benedikt Riedel <
bri...@wisc.edu> wrote:
> Hey,
>
> I am fairly new Scipy and am trying to do a least square fit to a set of
> data. Currently, I am using following code:
>
> fitfunc = lambda p,x: p[0]+ p[1]*exp(-x)
> errfunc = lambda p, x, y: (y-fitfunc(p,x))
> pinit = [20,20.]
> out = leastsq(errfunc, pinit, args=(tau,R4ctsdataselect), full_output=1)
>
> I am now trying to get the goodness of fit out of this data. I am sort of
> running into a brick wall because I found a lot of conflicting ways of how
> to calculate it.
For regression the usual is
http://en.wikipedia.org/wiki/Coefficient_of_determination
coefficient of determination is
R^2 = 1 - {SS_{err} / SS_{tot}}
Note your fitfunc is linear in parameters and can be better estimated
by linear least squares, OLS.
linear regression is handled in statsmodels and you can get lot's of
statistics without worrying about the formulas.
If you only have one slope parameter, then scipy.stats.linregress also works
scipy.optimize.curve_fit (scipy 0.8) can also give you the covariance
of the parameter estimates.
http://docs.scipy.org/scipy/docs/scipy.optimize.minpack.curve_fit
> I am aware of the chisquare function in stats function, but the
> documentation seems a little confusing to me. Any help would be greatly
> appreciates.
chisquare and others like kolmogorov-smirnov are more for testing the
goodness-of-fit of entire distributions, not for how well a curve or
line fits the data.
Josef
>
> Thanks very much in advance.
>
> Cheers,
>
> Ben
>
>
>
> _______________________________________________
> SciPy-User mailing list
>
SciPy...@scipy.org
>
http://mail.scipy.org/mailman/listinfo/scipy-user
>
>
_______________________________________________
SciPy-User mailing list
SciPy...@scipy.org
http://mail.scipy.org/mailman/listinfo/scipy-user
--
You received this message because you are subscribed to the Google Groups "SciPy-user" group.
To post to this group, send email to
scipy...@googlegroups.com.
To unsubscribe from this group, send email to
scipy-user+...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/scipy-user?hl=en.