set.seed(5)
# Fixing parameters for the simulation:
nObs <- 1000
m <- 10
beta <- c(1.5,-1.1)
sigma <- 0.8
# Simulating the covariate:
x <- runif(nObs,-5,5)
# Simulating the random effects:
z <- as.factor(rBI(nObs,5,0.5,2))
u <- rnorm(6,0,sigma)
# Getting the linear predictor and probability parameter.
X <- model.matrix(~x)
Z <- model.matrix(~z-1)
eta <- beta[1]+beta[2]*x+crossprod(t(Z),u)
p <- 1/(1+exp(-eta))
# Simulating the response variable
y <- rBI(nObs,m,p)
# Apply the model
model <- BImm(fixed.formula = y~x,random.formula = ~z,m=m)
print(model) # or just model
Run the code above in your browser using DataLab