Menu

#2574 function fitting of a time/date data set

None
closed-invalid
fit (6)
2022-12-29
2022-12-22
Anonymous
No

function fitting of a data set does not work when xdata format is time/date. It just works wrong.

Discussion

  • Ethan Merritt

    Ethan Merritt - 2022-12-22
    • status: open --> open-invalid
    • Group: -->
    • Priority: -->
     
  • Ethan Merritt

    Ethan Merritt - 2022-12-22

    This report is not useful without further information and a sample script showing the problem.

    For what it's worth, the usual difficulty with fitting to time/date data is that the data points are very far from the origin (time 0 = epoch date = is 1 Jan 1970). Generally you want to fit a relative time (offset from start of data) rather than an absolute time.

     
  • Justin Sales

    Justin Sales - 2022-12-22

    That's true, my time/date data are of Apr 2022. Trying with just the day (from day 2 to 29) works just fine. Still... maybe gnuplot could automatically subtract the first x value to make the fit work ? (that would simplify things a lot). My data are of the kind

    02/04/2022 -3,3
    03/04/2022 4,7
    04/04/2022 2,5
    05/04/2022 -1,2
    06/04/2022 1,0
    etc ; here is the result for the fitting function f(x) = r*x + z:

    iter chisq delta/lim lambda r z
    0 7.8958946412e+19 0.00e+00 1.17e+09 1.000000e+00 1.000000e+00
    1 2.2682834361e+16 -3.48e+08 1.17e+08 1.694915e-02 1.000000e+00
    2 6.7404943714e+08 -3.37e+12 1.17e+07 2.921210e-06 1.000000e+00
    3 2.4947496954e+02 -2.70e+11 1.17e+06 -5.487712e-10 1.000000e+00
    4 2.4947296583e+02 -8.03e-01 1.17e+05 -5.538087e-10 1.000000e+00
    iter chisq delta/lim lambda r z

    After 4 iterations the fit converged.
    final sum of squares of residuals : 249.473
    rel. change during last iteration : -8.03176e-06

    degrees of freedom (FIT_NDF) : 27
    rms of residuals (FIT_STDFIT) = sqrt(WSSR/ndf) : 3.03969
    variance of residuals (reduced chisquare) = WSSR/ndf : 9.23974

    Final set of parameters Asymptotic Standard Error
    ======================= ==========================
    r = -5.53809e-10 +/- 7.809e-07 (1.41e+05%)
    z = 1 +/- 1288 (1.288e+05%)

    correlation matrix of the fit parameters:
    r z
    r 1.000
    z -1.000 1.000

    [When plotting just the day (as xdata), I obtain reasonable values: r=0.0269 and z = -0.17]

     

    Last edit: Justin Sales 2022-12-22
    • Ethan Merritt

      Ethan Merritt - 2022-12-22

      Right, so instead of fitting f(time) = r·time+z , you define a suitable time 0 and fit the offset:

        time0 = strptime("%d/%m/%Y", "01/04/2022")
        f(time) = r * (time - time0) + z
        fit f(x) ...
      
       
  • Ethan Merritt

    Ethan Merritt - 2022-12-29
    • status: open-invalid --> closed-invalid
     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.