Reputation: 33
I'm trying to estimate a Markov-switching VAR in R using the command msvar. These are the first 10 entries of my two time series. I have 798. When I try to run this I get an Error message
a <- c(1.998513, 1.995302, 2.030693, 2.122130, 2.236770, 2.314639, 2.365214, 2.455784, 2.530696, 2.596537)
b <- c(0.6421369, 0.6341437, 0.6494933, 0.6760939, 0.7113511, 0.7173038, 0.7250545, 0.7812490, 0.7874657, 0.8275209)
x <- matrix (NA,10,2)
x[,1] <- a
x[,2] <- b
time.seriesx <- ts(x)
markov.switchingx <- msvar(time.seriesx, p = 2, h = 2, niterblkopt = 10)
The error message I get is the following:
Error in optim(par = c(beta0.it), fn = llf.msar, Y = Yregmat, X = Xregmat, : initial value in 'vmmin' is not finite
Anyone who could help me? Thanks
Upvotes: 0
Views: 513
Reputation: 1
I think that you have to run the log-likehood function first. I get the same error, but when i did this, it works. I'm not sure but i hope this can help you : (I used my data so don't pay attention to "M1euro")
library(base)
data <- data.matrix(M1euro, rownames.force = NA)
library(stats)
ss1<-ts(data, frequency=12, start=c(2007,1), end=c(2016,4))
class(ss1)
length(ss1)
ss <- na.approx(ss1,na.rm=F,rule=2)
ss
class(ss)
library(MSBVAR)
require(graphics)
set.seed(1)
Upvotes: 0