The setting: I have some data of the form
data=Table[{{x,y},Error[y]}]
with a analytic fit function
FQQ[A_,M_,R_,c_]:=A*Exp[-M*R]/R+c;
for which I'd like to perform a Non Linear Model Fit of the form
Fitdata[beg_,end_]:=NonlinearModelFit[
Table[data[[i]][[1]],{i,beg+1,Length[data]-end}],
FQQ[A,M,R,c],{A,M,c},R,
Weights -> 1/Table[(data[[i]][[2]][[1]])^2,{i,beg+1,Length[data]-end}]
];
Note that Fitdata[0,0]
includes all data points in data
and non zero values cut the beginning or the end of the data set, respectively.
I'm now interested in the fit parameters as functions of the cutting.
What I tried untill now is
Table[{beg,end,A/.Fitdata[beg,end]["BestFitParameters"],
M/.Fitdata[beg,end]["BestFitParameters"],c/.Fitdata[beg,end]["BestFitParameters"]},
{beg,0,Length[data]-3,1},{end,0,Length[data]-3,1}]
which should generate a table of the form
Table{beg,end,A,M,c}
which I'd like to plot in three difeerent 3D-plots later on.
EDIT: I'm obviously an idiot... I cut too much, which lead to too few data points being available.
Table[{beg,end,A/.FitWLCV1H00[beg,end]["BestFitParameters"],
M/.FitWLCV1H00[beg,end]["BestFitParameters"],
c/.FitWLCV1H00[beg,end]["BestFitParameters"]},
{beg,0,Length[formatedDataTrimmedWLCV1H00]-3,1},
{end,0,Length[formatedDataTrimmedWLCV1H00]-beg-3,1}]
accounts for a lot of my problems.
Now I'm "only" left with error messages of the type
NonlinearModelFit::sszero: 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.
NonlinearModelFit::cvmit: Failed to converge to the requested accuracy or precision within 100 iterations.
Any chance to adapt them on the fly? Hence, is it possible to alter PrecisionGoal
and AccuracyGoal
only if the fit does not converge? If so, what would be good values?
EDIT: As requested by @JimB, here's a example of the data that I'm working with. It is by far the smalles set. Others contain up to 1000 Points in a similar range.
{{{0.239975, 2.66302}, ErrorBar[0.00326151]},
{{0.358325, 2.33694}, ErrorBar[0.00308647]},
{{0.446625, 1.86911}, ErrorBar[0.0042742]},
{{0.485025, 1.64511}, ErrorBar[0.00425176]},
{{0.556175, 1.24764}, ErrorBar[0.00408676]},
{{0.6162, 0.956111}, ErrorBar[0.00515167]},
{{0.706675, 0.624671}, ErrorBar[0.00478222]},
{{0.7487, 0.501506}, ErrorBar[0.00338924]},
{{0.78755, 0.392851}, ErrorBar[0.00410899]},
{{0.82845, 0.34129}, ErrorBar[0.00536362]},
{{0.86895, 0.265029}, ErrorBar[0.00623553]},
{{0.900475, 0.217144}, ErrorBar[0.00404639]},
{{0.93585, 0.172457}, ErrorBar[0.0043178]},
{{0.997625, 0.117752}, ErrorBar[0.0046043]},
{{1.02973, 0.111512}, ErrorBar[0.00480712]},
{{1.0595, 0.098667}, ErrorBar[0.00455822]},
{{1.08963, 0.0603218}, ErrorBar[0.00519334]},
{{1.1166, 0.0835568}, ErrorBar[0.00408133]}}
MaxIterations
might resolve all of the issues. $\endgroup$sszero
messages around that I have never heard of and am unable to find information about. I'll take a look at your suggestedMaxIterations
approach. $\endgroup$