You know the saying, “it’s not on the outside that matters, it what’s on the inside that counts”? Well, that’s certainly the case with Mplus. It’s time to get a taste of what Mplus really has to offer with it’s very simple and intuitive syntax.

A good place to start is a blank slate. When you open up a new syntax window, that’s what you get. Oftentimes I’ll copy an old syntax and just replace the details, but it’s typically a wise decision to get a sense of the required syntax and how it works so that you can quickly troubleshoot when the time comes when Mplus refuses to run.

**Let’s get started with a few general notes (albeit very important notes – details matter in Mplus!):**

- All command headings/lines
__must__ be followed by a colon (:) and will turn blue
- Subcommands and syntax lines
__must__ be followed by a semicolon (;)
- Use an exclamation point (!) to make short notes that will turn green and Mplus does not read (note: if your note is not green, this means you forgot the exclamation point!)

**Next, I’ll go through the command lines and their respective subcommands.**

**TITLE:** ! command allows you to name or label what you are testing

Simply the best title ever; ! This is an example title

! Helpful for keeping track of multiple analyses, although I often forget to change this!

**DATA: **! command provides info about the dataset to be analyzed

! I will have a detailed post on getting your data into Mplus, but here are a couple helpful notes:

! Two types of data can be entered: individual data and summary data (see type subcommand below)

! Store data in the same folder as the Mplus syntax (for ease, otherwise must specify full path to file)

! Data Subcommands:

File is FILENAME.dat; ! Tells Mplus where the data file is stored

Type = !means stdeviations correlation; !can import individual or summary data, default is individual

Nobservations = !___; !this command tells MPlus # of observations when type = summary data

**VARIABLE:** ! command provides info about the variables in the dataset to be analyzed

!Names of variables MUST NOT exceed 8 characters

! Variable subcommands:

names are ! list your variables here; !this tells MPlus which variables are in the whole data set – you could also use the subcommand “Names=”

categorical are ! X1; ! describes type of variable, Mplus assumes variables are continuous unless told otherwise, can specify categorical, nominal, count, etc.

missing are all(-999); ! Must replace missing data with identifier (e.g., -999) before importing data

usevariables = ! list variables you want to use in analysis here;

!If variables are sequential you can simply place a hyphen between the first and last variables (e.g., for X1, X2, X3, X4 you can put X1-X4)

!If variables are created in define command below, add them to END of usevariables list

**DEFINE:** ! command used to transform existing variables and create new variables

! Define subcommands: you can…

! create new variables, “X12 = (X1 + X2)/2;” OR “X12 = mean(X1 X2);”

! create interaction terms, “int = X1*X2;”

! provide conditional statements, “IF (X1 EQ 1) THEN group = 1;” “IF (X1 EQ 2) THEN group = 2;” Mplus creates variable “group”

! make transformations,

! create parcels, X = mean(X1 X2 X3)

! center variables, “Center X1 X2 X3 (grandmean);”

**ANALYSIS:** ! command used to describe the nature of the analysis

! Analysis subcommands:

! Type = twolevel; ! nature of the model, default is general for typically don’t have to specify unless doing multilevel analysis (for SEM, regression)

! Estimator = ML; ! Tells Mplus which estimator you want to use, such as ML or Bayes

! Bootstrap = 10000; !Tells Mplus the number of bootstrap samples you want

**MODEL:** ! command used to describe the model to be estimated

!Three Fundamental commands:

! “ON”

! used to specify regression path (B matrix)

! Y on X1 X2; !regress Y on X1 and X1 or X1 and X2 predict Y

! “WITH”

! Used to specify covariance/correlation *double-headed arrow

! X1 with X2 !can be covariance between observed or latent variables

! “BY”

! Used to specify factor loadings

! X by X1 X2 X3;

! By default, first loading is fixed to 1.0 (similar to other programs)

!Some other things you can do under the model command:

!Constrain a parameter

! Y on X1@.25; ! Fixes regression weight of X1 to .25

! [X1@0]; ! Constrains X1 intercept to 0

! Label or name parameters/paths:

! M on X (a);

! Y on M (b);

! Y on X (c);

!These paths can then be used later for fun things in the model constrain command

!Constrain effects of IVs on DV to be equal:

!Y on X M (a);

**MODEL CONSTRAINT: **! Command used for applying your labelled parameters

! Example: mediation using labelled parameters above

new (med total);

med = a*b;

total = a*b+c;

**MODEL INDIRECT: **! Command designed for testing mediation effects

! Mplus provides total and indirect effects (similar to PROCESS macro in SPSS)

! Combine with bootstrap option in analysis to get bootstrapped indirect effects

! If using Bayes estimator, do not use this, but rather use model constraint above

**OUTPUT: **! Command used to request additional info not included in default

! Put all desired commands into a single line of syntax

! Popular output subcommand examples:

! standardized(all); !provides standardized estimates and standard errors

! sampstat; !provides sample statistics (e.g., sample means, (co)variances, correlations)

! modindices(all); !for SEM analyses, provides modification indices for model fit

! residual; !requests residuals for the observed variables in the model

! CInterval; request confidence (bootstrap)/credibility(HPD) intervals

! Tech1-16; Requests a variety of additional info on analysis

! Tech1; parameter specification and starting values

! Tech3; request estimated covariance and correlation matrices

! Tech4; means, covariances, correlations for latent variables

! Tech8; requests the optimization history in estimating the model (shows how long the analysis takes)

! See p.713+ of Mplus manual for other output subcommands

**SAVEDATA: **! Command saves sample correlation and covariance matrices in separate ASCII file

! Savedata subcommands:

FILE IS output.sav;

! SAMPLE is output.sav; !speficies file name for sample statistics to be saved

! RESULTS ARE output.sav; !specifies name of file in which results of an analysis will be saved

!See p.744+ of manual for all save subcommands

**PLOT:** ! Command used to request graphical displays of observed data and results

! Plot subcommands:

! Type=PLOT1-3; used to specify types of plots (3 settings)

! PLOT1; see p. 763 in manual

! PLOT2; see p. 764

! PLOT3; see p. 765

!plot command does not work on Macs yet unfortunately, but I do have a how to guide for plotting Mplus outputs in R

So those are essentially the basic commands, subcommands, and a little bit of syntax. It may seem like a lot, but rarely will you need very much to run a single analysis. Here is an example of plausible input with a factor loading and a latent factor predicting an observed factor and a copy-and-paste basic template:

TITLE:
ENTER TITLE HERE;
DATA:
File is ENTERFILENAMEHERE.dat;
VARIABLE:
names are ENTER VARIABLE NAMES HERE;
missing are all(-999); !or whatever your missing value ID value is
usevariables = ENTER VARIABLES TO BE USED;
ANALYSIS:
estimator = ML;
MODEL:
ENTER YOUR DESIRED ANALYSIS HERE
! ON for regression
! BY for factor analyses
! WITH for correlation
OUTPUT:
Standardized Sampstat;

Seems pretty straight forward, eh?