Description Usage Arguments Details Value Author(s) References Examples

This model fits a logistic regression with Gaussian random effects. The random effects are assumed to be distributed as a normal distribution with zero mean.

1 |

`formula` |
an object of class |

`n` |
the maximum score of the binomial trials. |

`random` |
a vector containing the names of the random components in the data frame, the names must be between quotes. |

`data` |
an optional data frame, list or environment (or object coercible by |

The model that is performed by this function is a especial case of generalized linear mixed models (GLMMs), in which conditioned on some random components the response variable has a binomial distribution. As in the binomial (logistic) regression a logit link function is applied to the probability parameter of the conditioned distribution, allowing the inclusion of random components in the linear predictor,

*logit(p)=Xβ+Zu,*

where *p* is the probability parameter, *X* a full rank matrix composed by the covariables, *β* the regression coefficients, *Z* the design matrix for the random effects and *u* are the random effects. These random effects are independent and has a normal distribution with the same variance and mean 0.

The model estimates the fixed effects and the variance of the random effects, and predicts those random effects for each observation.

The estimation of the parameters is done by likelihood approximation, via iterative weighted least squares (IWLS) method. The estimation is performed in two steps: (i) fixed and random parameters are calculated for some given random component variances (ii) variances of the random effects are calculated for some given regression and random coefficients. The estimation approach iterates between (i) and (ii) until convergence is obtained.

`BImmreg`

returns an object of class "`BIMreg`

".

The function `summary`

(i.e., `summary.BIMreg`

) can be used to obtain or print a summary of the results, `coef`

can be used to print the regression coefficients of the model, `fitted`

(i.e., `fitted.BIMreg`

) to print the fitted values and `residuals`

(i.e., `residuals.BIMreg`

) to get the residuals.

`coefficients` |
the estimated value of the fixed coefficients in the regression. |

`coef.vcov` |
the variance and covariance matrix of the estimated fixed coefficients in the regression. |

`random.coef` |
the predicted random effects of the regression. When more than one random effects are included the prediction of all the random coefficients is given, following the order defined in parameter |

`random.var` |
the variance of each random effect. |

`deviance` |
the deviance of the model based on the approximated log-likelihood. |

`fitted.values` |
the fitted mean values of the probability parameter of the conditioned binomial distribution, obtained by transforming the linear predictor by the inverse of the link function. |

`residuals` |
the residuals of the model. |

`random.se` |
the standard error of each random effect, the square of the variance of the random effects. |

`working` |
the final working vector of the iterative weighted least square method. |

`iter` |
the number of iterations in the estimation method. |

`nObs` |
the number of observations in the data. |

`nrand` |
the number of random components in the model. |

`cluster` |
the number of levels in each random component. |

`y` |
the dependent variable in the model. |

`X` |
the model matrix of the fixed effects. |

`Z` |
the model matrix of the random effects. |

`D` |
the variance and covariance matrix of the random effects. |

`n` |
the maximum score of the conditioned binomial trials. |

`W` |
the final weights matrix in the iterative weighted least square method. |

`call` |
the matched call. |

`formula` |
the formula supplied. |

Josu Najera Zuloaga

Dae-Jin Lee

Breslow N. E. & Clayton D. G. (1993): Approximate Inference in Generalized Linear Mixed Models, *Journal of the American Statistical Association*, 88, 9-25.

McCulloch C. E. & Searle S. R. (2001): Generalized, Linear, and Mixed Models, *John Wiley & Sons*.

Pawitan Y. (2001): In All Likelihood: Statistical Modelling and Inference Using Likelihood, *Oxford University Press.*

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | ```
set.seed(5)
# Create a dependent variable with a random covariable:
nObs <- 500
x <- rnorm(nObs,4,1)
id1 <- c(kronecker(seq(1,5),rep(1,100)))
id2 <- c(kronecker(seq(1,10),rep(1,50)))
p <- 1/(1+exp(-(5-5*x+kronecker(rnorm(5,0,0.5),rep(1,100))+kronecker(rnorm(10,0,1.2),rep(1,50)))))
y <- rbinom(nObs,10,p)
dat <- data.frame(cbind(y,x,id1,id2))
dat$id1 <- as.factor(dat$id1)
dat$id2 <- as.factor(dat$id2)
#Estimate the mixed model for one random component.
mm1 <- BIMreg(y~x,10,c("id1"),dat)
mm1
summary(mm1)
#Estimate the mixed model for two random components.
mm2 <- BIMreg(y~x,10,c("id1","id2"),dat)
mm2
summary(mm2)
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.