0

I am trying to check multiple time series on their optimal lag using VARselect(table$column,lag.max = 10,type="both") and using different values for lag.max.

My advisor told me, I should use a for loop and just store the output values to later find the best fitting value for lag.max.

This is what I tried so far:

for (i in 1:10){
  AIC_list[i]=VARselect(table$column, lag.max = i, type = c("const", "trend", "both", "none"), season = NULL, exogen = NULL) 
}

However, I get the error: Fehler in embed(y, lag) : wrong embedding dimension.

Does anybody know, how I can build the loop correctly?

Thank you very much!

Zta
  • 1

1 Answers1

0

Really difficult to help without any reproducible example!

Could you try this?

y <- as.matrix(table$column)

for (i in 1:10) {
  cat("Max Lag:", i)
  embed(y, as.integer(i + 1))
}

And see in which lag the error occurs?