TransWikia.com

Even though the fit seems correct, NonlinearModelFit throws a failed convergence error

Mathematica Asked on August 13, 2021

Consider the following data

data = {{2, -2.99380668585}, {4, -2.99413053462}, {6, -2.99439488497}, {8, -2.99467836024},
 {10, -2.99491958936}, {12, -2.99519218472}, {14, -2.99538900867}, {16, -2.99562768004}, 
{18, -2.99584876062}, {20, -2.99601713877}, {22, -2.99619549077}, {24, -2.99637350562}}

I am trying to fit to this data the (displaced) real part of some powers of a complex number

fit = NonlinearModelFit[ data, 
-a + [Rho] r^m Cos[m [Phi] + [Psi]], {a, [Rho], [Phi], [Psi], r},
 m,  MaxIterations -> 1000]

Even though the fit looks good

DiscretePlot[fit["BestFit"], {m, 2, 24, 2},  Epilog -> { Point[data]}]

I would like to know if the NonlinearModelFit::cvmit error that NonlinearModelFit shows can be removed by (somehow) improving the fit. I tried using some starting values, but I was unsuccessful.

One Answer

I think there are few issues with what you're attempting to do:

  • Fitting 6 parameters ($a$, $rho$, $phi$, $psi$, $r$, and the error variance) to just 12 data points is usually not enlightening. (This is not to say that obtaining more data is easy or even possible to do.)
  • The parameters estimates for $rho$, $phi$, and $psi$ are not even close to being statistically significant.
  • The correlation matrix estimate has nearly every correlation equal to 1. In other words, the model is way overparameterized given the available data. Predictions might be OK but you should definitely avoid interpreting coefficients (either the magnitude or the sign).

Here is the issue with the parameter estimates:

fit = NonlinearModelFit[data, -a + ρ r^m Cos[m ϕ + ψ], {a, ρ, ϕ, ψ, r}, m,
  MaxIterations -> 1000, Method -> "NMinimize"]
fit["ParameterTable"]

Parameter table with no restrictions on r

Here is the issue with the correlation matrix:

fit["CorrelationMatrix"] // MatrixForm 

Correlation matrix

The model is just overparameterized given the available data. Note that if one rationalizes the data, only the P-value for $a$ remains statistically significant:

fit2 = NonlinearModelFit[Rationalize[data, 0], {-a + ρ r^m Cos[m ϕ + ψ]}, {a, ρ, ϕ, ψ, r}, m, 
   MaxIterations -> 1000, Method -> "NMinimize", WorkingPrecision -> 30];
fit2["ParameterTable"]

Parameter table with rationalized data

fit2["CorrelationMatrix"] // MatrixForm

Correlation matrix with rationalized data

Correct answer by JimB on August 13, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP