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

aggregate_key for a linear combination #407

Open
SantiagoD999 opened this issue Jul 24, 2024 · 0 comments
Open

aggregate_key for a linear combination #407

SantiagoD999 opened this issue Jul 24, 2024 · 0 comments

Comments

@SantiagoD999
Copy link

SantiagoD999 commented Jul 24, 2024

Good morning,

I have been using the excellent fabletools package and I would like to know how to specify a linear combination in a hierarchical time series when using the aggregate_key function. In this simple reproducible example that I simulated I would like to have a TOTAL that is just 0.5FOOD+0.5CORE. Here I post the code:

library(fpp3)

FOOD<-rnorm(100)
CORE<-rnorm(100)
DATE<-yearmonth(seq.Date(from=as.Date("2001-01-01"),by="months",length.out = 100))
DF1<-as_tsibble(tibble(DATE,CORE,FOOD),index="DATE") %>%
pivot_longer(cols = c("CORE","FOOD"),names_to="COMPONENT") %>%
rename(INDEX=value)

DF1 %>%
aggregate_key(COMPONENT,INDEX=sum(INDEX))

#######

I would appreciate any comment.

Thank you very much.

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

1 participant