[R] Simulating multilevel responses

From: Elke Moons <elke.moons_at_uhasselt.be>
Date: Thu, 24 Jul 2008 00:03:57 +0200


Dear forum,    

I was wondering if one could create multilevel responses when at the same time controlling for everything (i.e. for the multilevel structure, the fixed and/or the random effect parameters). What I mean is the following: in an ordinary glm setting you can simulate a binary response variable in a simple way as follows:  

sample.size<-length(x1)

X<-cbind(rep(1, sample.size), x1, x2)

beta<-c(0,0.8,0.2)

logt<-X%*%beta  

expit<-exp(logt)/(1+exp(logt))

y<-rbinom(sample.size,1,expit)    

Now suppose you have created a multilevel setting (households and individuals within the households) and some covariates at both levels. Is there a way to create the response in a similar way, or by means of a package?  

Thanks in advance,    

Elke

        [[alternative HTML version deleted]]



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Wed 23 Jul 2008 - 22:07:53 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 23 Jul 2008 - 22:32:51 GMT.

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

list of date sections of archive