View source: R/lmer_multimember.R
glmer | R Documentation |
lme4::glmer but with multimembership random effects
glmer(
formula,
data = NULL,
family,
control = lme4::glmerControl(),
start = NULL,
verbose = 0L,
nAGQ = 1L,
weights = NULL,
na.action = na.omit,
offset = NULL,
contrasts = NULL,
devFunOnly = FALSE,
memberships = NULL
)
formula |
a two-sided linear formula object describing both the
fixed-effects and random-effects part of the model, with the response
on the left of a |
data |
an optional data frame containing the variables named in
|
family |
a GLM family, see |
control |
a list (of correct class, resulting from
|
start |
a named list of starting values for the parameters in the
model, or a numeric vector. A numeric |
verbose |
integer scalar. If |
nAGQ |
integer scalar - the number of points per axis for evaluating the adaptive Gauss-Hermite approximation to the log-likelihood. Defaults to 1, corresponding to the Laplace approximation. Values greater than 1 produce greater accuracy in the evaluation of the log-likelihood at the expense of speed. A value of zero uses a faster but less exact form of parameter estimation for GLMMs by optimizing the random effects and the fixed-effects coefficients in the penalized iteratively reweighted least squares step. (See Details.) |
weights |
an optional vector of ‘prior weights’ to be used
in the fitting process. Should be |
na.action |
a function that indicates what should happen when the
data contain |
offset |
this can be used to specify an a priori known
component to be included in the linear predictor during
fitting. This should be |
contrasts |
an optional list. See the |
devFunOnly |
logical - return only the deviance evaluation function. Note that because the deviance function operates on variables stored in its environment, it may not return exactly the same values on subsequent calls (but the results should always be within machine tolerance). |
memberships |
named list of weight matrices that will replace any (dummy) random effects with matching names |
lme4 model object
df <- data.frame(
x = runif(60, 0, 1),
y = rbinom(60, 1, 0.6),
memberships = rep(c("a,b,c", "a,c", "a", "b", "b,a", "b,c,a"), 10)
)
weights <- weights_from_vector(df$memberships)
# note that the grouping variable name is arbitrary -- it just has
# to match the name in the list and doesn't need to correspond to a column
# name in the data
glmer(y ~ x + (1 | members),
data = df,
family = binomial,
memberships = list(members = weights)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.