Fit a curve using a parametric function from phenopix::greenProcess().

fit_curve(ts, cycles, fit = c("gu", "klosterman"))



Time series in s2ts format (generated using fill_s2ts()).


Cycles allocation (data table generated by cut_cycles(), eventually filtered using assign_season()).


Fitting function among "klosterman", "beck", "elmore", "gu" and "no" (see phenopix::greenProcess()). Value "no" can be used to convert a s2ts time series in the format returned by this function without making any interpolation. A vector of length > 1 can be specified, in which case the second element is used if the first method fails.


A named list of n elements (being n the number of IDs included in ts). Each element is a named list of m elements (being m the number of detected cycles). Each element is a list including the following elements:

  • fit: the fitted curve as returned by phenopix fitting functions;

  • ts: a data table of fitted values, containing the columns date (date of the record) and value (fitted value);

  • maxval: the date of the maximum value in the cycles (obtained from input cycles and here reported).


Luigi Ranghetti, PhD (2020)


# Load input data data("ts_filled") data("dt_cycles") # \donttest{ # Standard interpolation cf <- fit_curve(ts_filled, dt_cycles) plot(ts_filled, fitted = cf)
# } # Interpolation using a different method cf_2 <- fit_curve(ts_filled, dt_cycles, fit = "no")