Issue with JohansenTest

Home 2015 Forums Numerical Method Bug Reports Issue with JohansenTest

This topic contains 10 replies, has 4 voices, and was last updated by avatar Kevin 3 years ago.

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #2777
    avatar
    Kevin
    Participant

    I have encountered a problem using the CointegrationMLE with the JohansenTest. I have several time series that get a high t-statistic, but a low significances value via the .r method.

    I have attached a .txt file with code to reproduce the error with one time series.

    I call it an error, because when I run the same data in Matlab with johansen(y,0,2), y being the data (toolbox spartial econometrics). The results are different, a high Eigen statistic is very significant.

    Below is the matlab output.

    Johansen MLE estimates
    NULL: Trace Statistic Crit 90% Crit 95% Crit 99%
    r <= 0 variable 1 16.561 13.429 15.494 19.935
    r <= 1 variable 2 7.098 2.705 3.841 6.635

    NULL: Eigen Statistic Crit 90% Crit 95% Crit 99%
    r <= 0 variable 1 9.462 12.297 14.264 18.520
    r <= 1 variable 2 7.098 2.705 3.841 6.635

    I would also appreciate it if it was possible to simply get the boundary significance level straight from a method. Instead of only being able to test whether a certain it is significant at a certain level.

    I hope you can help me out.

    Kind regards,
    Kevin Wong

    • This topic was modified 3 years, 1 month ago by avatar Kevin.
    #2779
    avatar
    Kevin
    Participant

    I cannot upload .txt .zip or .java files. How do I upload a file?

    I am prevented by:
    Upload Errors:

    JohansenTest.zip: Sorry, this file type is not permitted for security reasons.

    • This reply was modified 3 years, 1 month ago by avatar Kevin.
    • This reply was modified 3 years, 1 month ago by avatar Kevin.
    #2782
    avatar
    hao.ding
    Participant

    Hi Kevin,

    I think I have your data (if it is the same as in your previous email.)
    Due to the differences in algorithms, results computed by SuanShu are not exactly the same with those in MATLAB. However, SuanShu and R can return the same results (Johansen statistics). The R code is attached in case you want to check it.

    Usually the critical values of Johansen test are taken from the critical value table, you can take a look at the table by typing “co.ja” in R. And the details of the program will show in the screen. Inside the program you can find the critical value table (search for key word cv.none, cv.const, and cv.trend). Currently this table in SuanShu is not public. You can refer to the table in R, the values are very similar.

    R code for Johensen Test:

    data1<-c(1.06590909090909, 1.04393939393939, 0.991666666666666, 0.989393939393939, 0.988636363636363, 0.946969696969696, 0.931818181818181, 0.893939393939394, 0.872727272727272, 0.926515151515151, 0.825757575757575,
    0.821969696969696, 0.825757575757575, 0.834090909090909, 0.899242424242424, 0.852272727272727, 0.916666666666666, 0.916666666666666, 0.949242424242424, 0.931818181818182, 0.909090909090909, 0.988636363636364, 0.98030303030303,
    1.02424242424242, 0.963636363636364, 1.05075757575757, 1.04166666666666, 1.10454545454545, 1.13863636363636, 1.14166666666666, 1.13333333333333, 1.07651515151515, 1.06439393939394, 1.02575757575757, 1.04545454545454,
    1.01515151515151, 1.0590909090909, 1.04545454545454, 1.03030303030303, 1.25757575757575, 1.28863636363636, 1.38181818181818, 1.38257575757575, 1.47954545454545, 1.42121212121212, 1.48333333333333, 1.47045454545454, 1.46212121212121,
    1.36818181818181, 1.29621212121212, 1.2840909090909, 1.27196969696969, 1.24242424242424, 1.3, 1.31212121212121, 1.30151515151515, 1.3030303030303, 1.33484848484848, 1.31818181818181, 1.27651515151515, 1.26969696969696,
    1.36363636363636, 1.40454545454545, 1.3810606060606, 1.38636363636363, 1.37878787878787, 1.36439393939393, 1.36060606060606, 1.45, 1.44318181818181, 1.51212121212121, 1.49848484848484, 1.42575757575757, 1.48257575757575,
    1.50757575757575, 1.48636363636363, 1.50833333333333, 1.43030303030302, 1.41515151515151, 1.36742424242424, 1.34015151515151, 1.31969696969696, 1.31590909090909, 1.26515151515151, 1.22954545454545, 1.27272727272727, 1.29090909090909,
    1.22272727272727, 1.24848484848484, 1.24924242424242, 1.23484848484848, 1.23636363636363, 0.928787878787878, 0.867424242424241, 0.888636363636363, 0.912878787878787, 0.941666666666666, 0.943181818181817, 0.94621212121212,
    0.962121212121211, 0.949242424242423, 0.954545454545453, 1.01893939393939, 0.984090909090908, 0.998484848484847, 0.969696969696969, 0.992424242424241, 0.999999999999999, 0.986363636363635, 0.973484848484847, 0.987121212121211,
    0.989393939393938, 1.01439393939393, 0.979545454545453, 0.951515151515151, 0.940151515151514, 0.987121212121211, 1.01439393939393, 1.06515151515151, 1.12121212121212, 1.11060606060606, 1.12348484848484, 1.12121212121212,
    1.08030303030302, 1.07575757575757, 1.06363636363636, 1.07121212121212, 1.05454545454545, 0.99621212121212, 1.02272727272727, 1.08787878787878, 1.09090909090908, 1.08787878787878, 1.08181818181818, 1.08484848484848, 1.04015151515151,
    1.06666666666666, 1.05984848484848, 1.06818181818181, 1.07424242424242, 1.1060606060606, 1.13181818181818, 1.15757575757575, 1.17575757575757, 1.22954545454545, 1.20454545454545, 1.18333333333333, 1.21287878787878, 1.22045454545454,
    1.21363636363636, 1.22651515151515, 1.2310606060606, 1.21212121212121, 1.21742424242424, 1.21136363636363, 1.21363636363636, 1.23712121212121, 1.23484848484848, 1.23030303030302, 1.2340909090909, 1.26590909090909, 1.25075757575757,
    1.17499999999999, 1.21515151515151, 1.20075757575757, 1.22424242424242, 1.23181818181818, 1.29924242424242, 1.33712121212121, 1.33636363636363, 1.37348484848484, 1.41893939393939, 1.44318181818181, 1.50833333333333, 1.48863636363636,
    1.46287878787878, 1.42348484848484, 1.42424242424242, 1.4310606060606, 1.42727272727272, 1.43333333333333, 1.45757575757575, 1.45757575757575, 1.48181818181818, 1.4590909090909, 1.44393939393939, 1.4310606060606, 1.42045454545454,
    1.43333333333333, 1.46590909090908, 1.4810606060606, 1.4810606060606, 1.50833333333333, 1.53787878787878, 1.51439393939393, 1.61287878787878, 1.64242424242424, 1.64924242424242, 1.59545454545454, 1.64393939393939)
    data2<-c(1.07440925087983, 1.05580693815987, 1.04374057315233, 0.990447461035696, 1.06334841628959, 1.07591754650578, 1.04524886877828, 0.970839617898441, 0.938662644544997, 0.933634992458521, 0.919557566616389,
    1.00703871292106, 1.07893413775766, 1.1236802413273, 1.25439919557566, 1.18049270990447, 1.28004022121669, 1.29462041226747, 1.37154348919054, 1.24685771744595, 1.32830568124685, 1.28154851684263, 1.35545500251382, 1.33232780291603,
    1.2875816993464, 1.40774258421317, 1.34741075917546, 1.39215686274509, 1.54399195575666, 1.4630467571644, 1.45801910507792, 1.35243841126194, 1.35344394167923, 1.28104575163398, 1.36752136752136, 1.35444947209653, 1.48114630467571,
    1.45500251382604, 1.42785319255907, 1.40774258421317, 1.49874308697838, 1.55806938159879, 1.49321266968325, 1.57214680744092, 1.46857717445952, 1.56862745098039, 1.54298642533936, 1.55052790346907, 1.48667672197083, 1.38964303670185,
    1.35847159376571, 1.37707390648567, 1.29411764705882, 1.37154348919054, 1.37104072398189, 1.3700351935646, 1.32277526395173, 1.35595776772247, 1.35294117647058, 1.26948215183509, 1.25439919557566, 1.27953745600804, 1.29864253393665,
    1.27501256913021, 1.25641025641025, 1.24183006535947, 1.19658119658119, 1.20010055304172, 1.30216189039718, 1.3076923076923, 1.38813474107591, 1.39467068878833, 1.35796882855706, 1.42533936651583, 1.45500251382604, 1.39265962795374,
    1.40824534942181, 1.38009049773755, 1.33735545500251, 1.2559074912016, 1.236802413273, 1.23780794369029, 1.28858722976369, 1.25842131724484, 1.23730517848164, 1.25892408245349, 1.2664655605832, 1.1850175967823, 1.20311714429361,
    1.19356460532931, 1.19356460532931, 1.18099547511312, 1.15837104072398, 1.15937657114127, 1.17948717948717, 1.20663650075414, 1.20663650075414, 1.20060331825037, 1.35243841126193, 1.39567621920563, 1.37254901960784, 1.40271493212669,
    1.420814479638, 1.4007038712921, 1.40623428858722, 1.37053795877325, 1.42483660130718, 1.46606334841628, 1.40271493212669, 1.37405731523378, 1.39969834087481, 1.3700351935646, 1.35746606334841, 1.30970336852689, 1.31372549019607,
    1.34539969834087, 1.46354952237305, 1.44595274007038, 1.52639517345399, 1.55203619909502, 1.54248366013071, 1.51935646053293, 1.53996983408748, 1.45600804424333, 1.50075414781297, 1.4927099044746, 1.47812971342382, 1.4524886877828,
    1.38260432378079, 1.39517345399698, 1.48717948717948, 1.49069884364001, 1.46706887883358, 1.50125691302161, 1.37606837606837, 1.37657114127702, 1.38612368024132, 1.35344394167923, 1.40472599296128, 1.42332830568124, 1.52136752136752,
    1.57466063348416, 1.58371040723981, 1.64555052790346, 1.67420814479637, 1.6586224233283, 1.57466063348416, 1.64705882352941, 1.70035193564605, 1.66515837104072, 1.66716943187531, 1.67169431875314, 1.69733534439416, 1.71845148315736,
    1.68828557063851, 1.65510306686777, 1.72197083961789, 1.77023629964806, 1.73956762192056, 1.7094017094017, 1.771744595274, 1.75615887380593, 1.67320261437908, 1.69079939668174, 1.72197083961789, 1.75565610859728, 1.75465057817998,
    1.84514831573655, 1.86274509803921, 1.9270990447461, 1.93815987933634, 1.87933634992458, 1.90296631473101, 1.98592257415786, 1.95123177476118, 1.93715434891905, 1.84514831573654, 1.8743086978381, 1.83207642031171, 1.77476118652589,
    1.7315233785822, 1.75967823026646, 1.70437405731523, 1.76822523881347, 1.76822523881347, 1.70889894419306, 1.66163901458018, 1.64655605832076, 1.66113624937154, 1.73755656108597, 1.71191553544494, 1.7506284565108, 1.77224736048265,
    1.80090497737556, 1.80995475113122, 1.84565108094519, 1.87481146304675, 1.88235294117646, 1.8225238813474, 1.84514831573654)

    library(urca)
    reEigen<-ca.jo(data.frame(data1, data2), type=”eigen”, ecdet=”none”,K=2)
    reTrace<-ca.jo(data.frame(data1, data2), type=”trace”, ecdet=”none”,K=2)
    summary(reEigen)
    summary(reTrace)

    • This reply was modified 3 years, 1 month ago by avatar hao.ding.
    • This reply was modified 3 years, 1 month ago by avatar hao.ding.
    • This reply was modified 3 years, 1 month ago by avatar hao.ding.
    • This reply was modified 3 years, 1 month ago by avatar hao.ding.
    • This reply was modified 3 years, 1 month ago by avatar hao.ding.
    #2788
    avatar
    Kevin
    Participant

    It is not the same data. My problem is not that when I run the data in R, I get 4.77 t-stat for rank >1 and only 4.52 in SuanShu. The problem is that when I get the P-value in SuanShu for a t-stat of 4.52 I expect it to be around 0.3 instead I get 0.77. I expect around 0.3, because I have several time series of similar type giving t-stats near and above and below 4.52 all yielding around 0.3 in p-value. Yet, this time series gives 0.77.

    I am not sure how to see what the actual p-value is in R, as they only display the table of 10%, 5%, 1%. The is below 10% though.

    I have pasted the data below

    As well as the java file.

    • This reply was modified 3 years, 1 month ago by avatar Kevin.
    • This reply was modified 3 years, 1 month ago by avatar webmaster.
    #2790
    avatar
    Haksun Li
    Moderator

    I would like to point out that SuanShu and R give different results for the p-values and statistics. R is not accurate. As you note, R has only a few critical points, e.g., 10%, 5%, 1%, and does a linear interpolation for the other values.

    On the other hand, SuanShu computes the asymptotic distribution for Johansen tests using the exact distribution functions. More details can be found in these two references: MacKinnon et al (1999) and Pesaran et al (2000).

    #2799
    avatar
    webmaster
    Keymaster

    You may now upload attachments.

    #2804
    avatar
    hao.ding
    Participant

    Hi Kevin,

    I tested your data in both SuanShu and R, the statistics are:
    R:
    test 10pct 5pct 1pct
    r <= 1 | 4.52 6.50 8.18 11.65
    r = 0 | 5.37 12.91 14.90 19.19

    SuanShu:
    eigen stats = [5.369706, 4.521464]

    The results are same up to 2 digits. Therefore I think the computation results for statistics are correct.

    (R commands:
    library(urca)
    reEigen<-ca.jo(data.frame(data1, data2), type=”eigen”, ecdet=”none”,K=2)
    summary(reEigen)
    )

    I do not understand the part on t test. Do you mean p(x<=4.52) should be 0.3 but SuanShu returns 0.77? If so may I take a look at the codes? Thanks.

    #2807
    avatar
    Kevin
    Participant

    I will clarify as soon as possible with code and example, right now I am quite tied up with a deadline. Promise to get back to you.

    #2914
    avatar
    Kevin
    Participant

    Yes, I had the wrong settings in R. Sorry.

    The issue with the sometimes odd translation between T-Statistic and probability is presented in the code attached.

    From what I understand, as the T-statistic decreases in value the probability (significance level) should fall, vice versa and with no exceptions.

    • This reply was modified 3 years ago by avatar Kevin.
    Attachments:
    You must be logged in to view attached files.
    #2922
    avatar
    hao.ding
    Participant

    Hi kevin,

    The method “r” in JohansenTest returns the number of stationary vectors, which are linear combination of input time series.

    For example, if we are testing m time series, the value of r could be 0,1,…,m.
    r=0: The m time series are not cointegrated.
    1<=r<m: The m time series are cointegrated, there are r independent linear combinations of the m time series that are stationary.
    r=m: There are m independent linear combinations of the original m times series. This means that the original m time series are already stationary. So there is no cointegration.

    In your codes, you are test the case “johansenTest.r(coint, level) > 1” when the number of time series is 2.
    Therefore the test is equivalent to “johansenTest.r(coint, level) == 2”, because the largest value r could get is 2.

    In SuanShu, the procedure to compute r is:
    step 1: compute the statistics when r=0 and r=1.
    step 2: compute the asymptotic Johansen distribution when r=0 and r=1.
    step 3: based on the input significant level, compute the quantile of the distribution when r=0 and r=1.
    step 4: compare the statistic of r=0 with quantile from distribution of r=0.
    – If the statistics is larger than quantile, then null hypothesis r=0 is rejected. And we move on to consider the case r=1.
    – Else we output r=0.

    -If we are considering r=1 and we can reject the null hypothesis r=1, then r=2.
    -Else we output r=1.

    So to answer your question, the results from SuanShu are consistent. To get r=2, we need to compare two statistics, one is the statistics when r=0, and the other is the statistics when r=1. The vector you get from “johansenTest.getStats(coint)” are two statistics. The first value in the vector is the statistics when r=0. And the second value in the vector is for r=1.
    For example, consider data set A, the statistics is 23.02 and 10.38.
    when r=0, we will compare 23.02 with the quantile from Johansen distribution for r=0.
    If r=0 could be rejected, then we will compare 10.38 with the quantile from the Johansen distribution for r=1. If r=1 could be rejected, we conclude that r=2.

    Hope this helps.

    #2928
    avatar
    Kevin
    Participant

    I see it now! I don’t know why I was thinking the way I was. I was looking at rank == 2 when I should have been looking for rank > 0. It all makes perfect sense now. I greatly appreciate your help. Thank you!

Viewing 11 posts - 1 through 11 (of 11 total)

You must be logged in to reply to this topic.