0
$\begingroup$

When running NonlinearModelFit on certain functional forms, the method just returns the input expression without evaluating. For example:

nlm2 = 
 NonlinearModelFit[
  rUnder, {a (t/tl (1 - t/tl)^b)^(1/2)}, {{a, 21}, {b, .5}, {tl, 
    2.17}}, t, Weights -> weightsUnder, 
  VarianceEstimatorFunction -> (1 &)]

Out[1]= NonlinearModelFit[{{1.81593, 20.}, {1.9886, 
   16.6667}, {2.02291, 15.625}, {2.09426, 13.8889}, {2.12865, 
   11.3636}, {2.158, 7.8125}, {2.17323, 7.57576}, {2.18395, 
   4.16667}, {2.1344, 12.5}, {2.08936, 13.8889}, {1.99008, 
   17.8571}, {1.89548, 19.2308}, {1.83101, 19.2308}, {1.7435, 
   21.1795}, {1.7158, 22.7273}, {1.6527, 20.8333}, {1.63489, 
   20.}, {1.616, 20.}, {1.59589, 20.}, {2.04861, 17.3524}, {1.9781, 
   18.2618}, {1.96271, 18.6676}, {1.9468, 18.9353}, {1.93863, 
   19.1374}, {1.81373, 19.9836}, {1.80704, 19.9943}, {1.7933, 
   19.9749}, {1.78147, 19.872}, {1.76925, 20.0654}, {1.78387, 
   20.0318}, {2.04328, 20.1613}, {2.03385, 20.4918}, {1.9062, 
   23.1481}, {1.8732, 25.}}, {a Sqrt[(t (1 - t/tl)^b)/tl]}, {{a, 
   21}, {b, 0.5}, {tl, 2.17}}, t, 
 Weights -> {11.3798, 34.9676, 23.1823, 41.8684, 59.9708, 168.066, 
   246.244, 112.401, 35.5266, 29.2875, 18.9364, 16.1314, 12.3042, 
   49.706, 13.9461, 53.9137, 52.9276, 49.7358, 46.7365, 21.7433, 
   71.1736, 67.3292, 129.239, 15.842, 149.66, 72.7971, 84.6504, 
   82.3477, 68.1859, 24.7328, 105.164, 18.0225, 26.1849, 33.8865}, 
 VarianceEstimatorFunction -> (1 &)]

A similar error occurs with CubeRoot (not shown for conciseness).

The problem does go away if I put Abs around the interior of the root, but this produces an unsatisfactory fit. It also goes away if I use Re instead, but breaks again if I change the starting parameter away from .5 (and indeed does not appear to vary that parameter).

I could try using FindFit or taking the logarithm of my data, but I don't know how to un-transform the resulting statistical error measures.

$\endgroup$
7
$\begingroup$

The eighth data point is {2.18395, 4.16667} and the parameter tl starting value is 2.17. So, this data point will give a complex value for the starting parameter values. A fix is change the starting value of tl and add a constraint that tl cannot be less than the greatest value of t in the data.

Try this:

nlm2 = NonlinearModelFit[rUnder,
   {a (t/tl (1 - t/tl)^b)^(1/2),
    tl > Max[rUnder[[All, 1]]]},
   {{a, 21}, {b, .5}, {tl, 2.2}},
   t, Weights -> weightsUnder,
   VarianceEstimatorFunction -> (1 &)];

nlm2["BestFitParameters"]

Plot[nlm2[t],
 {t, Min[rUnder[[All, 1]]], Max[rUnder[[All, 1]]]},
 Epilog -> {Point[rUnder]}]

(*  {a -> 37.8786, b -> 0.600229, tl -> 2.18499}  *)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.