fit_curve: Fit curve over cycles

View source: R/fit_curve.R

fit_curveR Documentation

Fit curve over cycles

Description

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

Usage

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(s)

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

Examples

# Load input data
data("ts_filled")
data("dt_cycles")


# 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")

ranghetti/sen2rts documentation built on March 31, 2024, 1:18 a.m.