Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1995
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1995

[Date Index] [Thread Index] [Author Index]

Search the Archive

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[1]:=
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[2]:=
Needs["Statistics`NonlinearFit`"]
In[3]:=
Needs["Statistics`LinearRegression`"]
In[4]:=
(* 2-parameter power curve to fit *)
f[x_] = 189 + a x^(-b);
In[5]:=
par = NonlinearFit[e1DataBlock,f[x],x,{{a,5036.4},{b,.24501}}]
Out[1]=
{a -> 8073.76, b -> 0.326802}
In[6]:=
xval = Transpose[e1DataBlock][[1]];
In[7]:=
predicted = Table[f[ xval[[i]] ] /. par ,{i,1,Length[xval]}];
In[8]:=
observed = Transpose[e1DataBlock][[2]];
In[9]:=
p1 = Transpose[List[predicted, observed]];
Regress[p1,{1,x},x,OutputList->RSquared,OutputControl->NoPrint]
Out[2]=
RSquared -> 0.852369

-Bill-

-- 
william.oliver at colorado.edu


  • Prev by Date: mma graphics
  • Next by Date: Thanks from Blind User
  • Previous by thread: Re: Finding Regression Coefficient
  • Next by thread: Re: Sort[] accuracy problem