Non-overlapping temporal aggregation of a time series according to a specific aggregation order.
Arguments
- y
Univariate or multivariate time series: a vector/matrix or a
tsobject.- agg_order
A numeric vector with the aggregation orders to consider.
- tew
A string specifying the type of temporal aggregation. Options include: "
sum" (simple summation, default), "avg" (average), "first" (first value of the period), and "last" (last value of the period).- align
A string or a vector specifying the alignment of
y. Options include: "end" (end of the series, default), "start" (start of the series), an integer (or a vector of integers) indicating the starting period of the temporally aggregated series.- rm_na
If
TRUEthe missing values are removed.
See also
Utilities:
FoReco2matrix(),
as_ctmatrix(),
as_tevector(),
balance_hierarchy(),
commat(),
csprojmat(),
cstools(),
ctprojmat(),
cttools(),
df2aggmat(),
lcmat(),
recoinfo(),
res2matrix(),
set_bounds(),
shrink_estim(),
shrink_oasd(),
teprojmat(),
tetools(),
unbalance_hierarchy()
Examples
# Monthly time series (input vector)
y <- ts(rnorm(24), start = 2020, frequency = 12)
# Quarterly time series
x1 <- aggts(y, 3)
# Monthly, quarterly and annual time series
x2 <- aggts(y, c(1, 3, 12))
# All temporally aggregated time series
x3 <- aggts(y)
# Ragged data
y2 <- ts(rnorm(11), start = c(2020, 3), frequency = 4)
# Annual time series: start in 2021
x4 <- aggts(y2, 4, align = 3)
# Semi-annual (start in 2nd semester of 2020) and annual (start in 2021)
# time series
x5 <- aggts(y2, c(2, 4), align = c(1, 3))