MathGroup Archive 2003

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

Search the Archive

Re: Linear and logarithmic fit

  • To: mathgroup at
  • Subject: [mg39387] Re: Linear and logarithmic fit
  • From: Bill Rowe <listuser at>
  • Date: Thu, 13 Feb 2003 04:54:10 -0500 (EST)
  • Sender: owner-wri-mathgroup at

On 2/12/03 at 3:54 AM, joh_nson at (jay Johnson) wrote:

>If I have 9 points in a 2 dimensional space how do I decide if they
>fit better a linear function or a logarithmic function?

One choice would be to use the sum of the errors squared. For example:

First create some data.



do a linear fit


0.573502\[InvisibleSpace]-0.0848516 x

do a logarithmic fit

g=Fit[data,{1 Log[x]},x]

-0.455209 Log[x]

Sum the squared errors for the linear fit

Tr[((#1[[2]] - f /. x -> #1[[1]])^2 & ) /@ data]


sum the squared errors for the logarithmic fit

Tr[((#1[[2]] - g /. x -> #1[[1]])^2 & ) /@ data]


Since sum of the squared errors for the logarithmic fit is greater than for the linear fit, conclude the linear fit is better.

Note, using the sum of the squared errors is probably the most commonly used measure of goodness of fit, but it is not the only measure that could be used. I've used this measure since that is what Fit minimizes to compute the fit coefficients.

Also, if you want to compare several different models using a least squares fit, it would probably be better to use the Regress function in the package Statistics`LinearRegression` . There are options for this function to include in the output the sum of the error squared as well as other statistics to judge the fit of the model to the data.

Finally, if you are going to be fitting models to data often it would be a good idea to read a good text on fitting models to data. There are several pitfalls that can lead to very misleading results. A couple of possilbe texts are

Fitting Equations to Data by Daniel and Wood
Applied Linear Regression by Weisberg

  • Prev by Date: Re: Input output disappear
  • Next by Date: Re: a first-time user question
  • Previous by thread: Re: Linear and logarithmic fit
  • Next by thread: Fwd: Linear and logarithmic fit