Confirmatory Factor Analysis: Step-by-Step in R
SEM

Confirmatory Factor Analysis: Step-by-Step in R

February 20, 202511 min read

Walk through a full CFA workflow from model specification to fit evaluation, modification indices, and reporting results in APA format.

What is Confirmatory Factor Analysis?

Confirmatory Factor Analysis (CFA) is a statistical technique used to verify whether a set of observed variables (items) loads onto a hypothesised factor structure. Unlike Exploratory Factor Analysis (EFA), where the structure emerges from the data, CFA tests a pre-specified model grounded in theory or prior research. CFA is a critical step in scale validation, measurement invariance testing, and as the measurement component of structural equation models.

Step 1: Model Specification

In lavaan, you specify the CFA model using the =~ operator. For a three-factor model with three indicators each: model <- 'F1 =~ x1 + x2 + x3; F2 =~ x4 + x5 + x6; F3 =~ x7 + x8 + x9'. By default, lavaan fixes the loading of the first indicator of each factor to 1 for identification. You can also allow factors to correlate (the default) or fix correlations to zero if your theory requires orthogonal factors.

Step 2: Fitting the Model

Fit the model with: fit <- cfa(model, data=mydata). For ordinal data, add ordered=TRUE. For non-normal data, use estimator="MLR" (robust maximum likelihood) or estimator="WLSMV" (for categorical indicators). After fitting, obtain results with summary(fit, fit.measures=TRUE, standardized=TRUE). This gives you factor loadings, standard errors, p-values, and fit indices.

Step 3: Evaluating Model Fit

Assess fit using multiple indices: CFI ≥ 0.95 (acceptable ≥ 0.90), TLI ≥ 0.95, RMSEA ≤ 0.06 (acceptable ≤ 0.08) with its 90% confidence interval, and SRMR ≤ 0.08. The chi-square test is reported but often significant with large samples — focus on the ratio χ²/df (target < 3). Use fitMeasures(fit, c("cfi","tli","rmsea","rmsea.ci.lower","rmsea.ci.upper","srmr")) to extract specific indices. Never rely on a single index; the pattern across multiple indices matters.

Step 4: Modification and Refinement

If the model fits poorly, inspect modification indices with modificationIndices(fit, sort.=TRUE). These suggest which parameters, if freed, would improve fit the most. Common modifications include allowing error covariances between items with similar wording or method effects. However, every modification must be theoretically justifiable — data-driven modifications without substantive reasoning lead to models that capitalise on chance and will not replicate. Report all modifications transparently.

Reporting CFA Results in APA Format

A well-written CFA report includes: the hypothesised model with a path diagram, sample size and estimation method, all fit indices, standardised factor loadings with significance, factor correlations, and any modifications made with justification. Include a table of loadings and a figure of the final model. For example: "A three-factor CFA was conducted using lavaan in R with MLR estimation (N = 450). The model demonstrated good fit: χ²(24) = 38.52, p = .031, CFI = .97, TLI = .96, RMSEA = .036 [90% CI: .010, .056], SRMR = .032. All standardised factor loadings exceeded .50 (range: .58–.89)."

SEM