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: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 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