createSyntax: Create the Mplus input text for an mplusObject

Description Usage Arguments Value Author(s) See Also Examples

View source: R/mplus.R

Description

This function takes an object of class mplusObject and creates the Mplus input text corresponding to it, including data link and variable names.

Usage

1
createSyntax(object, filename, check = TRUE, add = FALSE, imputed = FALSE)

Arguments

object

An object of class mplusObject

filename

The name of the data file as a character vector

check

A logical indicating whether or not to run parseMplus on the created input file. Checks for errors like lines that are too long, or for missing semi-colons and gives notes.

add

A logical passed on to parseMplus whether to add semi colons to line ends. Defaults to FALSE.

imputed

A logical whether the data are multiply imputed. Defaults to FALSE.

Value

A character string containing all the text for the Mplus input file.

Author(s)

Joshua F. Wiley <jwiley.psych@gmail.com>

See Also

prepareMplusData, mplusModeler

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
# example mplusObject
example1 <- mplusObject(MODEL = "mpg ON wt;",
  usevariables = c("mpg", "hp"), rdata = mtcars)

# create the Mplus input text
cat(createSyntax(example1, "example1.dat"), file=stdout(), fill=TRUE)

# update the object, then create input text
cat(createSyntax(update(example1,
  TITLE = ~ "This is my title;",
  MODEL = ~ . + "\nmpg ON hp;",
  usevariables = c("mpg", "hp", "wt")), "example1.dat"),
  file=stdout(),
  fill=TRUE)
rm(example1)

Example output

sh: 1: cannot create /dev/null: Permission denied
Version:  0.7-3
We work hard to write this free software. Please help us get credit by citing: 

Hallquist, M. N. & Wiley, J. F. (2018). MplusAutomation: An R Package for Facilitating Large-Scale Latent Variable Analyses in Mplus. Structural Equation Modeling, 25, 621-638. doi: 10.1080/10705511.2017.1402334.

-- see citation("MplusAutomation").
All ok
DATA:
FILE = "example1.dat";
 
VARIABLE:
NAMES = mpg hp; 
 MISSING=.;
 
MODEL:
mpg ON wt;
R variables selected automatically as any variable name that
occurs in the MODEL, VARIABLE, or DEFINE section.
If any issues, suggest explicitly specifying USEVARIABLES.
A starting point may be:
USEVARIABLES = mpg hp wt;
All ok
TITLE:
 This is my title;
DATA:
FILE = "example1.dat";
 
VARIABLE:
NAMES = mpg hp wt; 
 MISSING=.;
 
MODEL:
mpg ON wt;
 
mpg ON hp;

MplusAutomation documentation built on July 1, 2021, 9:07 a.m.