Re: NonlinearModelFit and ParameterTable
- To: mathgroup at smc.vnet.net
- Subject: [mg106395] Re: [mg106359] NonlinearModelFit and ParameterTable
- From: Bob Hanlon <hanlonr at cox.net>
- Date: Mon, 11 Jan 2010 05:32:21 -0500 (EST)
- Reply-to: hanlonr at cox.net
For the following, eliminate the extraneous list brackets and use the symbolic Sum
{Sum[{var1*(tsum + var2 - qtime)*(1 - P)},
{tsum, t - ltime + 1, t, 1}]} // FullSimplify
{{(1/2)*ltime*(P - 1)*var1*(ltime + 2*qtime - 2*t - 2*var2 - 1)}}
Instead of
If[var1*(tsum + var2 - qtime) > 8000,
8000*(1 - P),
var1*(tsum + var2 - qtime)*(1 - P)]
Use
Min[8000*(1 - P), var1*(tsum + var2 - qtime)*(1 - P)]
Then use Piecewise instead of the outer If.
If is primarily a programming construct; whereas, Piecewise is intended as a mathematical construct.
mtest1[t_, ltime_] :=
Piecewise[{{
Sum[
Min[
8000*(1 - P),
var1*(tsum + var2 - qtime)*(1 - P)],
{tsum, t - ltime + 1, t, 1}],
var1*(t + var2 - qtime) > 8000}},
Max[
ltime*(P - 1)*var1*
(ltime + 2*(qtime - t - var2) - 1)/2,
0]]/156000
Without realistic test data and knowing the values of the constants that are not parameters, I will not go further.
Also, if you look at the symbolic output expression for mtest1[t, ltime] you will see that it might simplify considerably if you include any known constraints on the constants and/or parameters.
Bob Hanlon
---- Ktota <nuktobi at gmail.com> 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