This is the mail archive of the gsl-discuss@sourceware.org mailing list for the GSL project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: computing R-squared with gsl_multifit


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]