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 at the end of May, 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 clustered data


From   Stas Kolenikov <skolenik@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Generating clustered data
Date   Mon, 16 May 2011 20:50:13 -0500

On Mon, May 16, 2011 at 11:17 AM, John Antonakis <John.Antonakis@unil.ch> wrote:
> Would anyone have a code to generate data (panel) that is clustered and
> where the conditional variance depends on a cluster-level shock?

Oh, not again. Wasn't there a query about correlated data last week?

set obs 100
gen int clusterID = _n
gen u = rnormal()
expand 20
bysort clusterID : gen int t = _n
gen e = rnormal()*exp( 0.2*u - 1 )
gen y = u + e

Of course you can add xb to this y. Austin Nichols suggested to
generate xs to be clustered correlated, as well.


-- 
Stas Kolenikov, also found at http://stas.kolenikov.name
Small print: I use this email account for mailing lists only.
*
*   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