VAR model with exogenous variable doesn't work in Shiny
问题 Let's consider a VAR model with an exogenous variable to distinguish two periods. This model works perfectly as follows: library(shiny) library(vars) #--- Create Exogenous Variable 'periods' data(Canada) canTS <- Canada periods <- as.matrix(data.frame(period=ifelse(index(canTS)>1996, 1, 0 ) ) ) #--- Fit the Model fit1 <- VAR(Canada, p = 2, type = "none", exogen=periods) coef(fit1)[[1]] #-- Make Prediction period2 <- as.matrix(data.frame(period = rep(1, 12)) ) # Future Exogen Values = 1