ts2tsd: Mobile Window on a Time Series

View source: R/util-ts2tsd.R

ts2tsdR Documentation

Mobile Window on a Time Series

Description

This function performs a mobile average windows on the whole time series. Thus, if the time series represents flood discharges, it returns the averaged discharges over a specific duration.

Usage

ts2tsd(ts, d, vol = FALSE, method = "linear")

Arguments

ts

The time series. It consists of two columns: one named "time" and the second "obs".

d

Numeric which corresponds of the duration for the mobile window.

vol

Logical. If FALSE -the default, average values are computed, else volumes.

method

Specifies the interpolation method to be used. Choices are "linear" or "constant".

Details

A mobile windows of length d is performed on the whole time sire. The “discrete” time series in first transformed in a function; interpolation are obtained using the approx function. Thus, if f(t) is the function representing the time series, volume over duration d is defined by:

vol(t) = \int_{t-d/2}^{t+d/2} f(u)du

while average values are:

ave(t) = 1/d \int_{t-d/2}^{t+d/2} f(u)du

Value

Returns a time series like object ts. In particular ts[,"time"] and tsd[,"time"] are identical.

Warnings

Please note that as the time series is interpolated, caution should be taken if the method to interpolate is not efficient.

Note that object d should have the same unit than ts[,"time"].

Author(s)

Mathieu Ribatet

See Also

approx

Examples

data(ardieres)
tsd <- ts2tsd(ardieres, 3 / 365)
plot(ardieres, type = "l", col = "blue")
lines(tsd, col = "green")

POT documentation built on April 14, 2022, 3:03 a.m.