RRmixed: Mixed Effects Logistic Regression for RR Data

View source: R/RRmixed.R

RRmixedR Documentation

Mixed Effects Logistic Regression for RR Data

Description

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

Usage

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

Arguments

formula

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

data

an optional data frame with variables named in formula

model

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.

p

randomization probability

const

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.

adjust_control

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

Details

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.

Value

an object of class glmerMod

References

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.

Examples

# generate data with a level-1 predictor
set.seed(1234)
d <- data.frame(
  group = factor(rep(LETTERS[1:20], each = 50)),
  cov = rnorm(20 * 50)
)
# generate dependent data based on logistic model (random intercept):
d$true <- simulate(~ cov + (1 | group),
  newdata = d,
  family = binomial(link = "logit"),
  newparams = list(
    beta = c("(Intercept)" = -.5, cov = 1),
    theta = c("group.(Intercept)" = .8)
  )
)[[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)
summary(mod)

danheck/RRreg documentation built on Dec. 3, 2022, 7:50 p.m.