# Test for Cointegration Using the Engle-Granger Test

This example shows how to test the null hypothesis that there are no cointegrating relationships among the response series composing a multivariate model.

Load Data_Canada into the MATLAB® Workspace. The data set contains the term structure of Canadian interest rates . Extract the short-term, medium-term, and long-term interest rate series.

load Data_Canada Y = Data(:,3:end); % Multivariate response series

Plot the response series.

figure plot(dates,Y,'LineWidth',2) xlabel 'Year'; ylabel 'Percent'; names = series(3:end); legend(names,'location','NW') title '{\bf Canadian Interest Rates, 1954-1994}'; axis tight grid on The plot shows evidence of cointegration among the three series, which move together with a mean-reverting spread.

To test for cointegration, compute both the $\tau$ (t1) and $z$ (t2) Dickey-Fuller statistics. egcitest compares the test statistics to tabulated values of the Engle-Granger critical values.

[h,pValue,stat,cValue] = egcitest(Y,'test',{'t1','t2'})
h = 1x2 logical array 0 1 
pValue = 1×2 0.0526 0.0202 
stat = 1×2 -3.9321 -25.4538 
cValue = 1×2 -3.9563 -22.1153 

The $\tau$ test fails to reject the null of no cointegration, but just barely, with a p-value only slightly above the default 5% significance level, and a statistic only slightly above the left-tail critical value. The $z$ test does reject the null of no cointegration.

The test regresses Y(:,1) on Y(:,2:end) and (by default) an intercept c0. The residual series is

[Y(:,1) Y(:,2:end)]*beta - c0 = Y(:,1) - Y(:,2:end)*b - c0.

The fifth output argument of egcitest contains, among other regression statistics, the regression coefficients c0 and b.

Examine the regression coefficients to examine the hypothesized cointegrating vector beta = [1; -b].

[~,~,~,~,reg] = egcitest(Y,'test','t2'); c0 = reg.coeff(1); b = reg.coeff(2:3); beta = [1;-b]; h = gca; COrd = h.ColorOrder; h.NextPlot = 'ReplaceChildren'; h.ColorOrder = circshift(COrd,3); plot(dates,Y*beta-c0,'LineWidth',2); title '{\bf Cointegrating Relation}'; axis tight; legend off; grid on; The combination appears relatively stationary, as the test confirms.
{"ft_lang_label":"__label__en","ft_lang_prob":0.7299362,"math_prob":0.98756903,"size":2103,"snap":"2021-43-2021-49","text_gpt3_token_len":597,"char_repetition_ratio":0.10624107,"word_repetition_ratio":0.006779661,"special_character_ratio":0.29196388,"punctuation_ratio":0.22171946,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9958506,"pos_list":[0,1,2,3,4,5,6],"im_url_duplicate_count":[null,1,null,1,null,1,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-11-29T18:22:05Z\",\"WARC-Record-ID\":\"<urn:uuid:3929d733-451e-4426-a440-1121de6b2c16>\",\"Content-Length\":\"77845\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:61b82813-8a59-4cdf-abf8-4dccf70eec8e>\",\"WARC-Concurrent-To\":\"<urn:uuid:d9bce3e6-352d-423d-ad02-4e3beb303322>\",\"WARC-IP-Address\":\"184.25.188.167\",\"WARC-Target-URI\":\"https://nl.mathworks.com/help/econ/test-for-cointegration-using-the-engle-granger-test.html\",\"WARC-Payload-Digest\":\"sha1:PNCM73XZKICR2CCXRG4EY5LO2EILJFNM\",\"WARC-Block-Digest\":\"sha1:YCTBGN7QEKP7QRLSHD6N56KWNWI2CJYA\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-49/CC-MAIN-2021-49_segments_1637964358786.67_warc_CC-MAIN-20211129164711-20211129194711-00029.warc.gz\"}"}