Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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];


{-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?

share|improve this question
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. – Oleksandr R. Mar 5 '13 at 13:41
up vote 5 down vote accepted

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}]]

enter image description here

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

share|improve this answer
Ahh, it seems my problem is having Mathematica 7! Thanks for the tip. – joshsilverman Mar 5 '13 at 6:22

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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