MathGroup Archive 2005

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

Search the Archive

Re: changing algorithm, finding residuals w/FindFit

  • To: mathgroup at smc.vnet.net
  • Subject: [mg56724] Re: changing algorithm, finding residuals w/FindFit
  • From: dh <dh at metrohm.ch>
  • Date: Thu, 5 May 2005 06:01:09 -0400 (EDT)
  • References: <d59l9q$6h6$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Hi Ed,
if you want linear least square, you can use the one liner:
points[[All, 2]] - ( Fit[points, {1, x, x^2}, x] /. x :> points[[All, 1]])

Note also ready made solutions in the the packages:
Statistics`LinearRegression`
Statistics`NonlinearFit`
with the option RegressionReport -> {FitResiduals}

The option "Method" can have following values:
  Possible settings for Method include "ConjugateGradient", "Gradient", 
"LevenbergMarquardt", "Newton" and "QuasiNewton", with the default being 
Automatic.

Sincerely, Daniel

Edward Peschko wrote:
> hey all,
> 
> I was wondering if there was a integral way to get the residuals that that least
> squares fit offered:
> 
> 	points = { { 1,2 } , { 3, 4 } , {5,6} };
> 
> 	fit = FindFit[points, c + d x + e x^2, {c,d,e}, x];
> 
> 	{ c -> ..., d -> ..., e -> ... }
> 
> 	residuals = Residual[points, c + d + e x^2 /. fit, ResidualType -> squarex ], 
> 
> 
> I would think that there would be a oneliner (or oneliner function) to express this 
> succinctly, but I'm having difficulty expressing it.. The closest I could 
> get to in perl is:
> 
> 	@points = ( [1,2], [3,4], [5,6] );
> 	@residuals = map( [ $_->[0], ($_->[1] - &$function($_->[0]))**2 ], @$points);
> 
> 
> Also, is there a way to change the method which is used for FindFit and 
> FindMinimum/FindMaximum? I see there's a Method attribute, but there doesn't 
> seem to be any options for setting it, other than 'Automatic'. In particular,
> I'd like to use adaptive simulated annealing:
> 
> 	http://www.ingber.com/#ASA
> 
> for more complicated functons..
> 
> Ed
> 


  • Prev by Date: Re: Variant of inner Product ...
  • Next by Date: Re: Cases and Nonatomic expression
  • Previous by thread: changing algorithm, finding residuals w/FindFit
  • Next by thread: Re: changing algorithm, finding residuals w/FindFit