Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Simulating ARMA(2,1) process

    I am trying to simulate an ARMA(2,1) process using the following code:
    Code:
    clear
    set obs 100
    gen t=_n
    tsset t
    
    
    gen et = rnormal()   // generating epsilon_t
    gen ut = et in 1
    
    replace ut = 0.8*L1.ut - 0.6*L2.ut + et + 0.5*L1.et if t>1
    For some reason, the rest of the observations for ut remain missing values after I run the last line of the code. I can't figure out exactly what I am doing wrong. I would really appreciate some help.

    Thanks!

  • #2
    The second lag of "ut" is missing as you initially have

    gen ut = et in 1
    [.] So subtracting a missing value will result in missing values. A possible modification could be:

    Code:
    clear
    set obs 100
    gen t=_n
    tsset t
    
    
    gen et = rnormal()   // generating epsilon_t
    gen ut = et if t<=2
    
    replace ut = 0.8*L1.ut - 0.6*L2.ut + et + 0.5*L1.et if t>2
    Last edited by Andrew Musau; 05 Apr 2023, 16:46.

    Comment

    Working...
    X