       Re: Finding Regression Coefficient

• To: mathgroup at christensen.cybernetics.net
• Subject: [mg1221] Re: Finding Regression Coefficient
• From: william.oliver at colorado.edu (Bill Oliver)
• Date: Fri, 26 May 1995 02:19:54 -0400

```In article <3prrh5\$533 at news0.cybernetics.net>, Andreas Fischer
<w81b8512 at infosrv.RZ.UniBw-Muenchen.de> wrote:

> I think it is not allowed to compute r^2, because this coefficient
> (BRAVAIS-PEARSON correlation coefficient) is only appropriate for linear
> regressions. A high r or r^2 doesn't tell anything about the correlation
> between x and y if you assume a nonlinear function between them.
> If I am wrong with this or if someone knows a nonlinear regression
> coefficient, please let me know.
>
> Andreas Fischer
> University of Armed Forces
> Munich, Germany
> andreas.fischer at rz.unibw-muenchen.de

The original question, as I understood it, concerned how one computes the
fit between the  observed values and the expected values based on the
best-fitting function. The NonLinearFit function provides the Chi-squared
measure of fit when ShowProgress is set to True, but some people prefer
R^2. The following example shows how I go about it--inelegant, but it
seems to work.

In:=
e1DataBlock = { {24,2734},{72,1877},{120,2071},
{168,1845},{216,1768},{264,1645},{312,1518},
{360,1606}, {24,3316},{72,2531},{120,1851},
{168,1511},{216,1408},{264,1281},{312,1201},
{360,1188} };
In:=
Needs["Statistics`NonlinearFit`"]
In:=
Needs["Statistics`LinearRegression`"]
In:=
(* 2-parameter power curve to fit *)
f[x_] = 189 + a x^(-b);
In:=
par = NonlinearFit[e1DataBlock,f[x],x,{{a,5036.4},{b,.24501}}]
Out=
{a -> 8073.76, b -> 0.326802}
In:=
xval = Transpose[e1DataBlock][];
In:=
predicted = Table[f[ xval[[i]] ] /. par ,{i,1,Length[xval]}];
In:=
observed = Transpose[e1DataBlock][];
In:=
p1 = Transpose[List[predicted, observed]];
Regress[p1,{1,x},x,OutputList->RSquared,OutputControl->NoPrint]
Out=
RSquared -> 0.852369

-Bill-

--