Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: generating dynamic panel data


From   billy mairs <[email protected]>
To   statalist <[email protected]>
Subject   st: generating dynamic panel data
Date   Thu, 21 Jul 2011 11:37:30 +0000

Dear reader, I am having trouble trying to create dynamic panel data in stata.

I want to generate panel data with say n=20, t=5. I want the panel data to be ar(1) and follow the form y(t) = 0.8*y(t-1) + 2*x(t) + u(t), i.e dynamic panel data. x(t) is a standard normally distributed random variable and u(t) is an error term that I can change the distribution of to assess non-normality robustness.It is important that the panels are independent.
 
This is my attempt so far: 
 
clear all
set obs 20
gen i = _n
gen y = rnormal()
expand 5
sort i
by i: gen t=_n
gen x = rnormal()
gen u = rchi2(2) 
 
and then using something like 
 
by i: replace y = 0.8*y[_n-1] + 2*x + u
 
in the hope that I have 20 independent cross sections that follow an ar(1) process. However the above method will generate missing values. Any help will be greatly appreciated. 		 	   		  
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index