Fourier (adf-kpss-lm) unit root test results in tspdlib do not include F test statistics. How can I get the F test results.
7 Answers
0
I am assuming you are referring to the F-test statistics used to test for the null hypothesis of linearities as discussed in Enders and Lee, 2012. The computation of these are not yet included in the TSPDLIB library but are planned for the next version.
I've written some code that demonstrates how this can be after the Fourier_ADF
procedure.
To use this code you should:
- Have the
tspdlib
library installed. - Call the
Fourier_ADF
procedure first to find the optimal Fourier frequency and the number of lags. - Copy and paste the code below to the program file being used to call the
Fourier_ADF
procedure.
The code to generate the F-stat following the Fourier_ADF
call is below:
proc (2) = fourierADFFTest(y, model, k, p);
local t, dy, ly, dc, dt, sink, cosk,
dep, y1, ldy, sbt, trnd, sinp, cosp, z1, z2,
b1, e1, sig21, se1, ssr1, b2, e2, sig22, se2, ssr2,
k1, k2, lmat, j, cv_fstat;
// Check number of columns of y
if cols(y) > 1;
errorlogat "Cannot run test, y must be single column.";
end;
endif;
t = rows(y);
dy = diff(y, 1);
ly = lagn(y, 1);
// Deterministic term=constant
dc = ones(t, 1);
// Deterministic term=trend
dt = seqa(1, 1, t);
sink = sin(2 * pi * k * seqa(1, 1, t)/t);
cosk = cos(2 * pi * k * seqa(1, 1, t)/t);
// Find lmat
lmat = zeros(rows(dy), p + 1);
j = 1;
do while j <= p;
local tmp;
tmp = lagn(dy, j);
lmat[., j] = lagn(dy, j);
j = j + 1;
endo;
// Prepare data
dep = trimr(dy, p + 1, 0);
y1 = trimr(ly, p + 1, 0);
ldy = trimr(lmat, p + 1, 0);
sbt = trimr(dc, p + 1, 0);
trnd = trimr(dt, p + 1, 0);
sinp = trimr(sink, p + 1, 0);
cosp = trimr(cosk, p + 1, 0);
if p == 0;
if model == 1;
z1 = y1~sbt;
endif;
if model == 2;
z1 = y1~sbt~trnd;
endif;
elseif p > 0;
if model == 1;
z1 = y1~sbt~ldy[., 1:p];
endif;
if model == 2;
z1 = y1~sbt~trnd~ldy[., 1:p];
endif;
endif;
// Unrestricted model
z2 = z1~sinp~cosp;
// Estimate model one
// Restricted model
{b1, e1, sig21, se1, ssr1} = myols(dep, z1);
// Unrestricted model
{b2, e2, sig22, se2, ssr2} = myols(dep, z2);
// Count dimension of models
k1 = cols(z1);
k2 = cols(z2);
// Generate F_stat
F_stat = ((ssr1 - ssr2)/(k2 - k1))/(ssr2/(t-k2));
// Find critical values
cv_fstat = fstatcv(model, t);
_printHeaderTSPDLIB(0, 0, 2, model, 4, 0, "Fourier ADF F-Stat", "linearity", 0);
// Print results & Critical values
local top, side, stats, dec, colwidth;
side = "F-stat:";
top = "";
stats = F_stat;
dec = 3;
colwidth = 15;
_printStatsTable(top, side, stats, cv_fstat', dec, colwidth, 0, p, k);
_printConclusion(F_stat, cv_fstat, 1, "linearity");
retp(F_stat, cv_fstat);
endp;
proc (1) = fstatcv(model, T);
local crit;
// Critical Values (see, Enders & Lee, 2012, Table 1b)
crit = zeros(5, 3);
if model == 1;
if T <= 150;
crit = { 6.35 7.58 10.35 };
endif;
if 151 < T and T <= 349;
crit = { 6.25 7.41 10.02 };
endif;
if 350 < T and T <= 500;
crit = { 6.16 7.29 9.78 };
endif;
if 500 < T;
crit = { 6.11 7.25 9.72 };
endif;
endif;
if model == 2;
if T <= 150;
crit = { 7.78 9.14 12.21 };
endif;
if 151 < T and T <= 349;
crit = { 7.62 8.88 11.70 };
endif;
if 350 < T and T <= 500;
crit = { 7.53 8.76 11.52 };
endif;
if 500 < T;
crit = { 7.50 8.71 11.35 };
endif;
endif;
retp(crit);
endp;
To call the fourierADFFTest
using the data vector y[., "Y"]
:
// Find F-stat
{ f_stat, p_val } = fourierADFFTest(y[., "Y"], model, f, p);
0
Hi;
I added the above code to the fourier_adf (src) file. Then file fourier_adf (e) "// Find F-stat { f_stat, p_val } = fourierADFFTest(y[., "Y"], model, f, p);" I added the command. But when I run it, I get the error "G0025 : Undefined symbol: 'fourierADFFTest' [fourier_adf.e, line 25]".
0
0
I refreshed the TSPDLIB library after adding the code to the fourier_adf.src file. But it still gave this error:
G0025 : Undefined symbol: 'Fourier_ADF' [fourier_adf.e, line 25]
line 25 :
// Find F-stat
{ f_stat, p_val } = fourierADFFTest(y[., "Y"], model, f, p);
0
Can you confirm that you are loading the TSPDLIB library at the top of the fourier_adf.e
file? It should include this line somewhere at the top of the file:
library tspdlib;
0
Yes, there is a library tspdlib line at the top of the fourier_adf.e file.
0
Your Answer
7 Answers
I am assuming you are referring to the F-test statistics used to test for the null hypothesis of linearities as discussed in Enders and Lee, 2012. The computation of these are not yet included in the TSPDLIB library but are planned for the next version.
I've written some code that demonstrates how this can be after the Fourier_ADF
procedure.
To use this code you should:
- Have the
tspdlib
library installed. - Call the
Fourier_ADF
procedure first to find the optimal Fourier frequency and the number of lags. - Copy and paste the code below to the program file being used to call the
Fourier_ADF
procedure.
The code to generate the F-stat following the Fourier_ADF
call is below:
proc (2) = fourierADFFTest(y, model, k, p);
local t, dy, ly, dc, dt, sink, cosk,
dep, y1, ldy, sbt, trnd, sinp, cosp, z1, z2,
b1, e1, sig21, se1, ssr1, b2, e2, sig22, se2, ssr2,
k1, k2, lmat, j, cv_fstat;
// Check number of columns of y
if cols(y) > 1;
errorlogat "Cannot run test, y must be single column.";
end;
endif;
t = rows(y);
dy = diff(y, 1);
ly = lagn(y, 1);
// Deterministic term=constant
dc = ones(t, 1);
// Deterministic term=trend
dt = seqa(1, 1, t);
sink = sin(2 * pi * k * seqa(1, 1, t)/t);
cosk = cos(2 * pi * k * seqa(1, 1, t)/t);
// Find lmat
lmat = zeros(rows(dy), p + 1);
j = 1;
do while j <= p;
local tmp;
tmp = lagn(dy, j);
lmat[., j] = lagn(dy, j);
j = j + 1;
endo;
// Prepare data
dep = trimr(dy, p + 1, 0);
y1 = trimr(ly, p + 1, 0);
ldy = trimr(lmat, p + 1, 0);
sbt = trimr(dc, p + 1, 0);
trnd = trimr(dt, p + 1, 0);
sinp = trimr(sink, p + 1, 0);
cosp = trimr(cosk, p + 1, 0);
if p == 0;
if model == 1;
z1 = y1~sbt;
endif;
if model == 2;
z1 = y1~sbt~trnd;
endif;
elseif p > 0;
if model == 1;
z1 = y1~sbt~ldy[., 1:p];
endif;
if model == 2;
z1 = y1~sbt~trnd~ldy[., 1:p];
endif;
endif;
// Unrestricted model
z2 = z1~sinp~cosp;
// Estimate model one
// Restricted model
{b1, e1, sig21, se1, ssr1} = myols(dep, z1);
// Unrestricted model
{b2, e2, sig22, se2, ssr2} = myols(dep, z2);
// Count dimension of models
k1 = cols(z1);
k2 = cols(z2);
// Generate F_stat
F_stat = ((ssr1 - ssr2)/(k2 - k1))/(ssr2/(t-k2));
// Find critical values
cv_fstat = fstatcv(model, t);
_printHeaderTSPDLIB(0, 0, 2, model, 4, 0, "Fourier ADF F-Stat", "linearity", 0);
// Print results & Critical values
local top, side, stats, dec, colwidth;
side = "F-stat:";
top = "";
stats = F_stat;
dec = 3;
colwidth = 15;
_printStatsTable(top, side, stats, cv_fstat', dec, colwidth, 0, p, k);
_printConclusion(F_stat, cv_fstat, 1, "linearity");
retp(F_stat, cv_fstat);
endp;
proc (1) = fstatcv(model, T);
local crit;
// Critical Values (see, Enders & Lee, 2012, Table 1b)
crit = zeros(5, 3);
if model == 1;
if T <= 150;
crit = { 6.35 7.58 10.35 };
endif;
if 151 < T and T <= 349;
crit = { 6.25 7.41 10.02 };
endif;
if 350 < T and T <= 500;
crit = { 6.16 7.29 9.78 };
endif;
if 500 < T;
crit = { 6.11 7.25 9.72 };
endif;
endif;
if model == 2;
if T <= 150;
crit = { 7.78 9.14 12.21 };
endif;
if 151 < T and T <= 349;
crit = { 7.62 8.88 11.70 };
endif;
if 350 < T and T <= 500;
crit = { 7.53 8.76 11.52 };
endif;
if 500 < T;
crit = { 7.50 8.71 11.35 };
endif;
endif;
retp(crit);
endp;
To call the fourierADFFTest
using the data vector y[., "Y"]
:
// Find F-stat
{ f_stat, p_val } = fourierADFFTest(y[., "Y"], model, f, p);
Hi;
I added the above code to the fourier_adf (src) file. Then file fourier_adf (e) "// Find F-stat { f_stat, p_val } = fourierADFFTest(y[., "Y"], model, f, p);" I added the command. But when I run it, I get the error "G0025 : Undefined symbol: 'fourierADFFTest' [fourier_adf.e, line 25]".
I refreshed the TSPDLIB library after adding the code to the fourier_adf.src file. But it still gave this error:
G0025 : Undefined symbol: 'Fourier_ADF' [fourier_adf.e, line 25]
line 25 :
// Find F-stat
{ f_stat, p_val } = fourierADFFTest(y[., "Y"], model, f, p);
Can you confirm that you are loading the TSPDLIB library at the top of the fourier_adf.e
file? It should include this line somewhere at the top of the file:
library tspdlib;
Yes, there is a library tspdlib line at the top of the fourier_adf.e file.