0
$\begingroup$

I have a complicated model and I want to fit it to my data. I used NonlinearModelFit. The fit quality is very poor (P is infinitesimal) and it comes with a warning that I don't know how to avoid.

FittedModel::constr: The property values {ParameterTable} assume an unconstrained model. The results for these properties may not be valid, particularly if the fitted parameters are near a constraint boundary.

data2 = {{0.26, 0.002}, {2.61, 0.0011}, {6.39, 0.0029}, {6, 
0.003575}, {19, 0.002405}, {63, 0.004875}, {13, 0.007995}, {87, 
0.002665}, {122, 0.00364}, {31, 0.00546}, {361, 0.007475}, {491, 
0.007085}};

dataerror2 = {0.0008, 0.0004, 0.0005, 0.001235, 0.00104, 0.00078,  0.00364, 0.000455, 0.00039, 0.001495, 0.00104, 0.000975};

Ieff = 83.2 ;
lambdamin = LETmin/Ieff*1000 ; 
LETmin = 0.26;
Np = 0.0811;
Ns = 0.080;
Nt = 0.1611;
lambdaLET[let_] = lambdamin*let/LETmin; 
NpCumulative[k_, r0_, lambda_] = Np*(1. - CDF[PoissonDistribution[r0*lambda], k])/(r0*lambda);
NsCumulative[k_, r0_, lambda_] = Ns*(1. - CDF[PoissonDistribution[r0*lambdamin], k])/(r0*lambdamin); 
NtCumulative[k_, r0_, lambda_] =  NpCumulative[k, r0, lambda] + NsCumulative[k, r0, lambda];


datalist2 = Join[data2, List /@ dataerror2, 2];
Data2 = ListLogLogPlot[{#1, Around[#2, #3]} & @@@ datalist2,Axes -> False, PlotRange -> {{0.2, 1000}, {.0001, 0.5}}, Frame -> True, ImageSize -> 500, PlotStyle -> {Red, PointSize[0.008]},FrameLabel -> {Style["LET", 14], Style["rate ", 14]}, PlotLabel -> Style[" rate", 18]];
datafittD2 = NonlinearModelFit[data2, {Eff2*NtCumulative[1, r0, lambdaLET[let]], {0.001 < r0 < 0.1}, {0.1 < Eff2 < 0.9}}, {{r0, 0.003}, {Eff2, 0.6}}, {let}, Weights -> 1/dataerror2^2, VarianceEstimatorFunction -> (1 &)];
datafittD2plot = LogLogPlot[datafittD2[let], {let, 0.2, 1000}];
datafittD2["BestFitParameters"];
datafittD2["ParameterTable"]
DOF2 = Length[dataerror2] - 2
datachisquare2 =Sum[(datafittD2["FitResiduals"][[i]]/dataerror2[[i]])^2, {i, 1,  Length[dataerror2]}]
datafittDplot2 = Show[Data2, datafittD2plot, Frame -> True]
$\endgroup$
3
  • $\begingroup$ Please fix the code by removing the multiple occurrences of backticks ("`"). $\endgroup$
    – JimB
    Commented May 30, 2023 at 13:51
  • 3
    $\begingroup$ You can ignore the warning because the estimates are not near the constraint boundaries. The data simply does not fit the proposed model. Also, there are two sources of error: the measurement error you give in dataerror2 and the lack-of-fit error. But by using the option VarianceEstimatorFunction -> (1 &) one is pretending that there is no above and beyond any measurement error. Mathematica really needs to add "mixed model" capability (i.e., multiple sources of error). So, yes, there is a poor fit but it not Mathematica's fault. You need a better model or better data or both. $\endgroup$
    – JimB
    Commented May 30, 2023 at 15:07
  • $\begingroup$ Your data has no discernible trend I can see. It is going to be extremely difficult to meaningfully fit any model to such data. $\endgroup$
    – MarcoB
    Commented May 30, 2023 at 15:07

1 Answer 1

0
$\begingroup$

Infinitesimal P means the fitted model parameters are highly significant (i.e., different form zero). Which doesn't necessarily mean the model is actually a good fit — it isn't.

Your model is very specific, and one possibility is that it doesn't have the flexibility to fit these data. Do you have external reason to think it does?

Also, you are fitting a model with three parameters — albeit constrained ones — to only twelve data points. Just looking at the data, there is no obvious curved trend that would require three parameters. Especially not before log-transformation. These data look like they wold benefit from log-transformation before fitting. Maybe try that?

$\endgroup$
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.