### simulate arch(1) & arch(2)

Posted:

**Sun Mar 26, 2017 1:58 pm**Hi everyone

I have problem with this two code, i get NA series after the first observation for the 1st code, and i get error message for the second code.

i would highly appreciate if any of you could help me!

1/first code ARCH(1)

2/ second code

I have problem with this two code, i get NA series after the first observation for the 1st code, and i get error message for the second code.

i would highly appreciate if any of you could help me!

1/first code ARCH(1)

Code: Select all

`' program 1 simulation ARCH(1)`

wfcreate u 1000

smpl @all

'define series: normal innovation (z),variance (vr), error (e), return (r)

series z= nrnd

series vr

series e

series r

'initialize the series to start the recursion, the vr starts at the unconditional variance value of 4

smpl @first @first

vr=4

e = @sqrt(vr)*z

r= 2+e

'start the recursion from 2 to the number of observations you wish to generate we have set omega = 2 and alpha = 0.5

smpl @first+1 @last

vr=2+0.5*e^2

e = @sqrt(vr)*z

r= 2+e

smpl @all

2/ second code

Code: Select all

`' program 2 simulation ARCH(2)`

wfcreate u 1000

smpl @all

'define series: normal innovation (z),variance (vr), error (e), return (r)

series z= nrnd

series vr

series e

series r

'initialize the series to start the recursion, the vr starts at the unconditional variance value of 2.5

smpl @first @first+1

vr(1)=2.5

vr(2)=vr(1)

e(1) = @sqrt(vr(1))*z

e(2)=@sqrt(vr(1))*z

r(1)= 2+e(1)

r(2)= 2+e(2)

'start the recursion from 3 to the number of observations you wish to generate we have set omega = 2 and alpha1 = 0.5, alpha 2= 0.3

smpl @first+2 @last

vr=2+0.5*e^2+0.3*e^2

e = @sqrt(vr)*z

r= 2+e

smpl @all