The time series from selected levels of a hierarchical/grouped time series or a forecasted hierarchical/grouped time series are returned as a multivariate time series.

aggts(y, levels, forecasts = TRUE)

Arguments

y

An object of class {gts}.

levels

Integer(s) or string(s) giving the specified level(s).

forecasts

If y contains forecasts and historical data, then forecasts indicates whether to return the forecasts or the historical data. Otherwise it is ignored.

See also

Author

Earo Wang

Examples


aggts(htseg1, levels = c(0, 2))
#> Time Series:
#> Start = 1992 
#> End = 2001 
#> Frequency = 1 
#>         Total       AA        AB       AC       BA       BB
#> 1992 48.74808 7.862669  9.267647 10.08102 10.49276 11.04398
#> 1993 49.48047 8.340355  9.416544 10.08193 10.51712 11.12452
#> 1994 49.93238 8.549132  9.479022 10.11719 10.54013 11.24691
#> 1995 50.24070 8.597699  9.532376 10.14705 10.61220 11.35138
#> 1996 50.60846 8.770196  9.547591 10.16021 10.64932 11.48114
#> 1997 50.84851 8.837793  9.555664 10.17101 10.70736 11.57668
#> 1998 51.70922 8.893267  9.730347 10.28392 10.86323 11.93846
#> 1999 51.94330 8.933993  9.797294 10.29026 10.92463 11.99712
#> 2000 52.57796 9.133653  9.921262 10.34817 11.00622 12.16865
#> 2001 53.21496 9.152636 10.022783 10.46706 11.03531 12.53717
aggts(infantgts, levels = "State")
#> Time Series:
#> Start = 1933 
#> End = 2003 
#> Frequency = 1 
#>      State/NSW State/VIC State/QLD State/SA State/WA State/NT State/ACT
#> 1933      1740      1148       734      286      290        7         7
#> 1934      2009      1242       706      301      319        7         1
#> 1935      1763      1148       659      289      326        7         7
#> 1936      2008      1222       679      277      358        3         4
#> 1937      1932      1091       683      297      323        3         3
#> 1938      1981      1038       784      287      309        6         8
#> 1939      1970      1085       722      336      369        8         6
#> 1940      1927      1261       721      356      403        8         3
#> 1941      2264      1246       842      356      357       18         6
#> 1942      2116      1497       736      448      365        4         9
#> 1943      2072      1399       878      482      342        6         7
#> 1944      1829      1258       768      387      354        2         9
#> 1945      1889      1155       804      394      315        5         5
#> 1946      2032      1268       791      428      376        4        10
#> 1947      2069      1245       874      396      398       12        13
#> 1948      2038      1103       779      472      331       10        17
#> 1949      1878      1026       686      444      357       13        13
#> 1950      1937      1001       719      416      386       15        20
#> 1951      1895      1143       761      428      425       18        12
#> 1952      1818      1198       772      413      384       14        26
#> 1953      1846      1134       769      375      378       18        17
#> 1954      1850      1055       695      388      359        9         4
#> 1955      1850      1035       656      431      373       26        12
#> 1956      1777      1128       737      377      384       24        11
#> 1957      1804      1219       732      403      357       22        10
#> 1958      1704      1179       657      449      360       22        23
#> 1959      1832      1320       721      422      345       31        16
#> 1960      1736      1182       740      397      366       26        28
#> 1961      1800      1173       733      448      336       21        27
#> 1962      1826      1219       754      409      380       37        32
#> 1963      1673      1242       722      399      353       27        38
#> 1964      1634      1098       673      397      328       30        41
#> 1965      1492      1109       598      385      351       23        34
#> 1966      1490      1116       581      356      329       19        46
#> 1967      1452      1101       678      346      314      122        44
#> 1968      1525      1010       716      345      398      102        45
#> 1969      1625      1066       691      347      453      103        58
#> 1970      1743      1060       672      367      459      126        61
#> 1971      1710      1107       766      366      464      170        80
#> 1972      1663      1048       697      367      348      113        67
#> 1973      1491       958       666      276      394      100        63
#> 1974      1429       989       606      312      327      103        70
#> 1975      1231       806       547      222      271       58        62
#> 1976      1152       702       535      276      273       59        76
#> 1977       953       653       478      221      251      107        59
#> 1978      1004       616       444      227      230       53        62
#> 1979       878       652       380      166      247       64        52
#> 1980       847       592       394      187      239       40        39
#> 1981       809       562       425      157      193       70        45
#> 1982       823       641       432      221      204       57        49
#> 1983       805       561       426      189      177       52        43
#> 1984       705       525       368      158      230       44        52
#> 1985       840       613       418      194      209       55        36
#> 1986       751       529       355      146      212       51        36
#> 1987       715       503       375      168      195       55        40
#> 1988       760       494       339      155      212       67        44
#> 1989       708       431       370      153      194       44        36
#> 1990       714       538       356      168      214       55        40
#> 1991       619       439       340      110      182       49        36
#> 1992       674       371       370      126      171       56        32
#> 1993       538       357       333      106      143       54        23
#> 1994       535       338       294       99      137       37        26
#> 1995       483       317       297      117      128       44        26
#> 1996       486       311       310      100      155       43        28
#> 1997       427       319       285       85      126       42        22
#> 1998       363       297       305       74      118       41        27
#> 1999       485       345       273       77      116       41        32
#> 2000       432       285       297       86      105       41        20
#> 2001       449       284       282       79      122       41        12
#> 2002       397       305       277       90      102       42        14
#> 2003       398       309       230       65      100       32        25
#>      State/TAS
#> 1933       214
#> 1934       210
#> 1935       302
#> 1936       262
#> 1937       240
#> 1938       214
#> 1939       230
#> 1940       218
#> 1941       278
#> 1942       260
#> 1943       272
#> 1944       212
#> 1945       174
#> 1946       234
#> 1947       224
#> 1948       228
#> 1949       204
#> 1950       178
#> 1951       228
#> 1952       198
#> 1953       206
#> 1954       186
#> 1955       188
#> 1956       192
#> 1957       204
#> 1958       192
#> 1959       228
#> 1960       192
#> 1961       162
#> 1962       204
#> 1963       198
#> 1964       202
#> 1965       132
#> 1966       128
#> 1967       148
#> 1968       152
#> 1969       164
#> 1970       132
#> 1971       146
#> 1972       162
#> 1973       140
#> 1974       138
#> 1975       144
#> 1976        88
#> 1977       112
#> 1978        96
#> 1979       118
#> 1980       100
#> 1981       104
#> 1982        58
#> 1983        96
#> 1984       102
#> 1985       108
#> 1986        82
#> 1987        80
#> 1988        72
#> 1989        82
#> 1990        64
#> 1991        76
#> 1992        48
#> 1993        44
#> 1994        58
#> 1995        54
#> 1996        34
#> 1997        46
#> 1998        36
#> 1999        44
#> 2000        26
#> 2001        44
#> 2002        44
#> 2003        48