# NonlinearModelFit not running

**URL:** <https://community.wolfram.com/t/nonlinearmodelfit-not-running/2035>\
**Category:** Questions\
**Tags:** mathematica, optimization\
**Created:** [April 22, 2014, 5:34am UTC](https://community.wolfram.com/t/nonlinearmodelfit-not-running/2035 "2014-04-22T05:34:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![armansoufiani](https://avatars.discourse-cdn.com/v4/letter/a/e9bcb4/32.png) [@armansoufiani](https://community.wolfram.com/u/armansoufiani)\
**Post date:** [April 22, 2014, 5:34am UTC](https://community.wolfram.com/t/nonlinearmodelfit-not-running/2035/1 "2014-04-22T05:34:23Z")

</div>

Dear All,

I’m fairly new to Mathematica. Please bear with me.  
I’ve already been able to fit some experimental data in Matlab. However, I want to implement it in Mathematica as well, so as to extract the statistics easier each time.  
The following is the model function I use. However, as I run the code it gives me a straight line which does not match my experimental data at all.  
My very first question is, whether the way I’ve defined the function is correct or not?

I’ve attached the file which containes both the experimental data and the fitting function.  
I greatly appreacite your helps in advance.

Kind Regards,  
Arman

---

<div class="post-metadata">

**Author:** ![degnen](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/degnen/32/21900_2.png) [@degnen](https://community.wolfram.com/u/degnen)\
**Post date:** [April 22, 2014, 8:11am UTC](https://community.wolfram.com/t/nonlinearmodelfit-not-running/2035/2 "2014-04-22T08:11:43Z")

</div>

```auto

```

---

<div class="post-metadata">

**Author:** ![sukrause](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/sukrause/32/41348_2.png) [@sukrause](https://community.wolfram.com/u/sukrause)\
**Post date:** [April 22, 2014, 1:39pm UTC](https://community.wolfram.com/t/nonlinearmodelfit-not-running/2035/3 "2014-04-22T13:39:40Z")

</div>

As it stands, the starting parameters are bad and the model has no variance over the range, try

```auto
Plot[model[x, 37., 1.68, 50., 0.46, 0.73], {x, 1.63, 1.71}, 
 Epilog -> {PointSize[Small], Point[Data4kI3]}, PlotRange -> Automatic]

```

and see that the model grows seemingly linear between

```auto
In[60]:= model[#, 37., 1.68, 50., 0.46, 0.73] & /@ {1.63, 1.71}
Out[60]= {3.21643, 3.21647}

```

3.21643 and 3.21647, but the data vary in y from 0.56 to 0.63 over the range and have a strong peak around x = 0.65.  
Look at this

```auto
Plot[model[x, 37., 1.68, 50., 0.01, 0.55], {x, 1.63, 1.71}, 
 Epilog -> {PointSize[Small], Point[Data4kI3]}, PlotRange -> {{1.63, 1.71}, {0.56, 0.64}}]

```

to estimate how bad (without variability) the model is over the x-range the data have. Therefore NonlinearModelFit[] gives nothing but a horizontal line at about y=0.601 back.

What to do next:

- Check the model (typos, missing expressions, …)
- find a parameter area where it has the variability which is necessary to fit the data
- if such an area of parameters is not available: change the model
- return to NonlinearModelFit[] and get the job done
