I have been asked to estimate an AR(1)-ARCH(2) model with gmm (twostep, itererated) and by MLE, and report mean, median, std and mse.
However, I do not know how to perform the actual estimation. I figure, I need to use the commands arch and gmm.
Instruments:
x=(1,y[t-1,1])
z=(1,(y[t-1,1]-phi_0-phi_1*y[t-2,1])^2,(y[t-2,1]-phi_0-phi_1*y[t-3,1])^2,(y[t-3,1]-phi_0-phi_1*y[t-4,1])^2)
So far, I have done the following:
(Unsure of whether to use: "Matrix function AR_gen(ome, phi_0, phi_1, T, alp_1, alp_2)" here)
Generated the data and set the initial values:
{
eta = rnormal(T+1,1,0,1)
y=J(T+1,1,.)
veps=J(T+1,1,.)
eps2=J(T+1,1,.)
sig2=J(T+1,1,.)
y[1,1]=phi_0/(1-phi_1)
eps2[1,1]=(ome/(1-alp_1-alp_2))
sig2[1,1]=(ome/(1-alp_1-alp_2))
for (t=2; t<=T+1; t++){
y[t]=phi_0+phi_1*y[t-1,1]+vept[t]
veps[t]=sqrt(sig2[t])*eta[t]
sig2[t]=ome+alp_1*eps2[t-1,1]+alp_2*eps2[t-2,1]
eps2[t]=(y[t]-phi_0-phi_1*y[t-1,1])^2
}
y=y[2::T+1]
sig2=sig2[2::T+1]
}
Made the sample size vector, set the seed and repetitions:
M = 500
Ts = (1000,2000,3000,4000,5000)
rseed(1)
Set the values:
phi_0 = 0.1
phi_1 = 0.7
ome = 0.05
alp_1=0.12
alp_2=0.07
Preallocated memory:
bgmm_two_unadj=J(M,length(Ts),0)
bgmm_iter_unadj=J(M,length(Ts),0)
bmle=J(M,length(Ts),0)
results_mean=J(3,length(Ts),0)
results_median=J(3,length(Ts),0)
results_std=J(3,length(Ts),0)
results_msq=(3,length(Ts),0)
timer_clear()
timer_on(1)
Looped for the sample size and replication:'
for(j=1; j<=length(Ts); j++) {
// Select current sample size
T = Ts[1,j]
time=1::T
// Loop for replications
for(i=1; i<=M; i++) {
stata("clear")
And I'm stuck.
However, I do not know how to perform the actual estimation. I figure, I need to use the commands arch and gmm.
Instruments:
x=(1,y[t-1,1])
z=(1,(y[t-1,1]-phi_0-phi_1*y[t-2,1])^2,(y[t-2,1]-phi_0-phi_1*y[t-3,1])^2,(y[t-3,1]-phi_0-phi_1*y[t-4,1])^2)
So far, I have done the following:
(Unsure of whether to use: "Matrix function AR_gen(ome, phi_0, phi_1, T, alp_1, alp_2)" here)
Generated the data and set the initial values:
{
eta = rnormal(T+1,1,0,1)
y=J(T+1,1,.)
veps=J(T+1,1,.)
eps2=J(T+1,1,.)
sig2=J(T+1,1,.)
y[1,1]=phi_0/(1-phi_1)
eps2[1,1]=(ome/(1-alp_1-alp_2))
sig2[1,1]=(ome/(1-alp_1-alp_2))
for (t=2; t<=T+1; t++){
y[t]=phi_0+phi_1*y[t-1,1]+vept[t]
veps[t]=sqrt(sig2[t])*eta[t]
sig2[t]=ome+alp_1*eps2[t-1,1]+alp_2*eps2[t-2,1]
eps2[t]=(y[t]-phi_0-phi_1*y[t-1,1])^2
}
y=y[2::T+1]
sig2=sig2[2::T+1]
}
Made the sample size vector, set the seed and repetitions:
M = 500
Ts = (1000,2000,3000,4000,5000)
rseed(1)
Set the values:
phi_0 = 0.1
phi_1 = 0.7
ome = 0.05
alp_1=0.12
alp_2=0.07
Preallocated memory:
bgmm_two_unadj=J(M,length(Ts),0)
bgmm_iter_unadj=J(M,length(Ts),0)
bmle=J(M,length(Ts),0)
results_mean=J(3,length(Ts),0)
results_median=J(3,length(Ts),0)
results_std=J(3,length(Ts),0)
results_msq=(3,length(Ts),0)
timer_clear()
timer_on(1)
Looped for the sample size and replication:'
for(j=1; j<=length(Ts); j++) {
// Select current sample size
T = Ts[1,j]
time=1::T
// Loop for replications
for(i=1; i<=M; i++) {
stata("clear")
And I'm stuck.