Dear all,
I experimenting a bit with simulating dynamic ARDL models. I've got
three questions:
1) In the script below, you see a simulation of an AR(p) model for two
different initial values which are sent to filter(), y0 and y00. I think
y00 should be the correct initial value but I would like to know your
opinion.
2) Do you think there are any concerns about the ysim() function?
3) I was thinking of simulating a series of length k*T where k is some
positive integer and T the length of the actual series. The first
(k-1)*T values would be taken as the "burn-in phase". However, I am not
sure how to program this cleverly as "Z" and thus "z" have some fixed
length in the ysim() function. Much appreciated if somebody comes up
with a nice idea ;-)
Best,
Artur
<hansl>
clear
set echo off
set messages off
open denmark.gdt -q
set seed 1234
function void ysim (series y,
matrix ARcoef,
list Z "lD~uhat",
matrix Zbeta "Coefficients of all exogenous | 1 (for uhat)",
scalar pq, scalar y0, series *Ysim)
series z = lincomb(Z, Zbeta)
series Ysim = filter(z,1,ARcoef,y0)
smpl $t1 $t1+pq-1
Ysim = y # add first initial (historical) values
smpl full
end function
series Y = LRY
list lD = const #time
scalar nD = nelem(lD)
# AR(p)
scalar p = 2
ols Y lD Y(-1 to -p)
matrix ARbeta = $coeff[(1+nD):]
matrix Zbeta = $coeff[1:nD]
# Simulate the Y-series
series uhat = resample($uhat)
scalar y0 = Y[$t1] # initial value 1
scalar y00 = Y[$t1+p-1] # initial value 2
list Z = lD uhat
Zbeta |= 1 # add unit coeff for uhat
series Yb0 = 0 # simulated series 1
ysim(Y,ARbeta,Z,Zbeta,p,y0,&Yb0)
series Yb00 = 0 # simulated series 2
ysim(Y,ARbeta,Z,Zbeta,p,y00,&Yb00)
gnuplot Y Yb0 Yb00 --with-lines --time-series --output=display
</hansl>