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.
Comment