Exploratory Factor Analysis (EFA) Example in Mplus

Exploratory Factor Analysis (EFA) Example in Mplus

Ben Kite

Center for Research Methods and Data Analysis, University of Kansas

Tags: Structural Equation Modeling, Exploratory Factor Analysis, Mplus

2019-02-08

Abstract: This guide outlines how to specify an exploratory factor analysis in R. An example with six manifest variables measuring one or two latent factors is presented. The model estimation results can be compared to the same model fitted with the R factanal package.

Table of Contents

1 TITLE Command

This is used to name your Mplus input file. Insert a memorable description of the exercise, so you can remember what it does when you return in the future.

TITLE:
Example 1 - Exploratory Factor Analysis;

2 DATA Command

This is where the data file is specified. If the data file is in the same folder as your .inp file, the user simply needs to specify the name of the file (e.g., "FILE IS job_placement.csv"). If the data file is in different folder, the user needs to specify the path to the datafile here. Below the "../../data/job_placement.csv" command is telling Mplus to start in the folder where the .inp file is saved, then go back two levels ("../../"), go into the "data" folder ("data/"), and then find the data file ("job_placement.csv"). Note that the FILE is line ends with a semicolon, this is required at the end of each line in all commands except the TITLE command. Remember, the datafile can only be a matrix of numerical values, no variable names are allowed in the imported data. Treatment options for missing data is also specified under the DATA command - pairwise deletion is the default in Mplus, "LISTWISE = ON" can be specified if the user wishes to use listwise deletion.

DATA:
  FILE IS "../../data/job_placement.csv";
  LISTWISE = ON;

3 VARIABLE Command

Once the data file is read in, information about the dataset must be provided. This is done in the VARIABLE command. There are no variable names in the data file, so these must be entered here by the user. Under "NAMES ARE", the user must list the variable columns in the data file from left to right. It is extremely important that the number of variables and the order of the variables are entered correctly.

VARIABLE:
  NAMES ARE
  id wjcalc wjspl wratspl wratcalc waiscalc waisspl
  edlevel newschl suspend expelled haveld female age;

After the variables in the data file are named, the user can then specify which variables they want to include in the model under "USEVARIABLES ARE". In this example the user wants to run an EFA with six indicator variables, so only those six variables are entered into the "USEVARIABLES ARE" command.

USEVARIABLES ARE
wjcalc wjspl wratspl wratcalc waiscalc waisspl;

Lastly, there are missing values in the data file that have been replaced with "99999". The "MISSING ARE all (99999);" command tells Mplus that all values equal to 99999 are not truly equal to 99999 and that they should be treated as missing.

MISSING ARE all(99999);

4 ANALYSIS Command

The ANALYSIS command can be used to specify a variety of analyses. Here the line "TYPE = EFA 1 2;" is telling Mplus to do an EFA and to fit models with 1 and 2 factors, plus all whole numbers in between (there are none in this case). If we were to enter "TYPE = EFA 1 3;", then Mplus would test models with 1, 2, and 3 latent factors.

ANALYSIS:
  TYPE = EFA 1 2;
  ROTATION = VARIMAX;

5 Run the Model

mplus efa-01.inp
Mplus VERSION 8.2 (Linux)
MUTHEN & MUTHEN

Running input file 'efa-01.inp'...

Beginning Time:  12:51:25
   Ending Time:  12:51:25
  Elapsed Time:  00:00:00

Output saved in 'efa-01.out'.

6 Review the Results

Click efa-01.out to see the output.

7 The R factanal Package Example

Last Updated 2019-02-08 Fri 12:51. Created by Emacs 25.1.1 (Org mode 9.1.13)