RRmixed | R Documentation |

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

`formula` |
two-sided formula including random and fixed effects (see below or |

`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., |

`p` |
randomization probability |

`const` |
the RR link function is not defined for small and/or large probabilities
(the boundaries depend on |

`adjust_control` |
whether to adjust the control arguments for |

`...` |
further arguments passed to |

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

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.