Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, is already up and running.

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

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

From   Nick Cox <>
Subject   Re: st: Program to simulate AR(1) time series and return autocorrelations
Date   Fri, 24 Feb 2012 23:59:59 +0000

You can't put a matrix into a value of a variable.


On Fri, Feb 24, 2012 at 7:02 PM, brandon lebeau <> wrote:
> 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.

*   For searches and help try:

© Copyright 1996–2015 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index