# NonlinearModelFit error messages

I am trying to fit the Strohmeyer equation to some fatigue life data using Mathematica 11.2 but I am receiving an error that I do not understand. Below is a MnonWE using a subset of the data:

In[1]:= dataRed={{7050,450},{9850,400},{10870,380},{11762,380},{12200,380},
{12483,380},{13319,380},{13573,380},{15406,380}};

In[2]:= TableForm[dataRed]
Out[2]//TableForm=
7050    450
9850    400
10870   380
11762   380
12200   380
12483   380
13319   380
13573   380
15406   380

In[3]:= model=Exp[Log[cs]-ks Log[s-\[Gamma]]]
Out[3]= cs (s-\[Gamma])^-ks

In[4]:= nlm = NonlinearModelFit[dataRed,model,{cs,ks,\[Gamma]},s]
During evaluation of In[4]:= NonlinearModelFit::nrlnum: The function value     {-1.243820030066139*10^396+7.585736074658929*10^395 I,<<7>>,-1.124410753827639*10^396+6.857489839258512*10^395 I} is not a list of real numbers with dimensions {9} at {cs,ks,\[Gamma]} = {551.67,-58.8257,4.8815*10^6}.
Out[5]= FittedModel[551.67 (-4.8815*10^6+s)^58.8257]


So while I do get a result it is completely wrong as it gives complex numbers and the value of $\gamma$ is both negative and enormous which is nor physically realistic.

Also, what is the nrlnum error telling me in plain English?

So thinking that I'd got the order of the independent and dependent variables wrong I swapped the data columns (which was annoyingly laborious. Is there are better way?) and tried again.

In[6]:= a=Transpose[dataRed][[1]]
Out[6]= {7050,9850,10870,11762,12200,12483,13319,13573,15406}
In[7]:= b=Transpose[dataRed][[2]]
Out[7]= {450,400,380,380,380,380,380,380,380}
In[8]:= dataTrans=Transpose[{b,a}]
Out[8]= {{450,7050},{400,9850},{380,10870},{380,11762},{380,12200},{380,12483},{380,13319},{380,13573},{380,15406}}

In[9]:= nlmtrans = NonlinearModelFit[dataTrans,model,{cs,ks,\[Gamma]},s]
During evaluation of In[26]:= NonlinearModelFit::nrlnum: The function value {-2.56588*10^296-1.16791*10^297 I,-2.62127*10^296-1.19313*10^297 I,-2.64376*10^296-1.20336*10^297 I,<<4>>,-2.64376*10^296-1.20336*10^297 I,-2.64376*10^296-1.20336*10^297 I} is not a list of real numbers with dimensions {9} at {cs,ks,\[Gamma]} = {349.398,-57.4312,134874.}.
Out[9]= FittedModel[349.398 (-134874.+s)^57.4312]


and I got the same errors but with different parameter values (which was an expected outcome).

It someone could please explain these errors to me it would be greatly appreciated. I have looked for them in the Mathematica documentation to no avail. If there is a canonical list of Mathematica error messages somewhere on the net that would also be good to know of.

I'm afraid that while I can use Mathematica I'm very much a novice and find its syntax arcane.

Regards,

Bruce

• Up to google.com/… statistics begins from sample size 30. Oct 8 '17 at 5:07
• @user64494, thanks for this but I get the same error even if I use the complete dataset of 105 point. Oct 8 '17 at 5:14
• BTW "nrlnum" is "not real numbers", if you read the full error message. At a guess, I'd say it comes from taking the Log of a negative number. So maybe adding some constraints to prevent that would fix it. Oct 8 '17 at 5:47
• Thanks @aardvark2012. I will put in sensible constraints and see what happens. The log of a negative number would explain the imaginary numbers that appear in the results given. Oct 8 '17 at 7:07

It turns out, the information provided by these options is completely useless. Maybe in version 11.next we'll get better documentation for error messages.

In this case, however, the full error message reveals that Mathematica is struggling with the parameters. For example, the current "best guess" for ks is -57, which when entered into your model equation returns a ridiculous value.

To move from the question you asked (about the error message) to the problem you have (fitting data), there are several steps that need to be taken.

1. A better minimal non-working example

The community appreciates when users try to avoid posting reams of raw data. In your case, note how there are only two points whose ordinate values are not 380. Any answer you obtain based upon this limited set of data should be held as suspicious.

1. A need for better starting parameters

Dug in the documentation on NonlinearModelFit is the important fact that Mathematica begins a fit with the parameters having a value of 1. One strategy for starting a modeling experiment is to see if this is reasonable:

dataRed /. {x_Integer, y_Integer} :> {x, y,
model /. {cs -> 1, ks -> 1, \[Gamma] -> 1, s -> x}} //
N // TableForm


The third column is the ordinate value when all parameters are equal to 1. The fit residuals at this stage are too large and too similar for Mathematica to make useful improvements to the parameter values.

1. Review the model

When I look closely at your data, large values of s should give a constant value of 380. The equation in model can never do that. Assuming that the exponential factor is positive:

Limit[model, s -> Infinity, Assumptions -> ks > 0]
(* 0 *)


Your model needs a constant offset, and when digging in the literature (the technical term I use for doing web searches nowadays) I find Strohmeyer fatigue equations that do have this offset, but are not equivalent to the model you've presented in this question.

• Thanks for these insights. It’s late at night but I will follow up your suggestions tomorrow. I have got the model to work now but the cross-correlations between the parameters are very close to 1 in all cases which tells me it’s a poor model. Oct 8 '17 at 11:30