Akakios Xag
Akakios Xag

Reputation: 1

Forecasting of a dynamac's package object

I have an ARDL model with co-integration so I used the "dynamac" package in R. I need to forecast for some horizons (different at each time). When I apply the forecast function from the package "forecast" an error occurs due to the fact that the "new data" were not imported.

ARDL_Model <- dynamac::dynardl(Y ~ X1 + X2 + X3 + X4 , data = My_Data,
                                   diffs = c("X1","X2", "X3","X4"),
                                   lagdiffs = list("X1" = c(1:5),"X2" = 1, "X3" = c(1:2), "X4" = c(1:2)), ec = TRUE, simulate = TRUE,shockvar = "X2", graph= TRUE)

forecast(All_ARDL_Model$model,h=1)#Horizon 1

R output - (forecast command): Error in as.data.frame(newdata) : argument "newdata" is missing, with no default

Upvotes: 0

Views: 603

Answers (1)

sorenjordan
sorenjordan

Reputation: 11

Perhaps I misunderstand your question, but your code already includes the relevant forecasting.

ARDL_Model <- dynamac::dynardl(Y ~ X1 + X2 + X3 + X4 , data = My_Data,
diffs = c("X1","X2", "X3","X4"),
lagdiffs = list("X1" = c(1:5), "X2" = 1, "X3" = c(1:2), "X4" = c(1:2)), 
ec = TRUE, simulate = TRUE, shockvar = "X2", graph= TRUE)

Will create a set of simulated results in ARDL_Model$simulate. ARDL_Model$simulate$central is the response of the dependent variable. At shocktime (since it isn't specified here will default to t = 10), X2 will be shocked by a standard deviation of its value (since shockval isn't specified). The other variables will be held at their means. So you will be able to forecast the response of the dependent variable, but will need to run a separate simulation (i.e. for each shockvar and shockval you'd like to forecast a response).

The vignette at https://cran.r-project.org/web/packages/dynamac/vignettes/dynamac-vignette.html might also be useful.

Upvotes: 1

Related Questions