Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bad allocation error in certain scenarios when calculating AIC/BIC benchmarks #46

Open
jonlachmann opened this issue Jan 16, 2024 · 1 comment

Comments

@jonlachmann
Copy link
Contributor

I had an issue where I got a C++ error saying std::bad_alloc when running some specific models. A minimal reproduction example is provided below. This appears to be caused by the function VARXForecastEvals when it is called on line 907 of BigVARObjectClass.R as follows:

X <- matrix(Y[(offset + 1):nrow(Y), (k1 + 1):ncol(Y)], ncol = m)
            AICbench1 <- VARXForecastEval(matrix(ZFull$Y[, 1:k1], ncol = k1), as.matrix(X), p, s, T2, T3, "AIC", h = h, loss = loss,
                                          delta = delta)

Here, the issue is that we are dropping max(p,s) observations (offset) from X and Y, and then internally the functions run (i.e. ICX) is dropping offset observations again.

I am unsure if it is best to just lag all the data to obtain a design matrix in the start, and then avoid doing any lagging again later on. But it seems like a neat solution in my opinion.

Minimal reproduction example:

data <- matrix(rnorm(108), 36)
varx <- list(k = 1, s = 12, contemp = F)
model <- constructModel(data, 12, struct = "Basic", 4, VARX = varx, T1 = 21, T2 = 22, gran = c(50, 10))
fit <- cv.BigVAR(model)
@wbnicholson
Copy link
Owner

This has been fixed with 5ab4c25

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants