Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


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

Re: st: generating dynamic panel data


From   Christophe Kolodziejczyk <ck.statalist@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: generating dynamic panel data
Date   Thu, 21 Jul 2011 15:43:22 +0200

the last line should be conditionned on _n>1

by i: replace y = 0.8*y[_n-1] + 2*x + u if _n>1

since you have specified y(1)=u(1)

Christophe

2011/7/21 billy mairs <mairs8@hotmail.com>:
> 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/
>

*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index