Re: Mathematica calculates RSquared wrongly?
- To: mathgroup at smc.vnet.net
- Subject: [mg112777] Re: Mathematica calculates RSquared wrongly?
- From: Darren Glosemeyer <darreng at wolfram.com>
- Date: Thu, 30 Sep 2010 04:51:09 -0400 (EDT)
- References: <i7seru$pt5$1@smc.vnet.net> <201009290815.EAA28196@smc.vnet.net>
On 9/29/2010 3:15 AM, Ray Koopman wrote: > On Sep 28, 3:09 am, Darren Glosemeyer<darr... at wolfram.com> wrote: >> On 9/27/2010 4:47 AM, Lawrence Teo wrote: >>> [...] >>> nlm = NonlinearModelFit[sbbBN, a*x^2 + b*x + c, {a, b, c}, x] >>> nlm["RSquared"] >>> >>> The RSquared by Mathematica is 0.963173 >>> Meanwhile, Excel and manual hand calculation show that R^2 should >>> be equal to 0.7622. >>> >>> Is Mathematica wrong? Thanks! >> This is as designed. For nonlinear models, the corrected (i.e. with >> the mean subtracted out) sum of squares is sometimes used. This is >> consistent with comparing to a constant model, but most nonlinear >> models do not include a constant in an additive way. For this reason, >> NonlinearModelFit uses the uncorrected (i.e. without subtracting out >> the mean) sum of squares. > This information should be included in the "Goodness-of-Fit Measures" > section of the NonlinearModelFit documentation, which should also > point out that RSquared is computed as 1 - (Residual SS)/(Total SS), > and that in nonlinear models this is generally different from the > ratio (Model SS)/(Total SS) that is sometimes cited -- e.g., > http://reference.wolfram.com/mathematica/RegressionCommon/ref/RSquared.html > -- as the definition of RSquared. > The RegressionCommon documentation is for a now obsolete standard package. The "RSquared" property for nonlinear models is described near the bottom of http://reference.wolfram.com/mathematica/tutorial/StatisticalModelAnalysis.html The current statement is: "The coefficient of determination "RSquared" is the ratio of the model sum of squares to the total sum of squares." I will modify this to mention that the total is the uncorrected total for the next version. Darren Glosemeyer Wolfram Research
- References:
- Re: Mathematica calculates RSquared wrongly?
- From: Ray Koopman <koopman@sfu.ca>
- Re: Mathematica calculates RSquared wrongly?