mplus | R Documentation |
This wrapper function creates a Mplus input file, runs the input file by using
the mplus.run()
function, and prints the Mplus output file by using the
mplus.print()
function.
mplus(x, file = "Mplus_Input.inp", data = NULL, comment = FALSE,
replace.inp = TRUE, mplus.run = TRUE, show.out = FALSE,
replace.out = c("always", "never", "modified"), Mplus = detect.mplus(),
print = c("all", "input", "result"),
input = c("all", "default", "data", "variable", "define", "analysis",
"model", "montecarlo", "mod.pop", "mod.cov", "mod.miss",
"message"),
result = c("all", "default", "summary.analysis.short",
"summary.data.short", "random.starts", "summary.fit",
"mod.est", "fit", "class.count", "classif", "mod.result",
"total.indirect"),
exclude = NULL, variable = FALSE, not.input = TRUE, not.result = TRUE,
write = NULL, append = TRUE, check = TRUE, output = TRUE)
x |
a character string containing the Mplus input text. |
file |
a character string indicating the name of the Mplus input
file with or without the file extension |
data |
a matrix or data frame from which the variables names for
the subsection |
comment |
logical: if |
replace.inp |
logical: if |
mplus.run |
logical: if |
show.out |
logical: if |
replace.out |
a character string for specifying three settings:
|
Mplus |
a character string for specifying the name or path of the Mplus executable to be used for running models. This covers situations where Mplus is not in the system's path, or where one wants to test different versions of the Mplus program. Note that there is no need to specify this argument for most users since it has intelligent defaults. |
print |
a character vector indicating which results to show, i.e.
|
input |
a character vector specifying Mplus input command sections
included in the output (see 'Details' in the |
result |
a character vector specifying Mplus result sections included
in the output (see 'Details' in the |
exclude |
a character vector specifying Mplus input command or result
sections excluded from the output (see 'Details' in the
|
variable |
logical: if |
not.input |
logical: if |
not.result |
logical: if |
write |
a character string naming a file for writing the output into
a text file with file extension |
append |
logical: if |
check |
logical: if |
output |
logical: if |
NAMES
OptionThe NAMES
option in the VARIABLE
section used to assign names to the variables in the data set can be specified by using the
data
argument:
Write Mplus Data File
: In the first step, the Mplus data
file is written by using the write.mplus()
function, e.g.
write.mplus(ex3_1, file = "ex3_1.dat")
.
Specify Mplus Input
: In the second step, the Mplus input
is specified as a character string. The NAMES
option is left out
from the Mplus input text, e.g.,
input <- 'DATA: FILE IS ex3_1.dat;\nMODEL: y1 ON x1 x3;'
.
Run Mplus Input
: In the third step, the Mplus input is run
by using the mplus()
function. The argument data
needs to be specified given that the NAMES
option was left out from
the Mplus input text in the previous step, e.g.,
mplus(input, file = "ex3_1.inp", data = ex3_1)
.
Returns an object of class misty.object
, which is a list with following
entries:
call |
function call |
type |
type of analysis |
x |
a character vector containing the Mplus input text |
args |
specification of function arguments |
input |
list with input command sections |
write |
write command sections |
result |
list with input command sections ( |
Takuya Yanagida
Muthen, L. K., & Muthen, B. O. (1998-2017). Mplus User's Guide (8th ed.). Muthen & Muthen.
read.mplus
, write.mplus
, mplus.update
,
mplus.print
, mplus.plot
, mplus.bayes
,
mplus.run
, mplus.lca
## Not run:
#----------------------------------------------------------------------------
# Example 1: Write data, specify input, and run input
# Write Mplus Data File
write.mplus(ex3_1, file = "ex3_1.dat")
# Specify Mplus input, specify NAMES option
input1 <- '
DATA: FILE IS ex3_1.dat;
VARIABLE: NAMES ARE y1 x1 x3;
MODEL: y1 ON x1 x3;
OUTPUT: SAMPSTAT;
'
# Run Mplus input
mplus(input1, file = "ex3_1.inp")
#----------------------------------------------------------------------------
# Example 2: Alternative specification using the data argument
# Specify Mplus input, leave out the NAMES option
input2 <- '
DATA: FILE IS ex3_1.dat;
MODEL: y1 ON x1 x3;
OUTPUT: SAMPSTAT;
'
# Run Mplus input, specify the data argument
mplus(input2, file = "ex3_1.inp", data = ex3_1)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.