Skip to content

Matrix of weights #84

@brunocarlin

Description

@brunocarlin

My suggestion is to create an matrix with all possible combinations of like

Then a function can create an matrix with all possible combinations e.g:

aut<- auto.arima() = 0.1 
ets <- ets() = 0,4

aut||---||---
---||ets||---
---||---||the
aut||ets||---
aut||---||aut
---||ets||aut
aut||ets||the
Then divide each line by sum of members

Maybe this demo demonstrates it better example from https://robjhyndman.com/hyndsight/benchmark-combination/

  h<- 12
  y<- USAccDeaths
  fcasts <- rbind(
    N = snaive(y, h)$mean,
    E = forecast(ets(USAccDeaths), h)$mean,
    A = forecast(auto.arima(y), h)$mean,
    T = thetaf(y, h)$mean)
  colnames(fcasts) <- seq(h)
  method_names <- rownames(fcasts)
  # Compute all possible combinations
  method_choice <- rep(list(0:1), length(method_names))
  names(method_choice) <- method_names
  combinations <- expand.grid(method_choice) %>% tail(-1) %>% as.matrix() #Here 
  # Construct names for all combinations
  for (i in seq(NROW(combinations))) {
    rownames(combinations)[i] <- paste0(method_names[which(combinations[i, ] > 0)], 
                                        collapse = "")
  }
  # Compute combination weights
  combinations <- sweep(combinations, 1, rowSums(combinations), FUN = "/")

The only thing holding me back is my inexperience with programming, but I would replace the 1s the #Here,we also we have an unique opportunity to leverage our knowledge of the weights generated in the cross validation process and semi-automate a good choice for all series for example if weight x < y , 1 in combinations = 0.

This matrix could be used to create accuracy() function to see which is the overall better combination, an extension would be to add the matrix for weights = "equal" and weights = "insample.errors"

Maybe add a similar matrix for all Horizons so we could implement #17.

Sorry if it was confusing, and for the bad english.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions