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]]

