The R package MCM for implementing the mobility contrast model

Update 02/07/2023: functions added to the MCM_STATA command to extract standard errors and p-values for immobility parameters, origin and destination main effects.

Update 10/06/2021: the R package MCM is now on CRAN: https://cran.r-project.org/web/packages/MCM/index.html

The Stata command MCM_STATA can be downloaded from https://github.com/Jiahui1902/MCM_STATA.

Title: How to use the R package MCM to implement the mobility contrast model

Authors: Liying Luo (liyingluo@psu.edu) and Jiahui Xu (jiahuixu@psu.edu)

MCM_0.1.0.tar  Version: 7/7/2021

Step 1. Download and save the attached tar.gz file on your local computer drive.

Step 2. Using the following code to install and load the package MCM in R
install.packages(‘[insert file path]/MCM_0.1.0.tar.gz’, repos = NULL, type=”source”)
library(MCM)

Step 3. Use the function mcm to implement the method. Note that origin and destination variables are assumed to be categorical.

mcm(y ~ x0*x1, origin = ‘x0’, destination = ‘x1’, mydata, family = gaussian())

where y is the outcome, x0 is the variable name for origin, x1 is the variable name for destination. Replace y, x0, and x1 with the variable names in your data set (named mydata in the example). Family is gaussian by default, Poisson for log linear models, or binomial for logistic models.