runAlignment | R Documentation |
Facilitates 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.
runAlignment(
model,
group,
dat,
categorical = NULL,
sim.samples = c(100, 500, 1000),
sim.reps = 500,
Mplus_com = "mplus",
path = getwd(),
summaries = FALSE,
estimator = "MLR",
parameterization = NULL,
listwise = "OFF",
processors = 2
)
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 |
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. |
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 extractAlignment
and/or extractAlignmentSim
reads 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/
## Not run: aling.res = runAlignment(model = "Moral1 BY prostit homosex abortion divorce;
Moral2 BY benefits taxes bribes;",
group = "country",
dat = wvs.s1,
Mplus_com = "mplus",
summaries = T
)
## End(Not run)
@seealso extractAlignment
, extractAlignmentSim
, extractAlignmentSim
, measurementInvarianceMplus
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.