mboeck11 / BGVAR

Toolbox for the estimation of Bayesian Global Vector Autoregressions in R.
27 stars 20 forks source link

bgvar fails to get weights? #18

Closed csupremacy closed 1 year ago

csupremacy commented 1 year ago

I read data from Excel and format it in the same way and with the same data classes as pesaranData, W.8016: "xts" "zoo" and "matrix" "array" respectively.

I run the following to assure compatibility:

reprolist <- import_list("reprod/dataset_alt_debcont.xlsx")
rexolist <- import_list("reprod/exog_alt_debcont.xlsx")

repWeights <- W_debcont
mWeightsrep <- as.matrix(repWeights)
rownames(mWeightsrep) <- colnames(mWeightsrep)

reprolz <- lapply(reprolist, function(x) read.zoo(x))
repxogz <- lapply(rexolist, function(x) read.zoo(x))

dataxtsrep <- lapply(reprolz, function(x) as.xts(x))
exogxtsrep <- lapply(repxogz, function(x) as.xts(x))

reprovar <- bgvar(Data = dataxtsrep, W = mWeightsrep, Ex = exogxtsrep)

where W_debcont is read via RStudio "Import Dataset" function.

However, on launch of the bgvar object I get an error: Error in dimnames(x) <- dn : length of 'dimnames' [1] not equal to array extent

The traceback() message is:

3: `rownames<-`(`*tmp*`, value = colnames(endonr))
2: .getweights(Data = Data, W = W, OE.weights = OE.weights, Wex.restr = Wex.restr, 
       variable.list = variable.list)
1: bgvar(Data = dataxtsrep, W = mWeightsrep, Ex = exogxtsrep)

Attached below is the truncated dataset that reproduces the error. Is there any way to solve this? W_debcont.xlsx dataset_alt_debcont.xlsx exog_alt_debcont.xlsx