This function fits a multilevel mobility contrast model to estimate and test inter-generational mobility effect on an outcome in longitudinal data.
mcm_lmer(
formula,
data = NULL,
REML = TRUE,
control = lme4::lmerControl(),
start = NULL,
verbose = 0L,
subset,
weights,
na.action,
offset,
contrasts = NULL,
devFunOnly = FALSE,
origin = NULL,
destination = NULL,
time = NULL,
displayresult = TRUE,
...
)
A list containing:
Fitted generalized models of outcome on predictors.
See more on function glm
in package stats
.
Estimated mobility effects.
Standard errors of the estimated mobility effects.
Statistical significance of the the estimated mobility effects.
Estimated mobility effects conditional on specific age.
Standard errors of the estimated mobility effects conditional specific age.
Statistical significance of the the estimated mobility effects conditional on age.
Inherit the function form from lme4
package. It is 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.
Two vertical bars (||
) can be used to specify
multiple uncorrelated random effects for the same
grouping variable. (Because of the way it is implemented,
the ||
-syntax works only for design matrices
containing numeric (continuous) predictors;
to fit models with independent categorical effects,
see dummy or the lmer_alt function from the afex
package.) A typical model used in studying social mobility with
longitudinal data
takes the form response ~ origin*destination + | id
, where
respose
is the numeric response vector and origin
(destination
) is a vector indicating the origin (destination).
The specification of origin*destination
indicates the cross of
origin
and destination
, which is the same as
origin + destination + origin:destination
where
origin:destination
indicates the interaction of origin
and destination
. id
is a identifier for the clusters.
an optional data frame, list or environment (or object coercible by as.data.frame to a data frame) containing the variables in the model. If not found in data, the variables are taken from environment(formula), typically the environment from which the function is called.
logical. Should the estimates be chosen be optimize the restricted log-likelihood (REML) criterial (as opposed to the log-likelihood)?
Inherit from lme4
package. It is a list (of correct
class, resulting from lmerControl() or glmerControl() respectively)
containing control parameters, including the nonlinear optimizer to
be used and parameters to be passed through to the nonlinear optimizer,
see the lmerControl
documentation in lme4
package for details.
Inherit from lme4
package. It is a named list of
starting values for the parameters in the model.
Inherit from lme4
package. It is an 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.
optional expression selecting the subset of the rows of data to fit the model.
an optional vector of ‘prior weights’ to be used in the fitting process. Should be NULL or a numeric vector.
a function which indicates what should
happen when the data contain NAs.The default is set by the
na.action
setting in options
and is
na.fail
if that is unset.
Inherit from lme4
package. 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.
an optional list. The default is set as sum-to-zero contrast.
logical - return only the deviance evaluation function.
a character indicating the column name of origin.
a character indicating the column name of destination.
a character indicating the time when individual was observed
logical. Should model results be displayed
after estimation. The default is TRUE
.
additional arguments to be passed to the function.
library(MCM)
library(lme4)
data("sim_datlmer")
fit_mcm_lmer <- mcm_lmer(yij ~ origin*destination*age +
(1|id), data = sim_datlmer,
origin = "origin",
destination = "destination",
time = "age")
Run the code above in your browser using DataLab