# NonlinearModelFit returning nonsense for very simple data

In fitting the following data, if I first log transform the y-values and use LinearModelFit I get a set of parameters that fits the data:

data = {{248, 0.032}, {280, 0.0498}, {327, 0.0971}, {360, 0.162}};
loggedData = ReplaceList[data, {__, {x_Integer, y_Real}, ___} -> {x, Log[y]}];
linFit = LinearModelFit[loggedData, t, t];

linFit["BestFitParameters"]

{-7.03516, 0.0144417}


However, if I instead use NonlinearModelFit on the data directly (not log transformed), I get nonsense

data = {{248, 0.032}, {280, 0.0498}, {327, 0.0971}, {360, 0.162}};
NonlinearModelFit[data, a Exp[b t], {a, b}, t]["BestFitParameters"]

{a -> 0., b -> 1.}


Have I found the one set of points that NonlinearModelFit cannot handle? It seems that any other exponential data I feed in can be fit just fine by NonlinearModelFit. Are there any additional directives I can give to NonlinearModelFit to get a sensible result?

• This is another case of having to give reasonable starting values when you have a function that depends exponentially on the parameters (cf. this). Try NonlinearModelFit[data, a Exp[b t], {{a, 0}, {b, 0}}, t]["BestFitParameters"] and you will find that it works correctly. Mar 5, 2013 at 13:41

Add Method -> "NMinimize" to the NonlinearModelFit call.

data = {{248, 0.032}, {280, 0.0498}, {327, 0.0971}, {360, 0.162}};
NonlinearModelFit[data, a Exp[b t], {a, b}, t,
Method -> "NMinimize"]["BestFitParameters"]

{a -> 0.000783053, b -> 0.0147985}


The fit looks good:

Show[ListPlot@data, Plot[a Exp[b t] /. fit, {t, 248, 360}]]


See this answer for more details on how the NMinimize method works.

• Ahh, it seems my problem is having Mathematica 7! Thanks for the tip. Mar 5, 2013 at 6:22