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

st: RE: Generate artificial variable for panel data


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: Generate artificial variable for panel data
Date   Thu, 17 Oct 2002 15:52:37 +0100

Patrice Yee Chong San
 
> Does anyone have any idea on how to do the following in Stata?
> 
> I wish to generate a series of NT observations for variable 
> X for an 
> artificial panel data generating process where
> i = 1,...,N = 50
> t =1,..., T = 10
> 
> X_i,t = 0.1*t + 0.5*X_i,t-1
> 
> The initial values are X_i,0 = 5 + 10w_i,0 
> 
> where w_i,t ~N(0,1)
>        _it denote subscript of the individual i at time t. 
> 
> The above was taken from Baltagi(1981)


Try 

set obs 550 
egen panel = seq(), b(50) 
egen time = seq(), from(0) to(10) 
tsset panel time 
gen X = 5 + invnorm(uniform()) 
replace X = 0.1 * time + 0.5 * L.X if time > 0 
drop if time == 0 

Nick 
[email protected] 
*
*   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