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