This is the mail archive of the
gsl-discuss@sourceware.org
mailing list for the GSL project.
Re: computing R-squared with gsl_multifit
- From: Brian Gough <bjg at network-theory dot co dot uk>
- To: gsl-discuss at sourceware dot org
- Date: Tue, 02 Oct 2007 09:34:43 +0100
- Subject: Re: computing R-squared with gsl_multifit
- References: <20070925194628.GA22578@hippogriff.physics.drexel.edu><m3ps054e88.wl%bjg@network-theory.co.uk><20070926162005.GA27449@hippogriff.physics.drexel.edu>
At Wed, 26 Sep 2007 10:20:05 -0600,
Patrick Alken wrote:
>
> > A question: is the formula the same for both weighted and unweighted
> > fits?
>
> No, unfortunately.
>
> R^2 = 1 - chisq / Sum [ w_i * (y_i - mean(y))^2 ].
>
> In the case of weighted data, the mean(y) is also a weighted mean:
>
> mean(y) = 1/sum [ w_i ] * sum [ w_i y_i ]
>
> I looked at the GNU R source to verify all this.
As a starting point I've added gsl_stats_ss and gsl_stats_wss for
computing the unweighted/weighted sum of squares.
Given chisq and the data this is sufficient for computing R^2 with the
formula above.
--
Brian Gough