Learn R Programming

MplusAutomation (version 0.6-1)

mplusObject: Create an Mplus model object

Description

This is a function to create an Mplus model object in R. The object holds all the sections of an Mplus input file, plus some extra R ones. Once created, the model can be run using other functions such as mplusModeler or updated using methods defined for the update function.

Usage

mplusObject(TITLE = NULL, DATA = NULL, VARIABLE = NULL,
    DEFINE = NULL, ANALYSIS = NULL, MODEL = NULL,
    OUTPUT = NULL, SAVEDATA = NULL, PLOT = NULL,
    usevariables = NULL, rdata = NULL)

Arguments

TITLE
A character string of the title for Mplus.
DATA
A charater string of the data section for Mplus (note, do not define the filename as this is generated automatically)
VARIABLE
A character string of the variable section for Mplus (note, do not define the variable names from the dataset as this is generated automatically)
DEFINE
A character string of the define section for Mplus (optional)
ANALYSIS
A character string of the analysis section for Mplus (optional)
MODEL
A character string of the model section for Mplus (optional, although typically you want to define a model)
OUTPUT
A character string of the output section for Mplus (optional)
SAVEDATA
A character string of the savedata section for Mplus (optional)
PLOT
A character string of the plot section for Mplus (optional)
usevariables
A character vector of the variables from the R dataset to use in the model.
rdata
An R dataset to be used for the model.

Value

  • A list of class mplusObject with elements
  • TITLEThe title in Mplus (if defined)
  • DATAThe data section in Mplus (if defined)
  • VARIABLEThe variable section in Mplus (if defined)
  • DEFINEThe define section in Mplus (if defined)
  • ANALYSISThe analysis section in Mplus (if defined)
  • MODELThe model section in Mplus (if defined)
  • OUTPUTThe output section in Mplus (if defined)
  • SAVEDATAThe savedata section in Mplus (if defined)
  • PLOTThe plot section in Mplus (if defined)
  • resultsNULL by default, but can be later updated to include the results from the model run.
  • usevariablesA character vector of the variables from the R data set to be used.
  • rdataThe R data set to use for the model.

Details

Mplus model objects allow a base model to be defined, and then flexibly update the data, change the precise model, etc. If a section does not vary between models, you can leave it the same. For example, suppose you are fitting a number of models, but in all cases, wish to use maximum likelihood estimator, ANALYSIS: ESTIMATOR = ML; and would like standardized output, OUTPUT: STDYX;. Rather than retype those in every model, they can be defined in one Mplus model object, and then that can simply be updated with different models, leaving the analysis and output sections untouched. This also means that if a reviewer comes back and asks for all analyses to be re-run say using the robust maximum likelihood estimator, all you have to do is change it in the model object once, and re run all your code.

See Also

mplusModeler

Examples

Run this code
example1 <- mplusObject(MODEL = "mpg ON wt;",
  usevariables = c("mpg", "hp"), rdata = mtcars)
str(example1)
rm(example1)

Run the code above in your browser using DataLab