Page 1 of 1

Accessing KPSS critical values in a loop

Posted: Wed Jun 26, 2019 6:13 am
by heer0
EDIT: As a workaround, I have defined a vector with asymptotic critical values for the KPSS test according to the original paper and included it in the loop.

Dear community,

I would like to perform the KPSS unit root test in EViews 10 (University ed.) on a group of monthly series and store the test results (critical value > test statistic?) in a table. So far, my code reads:

Code: Select all

'Create a blank output table to store test results for the seasonally adjusted series contained in the group "monthly_x13" table (5,monthly_x13.@count+1) KPSS_MONTHLY setcell(KPSS_MONTHLY, 1, 1, "Test / Series", "l") setcell(KPSS_MONTHLY, 2, 1, "KPSS (level, trend)", "l") setcell(KPSS_MONTHLY, 3, 1, "KPSS (level, constant)", "l") setcell(KPSS_MONTHLY, 4, 1, "KPSS (fd, trend)", "l") setcell(KPSS_MONTHLY, 5, 1, "KPSS (fd, constant)", "l") 'Loop through all series in the group "monthly_x13" for !i=1 to monthly_x13.@count 'Enforce the correct series names %name = monthly_x13.@seriesname(!i) 'Obtain and store kpss test results (p-values) uroot(kpss, trend, dif=0, save=kpss1) {%name} 'for levels, assuming an intercept and exogenous trend KPSS_MONTHLY(1,1+!i)=%name KPSS_MONTHLY(2, 1+!i)= kpss1(5,1)-kpss1(3,1) uroot(kpss, const, dif=0, save=kpss2) {%name} 'for levels, assuming an intercept KPSS_MONTHLY(3, 1+!i)= kpss2(5,1)-kpss2(3,1) uroot(kpss, trend, dif=1, save=kpss3) {%name} 'for first difference, assuming an intercept and exogenous trend KPSS_MONTHLY(4, 1+!i)= kpss3(5,1)-kpss3(3,1) uroot(kpss, const, dif=1, save=kpss4) {%name} 'for first difference, assuming an intercept KPSS_MONTHLY(5, 1+!i)= kpss4(5,1)-kpss4(3,1) next


However, the output table gives me only 'NA' values. This is due to the fact that the matrices kpss1 to kpss5 contain only 'NA' values where the critical values should be. Somehow my routine does not properly extract the critical values.

Could you please tell me how to access the individual critical values of the kpss test?

Thank you in advance!

Re: Accessing KPSS critical values in a loop

Posted: Wed Jun 26, 2019 7:43 am
by EViews Gareth
I don't think you can retrieve them easily like that. You'd have to freeze the unit root test output into a table and then extract them from the table.

Re: Accessing KPSS critical values in a loop

Posted: Wed Jun 26, 2019 7:51 am
by heer0
I don't think you can retrieve them easily like that. You'd have to freeze the unit root test output into a table and then extract them from the table.
Thank you Gareth. Makes sense!

Best wishes!