How to manually conduct a historical decomposition of shocks on a vars object

Hi, I'm hoping to get some help on how to manually tweak up some source code to apply to an SVAR Model using the vars dataset. Here is a snippet of the dataset I'm using

data <- structure(c(1.54054238132604, 5.22775636647117, 1.75154671443607, 
-4.00396437623925, -4.99849595390862, -3.58991362838901, -2.08646214793927, 
4.38408682550573, -1.32609419137286, -10.0477865139619, -10.5789067079456, 
3.53586648125426, 3.80285045230506, 4.54214390385599, 5.25998848716807, 
4.53265591355598, 4.18968593558051, 3.53167443997122, 2.68286514861102, 
2.28625948262682, 1.9539414753903, 2.30401026783675), .Dim = c(11L, 
2L), .Dimnames = list(NULL, c("GDP", "CPI")), index = structure(c(1514764800, 
1522540800, 1530403200, 1538352000, 1546300800, 1554076800, 1561939200, 
1569888000, 1577836800, 1585699200, 1593561600), tzone = "UTC", tclass = "Date"), class = c("xts", 

and the code for the model


var.model <- vars::VAR(data, p=1, type = 'cons')
svar.model <- vars::BQ(var.model)

I'm now looking to do a historical decomposition of the cumulative effects from shocks on each variable in my model. I've found a solution on stackoverflow (see here) which can be run on a varest object, however it gives the following error when run on an svarest object

historical_decomposition <- VARhd(Estimation=svar.model)

Error in (lags + 1):nrow(DATA) : argument of length 0

Any ideas on how to solve this issue? TIA

The VARhd() functions expect a class varest and not svarest which is the class of star.model.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.

Hi @Lesaffrea , the varest and svarest classes are from the same package. So I'm wondering if there might be a way to tweak this code to work on a svarest object?