Function to run generalized linear mixed-effects model (glmer
)
across multiple grouping variables.
grouped_glmer(
data,
grouping.vars,
...,
output = "tidy",
tidy.args = list(conf.int = TRUE, conf.level = 0.95, effects = "fixed", conf.method =
"Wald"),
augment.args = list()
)
Arguments
data |
Dataframe (or tibble) from which variables are to be taken. |
grouping.vars |
Grouping variables. |
... |
Arguments passed on to lme4::glmer
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 ~ operator and the terms, separated by
+ operators, on the right. Random-effects terms are
distinguished by vertical bars ("|" ) separating expressions
for design matrices from grouping factors.
family a GLM family, see glm and
family .
start a named list of starting values for the parameters in the
model, or a numeric vector. A numeric start argument will be
used as the starting value of theta . If start is a
list, the theta element (a numeric vector) is used as the
starting value for the first optimization step (default=1 for
diagonal elements and 0 for off-diagonal elements of the lower
Cholesky factor); the fitted value of theta from the first
step, plus start[["fixef"]] , are used as starting values for
the second optimization step. If start has both fixef
and theta elements, the first optimization step is skipped.
For more details or finer control of optimization, see
modular .
verbose integer scalar. If > 0 verbose output is
generated during the optimization of the parameter estimates. If
> 1 verbose output is generated during the individual
penalized iteratively reweighted least squares (PIRLS) steps.
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.)
subset an optional expression indicating the subset of the rows
of data that should be used in the fit. This can be a logical
vector, or a numeric vector indicating which observation numbers are
to be included, or a character vector of the row names to be
included. All observations are included by default.
weights an optional vector of ‘prior weights’ to be used
in the fitting process. Should be NULL or a numeric
vector.
na.action a function that indicates what should happen when the
data contain NA s. The default action (na.omit ,
inherited from the ‘factory fresh’ value of
getOption("na.action") ) strips any observations with any
missing values in any variables.
offset this can be used to specify an a priori known
component to be included in the linear predictor during
fitting. This should be NULL or a numeric vector of length
equal to the number of cases. One or more offset
terms can be included in the formula instead or as well, and if more
than one is specified their sum is used. See model.offset .
contrasts an optional list. See the contrasts.arg of
model.matrix.default .
mustart optional starting values on the scale of the
conditional mean, as in glm ; see there for
details.
etastart optional starting values on the scale of the unbounded
predictor as in glm ; see there for details.
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).
|
output |
A character describing what output is expected. Two possible
options: "tidy" (default), which will return the results, or "glance" ,
which will return model summaries. |
tidy.args |
A list of arguments to be used in the relevant S3 method. |
augment.args |
A list of arguments to be used in the relevant S3 method. |
Value
A tibble dataframe with tidy results from linear model or model
summaries.