BImm
function performs binomial logistic mixed-effects models, i.e., it allows the inclusion of gaussian random effects in the linear predictor of a logistic binomial regression model. The structure of the random part of the model can be expecified by two different ways: (i) determining the random.formula
argument, or (ii) especifying the model matrix of the random effects, Z
, and determining the number of random effects in each random component, nRandComp
.BImm(fixed.formula,random.formula,Z=NULL,nRandComp=NULL,m,data,maxiter=100)
"formula"
(or one that can be coerced to that class): a symbolic description of the fixed part of the model to be fitted."formula"
(or one that can be coerced to that class): a symbolic description of the random part of the model to be fitted. It must be specified in cases where the model matrix of the random effects Z
is not determined.random.formula
argument is specified this argument should not be specified, as we will be specifying twice the random structure of the model.Z
.as.data.frame
to a data frame) containing the variables in the model. If not found in data, the variables are taken from environment(formula).BImm
returns an object of class "BImm
". The function summary
(i.e., summary.BImm
) can be used to obtain or print a summary of the results. 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)
model
Run the code above in your browser using DataLab