Learn R Programming

POT (version 1.1-11)

ts2tsd: 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")

Value

Returns a time series like object ts. In particular

ts[,"time"] and tsd[,"time"] are identical.

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

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

Mathieu Ribatet

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) = \frac{1}{d}\int_{t-d/2}^{t+d/2} f(u)du$$

See Also

Examples

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

Run the code above in your browser using DataLab