| Title: | Estimating and Testing Intergenerational Social Mobility Effect |
|---|---|
| Description: | Estimate and test inter-generational social mobility effect on an outcome with cross-sectional or longitudinal data. |
| Authors: | Jiahui Xu [aut, cre], Liying Luo [aut] |
| Maintainer: | Jiahui Xu <[email protected]> |
| License: | GPL-2 |
| Version: | 0.1.7 |
| Built: | 2026-06-07 09:22:20 UTC |
| Source: | https://github.com/jiahui1902/mcm |
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, ... )mcm( formula, data, weights = 1, na.action = na.omit, origin, destination, family = gaussian(), contrasts = NULL, gee = FALSE, id = NULL, corstr = "exchangeable", displayresult = TRUE, ... )
formula |
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 |
data |
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. |
weights |
an optional vector of unit-level sampling weights to be used in analysis. Should be NULL or a numeric vector. |
na.action |
a function which indicates what should
happen when the data contain NAs.The default is set by the
|
origin |
a character indicating the column name of origin. |
destination |
a character indicating the column name of destination. |
family |
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. |
contrasts |
an optional list. The default is set as sum-to-zero contrast. |
gee |
logical. Should gee be used in estimating the model? |
id |
a vector which identifies the clusters, which is required while
|
corstr |
a character string specifying
the correlation structure.
The following are permitted: |
displayresult |
logical. Should model results be displayed
after estimation. The default is |
... |
additional arguments to be passed to the function. |
A list containing:
model |
Fitted generalized models of outcome on predictors.
See more on function |
origin_main |
Estimated main effects of origin. |
destination_main |
Estimated main effects of destination. |
immobile |
Estimated effects for the people without social mobility. |
mobility_estimates |
Estimated mobility effects. |
mobility_se |
Standard errors of the estimated mobility effects. |
mobility_sig |
Statistical significance of the the estimated mobility effects. |
library(MCM) data('sim_moderate_het') mcm(response ~ origin * destination, data = sim_moderate_het, origin = "origin",destination="destination")library(MCM) data('sim_moderate_het') mcm(response ~ origin * destination, data = sim_moderate_het, origin = "origin",destination="destination")
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, ... )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, ... )
formula |
Inherit the function form from |
data |
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. |
REML |
logical. Should the estimates be chosen be optimize the restricted log-likelihood (REML) criterial (as opposed to the log-likelihood)? |
control |
Inherit from |
start |
Inherit from |
verbose |
Inherit from |
subset |
optional expression selecting the subset of the rows of data to fit the model. |
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 which indicates what should
happen when the data contain NAs.The default is set by the
|
offset |
Inherit from |
contrasts |
an optional list. The default is set as sum-to-zero contrast. |
devFunOnly |
logical - return only the deviance evaluation function. |
origin |
a character indicating the column name of origin. |
destination |
a character indicating the column name of destination. |
time |
a character indicating the time when individual was observed |
displayresult |
logical. Should model results be displayed
after estimation. The default is |
... |
additional arguments to be passed to the function. |
A list containing:
model |
Fitted generalized models of outcome on predictors.
See more on function |
estimates |
Estimated mobility effects. |
se |
Standard errors of the estimated mobility effects. |
significance |
Statistical significance of the the estimated mobility effects. |
esti_3way |
Estimated mobility effects conditional on specific age. |
se_3way |
Standard errors of the estimated mobility effects conditional specific age. |
sig_3way |
Statistical significance of the the estimated mobility effects conditional on age. |
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")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")
This is a simulated data used to study social mobility under longitudinal setting.
data("sim_datlmer")data("sim_datlmer")
A data frame with 50000 observations on the following 14 variables.
idan ordered factor with levels
obsa numeric vector
eija numeric vector
origina factor with levels 1 2 3
destinationa factor with levels 1 2 3
origin_1a numeric vector
origin_2a numeric vector
origin_3a numeric vector
destination_1a numeric vector
destination_2a numeric vector
destination_3a numeric vector
yija numeric vector
agea numeric vector
dira factor with levels 0 1 2
data(sim_datlmer) ## maybe str(sim_datlmer) ; plot(sim_datlmer) ...data(sim_datlmer) ## maybe str(sim_datlmer) ; plot(sim_datlmer) ...
This is a simulated data used to study social mobility. In this dataset, it is assumed that there exists a moderate social mobility.
data("sim_moderate_het")data("sim_moderate_het")
A data frame with 30,000 observations on the following 6 variables.
responsea numeric vector indicating the outcome variable
origina numeric vector indicating parents' socioeconomic status
destinationa numeric vector indicating child' socioeconomic status
mobilitya numeric vector indicating if child's socioeconomic status is diffferent from that of parents'.
upmoba numeric vector indicating child' socioeconomic status is higher than that of parents'.
dowmoba numeric vector indicating child' socioeconomic status is lower than that of parents'.
data(sim_moderate_het) head(sim_moderate_het)data(sim_moderate_het) head(sim_moderate_het)