ts2tsd | R Documentation |
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.
ts2tsd(ts, d, vol = FALSE, method = "linear")
ts |
The time series. It consists of two columns: one named
|
d |
Numeric which corresponds of the duration for the mobile window. |
vol |
Logical. If |
method |
Specifies the interpolation method to be used. Choices
are |
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
Returns a time series like object ts
. In particular
ts[,"time"]
and tsd[,"time"]
are identical.
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"]
.
Mathieu Ribatet
approx
data(ardieres)
tsd <- ts2tsd(ardieres, 3 / 365)
plot(ardieres, type = "l", col = "blue")
lines(tsd, col = "green")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.