mplus.update: Mplus Input Updating

View source: R/mplus.update.R

mplus.updateR Documentation

Mplus Input Updating

Description

This function updates specific input command sections of a misty.object of type mplus to create an updated Mplus input file, run the updated input file by using the mplus.run() function, and print the updated Mplus output file by using the mplus.print() function.

Usage

mplus.update(x, update, file = "Mplus_Input_Update.inp",
             replace.inp = TRUE, mplus.run = TRUE,
             show.out = FALSE, replace.out = c("always", "never", "modified"),
             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)

Arguments

x

misty.object object of type mplus.

update

a character vector containing the updated input command sections.

file

a character string indicating the name of the updated Mplus input file with or without the file extension .inp, e.g., "Mplus_Input_Update.inp" or "Mplus_Input_Update".

replace.inp

logical: if TRUE (default), an existing input file will be replaced.

mplus.run

logical: if TRUE, the input file specified in the argument file containing the input text specified in the argument x is run using the mplus.run function.

show.out

logical: if TRUE, estimation output (TECH8) is show on the R console. Note that if run within Rgui, output will display within R, but if run via Rterm, a separate window will appear during estimation.

replace.out

a character string for specifying three settings: "always" (default), which runs all models, regardless of whether an output file for the model exists, "never", which does not run any model that has an existing output file, and "modified", which only runs a model if the modified date for the input file is more recent than the output file modified date.

print

a character vector indicating which results to show, i.e. "all" (default) for all results "input" for input command sections, and "result" for result sections.

input

a character vector specifiying Mplus input command sections included in the output (see 'Details' in the mplus.print function).

result

a character vector specifiying Mplus result sections included in the output (see 'Details' in the mplus.print function).

exclude

a character vector specifiying Mplus input command or result sections excluded from the output (see 'Details' in the mplus.print function).

variable

logical: if TRUE, names of the variables in the data set (NAMES ARE) specified in the VARIABLE: command section are shown. By default, names of the variables in the data set are excluded from the output unless all variables are used in the analysis (i.e., no USEVARIABLES command specified in the Mplus input file).

not.input

logical: if TRUE (default), character vector indicating the input commands not requested are shown on the console.

not.result

logical: if TRUE (default), character vector indicating the result sections not requested are shown on the console.

write

a character string naming a file for writing the output into a text file with file extension ".txt" (e.g., "Output.txt").

append

logical: if TRUE (default), output will be appended to an existing text file with extension .txt specified in write, if FALSE existing text file will be overwritten.

check

logical: if TRUE (default), argument specification is checked.

output

logical: if TRUE (default), output is shown on the console by using the function mplus.print.

Details

The ... Specification

The ... Specification can be used to update specific options in the VARIABLE and ANALYSIS section, while keeping all other options in the misty.object of type mplus specified in the argument x. Note that the ... specification is only available for the VARIABLE and ANALYSIS section.

The ---; Specification

can be used to remove entire sections (e.g., OUTPUT: ---;) or options within the VARIABLE: and ANALYSIS: section (e.g., ANALYSIS: ESTIMATOR IS ---;) from the Mplus input.

Comments in the Mplus Input

Comments in the Mplus Input can cause problems when following keywords in uppercase, lower case, or mixed upper and lower case letters are involved in the comments of the VARIABLE and ANALYSIS section:

  • VARIABLE section: "NAMES", "USEOBSERVATIONS", "USEVARIABLES", "MISSING", "CENSORED", "CATEGORICAL", "NOMINAL", "COUNT", "DSURVIVAL", "GROUPING", "IDVARIABLE", "FREQWEIGHT", "TSCORES", "AUXILIARY", "CONSTRAINT", "PATTERN", "STRATIFICATION", "CLUSTER", "WEIGHT", "WTSCALE", "BWEIGHT", "B2WEIGHT", "B3WEIGHT", "BWTSCALE", "REPWEIGHTS", "SUBPOPULATION", "FINITE", "CLASSES", "KNOWNCLASS", "TRAINING", "WITHIN", "BETWEEN", "SURVIVAL", "TIMECENSORED", "LAGGED", or "TINTERVAL".

  • ANALYSIS section: "TYPE", "ESTIMATOR", "MODEL", "ALIGNMENT", "DISTRIBUTION", "PARAMETERIZATION", "LINK", "ROTATION", "ROWSTANDARDIZATION", "PARALLEL", "REPSE", "BASEHAZARD", "CHOLESKY", "ALGORITHM", "INTEGRATION", "MCSEED", "ADAPTIVE", "INFORMATION", "BOOTSTRAP", "LRTBOOTSTRAP", "STARTS", "STITERATIONS", "STCONVERGENCE", "STSCALE", "STSEED", "OPTSEED", "K-1STARTS", "LRTSTARTS", "RSTARTS", "ASTARTS", "H1STARTS", "DIFFTEST", "MULTIPLIER", "COVERAGE", "ADDFREQUENCY", "ITERATIONS", "SDITERATIONS", "H1ITERATIONS", "MITERATIONS", "MCITERATIONS", "MUITERATIONS", "RITERATIONS", "AITERATIONS", "CONVERGENCE", "H1CONVERGENCE", "LOGCRITERION", "RLOGCRITERION", "MCONVERGENCE", "MCCONVERGENCE", "MUCONVERGENCE", "RCONVERGENCE", "ACONVERGENCE", "MIXC", "MIXU", "LOGHIGH", "LOGLOW", "UCELLSIZE", "VARIANCE", "SIMPLICITY", "TOLERANCE", "METRIC", "MATRIX", "POINT", "CHAINS", "BSEED", "STVALUES", "PREDICTOR", "ALGORITHM", "BCONVERGENCE", "BITERATIONS", "FBITERATIONS", "THIN", "MDITERATIONS", "KOLMOGOROV", "PRIOR", "INTERACTIVE", or "PROCESSORS".

Note that it is recommended to remove all comments in the VARIABLE and VARIABLE section when the function crashes.

Value

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 (input) and result sections (input)

Author(s)

Takuya Yanagida

References

Muthen, L. K., & Muthen, B. O. (1998-2017). Mplus User's Guide (8th ed.). Muthen & Muthen.

See Also

read.mplus, write.mplus, mplus.print, mplus, mplus.run, mplus.lca

Examples

## Not run: 
#----------------------------------------------------------------------------
# Example 1: Update VARIABLE and MODEL section

# Write Mplus Data File
write.mplus(ex3_1, file = "ex3_1.dat")

# Specify Mplus input
input <- '
DATA:     FILE IS ex3_1.dat;
VARIABLE: NAMES ARE y1 x1 x3;
MODEL:    y1 ON x1 x3;
OUTPUT:   SAMPSTAT;
'

# Run Mplus input
mod0 <- mplus(input, file = "ex3_1.inp")

# Update VARIABLE and MODEL section
update1 <- '
VARIABLE: ...
          USEVARIABLES ARE y1 x1;
MODEL:    y1 ON x1;
'

# Run updated Mplus input
mod1 <- mplus.update(mod1, update1, file = "ex3_1_update1.inp")

#----------------------------------------------------------------------------
# Example 2: Update ANALYSIS section

# Update ANALYSIS section
update2 <- '
ANALYSIS: ESTIMATOR IS MLR;
'

# Run updated Mplus input
mod2 <- mplus.update(mod2, update2, file = "ex3_1_update2.inp")

#----------------------------------------------------------------------------
# Example 3: Remove OUTPUT section

Remove OUTPUT section
update3 <- '
OUTPUT: ---;
'

# Run updated Mplus input
mod3 <- mplus.update(mod3, update3, file = "ex3_1_update3.inp")

## End(Not run)

misty documentation built on June 29, 2024, 9:07 a.m.

Related to mplus.update in misty...