Bookmark and Share

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

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

Re: st: Generating clustered data

From   Stas Kolenikov <>
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 <> 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
Small print: I use this email account for mailing lists only.
*   For searches and help try:

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