This function implements the mobility contrast model designed for estimating and testing inter-generational mobility effect on an outcome.
mcm(
formula,
data,
weights = 1,
na.action = na.omit,
origin,
destination,
family = gaussian(),
contrasts = NULL,
gee = FALSE,
id = NULL,
corstr = "exchangeable",
displayresult = TRUE,
...
)
A list containing:
Fitted generalized models of outcome on predictors.
See more on function glm
in package stats
.
Estimated main effects of origin.
Estimated main effects of destination.
Estimated mobility effects.
Standard errors of the estimated mobility effects.
Statistical significance of the the estimated mobility effects.
an object of class "formula" (or one that can
be coerced to that class): a symbolic description of the model
to be fitted. A typical model used in studying social mobility
takes the form response ~ origin*destination
, 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
.
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.
an optional vector of unit-level sampling weights to be used in analysis. 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.
a character indicating the column name of origin.
a character indicating the column name of destination.
a character string, a function or the result of a call to a family function describing the error distribution and link function to be used in the model.
an optional list. The default is set as sum-to-zero contrast.
logical. Should gee be used in estimating the model?
a vector which identifies the clusters, which is required while
gee
is used. The length of id
should be the same as
the number of observations. Data are assumed to be sorted
so that observations on a cluster are contiguous rows for
all entities in the formula.
a character string specifying
the correlation structure.
The following are permitted: "independence"
,
"fixed"
,
"stat_M_dep"
,
"non_stat_M_dep"
, "exchangeable"
,
"AR-M"
and "unstructured"
.
logical. Should model results be displayed
after estimation. The default is TRUE
.
additional arguments to be passed to the function.
library(MCM)
data('sim_moderate_het')
mcm(response ~ origin * destination, data = sim_moderate_het,
origin = "origin",destination="destination")
Run the code above in your browser using DataLab