AnomaliesFiltersLags {greenbrown} | R Documentation |
This function computes several time-variant statisttics of a time series like seasonal anomalies, time lagged versions of time series, and filters time series based on running windows (using rollapply
.
AnomaliesFiltersLags(x, funSeasonalCycle = MeanSeasonalCycle, funFilter = median, alignFilter = c("center", "left", "right"), filters = c(3, 5, 7, 9, 11, 13), lags = -1:-7, anom = TRUE, ...)
x |
univariate time series of class |
funSeasonalCycle |
a function to estimate the seasonal cycle of the time series. |
funFilter |
a function to filter the time series based on rolling windows. |
alignFilter |
specifies whether the index of the running filter results should be left- or right-aligned or centered (default) compared to the rolling window of observations. See |
filters |
window sizes for rolling filters to be applied. If NULL, do not apply filters. |
lags |
time lags to be applied for lagged time series. If NULL, do not apply lags. |
anom |
compute seasonal anomalies? |
... |
further arguments (currently not used) |
The function returns a multivariate time series of class 'mts' with the following columns:
orig
the original time series
msc
mean seasonal cycle as computed with funSeasonalCycle
(repeated for the full time series length)
anom
anomalies releative to mean seasonal cycle
orig.filterX
rolling window result based on the original time series as computed with funFilter
for the filter window size X
anom.filterX
rolling window result based on the anomaly time series as computed with funFilter
for the filter window size X
orig.lagX
time lagged version of the original time series for the time lag X
msc.lagX
time lagged version of the mean seasonal cycle time series for the time lag X
anom.lagX
time lagged version of the anomaly time series for the time lag X
Matthias Forkel <matthias.forkel@geo.tuwien.ac.at> [aut, cre]
# load a time series of Normalized Difference Vegetation Index data(ndvi) plot(ndvi) # do calculations afl <- AnomaliesFiltersLags(ndvi) colnames(afl) summary(afl) # seasonal anomalies plot(afl[,"anom"]) # running median filters on original time series plot(afl[, grep("orig.filter", colnames(afl))], plot.type="single", col=rainbow(6)) # running median filters on anomalies plot(afl[, grep("anom.filter", colnames(afl))], plot.type="single", col=rainbow(6)) # lagged versions of original time series plot(window(afl[, grep("orig.lag", colnames(afl))], start=c(1995, 1), end=c(2000, 12)), plot.type="single", col=rainbow(7), type="l") # lagged versions of anomaly time series plot(afl[, grep("anom.lag", colnames(afl))], plot.type="single", col=rainbow(7))