Skip to content

aggregate_key for a linear combination #407

Open
@SantiagoD999

Description

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.

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions