Dear Allin
I tried this
simulation script about z-test years ago. It's a great idea.
But I found that the result of this simulation depends on potential
"initial effect" since the script generate variables in this way:
...
series u = 0
...
series y = 0
To avoid the initial effect, the simulation would conventionally drop
some initial samples and do tests for the rest. So I slightly modified
your script to generate 130 sample per replication and dropped the
first 30 sample to do your comparison as shown below.
In shorts after dropping the first 30 samples, the AIC actually does a
good job for (100 samples of this) AR(3) simulation; BIC and HQC
select too short lags. Though the results are a little bit different
for other ICs, a good news is that the z-test proposed in gretl seems
more robust relatively.
Yi-Nung Yang
Dept. of International Business, Chung Yuan Christian University, Taiwan.
The original script's result:
-----------------------------------------------------------------------
1000 replications, test down from 6 lags
Lag order selected: mean on row 1, s.d. on row 2
AIC BIC HQC z-test
5.85 3.33 4.91 3.10
0.46 1.48 1.25 1.39
The result of dropping the first 30 samples:
-----------------------------------------------------------------------
1000 replications, test down from 6 lags
Lag order selected: mean on row 1, s.d. on row 2
AIC BIC HQC z-test
3.01 1.97 2.44 3.18
1.16 0.91 0.99 1.38
The modified script by me:
<script>
nulldata 130
# seed so that experiment can be repeated exactly
set seed 89675430
# params of error process: can set some to zero, but
# here we do AR(3)
scalar rho1 = 0.5
scalar rho2 = -0.3
scalar rho3 = 0.2
# y params: d = drift, a = autoregressive parameter
scalar d = 0.02
scalar a = 0.9
# test down from
scalar maxlag = 6
# test-recoding scalars
scalar zval, pz, zlag, pzstar
# replications
scalar replics = 1000
# matrix to record results across relications
matrix lsel = zeros(replics, 4)
# outer loop: replications
loop j=1..replics -q
# build stationary AR(p) error process for u
series u = 0
series e = normal()
u = rho1*u(-1) + rho2*u(-2) + rho3*u(-3) + e
# construct y series for "ADF testing"
series y = 0
series y = d + a*y(-1) + u
# difference for DF regression
dy = diff(y)
lags maxlag ; dy
# comprehensive list of lagged differences
list dyL = dy_*
# Information Criterion matrix
matrix IC = zeros(3, maxlag+1)
zlag = 0
# inner loop: test for lag length
loop for (i=maxlag; i>=0; i--) -q
smpl 31 130
ols dy 0 y(-1) dyL -q
IC[1,i+1] = $aic
IC[2,i+1] = $bic
IC[3,i+1] = $hqc
if (i > 0 && zlag == 0)
# we haven't yet found a significant "final lag"
zval = abs($coeff(dy_$i)/$stderr(dy_$i))
pz = 2 * pvalue(z, zval)
# printf "pz = %g\n", pz
if (pz <= 0.10)
zlag = i
pzstar = pz
endif
endif
if i > 0
# discard the last lag
dyL -= dy_$i
endif
endloop
# just for checking...
# print IC
matrix iCmin = iminr(IC) - 1
# Verbose printing to check results (set replics = 1)
# matrix Cmin = minr(IC)
# printf "AIC min = %8.3f at lag %d\n", Cmin[1], iCmin[1]
# printf "BIC min = %8.3f at lag %d\n", Cmin[2], iCmin[2]
# printf "HQC min = %8.3f at lag %d\n", Cmin[3], iCmin[3]
# if zlag > 0
# printf "z p-val = %8.3f at lag %d\n", pzstar, zlag
# else
# print "z-test selects no lags"
# endif
lsel[j,1:3] = iCmin'
lsel[j,4] = zlag
endloop
# Uncomment to print the full results
# print lsel
matrix stats = meanc(lsel) | sdc(lsel)
colnames(stats, "AIC BIC HQC z-test")
printf "\n%d replications, test down from %d lags\n", replics, maxlag
print "Lag order selected: mean on row 1, s.d. on row 2"
printf "\n%8.2f\n", stats
</script>
2011/3/19 Allin Cottrell <cottrell(a)wfu.edu>:
On Fri, 18 Mar 2011, Davor Horvatic wrote:
> Probably a year ago you posted script to test max lag in ADF using
> AIC or BIC or HQC criteria. I have trouble locating it the group archive.
> Can you dig this out ? I would be very grateful.
I think this must be what you have in mind:
http://lists.wfu.edu/pipermail/gretl-users/2009-February/003033.html
Allin Cottrell
_______________________________________________
Gretl-users mailing list
Gretl-users(a)lists.wfu.edu
http://lists.wfu.edu/mailman/listinfo/gretl-users