Learn R Programming

RRreg (version 0.6.0)

RRmixed: 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, ...)

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", "Kuk", "Mangat", "custom"). See
p
randomization probability
...
further arguments passed to glmer

Value

  • an object of class glmerMod

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)}

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

Run this code
# generate data with a level-1 predictor 
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)

Run the code above in your browser using DataLab