Johansen’s Cointegration Test in r

Hello, everyone here. I don't know how to find the number of lags from the VARselect when applying the Johansen's conintegration test in r. Does anyone help me to solve it?


# Simulate the data
data <- runif(100)

# i. Select the number of lags in the VAR model with 'VARselect' from vars
lag_num <- VARselect(data, lag.max = 12, type = "const")

# ii. Estimate a VECM with 'VECOM' from tsDyn
vecm <- VECM(gbp, estim = "ML", lag = length(lag_num)-1)

Also, I have two more questions.

Why does the Johansen’s test rely on the maximum likelihood estimator?

Can I choose a specification for the deterministic component other than an unrestricted constant?

Thanks a lot.

1 Like

I wont pretend to fully understand what you are trying to do; but how you are seeming to use the results of VARselect seem at a glance to be problematic.
VARselect always returns two things ; selection, and criteria, so if you check its length and subtract by 1, you will always get 1. i.e. when you call your VECM function, it is not in anyway informed by VARselect in any meaningful way; (putting aside that this gbp data has not been an input to VARselect)

Thanks for your reply. I now know that I need to check the selection from VARselect to decide the number of lags. I'd have used the data in VECM. Thanks again for your help.

This topic was automatically closed 42 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.