Learn R Programming

MCM (version 0.1.7)

mcm: Estimate and Test Inter-generational Social Mobility Effect on an Outcome

Description

This function implements the mobility contrast model designed for estimating and testing inter-generational mobility effect on an outcome.

Usage

mcm(
  formula,
  data,
  weights = 1,
  na.action = na.omit,
  origin,
  destination,
  family = gaussian(),
  contrasts = NULL,
  gee = FALSE,
  id = NULL,
  corstr = "exchangeable",
  displayresult = TRUE,
  ...
)

Value

A list containing:

model

Fitted generalized models of outcome on predictors. See more on function glm in package stats.

origin_main

Estimated main effects of origin.

destination_main

Estimated main effects of destination.

mobility_estimates

Estimated mobility effects.

mobility_se

Standard errors of the estimated mobility effects.

mobility_sig

Statistical significance of the the estimated mobility effects.

Arguments

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 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.

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 na.action setting in options and is na.fail if that is unset.

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 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.

corstr

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".

displayresult

logical. Should model results be displayed after estimation. The default is TRUE.

...

additional arguments to be passed to the function.

Examples

Run this code
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