Re: findfit or solve?
- To: mathgroup at smc.vnet.net
- Subject: [mg55026] Re: findfit or solve?
- From: "adamizer" <adam.smith at hillsdale.edu>
- Date: Thu, 10 Mar 2005 05:24:25 -0500 (EST)
- References: <d0modp$76l$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
For this to work in Mathematica you need to fix some syntax problems and load a special package, Statistic`NonlinearFit`. Be careful, the symbol enclosing the Nonlinear fit is not a single quote or apostrophe but a backwards single quote. On my keyboard it is the shifted key to the left of the "1" key. I have shown the two differenct versions: NonlinearFit just returns the best fit function. NonlinearRegress provides more detailed information. See the Help for more info. In my example below I load the graphics package Graphics`Colors` so that I can access the color names in the final plot (See the Help under Colors). I also load Graphics`Graphics` so that I can use the DisplayTogether command for showing multiple plot. The code is at the end Adam Smith In[1]:= << Statistics`NonlinearFit` In[2]:= <<Graphics`Graphics` <<Graphics`Colors` In[4]:= func = a - 2*(a-b)/(Exp[c*(t-d)]+Exp[e*(t-d)]) In[5]:= data={{6.968,117.1},{7.967,123.3},{9.046,129.4},{9.982,134.6},{10.951, 139.2},{11.973,145.2},{13.021,151.1},{13.892,159.9},{14.888, 167.8},{15.858,171.9},{16.857,175.7},{17.854,177.2},{18.724,175.6}}; In[6]:= fitfunc = NonlinearFit[data,func,t,{{a,176},{b,160},{c,0.1},{d,14},{e,1.2}}] In[7]:= NonlinearRegress[data,func,t,{{a,176},{b,160},{c,0.1},{d,14},{e,1.2}}] In[9]:= DisplayTogether[ ListPlot[data], Plot[func/.{a->176,b->160,c->0.1,d->14,e->1.2},{t,7,20}, PlotStyle\[Rule]{Blue}], Plot[fitfunc,{t,7,20},PlotStyle\[Rule]{Red}]] Tegla Bela wrote: > Greetings to everybody, > > I have found a model and I would like to use Mathematica for the data under > the model. The model is as follows: > > = h1 - ((2 * (h1 - h$B&H(B)) / ((EXP(s0 * (t -$B&H(B))) + (EXP(s1 * (t -$B&H(B))))) > > data = {{6.968, 117.1}, {7.967, 123.3}, {9.046, > 129.4}, {9.982, 134.6}, {10.951, > 139.2}, {11.973, 145.2}, {13.021, 151.1}, {13.892, 159.9}, { > 14.888, 167.8}, {15.858, 171.9}, {16.857, 175.7}, {17.854, 177.2}, { > 18.724, 175.6}}; > > I have managed to do it with nonlinear least-square fitting in other > program. But not working for me in Mathematica. (I do not know how to give > initial values to have the five unknown parameters estimated) These are the > initial values that I would like to use: a=176, b=160, c=0.1, d=14, e=1.2 > (t is the age, first value in each pair of the data) > > Does anybody have idea how it can be done? Any help is appreciated. > > Spiller > > _________________________________________________________________ > $BF|K\9qFb:GBg5i(B570$BK|%f!<%6!<$N(BMSN Hotmail > https://registernet.passport.net/reg.srf?id=2&lc=1041