March 28, 2011

Simulating an ARMA Process using STATA

If you need to simulate an ARMA process (provided you already know the coefficients of both the AR component and the MA component), you can use STATA to do so. What you need is the SIM_ARMA program created by Jeff Pitblado. You can download this program from the Boston College STATA program repository.

For example, suppose you want to simulate an ARMA(2,2) process with:

α (z) = 1 - 2/3 z + 1/9 z2
β (z) = 1 + ¼ z + ¼ z2
εt ∼ WN(o,1)
n = 600

You use the following stata command:

sim_arma y, arcoef(.66666667 -.11111111) macoef(.25 .25) et(e) nobs(600) sigma(1) time(time)

y is the resulting simulated data. The numbers inside the parenthesis of arcoef and macoef assigns the coefficients of the AR component and the MA component, respectively. Here, I use decimal numbers since it seems it does not read fractions (STATA seems to read and numbers with the "/" sign as an interval). et assigns the name of the error term while time assigns the name of the time variable. Finally, sigma assigns the standard deviation of the error term.