View source: R/lmer_multimember.R
lmer | R Documentation |
lme4::lmer but with multimembership random effects
lmer(
formula,
data = NULL,
REML = TRUE,
control = lme4::lmerControl(),
start = NULL,
verbose = 0L,
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
|
REML |
logical scalar - Should the estimates be chosen to optimize the REML criterion (as opposed to the log-likelihood)? |
control |
a list (of correct class, resulting from
|
start |
a named |
verbose |
integer scalar. If |
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 = seq(60) + runif(60, 0, 10),
y = seq(60) + rep(runif(6, 0, 10), 10),
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
lmer(y ~ x + (1 | members),
data = df,
memberships = list(members = weights)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.