MathGroup Archive 2000

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

Search the Archive

Re: Controlling how Mathematica fits data

  • To: mathgroup at smc.vnet.net
  • Subject: [mg21481] Re: [mg21450] Controlling how Mathematica fits data
  • From: "Mark Harder" <harderm at ucs.orst.edu>
  • Date: Tue, 11 Jan 2000 04:17:59 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

Steve,

    Q1.) I don't know if this is possible, or not.  If the cubic fit gives
you physically impossible points, then I think that either:    a.) The
system generates data that fits a cubic polynomial, but some error (eg.
noise) has created outliers to which the least squares norm is too
sensitive.  Use a more robust error measure.  Shaw & Tigg (Applied
Mathematica,...; chap.15) discuss this & provide a more robust method, Least
Median of Squares, with Mathematica code.
or
    b.) The data don't really fit a cubic polynomial, and you don't have a
realistic model with real physical parameters to use in its place.  In this
case, you are really trying to "smooth" the data.  This is a large subject
area itself.  See Q3.)

Q2.) You are not providing starting estimates for the parameters a,b,c,& d.
NonlinearFit is an iterative procedure, you must provide a reasonably good
initial guess for the parameter vector, or at least upper & lower bounds for
the parameter values.  Read the online documentation carefully for
instructions.

Q3.)  There are many methods for smoothing data.  Polynomial fitting is
often not suitable.  And your problem is literally the textbook case of what
goes wrong here.  Other methods are moving weighted averaging methods, and
spline approximation. The latter is my favorite. Splines are polynomials
defined on subranges of the domain,x.  They are typically used to do
interpolation, not smoothing, but the constraints placed on the splines
where they join guarantee smoothness and can minimize the "bumps" in the
fit.  There are several good sources of information about this.
-mark

-----Original Message-----
From: com3 at ix.netcom.com <com3 at ix.netcom.com>
To: mathgroup at smc.vnet.net
Subject: [mg21481] [mg21450] Controlling how Mathematica fits data


>Hello all,
>
>I have 7 (x,y) data points that I need to fit to an equation. My first
>attempt was as follows:
>
>xraw={437,438,439,440,548,555,563}
>yraw={-4.82,2.72,10.05,16.84,92.5,92.5,92.5}
>dataraw={xraw,yraw};
>data1=Transpose[dataraw];
>fitcurve1=Fit[data1,{1,X,X^2,X^3},X]
>
>This works in that it returns the best set of coefficients for cubic
>equation on a least-squares basis. The problem is that when  this
>equation is used at some x  values that weren't provided in xraw, it
>returns y values that are physically not possible in my application.
>For example, when x=500, y is greater that 92.5 due to the "bump" in
>the curve.
>
>Question 1: Is it possible to place constraints on Fit[] such that the
>results of the returned equation can be constrained ? In my case, the
>constraint would be that no computed y value can exceed 92.5 when
>given x values that range from 437 to 563. I'm only interested in the
>performance of the equation between these x values.
>
>My second attempt at this was to use NonlinearFit with a Weibull
>formula as a starting point as follows:
>
>Needs['Statistics`NonlinearFit'"]
>fitcurve1=NonlinearFit[data1, a-(b*Exp[-cX^d]),X,{a,b,c,d}]
>
>Mathematica simply echos this back and does no computing.
>
>Question 2: What am I doing wrong with NonlinearFit ?
>
>Question 3: Is there a better method of accomplishing this task ?
>
>I found a FAQ that talks about the difficulties of using "penalty
>functions" so as a new user I would prefer a safer approach if one
>exists.
>
>I'm running version 3.0 on Win95.
>
>Thanks in advance.
>
>Steve
>For any e-mail responses, please remove *NOSPAM* from my address.
>



  • Prev by Date: Re: Inner product can be modified?
  • Next by Date: Re: How do I copy cells to my e-mail browser for submissions...
  • Previous by thread: Re: Inner product can be modified?
  • Next by thread: RE: Controlling how Mathematica fits data