# What is the source of error in the following fitting procedure in Mathematica 8.0? [closed]

I am trying to fit the following data with a user-defined model. A priori, we know that this model is supposed to be the best fit for the given data. But, I do not know why I am receiving many error messages. Decent values for the parameters 1, 2 and 3 are respectively known to be in the range (10,11), (-1,-30) and (-1,-3). Your help is appreciated.

h=0.7;
data = {{7.558 - Log10[h], Log*10^-0.89613}, {7.7029 - Log10[h], Log*10^-1.0998}, {7.8551 - Log10[h], Log*10^-1.0591}, {8.0145 - Log10[h], Log*10^-1.2016}, {8.1522 - Log10[h], Log*10^-1.3442}, {8.3043 - Log10[h], Log*10^-1.3136}, {8.4783 - Log10[h], Log*10^-1.334}, {8.6232 - Log10[h], Log*10^-1.3136}, {8.7536 - Log10[h], Log*10^-1.3035}, {8.9058 - Log10[h], Log*10^-1.446}, {9.058 - Log10[h], Log*10^-1.558}, {9.1957 - Log10[h], Log*10^-1.5479}, {9.3478 - Log10[h], Log*10^-1.6802}, {9.5072 - Log10[h], Log*10^-1.7312}, {9.6594 - Log10[h], Log*10^-1.8432}, {9.8043 - Log10[h], Log*10^-1.9756}, {9.9565 - Log10[h], Log*10^-2.169}, {10.101 - Log10[h], Log*10^-2.4033}, {10.246 - Log10[h], Log*10^-2.7902}, {10.399 - Log10[h], Log*10^-3.0244}, {10.543 - Log10[h], Log*10^-3.4216}, {10.688 - Log10[h], Log*10^-4.0631}, {10.848 - Log10[h], Log*10^-4.8473}};
model = Log*Exp[-10^(x - Log10[h] - par1)]*10^par2*(10^(x - Log10[h] - par1))^(par3 + 1);
curve = FindFit[data, model, {par1, par2, par3}, x]


During evaluation of In:= General::unfl: Underflow occurred in computation. >>

During evaluation of In:= General::unfl: Underflow occurred in computation. >>

During evaluation of In:= General::unfl: Underflow occurred in computation. >>

During evaluation of In:= General::stop: Further output of General::unfl will be suppressed during this calculation. >>

During evaluation of In:= FindFit::fmgz: Encountered a gradient that is effectively zero. The result returned may not be a minimum; it may be a maximum or a saddle point. >>

Out= {par1 -> 1., par2 -> 1., par3 -> 1.}

## closed as off-topic by MarcoB, user9660, march, Öskå, kjoJul 4 '16 at 11:46

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – MarcoB, Community, march, Öskå, kjo
If this question can be reworded to fit the rules in the help center, please edit the question.

• I can't reproduce the underflow errors, but I do also receive the zero-gradient one. FindFit will automatically start with the parameters set to $1$, but you should probably provide better starting values for your parameters. – MarcoB Jun 30 '16 at 18:45
• How can I do that? I kind of know what are decent values for three parameters. – Benjamin Jun 30 '16 at 18:47
• You can use a parameter specification of the form: {{par1, ...}, {par2, ...}, {par3, ...}} within FindFit or NonlinearModelFit; substitute appropriate starting values where I left .... – MarcoB Jun 30 '16 at 18:50
• only NonlinearModelFit worked. Thanks, – Benjamin Jun 30 '16 at 18:57

## 1 Answer

You can't do without good starting values:

curve = FindFit[data, model, {{par1, 10}, {par2, -2}, {par3, -1}}, x]
Show[ListPlot[data], Plot[model /. curve, {x, 7, 11}]] However, the residuals suggest that the assumed constant variance about the line is unwarranted (residuals are much larger for smaller values of "x") and there is overestimation for larger values of "x". A plot on a log scale highlights some of the potential deficiencies: 