compute_derivative: Compute numeric derivatives of a time series.

View source: R/compute_derivative.R

compute_derivativeR Documentation

Compute numeric derivatives of a time series.

Description

Estimates the derivative of a time series using numeric methods.

Usage

compute_derivative(x, dt, r = min(dim(as.matrix(x))),
                          devMethod = c("FOCD", "GLLA", "FINITE"),
                          gllaEmbed = NA, gllaTau = NA, gllaOrder = NA)

Arguments

x

A vector or matrix of measurements over time.

dt

Numeric; the change in time between successive measurements.

r

An integer; the number of time series in x used to calculate dXdt.

devMethod

A character string. One of either "FOCD" for fourth order central difference, "GLLA" for generalized local linear approximation, or "FINITE" for simple finite difference.

gllaEmbed

An integer; t embedding dimension used for devMethod = "GLLA".

gllaTau

An integer; the time delay used for devMethod = "GLLA".

gllaOrder

An integer; the embedding dimension used for devMethod = "GLLA".

Value

  • If devMethod = "FOCD" - returns a vector or matrix of first order derivatives the first r columns of x with respect to time.

  • If devMethod = "GLLA" - returns a matrix or list of matrices of derivatives of the first r columns of x with respect to time. Derivatives returned by devMethod = "GLLA" are up to order "gllaOrder" and include the "0^{th}" derivative.

  • If devMethod = "FINITE" - returns a vector or matrix of first order derivatives the first r columns of x with respect to time.

References

Boker, S. M., Deboeck, P. R., Edler, C., & Keel, P. K. (2010). Generalized local linear approximation of derivatives from time series. In Chow S, Ferrer E, and Hsieh F, editors, Statistical methods for modeling human dynamics: An interdisciplinary dialogue.

Examples

data(ECG_measurements)

xdat <- ECG_measurements[,"channel1"]
dt <- ECG_measurements[2,"time"] - ECG_measurements[1,"time"]

compute_derivative(x = xdat, dt = dt, devMethod = "FOCD")

## Not run: 
compute_derivative(x = xdat, dt = dt, devMethod = "GLLA", gllaEmbed = 5, gllaTau = 1, gllaOrder = 1)

## End(Not run)

RobertGM111/havok documentation built on July 8, 2023, 8:23 p.m.