Re: NonLinearRegress question
- To: mathgroup at smc.vnet.net
- Subject: [mg12900] Re: [mg12860] NonLinearRegress question
- From: Carl Woll <carlw at fermi.phys.washington.edu>
- Date: Wed, 24 Jun 1998 03:44:23 -0400
- Sender: owner-wri-mathgroup at wolfram.com
Hi Easan, The specific problem that you are having is the following > NonlinearRegress[data, > N[func[t,a,b]] ,z, {{a,{-100,-101}},{b,{2,3}}}, ^ ^ | | > RegressionReport -> BestFitParameters, > Method->FindMinimum, > ShowProgress -> True] That is, the second line above should read N[fun[t,a,b]] ,t, {{a,{-100,-101}},{b,{2,3}}}, Mathematica then processes your commands without complaint. By giving two starting values for the parameters and selecting the method FindMinimum, NonlinearRegress will not attempt to evaluate the paramter derivatives of your model. This is good for your problem, as Mathematica is unable to find the parameter derivatives of your model. Still, there is a workaround which will enable NonlinearRegress to use parameter derivatives. If you are interested in this workaround, let me know, or search the archives for a message I sent to Tom Marchioro on this topic. Carl Woll Dept of Physics U of Washington On Wed, 17 Jun 1998, Easan Siviniah wrote: > Hi folks, > > I'm writing some data fitting code on Mathematica that uses the add-on > package > 'NonLinearRegress'. However I'm currently stumped because the model I > use > for fitting involves the use of conditional 'Ifs'. It seems that > Mathematica does not recoginise such a function as numerical. > Does Anyone have an idea of how to get round this. I've included a > typical > but simplified example below. > > In[1] Clear[fun,t,x,y] > fun[t_,x_,y_]:=If[t<10,t^2 x + Log[t] y, t^3 x + Log[t] y] > > data=Table[{t,N[fun[t,2,3]]},{t,1,21,2}] Out[1] > {{1,2.},{3,21.2958},{5,54.8283},{7,103.838},{9,168.592},{11,2669.19},{13, > > 4401.69},{15,6758.12},{17,9834.5},{19,13726.8},{21,18531.1}} > > In[2] << Statistics`NonlinearFit` > NonlinearRegress[data, > N[func[t,a,b]] ,z, {{a,{-100,-101}},{b,{2,3}}}, > RegressionReport -> BestFitParameters, > Method->FindMinimum, > ShowProgress -> True] > > Out[2] NonlinearRegress::"nonnum": "The model is not numerical at > (******) > Check that all model parameters are included in the > parameter list. > >