# Fitting experimental data with a Van der Pol model - FindFit error

I am trying to fit some experimental data to a Van der Pol oscillator model, solving the differential equation and using FindFit (like in the examples given in the Wolfram Documentation) like this:

    model[\[Mu]_?NumberQ,r_?NumberQ,a_?NumberQ,b_?NumberQ,c_?NumberQ,d_?NumberQ,
f_?NumberQ]:=(model[\[Mu],r,a,b,c,d,f]=First[x/. NDSolve[{x''[t]-\[Mu]*(r-b*x[t]^2)*x'[t]+d*x[t]==f, x[0]==a, x'[0]==c},x,{t,0,15}]])

fit=FindFit[data,model[\[Mu],r,a,b,c,d,f][x],{{\[Mu],143},{r,0.26},{a,-0.04},{b,800},{c,0.7},{d,48},{f,-0.55}},x]
gpp=Plot[model[\[Mu],r,a,b,c,d,f][x]/.fit,{x,0,5},PlotStyle->Red];

Show[gp,gpp]


where gp is simply the ListLinePlot of my data. I struggled a lot to find by hand some values for all the parameters in order to have already good overlap between the model and the data, because I know that the method above is quite sensitive to that. Anyway, when I input the parameters and run it, what eventually happens is that the method seems to work, optimising slightly the parameters and making the plot, BUT I always get the message:

FindFit: The step size in the search has become less than the tolerance prescribed by the PrecisionGoal option, but the gradient is larger than the tolerance specified by the AccuracyGoal option. There is a possibility that the method has stalled at a point that is not a local minimum.

I never understood what this means...Does it actually mean the fit didn't really work? How do I get rid of it and make sure the method I'm using is working??

Data sample here

Thanks, GIacomo

• a sample data would be highly appreciated. – Rupesh Mar 18 '20 at 12:57
• Ok, do you know how I can upload a .dat file here? In any case, I receive the same "error", if I generate points using the same model, and try to fit them afterwards (even if the fit looks great in this case obviously) – Giacomo F Mar 18 '20 at 14:18
• share some onedrive or google drive link – Rupesh Mar 18 '20 at 14:36
• Done! It's at the bottom of my question. Cheers – Giacomo F Mar 18 '20 at 14:46
• Show[ListPlot[data], gpp] certainly suggests that it might have worked. Adding in that figure would be helpful. – JimB Mar 18 '20 at 15:15

I don't think the model is flexible enough to fit the data. Playing with the parameters does not seem to produce a better fit. Below I use the parameter estimates for the initial values.

Manipulate[gpp = Plot[model[μ, r, a, b, c, d, f][x], {x, 0, 5}, PlotStyle -> Red];
Show[ListPlot[data], gpp],
{{μ, 149.836}, 140, 160, Appearance -> "Labeled"},
{{r, 0.235986}, 0.2, 0.3, Appearance -> "Labeled"},
{{a, -0.0412192}, -0.03, -0.05, Appearance -> "Labeled"},
{{b, 763.669}, 700, 800, Appearance -> "Labeled"},
{{c, 0.654687}, 0.6, 0.7, Appearance -> "Labeled"},
{{d, 49.8976}, 40, 60, Appearance -> "Labeled"},
{{f, -0.52549}, -0.4, -0.6, Appearance -> "Labeled"}]


• Yeah, I agree. That's what I've been doing by hand basically (The Manipulate tool is pretty useful though, this is the first time I use it, Thanks!). Well, good to know at least that I wasn't just doing something completely stupid. Thanks again! – Giacomo F Mar 18 '20 at 16:05