gts

0th

Percentile

Create a grouped time series

Method for creating grouped time series.

Keywords
ts
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.
Details

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

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.

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

Aliases
  • gts
  • print.gts
  • summary.gts
Examples
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)
Documentation reproduced from package hts, version 4.0, License: GPL (>= 2)

Community examples

akhangat@gmail.com at May 14, 2019 hts v5.1.5

#I will create y randomly y <- ts(matrix(rnorm(900),ncol=45,nrow=20)) #Then we can construct labels for the columns of this matrix as follows blnames <- paste(c(rep("A",20),rep("B",25)), # State rep(1:9,each=5), # County rep(c("X","X","X","Y","Y"),9), # Industry rep(c("a","b","c","a","b"),9), # Sub-industry sep="") colnames(y) <- blnames #We can then easily create the grouped time series object using gy <- gts(y, characters=list(c(1,1),c(1,1)))