hts (version 4.0)

gts: Create a grouped time series

Description

Method for creating grouped time series.

Usage

gts(y, groups, gnames = rownames(groups))

Arguments

y
A matrix or multivariate time series contains the bottom level series.
groups
Group matrix indicates the group structure, with one column for each series when completely disaggregated, and one row for each grouping of the time series. It allows either a numerical matrix or a matrix consisting of strings.
gnames
Specify the group names.

Value

  • btsMultivariate time series contains the bottom level series
  • groupsInformation about the groups of a grouped time series
  • labelsInformation about the labels that are used for plotting.

Details

If the argument groups is a matrix consisting of strings, these characters can be used for labelling.

References

R. J. Hyndman, R. A. Ahmed, G. Athanasopoulos and H.L. Shang (2011) Optimal combination forecasts for hierarchical time series. Computational Statistics and Data Analysis, 55(9), 2579--2589. http://robjhyndman.com/papers/hierarchical/

See Also

accuracy.gts, forecast.gts, plot.gts

Examples

Run this code
abc <- ts(5 + matrix(sort(rnorm(1600)), ncol = 16, nrow = 100))
sex <- rep(c("female", "male"), each = 8)
state <- rep(c("NSW", "VIC", "QLD", "SA", "WA", "NT", "ACT", "TAS"), 2)
gc <- rbind(sex, state)  # a matrix consists of strings.
gn <- rbind(rep(1:2, each = 8), rep(1:8, 2))  # a numerical matrix
rownames(gc) <- c("Sex", "State")
x <- gts(abc, gc)
y <- gts(abc, gn)

Run the code above in your browser using DataLab