Creates a list of aggregated time series from a time series of class ts.
Arguments
- y
univariate time series of class ts.
- agg_levels
user-selected list of aggregation levels.
Value
A list of ts objects each containing the aggregates time series in the order defined by agg_levels
.
Details
If agg_levels=NULL
then agg_levels
is automatically generated by taking all the factors of the time series frequency.
Examples
# Create a monthly count time series with 100 observations
y <- ts(data=stats::rpois(100,lambda = 2),frequency = 12)
# Create the aggregate time series according to agg_levels
y_agg <- temporal_aggregation(y,agg_levels = c(2,3,4,6,12))
# Show annual aggregate time series
print(y_agg$`f=1`)
#> Time Series:
#> Start = 1.333333
#> End = 8.333333
#> Frequency = 1
#> [1] 23 16 15 22 27 21 26 24