Simulating multiple AR(1) series

Use this forum to post questions about syntax problems or general programming issues. Questions on implementing a particular aspect of econometrics should go in "Econometrics Issues" below.

Simulating multiple AR(1) series

Postby basher » Tue Mar 08, 2011 12:06 pm

Hello,

I am trying to replicate a paper results, where I want to generate multiple (say, 10) AR(1) processes with AR(1) parameters randomly drawn from the [0.48,0.83] interval, and disturbances drawn from a zero-mean normal distribution where the standard deviation was randomly selected from the [0.005,0.014] interval. I have been trying to play with the following code without any success:

*--------------- begin --------------
seed 2011
all 100
set y = 0
com alpha = %uniform(.48,.83)
com sd = %uniform(.005,.014)
set et = %ran(sd)
do i = 1,10
set y(i) 2 100 = alpha*y{1}+et
end do i
*--------------- end --------------

Definitely I am missing something here. Your help will be highly appreciated. Thank you.

Basher
basher
 
Posts: 12
Joined: Tue Mar 08, 2011 7:11 am

Re: Simulating multiple AR(1) series

Postby TomDoan » Tue Mar 08, 2011 12:43 pm

This will generate 10 series using a single draw for the alpha and sd. If you also want to vary those with the draws, just move the two compute instructions inside the loop rather than leaving them outside.

Code: Select all
seed 2011
all 100
dec vect[series] y(10)
com alpha = %uniform(.48,.83)
com sd = %uniform(.005,.014)
set et = %ran(sd)
do i = 1,10
   set(first=0.0) y(i) 1 100 = alpha*y(i){1}+et
end do i
TomDoan
 
Posts: 2720
Joined: Wed Nov 01, 2006 5:36 pm

Re: Simulating multiple AR(1) series

Postby basher » Tue Mar 08, 2011 2:09 pm

Thank you Tom. I moved the two compute instructions inside the loop:
*--------------- begin --------------
seed 2011
all 100
dec vect[series] y(10)
do i = 1,10
com alpha = %uniform(.48,.83)
com sd = %uniform(.005,.014)
set et = %ran(sd)
set(first=0.0) y(i) 1 100 = alpha*y(i){1}+et
end do i
*--------------- end --------------
It is working fine. I wanted to create two variables x1 and x2, where x1 is a random series from the vector y(10) created above and x2 is the median of the 10 AR(1) series created above. I couldn't find an appropriate syntax for calling a series from a vector. Thank you once again.
basher
 
Posts: 12
Joined: Tue Mar 08, 2011 7:11 am


Return to Help With Programming

Who is online

Users browsing this forum: No registered users and 0 guests