Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: time series simulation study


From   "Sascha O. Becker" <[email protected]>
To   [email protected]
Subject   st: time series simulation study
Date   Tue, 6 May 2003 12:11:44 +0200 (MEST)

Dear statalisters,

in a simulation study (with something like 1000 replications), I want to
generate simple AR(k) time series 

y(t) = c +  b0 * t + b1 * y(t-1) + b2* y(t-2) +...+ bk* y(t-k)+ eps.

where I want to pick values t=450, ..., 500, i.e. after the time series has
somewhat stabilised. I.e. I want to generate 1000 time series like this
(using simul "around" the procedure below) . 

For the case where b2=...=bk=0, i.e. an AR(1), I can do it pretty easily
using the feature that Stata's "replace" command replaces recursively. What I do
is:

*********************
set seed 1;
set obs 10;
generate mynormal=invnorm(uniform());
g time=_n;
tsset time;
g y=.;
replace y=mynormal in 1; /* use the first entry in mynormal as a y(0) and
the rest as epsilons */
replace y=1+b0*time+b1*l.y+mynormal if time>1; /* NOTE: replace works
recursively !! */
list;
*********************

which yields

 list;

      mynormal       time          y
  1.  .4349075          1   .4349075
  2.  1.460773          2    13.0046
  3. -.0389092          3   29.03223
  4. -.0759261          4   49.95335
  5.  1.921223          5   77.76375
  6.  .1418411          6   108.6329
  7.  .8990735          7   145.0734
  8.  .9799716          8   186.3653
  9.  .2037313          9   231.6133
 10. -.3139055         10   281.0451

I do not see immediately how to generate higher order AR(k) (k>1). 
Any suggestions?

Best, Sascha

Dr. Sascha O. Becker - Center for Economic Studies
Department of Economics - University of Munich
Schackstr. 4 - 80539 Munich, Germany

-- 
+++ GMX - Mail, Messaging & more  http://www.gmx.net +++
Bitte l�cheln! Fotogalerie online mit GMX ohne eigene Homepage!

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index