mboeck11 / BGVAR

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

fix valgrind error #5

Closed hdarjus closed 3 years ago

hdarjus commented 3 years ago

Mistake was in https://github.com/mboeck11/BGVAR/commit/43a8b0368456f55a1cb8562c7dfffd797abe563e in src/BVAR_linear.cpp about the changes in variable Sv_para and pars_store and in particular in line 451. Sv_para has 4 rows but receives an arma vector of length 3. Therefore its 4th element is uninitialized in all columns.

With this change, the example that failed on CRAN passes valgrind checks on my computer. The test is

library(BGVAR)
set.seed(1)
data(eerDatasmall)
model.eer<-bgvar(Data=eerDatasmall,W=W.trade0012.small,draws=50,burnin=50,plag=1,eigen=TRUE)

and the command for running R was

R --debugger=valgrind --debugger-args='--track-origins=yes --leak-check=full --show-reachable=yes' --no-save --no-restore

after building and installing BGVAR with debug flags.