hts package ploting out of data range

43 views Asked by At

I want to plot a hierarchical time series with weekly frequency that starts in the first week of 2019, but when plotting the time series the x -axis goes back to almost 2016.

The hierarchical time series are created as follows:

library(hts)
abc <- matrix(sample(1:100, 32*140, replace=TRUE), ncol=32)
colnames(abc) <- c(
  paste0("A0",1:5), 
  paste0("B0",1:9),"B10",
  paste0("C0",1:8),
  paste0("D0",1:5),
  paste0("E0",1:4)
)
abc <- ts(abc, start=2019, frequency=365.25/7)
x <- hts(abc, characters = c(1,2))

and then plotted

plot(x, levels = c(0, 2))

enter image description here

x is described as

Hierarchical Time Series 
3 Levels 
Number of nodes at each level: 1 5 32 
Total number of series: 38 
Number of observations per series: 140 
Top level series: 
Time Series:
Start = 2019 
End = 2021.66392881588 
Frequency = 52.1785714285714

Note: If I only plot level 0 the x-axis starts correctly

0

There are 0 answers