Confirmatory Factor Analysis (CFA) Example in Mplus

Confirmatory Factor Analysis (CFA) Example in Mplus

Ben Kite

Center for Research Methods and Data Analysis, University of Kansas

Tags: SEM, CFA, R, Mplus

2019-02-08

Abstract: This guide outlines how to conduct a confirmatory factor analysis in Mplus. An example with six manifest variables measuring two latent factors is presented. The model estimation results can be compared to the same model fitted with the R lavaan package.

Table of Contents

1 TITLE Command

TITLE:
  Example 2 - Confirmatory Factor Analysis

2 DATA Command

DATA:
  FILE IS "../../data/job_placement.csv";

3 VARIABLE Command

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

  USEVARIABLES ARE
  wratcalc wjcalc waiscalc wratspl wjspl waisspl;

  MISSING ARE all(99999);

4 MODEL Command

There is typically no ANALYSIS command when conducting a basic CFA, instead the user needs a MODEL command. Here the CFA model to be tested is specified. There are two latent variables of interest, "MATH" and "SPELL". The "MATH" variable is measured by the "wratcalc", "wjcalc", and "waiscalc" variables; and "SPELL" is measured by "wratspl", "wjspl", and "waisspl" variables. The first two lines tell Mplus that the latent variables are measured by the listed manifest variables. The "BY" statement that separates the latent and manifest variables is what specifies that the variables on the left side are indicated or measured by the variables on the right. Further, the first variable in each indicator variable list is followed by an astrisk; this is used to indicate that those variables should have freely estimated factor loadings (the Mplus default is to set the factor loading for the first item to be 1 for identification purposes).

MODEL:
  MATH BY wratcalc* wjcalc waiscalc;
  SPELL BY wratspl* wjspl waisspl;

Because all factor loadings are freely estimated, the variances for each latent variable must be specified by the user in order for the model to be identified. The last line of this chapter shows that the variance for each latent variable is set to be equal to 1.

MATH@1 SPELL@1;

Mplus will also estimate the covariance between the latent variables by default.

5 OUTPUT Command

Here the user can request additional output.

OUTPUT:
  TECH1;
  STDYX;

6 Run the Model

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

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

Beginning Time:  13:19:42
   Ending Time:  13:19:43
  Elapsed Time:  00:00:01

Output saved in 'cfa-01.out'.

7 Review the Results

Click cfa-01.out to see the output.

8 The lavaan Example

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