GTS object plotting - label inconsistencies.
shea-parkes opened this issue · 4 comments
Here is a slightly altered example from the help docs:
bnames1 <- c("VICMelb", "VICGeel",
"NSWSynd", "NSWWoll")
bts1 <- matrix(ts(rnorm(160)), ncol = 4)
colnames(bts1) <- bnames1
x1 <- gts(bts1, characters = c(3, 4))
x1$groups
plot(x1)
From there, we can see in the graph that the third level isn't titled Bottom
, and the series there all begin with G1/...
instead of Bottom/...
or G1/VIC/...
and G1/NSW/...
. I don't imagine that was what was intended (but I could be wrong).
Additionally, it doesn't appear I can rename the Bottom
level; the gnames
argument to gts()
in this case only accepts a character vector of length 1 and applies that to the middle level. Is this intended?
> sessionInfo()
R version 3.1.1 (2014-07-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] hts_4.4 forecast_5.6 timeDate_3010.98 zoo_1.7-11
loaded via a namespace (and not attached):
[1] colorspace_1.2-4 fracdiff_1.4-2 grid_3.1.1 lattice_0.20-29 nnet_7.3-8 parallel_3.1.1 quadprog_1.5-5
[8] Rcpp_0.11.2 SparseM_1.05 tools_3.1.1 tseries_0.10-32
Hi there,
The labels you provided doesn't fit into a gts
object; instead it's a hts
object.
So please try to use this
bnames1 <- c("VICMelb", "VICGeel", "NSWSynd", "NSWWoll")
bts1 <- matrix(ts(rnorm(160)), ncol = 4)
colnames(bts1) <- bnames1
x1 <- hts(bts1, characters = c(3, 4))
plot(x1)
I was trying for a minimal-reproducible example. Given that a gts
object can have multiple hierarchies, I reasoned that it would be able to have a single hierarchy. Was I incorrect?
I came upon this because I writing code to build up to a multiple-hierarchy problem, so I started with a single hierarchy in gts
and hit some friction in places such as the plotting example above.
Upon reflection, I see why gnames
would take only a character vector of length 1 in the example above (there is only one group), but I still feel the plot labeling is not behaving as I would have anticipated. Is the bottom graph not meant to be the "Bottom" time-series? What happens if G1
shared node names in the second level of its hierarchy?
I've added some patches to the package and the new code will work for your example now
bnames1 <- c("VICMelb", "VICGeel",
"NSWSynd", "NSWWoll")
bts1 <- matrix(ts(rnorm(160)), ncol = 4)
colnames(bts1) <- bnames1
x1 <- gts(bts1)
x1$groups
plot(x1)
Thanks