Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #11856 > unrolled thread

NonlinearModelFit and assumptions on fit parameters

Started byNiles <niels.martinsen@gmail.com>
First post2012-09-23 07:00 +0000
Last post2012-09-24 04:48 +0000
Articles 3 — 3 participants

Back to article view | Back to comp.soft-sys.math.mathematica


Contents

  NonlinearModelFit and assumptions on fit parameters Niles <niels.martinsen@gmail.com> - 2012-09-23 07:00 +0000
    Re: NonlinearModelFit and assumptions on fit parameters DC <b.gatessucks@gmail.com> - 2012-09-24 04:47 +0000
    Re: NonlinearModelFit and assumptions on fit parameters Frank K <fkampas@gmail.com> - 2012-09-24 04:48 +0000

#11856 — NonlinearModelFit and assumptions on fit parameters

FromNiles <niels.martinsen@gmail.com>
Date2012-09-23 07:00 +0000
SubjectNonlinearModelFit and assumptions on fit parameters
Message-ID<k3mc32$72m$1@smc.vnet.net>
Hi

I have a set of data (x, y) that I can succesfully fit a nonlinear function to using NonlinearModelFit:


data = {{1, 1}, {2, 2}, {3, 3.2}};
fitFuncExactNoLosses[a_, b_, x_] := a*x^2 + b + x;
nlm = NonlinearModelFit[data, fitFuncExactNoLosses[a, b, x],
  {
   {a, 1},
   {b, 1}},
  x]


However, the paramter "b" comes out negative and it *must* be positive. Is there a way to utilize assumptions such that b is constrained to be grater than zero?

Best,
Niels.

[toc] | [next] | [standalone]


#11863

FromDC <b.gatessucks@gmail.com>
Date2012-09-24 04:47 +0000
Message-ID<k3oolj$bc9$1@smc.vnet.net>
In reply to#11856
You can include contraints on the parameters as in :

nlm = NonlinearModelFit[data, 
  {fitFuncExactNoLosses[a, b, x],b>0}, {{a, 1}, {b, 1}}, x]

[toc] | [prev] | [next] | [standalone]


#11864

FromFrank K <fkampas@gmail.com>
Date2012-09-24 04:48 +0000
Message-ID<k3oon0$bce$1@smc.vnet.net>
In reply to#11856
On Sunday, September 23, 2012 3:02:11 AM UTC-4, Niles wrote:
> Hi
> 
> 
> 
> I have a set of data (x, y) that I can succesfully fit a nonlinear function to using NonlinearModelFit:
> 
> 
> 
> 
> 
> data = {{1, 1}, {2, 2}, {3, 3.2}};
> 
> fitFuncExactNoLosses[a_, b_, x_] := a*x^2 + b + x;
> 
> nlm = NonlinearModelFit[data, fitFuncExactNoLosses[a, b, x],
> 
>   {
> 
>    {a, 1},
> 
>    {b, 1}},
> 
>   x]
> 
> 
> 
> 
> 
> However, the paramter "b" comes out negative and it *must* be positive. Is there a way to utilize assumptions such that b is constrained to be grater than zero?
> 
> 
> 
> Best,
> 
> Niels.

You could change b to b^2 in the fitting function and take the square root afterwards.  

[toc] | [prev] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web