Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error with hts forecasting with 2 levels #69

Open
felixfesca opened this issue Apr 18, 2024 · 1 comment
Open

Error with hts forecasting with 2 levels #69

felixfesca opened this issue Apr 18, 2024 · 1 comment

Comments

@felixfesca
Copy link

I get the following error for a hierarchcial model with only two levels (i.e. top and bottom level) if I try to apply the forecast function to an hts object:
Fehler in utmat %*% fcasts : non-conformable arguments
Zusätzlich: Warnmeldung:
In cbind.Matrix(x, y, deparse.level = 0L) :
number of rows of result is not a multiple of vector length

I'm relatively sure that this code still worked about a year ago. The error does also not occur for a hierarchie with 3 or more levels.

library(hts)
my_ts <- replicate(4, arima.sim(model = list(c(ma=0.8,alpha=1,beta=0)),n=12))
my_hts <- hts(my_ts)
forecast.gts(my_hts, h = 4)
@ShanikaLW
Copy link
Contributor

It works for me. See below.

library(hts)
#> Loading required package: forecast
#> Registered S3 method overwritten by 'quantmod':
#>   method            from
#>   as.zoo.data.frame zoo
set.seed(123)
my_ts <- replicate(4, arima.sim(model = list(c(ma = 0.8)), n = 12))
my_hts <- hts(my_ts)
#> Since argument characters are not specified, the default labelling system is used.
forecast.gts(my_hts, h = 4)
#> Hierarchical Time Series 
#> 2 Levels 
#> Number of nodes at each level: 1 4 
#> Total number of series: 5 
#> Number of observations in each historical series: 12 
#> Number of forecasts per series: 4 
#> Top level series of forecasts: 
#> Time Series:
#> Start = 13 
#> End = 16 
#> Frequency = 1 
#> [1] 0.08870912 0.08870912 0.08870912 0.08870912

Created on 2024-05-31 with reprex v2.1.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants