Simulating multiple AR(1) series
Simulating multiple AR(1) series
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
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
Re: Simulating multiple AR(1) series
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 iRe: Simulating multiple AR(1) series
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.
*--------------- 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.