Re: [R] generating clustered data

From: Hamilton, Cody <CodyH_at_baylorhealth.edu>
Date: Wed 12 Jul 2006 - 09:35:13 EST

Brian,

What about creating the covariance matrix with the help of the kronecker product? For instance, suppose your intercepts are ~ N(0,var1) and your residual errors are ~ N(0,var2). Suppose further that you want 10 clusters of 5 observations each. I believe you can create the overall covariance matrix with kronecker(diag(10),matrix(var1,5,5)) + var2*diag(50). This can then be fed as the variance to the mvtnorm function. Hope this helps.

Regards,

   -Cody

-----Original Message-----
From: r-help-bounces@stat.math.ethz.ch
[mailto:r-help-bounces@stat.math.ethz.ch] On Behalf Of Brian Perron Sent: Tuesday, July 11, 2006 15:59 PM
To: r-help@stat.math.ethz.ch
Subject: [R] generating clustered data

Hello R folks,

Does anybody have code to share for generating (via simulation) clustered data? The type of data I am looking to simulate would allow fitting of a multilevel model with random intercepts. I looked at the mvtnorm package but am not quite sure how to create clusters. (Can this

be done by simply changing the seed?) If somebody could point me where to look for the relevant code or perhaps send some sample code, that would be great.

Thanks,
Brian



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html

This e-mail, facsimile, or letter and any files or attachmen...{{dropped}}



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Wed Jul 12 09:39:32 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Wed 12 Jul 2006 - 12:18:13 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.