To perform cointegration analysis using the Engle-Granger test in R, you can use the ca.jo()
function from the "urca" package. Here's an example of how to do it:
334 chars15 lines
In the above example, we create two time series ts1
and ts2
, and combine them into a data frame data
. Then, we use the ca.jo()
function to perform the Engle-Granger cointegration test on data
. The type = "eigen"
specifies that we want to use the Johansen procedure based on eigenvalues. The K = 2
sets the maximum number of cointegrating equations to 2.
Finally, the summary()
function is used to print a summary of the test results, including critical values and test statistics.
Note that you may need to install the "urca" package before running the code, as shown in the example.
gistlibby LogSnag