Skip to content

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

@jonlachmann

Description

@jonlachmann

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions