Nonlinear fit versus FindMinimum
- To: mathgroup at smc.vnet.net
- Subject: [mg29408] Nonlinear fit versus FindMinimum
- From: "J. Guillermo Sanchez" <guillerm at gugu.usal.es>
- Date: Mon, 18 Jun 2001 03:39:08 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
(*Question: I wist fit some parameters of a model to experimental data. I get using FindMinimum but not using NonlinearFit. Why?. Can any body give me a hand*) MultiExpInput[matrixA_, opts2_, t_, x_] := Module[{A1, M1, M2, M9, R, i, T}, A1 = matrixA; M1 = MatrixExp[A1*t]; M0 = M1 /. t -> T; M2 = ExpandAll[M0 . opts2 /. t -> t - T]; R = Chop[M2 /. a_*E^(b_*t + c_*T) :> (a*(E^(b*t)*(E^(c*t) - 1)))/c]; Table[ExpandAll[Subscript[x, i][t] -> R[[i]]], {i, 1, Length[opts2]}]]; inp = 42.7/E^(100.*t) + 5.458/E^(24.*t); data = {{0, 0.002}, {50, 0.106}, {100, 0.077}, {150, 0.056}, {200, 0.041}, {250, 0.032}, {300, 0.023}, {350, 0.018}, {400, 0.011}, {450, 0.011}, {500, 0.007}}; (*a12 and a23 are the parameters to be fitted*) mA[a12_, a23_] := {{-1.9404 - a12, 0, 0.0462}, {a12, -a23, 0}, {0, a23, -0.05775}}; model[t_, A12_, A23_] := MultiExpInput[mA[A12, A23], {inp, 0, 0}, t, x][[2,2]]; sseH[{(a__)?NumberQ}, list_, model_] := Block[{q2}, q2[tiemp_] = model /. t -> tiemp; Plus @@ Apply[(q2[#1] - #2)^2 & , list, {1}]]; (*^Now, I fit the parameteres and it work*) FindMinimum[sseH[{e12, e23}, data, model[t, e12, e23]], {e12, 0.8, 1}, {e23, 0.007, 0.1}] (*Out[]:={0.0000148301,{e12=AE0.559099,e23=AE0.00763071}}*) (*But, I can't using NonlinearFit*) Needs["Statistics`NonlinearFit`"] NonlinearRegress[data, model[t, e12, e23], {t}, {e12, 0.8}, {e23, 0.007}]