Search code examples
wolfram-mathematicaprecisionnon-linear-regression

Warning Mathematica FittedModel: The precision of the argument function (MachinePrecision) is less than WorkingPrecision (MachinePrecision)


Fellows,

I couldn't figure why I am having the warning message from the following code in Mathematica:

data = {{0, 1}, {1, 0.02307044673005989`}, {2, 
0.00784879347316981`}, {3, 0.0061305265946403195`}, {4, 
0.0008550610216054799`}, {5, 0.00010928133254420425`}, {6, 
0.000011431049984759768`}, {7, 1.93788101788827`*^-6}, {8, 
1.6278670621771263`*^-6}, {9, 2.6661469926370584`*^-7}, {10, 
3.443821224260662`*^-8}, {11, 7.413060538191399`*^-9}, {12, 
1.4031525687948224`*^-9}, {13, 5.973790450062338`*^-10}, {14, 
1.7434844383850214`*^-10}, {15, 2.6053424128998922`*^-11}, {16, 
9.887095524831592`*^-12}, {17, 1.2318024865446659`*^-12}, {18, 
2.2125640342387203`*^-13}, {19, 1.3176590670511745`*^-13}, {20, 
2.7354393146500743`*^-14}};

fit = NonlinearModelFit[data, a + b Exp[-x/c], {a, b, c}, x, 
   MaxIterations -> \[Infinity], PrecisionGoal -> MachinePrecision, 
   WorkingPrecision -> MachinePrecision];

fit["BestFitParameters"] (* THE WARNING APPEARS AFTER CALLING THIS FUNCTION *)

The warning message is:

FittedModel: The precision of the argument function (MachinePrecision) is less than WorkingPrecision (MachinePrecision).

Thanks in advance.


Solution

  • The problem is that many of the data values are small and close to machine precision. You can try linear fitting to the Log of the data values.

    data2 = {First[#], Log[Last[#]]} & /@ data;
    lm = LinearModelFit[data2, x, x]
    Show[ListPlot[data2], Plot[lm[x], {x, 0, 20}]]
    

    The first data point {0, 1} does not look right. Are you sure it is correct?

    enter image description here