
Run alignment procedure using Mplus
runAlignment.RdFacilitates running alignmnet procedure in Mplus. It creates Mplus input and data from R data.frame, runs the input using Mplus, and returns its summaries back in R.
Arguments
- model
Character. Formula in Mplus format, e.g. "Factor1 BY item1 item2 item3 item4; item4 WITH item3;", see example.
- group
Character, name of the grouping variable.
- dat
Data frame containing data.
- categorical
Character vector of variable names. Indicators that are binary or ordinal. Default is NULL.
- sim.samples
Vector of integers. Group sample sizes for simulation, the length of this vector also determines a number of simulation studies. Default is `c(100, 500, 1000)`. May take a substantial amount of time. Use NULL to avoid running simulations.
- sim.reps
A number of simulated datasets in each simulation. Default is 500. Use 0 to avoid running simulations.
- Mplus_com
Sometimes you don't have a direct access to Mplus, so this argument specifies what to send to a system command line. Default value is "mplus".
- path
Where all the .inp, .out, and .dat files should be stored?
- summaries
If the
extractAlignmentandextractAlignmentSimshould be run after all the Mplus work is done. Default is FALSE.- estimator
Could be any estimator supported by Mplus. Default is "MLR".
- listwise
`Listwise` option of Mplus; whether the missing values should be deleted listwise.
- processors
`Processors` option of Mplus.
Details
The function runs in four steps to facilitate setting up and running alignment:
Converts data.drame into a dat file compatible with Mplus. Saves it on the disk.
Creates Mplus input file for free alignemnent. Saves it on the disk.
Runs this input using the saved data, which produces an .out file.
Reads in the output, selects the appropriate reference group, creates a new input file for fixed alignment, and runs it.
(Optional) Runs simulations to check the reliability of the fixed alignment results.
(Optional) Using
extractAlignmentand/orextractAlignmentSimreads in the output file of the fixed alignment and summarizies them in a convenient, publishable tables.
The sequence of free, fixed alignment and simulations follows recommendations of Muthen & Asparouhov (2014).
All the files created during these steps stay on the disk and can be used independently for reporting. For a detailed tutorial on alignment in general see https://maksimrudnev.com/2019/05/01/alignment-tutorial/
See also
extractAlignment, extractAlignmentSim, extractAlignmentSim, measurementInvarianceMplus