Announcement

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

  • Panel simulation code?


    Dear colleagues,

    Would you kindly help me to create appropriate simulation codes for time-varying Zit is affected by Xit-1 in this equation?

    Yit=Yit-t+Xit+Zit+Ui+Eit

    Ui is unobserved time-invariant heterogeneity.
    Zit is time-varying unobserved heterogeneity.

    Here is the code:

    gen Ui= `endo'*rnormal() // Ui

    gen Zi1 = `r'*Ui + `k'*rnormal() // Time-varying Zit is correlated with Ui and Zit-1
    gen Zi2 = `r'*Ui + `r1'*Zi1+ `k'*rnormal()
    gen Zi3 = `r'*Ui + `r2'*Zi2+ `k'*rnormal()


    gen x1 = `g'*rnormal() + `Zx1'*Zi1 + Ui // Xit is correlated both with Zit and Ui.
    gen x2 = `g'*rnormal() + `Zx2'*Zi2 + Ui
    gen x3 = `g'*rnormal() + `Zx3'*Zi3 + Ui


    gen y1 = `g'*rnormal() + `Zy1'*Zi1 + `beta'*x1 + Ui // Yit is the function of Yit-1, Zit, Xit, and Ui.
    gen y2 = `g'*rnormal() + `Zy2'*Zi2 + `beta'*x2 + Ui + `auto'*y1
    gen y3 = `g'*rnormal() + `Zy3'*Zi3 + `beta'*x3 + Ui + `auto'*y2


    In this setting, since Zit comes first, I cannot create the case that Zit is affected by Xit-1. Think that gen x1 = `g'*rnormal() + `Zx1'*Zi1 + Ui + Zit2 is not appropriate.

    Do you have any idea to do so? Your reply will be appreciated.








  • #2
    You have accidentally posted your topic in Statalist's Mata Forum, which is used for discussions of Stata's Mata language, which is different than Stata's command language, and different than Stata's matrix commands. Your question will see a more appropriate, and much larger audience if you post it in Statalist's General Forum.

    Comment


    • #3
      Thanks, William! Is there a way that I can delete this post?

      Comment


      • #4
        Deleting is not supported by the software - it prevents people mistakenly deleting posts to which they've gotten an answer thinking that "closing the problem ticket" is necessary, while the objective here is to build up a searchable body of knowledge.

        Comment

        Working...
        X