Error when adding fourth regressor to VAR - R

52 Views Asked by At

I am building a vector autoregressive model and got stuck on some problem. My regressors are some sentiment and financial values. For testing robustness I wanted to add multiple other economic variables to the model.

The problem I encounter is: when adding a fourth regressor I only get an error message in R. I can use three from any combination, but as soon as I add a fourth one, it wont work (see error message below)...

My Code:

library(dplyr)
library(readr)
library(tidyverse)
library(urca)
library(vars)
library(tseries)
library(forecast)
library(stargazer)

tr <- ts(TR$tr, start = c(2011, 1), frequency = 4) #4 because quarterly

Index1 <- ts(Index1$Value, start = c(2011, 1), frequency = 4)
Index2 <- ts(Index2$Value, start = c(2011, 1), frequency = 4)
Control1 <- ts(CPI$Value, start = c(2011, 1), frequency = 4)
Control2 <- ts(Spread$Value, start = c(2011, 1), frequency = 4)

# for finding optimal lags

tr.bv <- cbind(TR$tr, Index1$Value, Index2$Value, CPI$Value, Spread$Value)
colnames(tr.bv) <- cbind("Total Return", "Index1", "Index2", "CPI", "Spread")

lagselect <- VARselect(tr.bv, lag.max = 10, type = "const")
lagselect$selection

# Building the model

Model <- VAR(tr.bv, p = 10, type = "const", season = NULL, exog = NULL)

summary(Model_LSTM)

The error message I get:

Error in solve.default(Sigma) : 
  Lapack routine dgesv: system is exactly singular: U[1,1] = 0

In addition: Warning message:
In cor(resids) : Standarddeviation equals zero

I did build the same model in Python using the statsmodel VAR function -> here I only get 0's as p-values or nan's...

Hopefully someone can help me?

1

There are 1 best solutions below

0
br00t On

The problem likely lies with your data and the final parameter you have added to your model (possibly multicollinearity or overfitting). A reproducible example would be helpful here.

See: https://stats.stackexchange.com/questions/446707/var-model-error-in-solve-defaultsigma-system-is-computationally-singular-r