Hi all,
As I was trying to see how adf performs under different scenarios, I found somewhat
surprising results.
ADF seems to work fine when there are either an intercept, or a trend, or both. But when
there are none, the distribution of the resulting p-value become an uniform distribution.
What did I do wrong?
Fred
Here is the script to generate random walk series and then test to see how adf works or
not working:
# simulation of unit root process
# y(t)=b0+rho*y(t-1)+b1*time+error
# there are b0, rho, and b1 parameters to set
scalar N = 50 # series length
scalar R = 1000 # repeats or resampling
nulldata N --preserve
scalar rho = 1 # set rho from 0.0 to 1.0
scalar b0 = 0 # set intercept b0 = any value
scalar b1 = 0 # set trend b1 to any value
string outfilename =
sprintf("unitroot,N=%d,b0=%3.0f,b1=%3.0f,rho=%3.2f.gdt",N,b0,b1,rho)
loop R --progressive --quiet
series e = normal(0,10) # error vector
series y = 0
y = b0 + rho*y(-1) + b1*index + e
ols y const y(-1) index --quiet
scalar b_c = $coeff(const)
scalar b_rho = $coeff[2]
scalar b_t = $coeff[3]
adf -1 y --ct --quiet
scalar ct_p = $pvalue
scalar ct_t = $test
adf -1 y --c --quiet
scalar c_p = $pvalue
scalar c_t = $test
adf -1 y --nc --quiet
scalar nc_p = $pvalue
scalar nc_t = $test
print b_c b_rho b_t ct_p ct_t c_p c_t nc_p nc_t
store "@outfilename" b_c b_rho b_t ct_p ct_t c_p c_t nc_p nc_t
endloop
open "@outfilename"
freq b_c --plot=display
freq b_rho --plot=display
freq b_t --plot=display
freq ct_p --plot=display
#freq ct_t --plot=display
freq c_p --plot=display
#freq c_t --plot=display
freq nc_p --plot=display
#freq nc_t --plot=display