I've been looking for R packages that allow one to fit a logistic mixed model with an AR-1 correlation structure. I've found that it seems easy to do a logistic mixed model or to fit a linear mixed model with such a structure, but not both. Am I wrong in this, and if I'm not; what would an alternative be?


The following simulates and fits a model where the linear predictor in the logistic regression follows a zero-mean AR(1) process, see the glmmTMB package vignette for more details.

> library(glmmTMB)
> set.seed(1)
> n <- 1000
> size <- 10
> eta <- arima.sim(list(ar=.8),n)
> y <- rbinom(n, prob=plogis(eta), size=size)
> group <- factor(rep(1,n))
> time <- factor(1:n)
> fit <- glmmTMB(cbind(y,size-y) ~ -1 + ar1(time + 0|group), family=binomial)
> summary(fit)
 Family: binomial  ( logit )
Formula:          cbind(y, size - y) ~ -1 + ar1(time + 0 | group)

     AIC      BIC   logLik deviance df.resid 
  4329.5   4339.3  -2162.8   4325.5      998 

Random effects:

Conditional model:
 Groups Name  Variance Std.Dev. Corr      
 group  time1 2.528    1.59     0.77 (ar1)
Number of obs: 1000, groups:  group, 1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.