Issue with getting IRF from VAR model with categorical exogen variables

59 Views Asked by At

I am trying run a Vector Autoregression (VAR) model in R. Specifically I have two continous time series that are endogenous, and one exogenous time series as well as a exogenous factor variable. I want to run these models and understand the effect of my endogenous variables on each other when controlling for the exogenous variables, using the IRF function. However, while this works when I have an exogenous time series variable, it does not work when I try to control with a factor variable. Why is this?

data(iris)

#this works:

endogen <- iris[,c(1,2)]
exogen <- iris[,3]

exogen <- as.matrix(model.matrix(~Petal.Length+Species,data=iris))

model <- VAR(y=endogen,
             p=3,
             exogen=exogen)
irf_res <- irf(model,n.ahead=5,cumulative=T)

#this does not work
endogen <- iris[,c(1,2)]

exogen <- as.matrix(model.matrix(~Petal.Length+Species,data=iris))

model <- VAR(y=endogen,
             p=3,
             exogen=exogen)
irf_res <- irf(model,n.ahead=5,cumulative=T)
0

There are 0 best solutions below