Re: NonlinearModelFit and ParameterTable
- To: mathgroup at smc.vnet.net
- Subject: [mg106469] Re: NonlinearModelFit and ParameterTable
- From: Ktota <nuktobi at gmail.com>
- Date: Wed, 13 Jan 2010 06:00:54 -0500 (EST)
- References: <201001100830.DAA05542@smc.vnet.net> <higdnl$kjj$1@smc.vnet.net>
On 11 Jan, 23:54, Darren Glosemeyer <darr... at wolfram.com> wrote: > Ktota wrote: > > mtest1[t_,ltime_]:=If [var1*(t+var2-qtime)>8000,Sum[If [var1*(tsum > > +var2-qtime)>8000,8000*(1-P),var1*(tsum+var2- qtime)*(1-P)],{tsum,t- > > ltime+1, t,1}],Max[{Sum[{var1*(tsum+var2- qtime)*(1-P)},{tsum,t-ltime > > +1, t,1}]},0]]/156000 > > > i optimize the model above with: > > > parameter2= > > NonlinearModelFit[ExpData, mtest1[t, ltime], {ltime}, > > t] > > > which is perfectly fine... > > > but as soon i want to see the ParameterTable or the > > ConfidenceIntervals by doing this: > > > parameter2["ParameterTable"] > > > I get the following error message: > > > and this only happens if i want to fit for ltime.. parameters P and > > var1 are perfectly fine.... > > > In[374]:= parameter2["ParameterTable"] > > During evaluation of In[374]:= General::ivar: 9.125191604503259` is > > not a valid variable. >> > > During evaluation of In[374]:= General::ivar: 9.125191604503259` is > > not a valid variable. >> > > During evaluation of In[374]:= General::ivar: 9.125191604503259` is > > not a valid variable. >> > > During evaluation of In[374]:= General::stop: Further output of > > General::ivar will be suppressed during this calculation. >> > > Out[374]= $Aborted > > > if i only want to see the result it gives me no error: > > In[370]:= parameter2["BestFitParameters"] > > Out[370]= {ltime->9.12519} > > > hope somebody can help...as this drives me mad... > > > thank you very much > > > NuKtoBi > > A working example would be needed to figure out what is happening. My > best guess is that there is a problem with the model specification > (Daniel and Bob mentioned a couple possible issues) or that this example > runs into trouble computing derivatives of the model which are needed > for standard errors and such. If it is trouble with derivatives, it may > be a bug in need of fixing, but a full working example would be needed. > > Darren Glosemeyer > Wolfram Research Dear All, thank you for your replies. I try to post a working example again... i though i send it yesterday. I guess I didn't actually press the send button as my message still doesn't appear. Even with the nice changes suggested by bob it didn't work (Daniel: clearing didn't help :( ), it made the code certainly more elegant. Nevertheless this is what happened when I introduced the changes: Mathematica got stuck, till I was forced to abort the evaluation with no result (mathematica prompted me several times to abort the evaluation... if i don't do that the mathematica crashes after a time). When I tried to see what happens if I use StepMonitor or EvaluationMonitor I could see that Mathematica didn't even try to give my parameters a value... so it must have got stuck at the very beginning. again: Using my code I get the same error messages as described in my previous post. Ok, I want to provide yo with an working example: This are the optimum parameter sets: 1.Please replace the 8000 with 6600, it should not matter to much at the end... but well, this would be the optimum number to set. 2.Here are the constant values: ltime = 10 var1=40 qtime=40 var2=10 P=0.7 suitable ranges for t <360 (but you can see that from the example data provided) Right now i proceed the following way: I clear the parameter i'm looking for and set the rest (and update replace the corresponding line of code). So if you fitting for ltime or P you need to set the values above correspondingly. Usually what i get if i fit for P is approx. 0.7, if i fit for ltime approx. 9.5. 3. A working dataset for tests: {{10, 0}, {20, 0}, {30, 0}, {40, 0}, {50, 0}, {60, 0.00585596}, {70, 0.00978394}, {80, 0.014027}, {90, 0.0193965}, {100, 0.033127}, {110, 0.0229201}, {120, 0.0342658}, {130, 0.038038}, {140, 0.0467315}, {150, 0.0599289}, {160, 0.0843373}, {170, 0.0933467}, {180, 0.0972515}, {200, 0.124476}, {220, 0.126171}, {240, 0.149213}, {260, 0.125667}, {280, 0.131284}, {300, 0.111403}, {20, 0}, {30, 0}, {40, 0}, {50, 0}, {60, 0.00504185}, {70, 0.00105643}, {80, 0.00476066}, {90, 0.0199289}, {100, 0.0278976}, {110, 0.0363378}, {120, 0.0487953}, {130, 0.0592385}, {140, 0.0586732}, {150, 0.0720589}, {160, 0.0790288}, {170, 0.0908122}, {180, 0.098357}, {200, 0.120454}, {220, 0.133432}, {240, 0.137956}, {270, 0.159881}, {300, 0.152705}, {330, 0.170188}, {360, 0.125013}, {20, 0}, {30, 0}, {40, 0}, {50, 0.0057359}, {60, 0.00883602}, {70, 0.0155384}, {80, 0.0219417}, {90, 0.0356022}, {100, 0.0309318}, {110, 0.0378177}, {120, 0.0602476}, {130, 0.0657433}, {140, 0.0676202}, {150, 0.0840599}, {160, 0.100496}, {170, 0.0842674}, {180, 0.113089}, {200, 0.0969867}, {220, 0.123612}, {240, 0.119192}, {270, 0.115528}, {300, 0.129542}, {330, 0.119207}, {360, 0.124696}} 3. For convinience here also an updated model: mtest1[t_,ltime_]:=If [var1*(t+var2-qtime)>6600,Sum[If [var1*(tsum +var2-qtime)>6600,6600*(1-P),var1*(tsum+var2- qtime)*(1-P)],{tsum,t- ltime+1, t,1}],Max[{Sum[{var1*(tsum+var2- qtime)*(1-P)},{tsum,t-ltime +1, t,1}]},0]]/156000 This is how i do the fitting: parameterWT2 = NonlinearModelFit[ExperimentalData, mtest1[t, ltime], {ltime}, t] I hope i didn't miss out anything. Best Wishes
- References:
- NonlinearModelFit and ParameterTable
- From: Ktota <nuktobi@gmail.com>
- NonlinearModelFit and ParameterTable