RRmixed: Mixed Effects Logistic Regression for RR Data

View source: R/RRmixed.R

RRmixedR Documentation

Mixed Effects Logistic Regression for RR Data


Uses the package lme4 to fit a generalized linear mixed model (GLMM) with an adjusted link funciton.


RRmixed(formula, data, model, p, const = 1e-04, adjust_control = FALSE, ...)



two-sided formula including random and fixed effects (see below or glmer for details)


an optional data frame with variables named in formula


type of RR design. Only 1-group RR designs are supported at the moment (i.e., "Warner", "FR", "UQTknown", "Crosswise", "Triangular", "Kuk", "Mangat", "custom"). See RRuni or vignette(RRreg) for details.


randomization probability


the RR link function is not defined for small and/or large probabilities (the boundaries depend on model and p). To increase robustness of the estimation, these probabilities smaller and larger than the respective boundaries (plus/minus a constant defined via const) are smoothed by separate logit-link functions.


whether to adjust the control arguments for glmer, which might help in case of convergence issues for some models. lmerControl settings are changed to nAGQ0initStep = FALSE and optimizer = "bobyqa".


further arguments passed to glmer


Some examples for formula:

  • random intercept: response ~ covariate + (1 | group)

  • random slope: response ~ covariate + (0 + covariate | group)

  • both random slope and intercept: response ~ covariate +(covariate | group)

  • level-2 predictor (must have constant values within groups!): response ~ lev2 + (1|group)

Note that parameter estimation will be unstable and might fail if the observed responses are not in line with the model. For instance, a Forced-Response model (model="FR") with p=c(0,1/4) requires that expected probabilities for responses are in the interval [.25,1.00]. If the observed proportion of responses is very low (<<.25), intercepts will be estimated to be very small (<<0) and/or parameter estimation might fail. See glmer for setting better starting values and lmerControl for further options to increase stability.


an object of class glmerMod


van den Hout, A., van der Heijden, P. G., & Gilchrist, R. (2007). The Logistic Regression Model with Response Variables Subject to Randomized Response. Computational Statistics & Data Analysis, 51, 6060–6069.


# generate data with a level-1 predictor 
d <- data.frame(group=factor(rep(LETTERS[1:20],each=50)), 
# generate dependent data based on logistic model (random intercept):
d$true <- simulate(~  cov + (1|group), newdata=d,
                     newparams=list(beta=c("(Intercept)"=-.5, cov=1),
# scramble responses using RR:
model <- "FR"
p <- c(true0=.1, true1=.2)
d$resp <- RRgen(model="FR", p=p, trueState=d$true)$response
# fit model:
mod <- RRmixed(resp ~  cov +(1|group), data=d, model="FR", p=p)

danheck/RRreg documentation built on Nov. 13, 2022, 11:41 p.m.