I perform a simulation on AIC model selection, in the literature, it is well known that AIC will lead to overfit,i.e take more lags than the true d.g.p,however,my codes result in a very different output, that is alway take one lag, no matter what the d.g.p is. below is the code, somebody help me please.Thany you very much.
Code: Select all
create a workfile
!N=10000
!M=30
workfile simu1 u 1 !N
'create a variable
series order
equation eq
for !j=1 to !N
smpl 1 !M+100
series u=nrnd
series v=nrnd
series y
y(1)=v(6)
y(2)=v(8)
y(3)=v(4)
y(4)=v(2)
smpl 5 !M
y=0.2*y(-1)+0.1*y(-2)+0.1*y(-3)+0.1*y(-4)+u
smpl 1 !M
'variable to store the minimum AIC. Initialise it to a large number
!aic = 99999999
'variable saying how many lags to go up to
!maxlags = 10
'Variable to store the "best" number of lags
!bestlag = 0
'set sample to be the !maxlag'th value onwards
smpl !maxlags !M
for !i=1 to !maxlags
eq.ls y c y(-1 to -!i) 'run regression of Y on a constant and lagged values of itself up to the iTH lag.
if eq.@aic < !aic then
!bestlag = !i 'if this lag specification has the best AIC, then store this lag as !bestlag.
!aic = eq.@aic
endif
next
smpl @all
order(!j)=!bestlag
'reset sample
next
