Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2001

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

Search the Archive

Re: Fit[]: how to obtain the parameter values?

  • To: mathgroup at
  • Subject: [mg31839] Re: Fit[]: how to obtain the parameter values?
  • From: "Allan Hayes" <hay at>
  • Date: Fri, 7 Dec 2001 05:55:54 -0500 (EST)
  • References: <9ul2bt$6lu$>
  • Sender: owner-wri-mathgroup at


Not my area, and someone may have a better way, but two of the packages
might help:

    f1[x_]=2 ;f2[x_]=3x;


    reg=Regress[data,{2, 3x},{x},

params= (ParameterTable/.reg)[[1,All,1]]



BestFitParameters/.NonlinearRegress[data,a  2 + b 3x,{x},{a,b},


The use of the option RegressionReport simply stops the calculation of
unwanted material - it can be left out at the cost of slower computation.


Allan Hayes
Mathematica Training and Consulting
Leicester UK
hay at
Voice: +44 (0)116 271 4198
Fax: +44 (0)870 164 0565

"Peter Marzlin" <peter.marzlin at> wrote in message
news:9ul2bt$6lu$1 at
> Hi all,
> I am trying to use Fit to get a linear least square fit with some
> complicated functions. In principle this works fine, but I cannot
> get the parameter values.
> For instance, using the two functions
> f1[x] = 2    and    f2[x] = 3x
> I would like to get the parameters a1 and a2 in the fit function
> f[x] = a1 f1[x] + a2 f2[x]
> for the set of data     data = {{1, 2}, {2, 2.5}, {3, 3}}
> Using the command
> Fit[data, {f1[x], f2[x]}, x]
> I get the answer 1.5 + 0.5 x
> This is correct but not what I want. I need a1 and a2, but
> they cannot easliy be obtained because Fit merges the prefactors
> in the definition of f1 and f2 with the value of the parameters
> a1 and a2.
> Of course, in this simple example I can get a1 and a2 by hand, but
> I am actually interested in a much more involved problem where
> extracting
> the parameter values from the Fit output is a rather tedious if not
> practically impossible task.
> Any help would be greatly appreciated.
> Peter

  • Prev by Date: Penrose Seasons Greetings
  • Next by Date: Re: Fit[]: how to obtain the parameter values?
  • Previous by thread: Re: Fit[]: how to obtain the parameter values?
  • Next by thread: Re: Fit[]: how to obtain the parameter values?