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

## Arguments

ts |
Time series in `s2ts` format (generated using `fill_s2ts()` ). |

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

fit |
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. |

## Value

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).

## Author

Luigi Ranghetti, PhD (2020) luigi@ranghetti.info

## Examples

# }
# Interpolation using a different method
cf_2 <- fit_curve(ts_filled, dt_cycles, fit = "no")