MathGroup Archive 2002

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

Search the Archive

Re: Weights syntax in NonlinearRegress/Fit

  • To: mathgroup at smc.vnet.net
  • Subject: [mg34097] Re: [mg34065] Weights syntax in NonlinearRegress/Fit
  • From: BobHanlon at aol.com
  • Date: Thu, 2 May 2002 03:49:49 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

In a message dated 5/1/02 9:58:10 AM, dlewis at kerr.phys.utas.edu.au writes:

>It seems I have an identical problem to Frederic Fontaine dated 22 Jun
>1999 that didn't get answered in the threads.
>
>I'm ALSO having troubles with the syntax of the Weights option in
>NonlinearRegress.  I want to input an equation not simply values.
>I'm not a member of this list so Im not sure if this will get back to me
>either...
>I'd appreciate any help, for ease I have cut and pasted his eloquent
>version...
>
>
>NonlinearRegress, Weights, Syntax
>Subject: [mg34097] [mg34065] [mg18212] NonlinearRegress,Weights, Syntax 
>From: Frederic Fontaine <F.Fontaine at fz-rossendorf.de> 
To: mathgroup at smc.vnet.net
>
>Hi,
>
>I've been fighting against the syntax of the option "Weights" in the
>NonlinearRegress command. I want to fit large data sets and I don't want
>to type hundreds of values. I'd rather use a function defining the weight
>of each data points. But how to do it with Mathematica 3 for Unix?
>For instance:
>NonlinearRegress[dataset, fitfunction(x,para),{x},{para},Weights->{???}]
>I would appreciate someone helping me remove the question marks!
>
>**Edited from F.F.**
>

Needs["Statistics`NonlinearFit`"];

data={{1.0,1.0,.126},{2.0,1.0,.219},
      {1.0,2.0,.076},{2.0,2.0,.126},{.1,.0,.186}};

model = theta1 theta3 x1/(1+theta1 x1+theta2 x2);

vars = {x1,x2}; params = {theta1,theta2,theta3};

BestFitParameters /.
 
  NonlinearRegress[data, model, vars, params]

{theta1 -> 3.131506813950309, theta2 -> 15.159362262745494,
 
  theta3 -> 0.7800623127085422}

The default (Weights -> Automatic) is equivalent to

% == BestFitParameters /.
 
  NonlinearRegress[data, model, vars, params,
    Weights -> Table[1, {Length[data]}]]

True

To use a function to define the weights, just enter it as a pure function, 
e.g.,

BestFitParameters /.
 
  NonlinearRegress[data, model, vars, params,
    Weights ->(Sqrt[#]&)]

{theta1 -> 3.000637103931437, theta2 -> 15.156127640686117,
 
  theta3 -> 0.8059628665159697}


Bob Hanlon
Chantilly, VA  USA


  • Prev by Date: Re: Split Polynom into Sum of Monomials
  • Next by Date: Multiplying Roots
  • Previous by thread: Re: Weights syntax in NonlinearRegress/Fit
  • Next by thread: Re: Weights syntax in NonlinearRegress/Fit