Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: Program to simulate AR(1) time series and return autocorrelations


From   brandon lebeau <[email protected]>
To   [email protected]
Subject   st: Program to simulate AR(1) time series and return autocorrelations
Date   Fri, 24 Feb 2012 13:02:38 -0600

I am attempting to write a program that simulates an AR(1) time series
using the sim_arma command
and computes autocorrelations with the corrgram function.  I'm having
difficulties accessing the stored
results from the corrgram function, specifically the matrix r(AC).I
have also tried just accessing r(ac1),
r(ac2), etc. and that works, but does not work when I try to use the
simulate command.

Here is my program so far:

program define simarmaT, rclass
   sim_arma simy, nobs(20) arcoef(.45) time(time) spin(2000)
   tsset time
   corrgram simy, lags(13) noplot
   return matrix autoC = r(AC)
end

Then I'd like to use the simulate function to replicate this about
10,000 times.
Here is a version of my simulate command:

simulate autoC = r(AC), reps(20): simarmaT


I'm hoping their is a simple solution to this as I'm a new user to
Stata, I primarily use R,
but need to replicate my simulation done in R with another program.

Cheers
Brandon
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index