6 Exploratory Factor Analysis
R code for this chapter: efa_figures.R (data and figures) and _common.R (shared helpers). Save both in one folder and run source("efa_figures.R"); every figure is then one function call, as shown under the Code buttons.
Slides for this chapter: efa_slides.html (opens in a new tab; use the arrow keys to move between slides).
Variables often move together because a few hidden forces drive them all. A factor model describes exactly that: a few common factors move all the variables, and each variable also has a unique shock of its own. The Introduction met the idea with two food critics (Section 1.7.1), and this chapter starts from the same example.
PCA (Chapter 4) explains the variances of the variables, with as many shocks as variables. A factor model explains the covariances between the variables: only the common factors move several variables at once, so only they create covariance. With two critics, though, the data cannot tell how much of each rating comes from the common factor and how much from the critic’s own quirks. This chapter shows that a third critic settles the question and that a fourth makes the model testable. With two or more factors an old problem returns: the factors can be turned without changing the fit, as in PCA and MDS, and the conventions for choosing the turn are called rotations. The chapter then estimates the factors behind each observation (factor scores), analyses the state indicators of Chapter 2, and compares factor analysis with PCA.
The analysis is exploratory: the number of factors, and which variables depend on which factor, are left for the data to suggest. In confirmatory factor analysis (Chapter 8) they are fixed in advance, from theory.
6.1 Two critics, one quality
6.1.1 Why two ratings move together
Two food critics rate the same restaurants. Their ratings are correlated: a restaurant that one critic likes, the other tends to like as well. The reason is that both taste the same food. The restaurant’s quality is a common factor, a hidden force that moves both ratings. Each critic also has her own quirks and her good and bad evenings, a unique shock that moves only her own rating.
Measure each rating as a deviation from the critic’s average rating, and write \(f_t\) for the quality of restaurant \(t\). The two ratings are then
\[ \begin{aligned} x_{t1}&=\lambda_1f_t+u_{t1},\\ x_{t2}&=\lambda_2f_t+u_{t2}. \end{aligned} \]
- The quality \(f_t\) has mean zero and variance one, so it has no units: \(f_t=1\) means a restaurant one standard deviation better than average.
- The loading \(\lambda_i\) (lambda) says by how many points critic \(i\)’s rating rises when the quality rises by one standard deviation.
- The unique shock \(u_{ti}\) holds critic \(i\)’s quirks. Its variance \(\psi_i\) (psi) is her unique variance. The quirks are uncorrelated with the quality and with each other.
The figure shows the ratings of many restaurants. The purple arrow, \((\lambda_1,\lambda_2)\), is what one standard deviation of quality does to the two ratings. The blue and red arrows, of lengths \(\sqrt{\psi_1}\) and \(\sqrt{\psi_2}\), are one standard deviation of each critic’s quirks. Each quirk moves only one rating, so its arrow lies along one axis.
fig_factor_choices(nrow = 1, pick = 3, critics = TRUE, panels = c("", "", "", "")) +
labs(title = "Two critics, one restaurant quality",
subtitle = "purple λ: quality · blue, red: each critic's quirks")
6.1.2 Only quality creates covariance
The quality and the two quirks are uncorrelated, so the variances and the covariance of the ratings follow from the rule for linear combinations (Section 3.5.4):
\[ \operatorname{Var}(x_{t1})=\lambda_1^2+\psi_1,\qquad \operatorname{Var}(x_{t2})=\lambda_2^2+\psi_2,\qquad \operatorname{Cov}(x_{t1},x_{t2})=\lambda_1\lambda_2 . \]
Each variance has a common part, \(\lambda_i^2\), and a unique part, \(\psi_i\). The covariance has only a common part. The quirks add to the variances, but they never make the two ratings move together. Only the quality does.
6.1.3 More shocks than ratings
The quality and the two quirks are three shocks, but there are only two ratings. Write each quirk as its standard deviation times a shock with variance one, \(u_{ti}=\sqrt{\psi_i}\,\varepsilon_{ti}\). The model then has the form \(\mathbf x_t=A\boldsymbol\varepsilon_t\) of the Introduction,
\[ \begin{pmatrix}x_{t1}\\ x_{t2}\end{pmatrix} =\begin{pmatrix}\lambda_1&\sqrt{\psi_1}&0\\ \lambda_2&0&\sqrt{\psi_2}\end{pmatrix} \begin{pmatrix}f_t\\ \varepsilon_{t1}\\ \varepsilon_{t2}\end{pmatrix} , \]
but now \(A\) has more columns than rows. Its two zeros say that each critic’s quirks move only her own rating.
6.1.4 The data leave one number open
The covariance matrix of the two ratings holds three numbers: two variances and one covariance. The model has four parameters, \(\lambda_1\), \(\lambda_2\), \(\psi_1\) and \(\psi_2\). So the data fix three of them, and one is left open: how the noise is split between the two critics.
3 numbers in the covariance matrix, 4 parameters: one number is left open.
Two numbers help to read the stories. The communality of critic \(i\),
\[ h_i=\frac{\lambda_i^2}{\operatorname{Var}(x_{ti})}=\frac{\lambda_i^2}{\lambda_i^2+\psi_i} , \]
is the share of her rating variance that comes from quality. The data fix the product of the two communalities. Since \(\operatorname{Cov}(x_{t1},x_{t2})=\lambda_1\lambda_2\),
\[ h_1h_2=\frac{\lambda_1^2\lambda_2^2}{\operatorname{Var}(x_{t1})\operatorname{Var}(x_{t2})} =\frac{\operatorname{Cov}(x_{t1},x_{t2})^2}{\operatorname{Var}(x_{t1})\operatorname{Var}(x_{t2})} , \]
the squared correlation of the two ratings. What they leave open is how this product splits into \(h_1\) and \(h_2\).
The slider moves through all the one-factor stories that fit the ratings equally well. At its left end critic 1 never errs, at its right end critic 2 never errs, and in between it sets critic 1’s share of the noise, \((1-h_1)/\big((1-h_1)+(1-h_2)\big)\). The ratings never move. What changes is how much of each rating is put down to quirks, and with it the quality attributed to each restaurant (the colour). The figure also reports \(\operatorname{Var}(f\mid\mathbf x)\), how uncertain the quality of a restaurant remains once both ratings are known (Section 6.7):
Four natural restrictions pick one story each:
fig_factor_choices(critics = TRUE,
panels = c("Critic 1 never errs", "Critic 2 never errs", "Equally reliable", "Equal noise"))
- Critic 1 never errs (\(\psi_1=0\)): her rating is the quality, and critic 2’s rating is a regression on hers. This is the Cholesky choice of the Introduction.
- Critic 2 never errs (\(\psi_2=0\)): the same with critic 2 first.
- Equally reliable (\(h_1=h_2\)): the quality explains the same share of each critic’s rating variance, so the two communalities are equal.
- Equal noise (\(\psi_1=\psi_2\)): both critics’ quirks are equally large.
Check your understanding
- In the model of the two critics, the covariance of their ratings is
- \(\lambda_1\lambda_2\)
- \(\lambda_1^2+\psi_1\)
- \(\psi_1\psi_2\)
- zero
- With two critics and one factor, the covariance matrix holds 3 numbers and the model has 4 parameters. So
- the model cannot fit the data
- one number, how the noise is split between the critics, is left open
- the quality of each restaurant is known exactly
- the loadings are zero
- “Critic 1 never errs” is the restriction
- \(\psi_1=0\)
- \(\lambda_1=0\)
- \(\psi_1=\psi_2\)
- \(\lambda_1=\lambda_2\)
Answers
1 a. 2 b. 3 a.6.2 The factor model
6.2.1 Four critics
Two more critics join the first two, and all four rate the same restaurants. Each rating follows the same pattern:
\[ \begin{aligned} x_{t1}&=\lambda_1f_t+u_{t1},\\ x_{t2}&=\lambda_2f_t+u_{t2},\\ x_{t3}&=\lambda_3f_t+u_{t3},\\ x_{t4}&=\lambda_4f_t+u_{t4}. \end{aligned} \]
Here they are as a path diagram. Circles are unobserved, boxes are measured, and each arrow points from a cause to what it moves. The numbers on the arrows are the loadings, and the number under each unique shock \(u_i\) is its variance \(\psi_i\). These four critics are the running example of the chapter, and critics 1 and 2 are the two critics of the figures above.
sub_digit <- function(i) chartr("0123456789", "\u2080\u2081\u2082\u2083\u2084\u2085\u2086\u2087\u2088\u2089", as.character(i))
f2 <- function(x, d = 2) formatC(x, format = "f", digits = d)
fig_path <- function(model = c("critics", "tests", "heywood")) {
model <- match.arg(model)
phi <- NA
if (model == "critics") {
vars <- tibble(lab = crit_names, x = c(1, 2.45, 3.9, 5.35), psi = crit_psi, idx = 1:4)
facs <- tibble(lab = "quality", x = mean(vars$x), col = col_f)
arr <- tibble(from = 1, to = 1:4, lam = crit_lam)
} else if (model == "tests") {
vars <- tibble(lab = tests_items, x = c(1, 2.2, 3.4, 4.9, 6.1, 7.3), psi = 1 - tests_h2, idx = 1:6)
facs <- tibble(lab = c("verbal", "math"), x = c(2.2, 6.1), col = c(col_verb, col_math))
arr <- tibble(from = rep(1:2, each = 3), to = 1:6, lam = c(tests_P[1:3, 1], tests_P[4:6, 2]))
phi <- tests_Phi[1, 2]
} else { # the two-factor story behind the Heywood case: critic 1 in the middle
L <- heywood_two$L
vars <- tibble(lab = crit_names[c(2, 1, 3)], x = c(1, 2.6, 4.2), psi = heywood_two$psi[c(2, 1, 3)], idx = c(2, 1, 3))
facs <- tibble(lab = c("food", "service"), x = c(1.8, 3.4), col = c(col_verb, col_math))
arr <- tibble(from = c(1, 1, 2, 2), to = c(1, 2, 2, 3), lam = c(L[2, 1], L[1, 1], L[1, 2], L[3, 2]))
phi <- heywood_two$phi
}
yf <- 2.45; yv <- 1; yu <- -0.1; rf <- 0.45; ru <- 0.2; bw <- 0.52; bh <- 0.22
circle <- function(x0, y0, r, id) tibble(t = seq(0, 2 * pi, length.out = 100), x = x0 + r * cos(t),
y = y0 + r * sin(t), id = id)
fc <- purrr::map2_dfr(facs$x, seq_len(nrow(facs)), ~ circle(.x, yf, rf, .y))
uc <- purrr::map2_dfr(vars$x, seq_len(nrow(vars)), ~ circle(.x, yu, ru, .y))
a <- arr |> mutate(fx = facs$x[from], vx = vars$x[to], dx = vx - fx, dy = (yv + bh) - yf, len = sqrt(dx^2 + dy^2),
x0 = fx + rf * dx / len, y0 = yf + rf * dy / len, x1 = vx, y1 = yv + bh,
lx = x0 + 0.6 * (x1 - x0), ly = y0 + 0.6 * (y1 - y0), col = facs$col[from])
p <- ggplot() +
geom_polygon(data = fc, aes(x, y, group = id, colour = facs$col[id]), fill = "#f6f3fa", linewidth = 1) +
geom_text(data = facs, aes(x, yf, label = lab, colour = col), size = 4.6, fontface = "bold") +
geom_segment(data = a, aes(x0, y0, xend = x1, yend = y1, colour = col), linewidth = 0.9,
arrow = arrow(length = unit(0.18, "cm"), type = "closed")) +
geom_label(data = a, aes(lx, ly, label = f2(lam), colour = col), size = 3.9, label.size = 0,
label.padding = unit(0.12, "lines"), fill = "white") +
geom_rect(data = vars, aes(xmin = x - bw, xmax = x + bw, ymin = yv - bh, ymax = yv + bh),
fill = "white", colour = "#2c3e50", linewidth = 0.8) +
geom_text(data = vars, aes(x, yv, label = lab), size = 3.9, colour = "#2c3e50") +
geom_segment(data = vars, aes(x, yu + ru, xend = x, yend = yv - bh), colour = "grey45", linewidth = 0.7,
arrow = arrow(length = unit(0.15, "cm"), type = "closed")) +
geom_polygon(data = uc, aes(x, y, group = id), fill = "#f2f2f2", colour = "grey45", linewidth = 0.7) +
geom_text(data = vars, aes(x, yu, label = paste0("u", sub_digit(idx))), size = 3.8, colour = "grey25") +
geom_text(data = vars, aes(x, yu - ru - 0.16, label = paste0("\u03c8 = ", f2(psi))), size = 3.6, colour = "grey30") +
scale_colour_identity() + coord_equal(clip = "off") + theme_void()
if (!is.na(phi)) { # the correlation of two factors, as a curved double arrow
xs <- facs$x[1] + rf * cos(pi / 5); xe <- facs$x[2] - rf * cos(pi / 5); ys <- yf + rf * sin(pi / 5)
p <- p + annotate("curve", x = xs, y = ys, xend = xe, yend = ys, curvature = -0.3, colour = "grey35",
linewidth = 0.8, arrow = arrow(length = unit(0.16, "cm"), type = "closed", ends = "both")) +
annotate("label", x = mean(facs$x), y = ys + 0.3 * (xe - xs) / 2 + 0.02, label = f2(phi),
size = 3.9, colour = "grey25", label.size = 0, fill = "white")
}
p
}
# draw the figure
fig_path("critics")
6.2.2 Many variables, several factors
In general there are \(p\) variables and \(k\) common factors, \(f_{t1},\dots,f_{tk}\). Variable \(i\) responds to each factor with its own loading:
\[ x_{ti}=\lambda_{i1}f_{t1}+\lambda_{i2}f_{t2}+\dots+\lambda_{ik}f_{tk}+u_{ti},\qquad i=1,\dots,p . \]
The loading \(\lambda_{il}\) says by how much variable \(i\) moves when factor \(l\) rises by one standard deviation. The factors are uncorrelated and have variance one. The unique shocks are uncorrelated with each other and with the factors, and \(\psi_i\) is the variance of \(u_{ti}\).
Stacking the \(p\) equations gives the matrix form, the factor model
\[ \underbrace{\begin{pmatrix}x_{t1}\\ \vdots\\ x_{tp}\end{pmatrix}}_{\mathbf x_t} =\underbrace{\begin{pmatrix}\lambda_{11}&\cdots&\lambda_{1k}\\ \vdots&&\vdots\\ \lambda_{p1}&\cdots&\lambda_{pk}\end{pmatrix}}_{\Lambda} \underbrace{\begin{pmatrix}f_{t1}\\ \vdots\\ f_{tk}\end{pmatrix}}_{\mathbf f_t} +\underbrace{\begin{pmatrix}u_{t1}\\ \vdots\\ u_{tp}\end{pmatrix}}_{\mathbf u_t}, \qquad\text{in short}\qquad \mathbf x_t=\Lambda\,\mathbf f_t+\mathbf u_t , \]
with three parts:
- \(\mathbf f_t\) holds the \(k\) common factors, with \(\operatorname{Var}(\mathbf f_t)=I\).
- \(\Lambda\) (capital lambda) is the \(p\times k\) matrix of loadings.
- \(\mathbf u_t\) holds the \(p\) unique shocks, and \(\Psi\) (capital psi) is the diagonal matrix with the unique variances \(\psi_1,\dots,\psi_p\) on its diagonal.
For the four critics, \(k=1\): \(\Lambda\) is the single column \((\lambda_1,\lambda_2,\lambda_3,\lambda_4)'\), and \(\mathbf f_t\) is the single number \(f_t\). (The factors \(\mathbf f_t=\Delta\boldsymbol\varepsilon_t\) of Chapter 4 had units. Here, as in most books on factor analysis, the factors have variance one, so their units sit in the loadings.)
6.2.3 The covariances
The variances and covariances follow as for the two critics. With \(\sigma_{ij}\) the covariance of variables \(i\) and \(j\) and \(\sigma_{ii}\) the variance of variable \(i\),
\[ \sigma_{ii}=\sum_{l=1}^k\lambda_{il}^2+\psi_i ,\qquad\qquad \sigma_{ij}=\sum_{l=1}^k\lambda_{il}\lambda_{jl}\quad(i\neq j). \]
The covariances come from the common factors alone. Each variance splits into a common part \(\sum_l\lambda_{il}^2\) and a unique part \(\psi_i\). The share of the common part, \(h_i=\sum_l\lambda_{il}^2/\sigma_{ii}\), is the variable’s communality, as for the two critics. For standardised variables, with variance one, the communality is the common part itself, \(h_i=\sum_l\lambda_{il}^2\), and \(\psi_i=1-h_i\) is called the uniqueness. (Many books write the communality as \(h_i^2\).) In matrix form, all these equations together read (Section 3.5.4)
\[ \Sigma=\operatorname{Var}(\Lambda\mathbf f_t)+\operatorname{Var}(\mathbf u_t)=\Lambda\,I\,\Lambda'+\Psi =\Lambda\Lambda'+\Psi . \]
6.2.4 More shocks than variables
In the language of the Introduction, the factor model is a structural form with more shocks than variables. Divide each unique shock by its standard deviation, and stack the factors and these shocks into one vector \(\boldsymbol\varepsilon_t\) of \(k+p\) uncorrelated shocks with variance one:
\[ \mathbf x_t=\begin{pmatrix}\Lambda & \Psi^{1/2}\end{pmatrix} \begin{pmatrix}\mathbf f_t\\ \Psi^{-1/2}\mathbf u_t\end{pmatrix}=A\,\boldsymbol\varepsilon_t , \]
where \(\Psi^{1/2}\) is the diagonal matrix of the standard deviations \(\sqrt{\psi_i}\). The matrix \(A\) has \(p\) rows and \(k+p\) columns. For the two critics it is the matrix of Section 6.1. The factor model is the restriction that the last \(p\) columns of \(A\) form a diagonal matrix: each unique shock moves only its own variable.
Check your understanding
- A factor model for \(p=6\) variables with \(k=2\) factors has a loading matrix \(\Lambda\) with
- 6 rows and 2 columns
- 2 rows and 6 columns
- 6 rows and 6 columns
- 8 rows and 8 columns
- In a factor model, the covariance of two different variables comes from
- the common factors only
- the unique shocks only
- both
- neither
- A standardised variable with communality 0.7 has
- 70% of its variance from the common factors and a uniqueness of 0.3
- a loading of 0.7 on every factor
- a uniqueness of 0.7
- no unique shock
Answers
1 a. 2 a. 3 a.6.3 One factor: how many variables does it take?
6.3.1 Two critics: a curve of answers
Section 6.1 showed that two critics leave one number open. Here is the same in numbers. Suppose we know the covariance matrix of the two critics’ ratings exactly:
\[ \Sigma=\begin{pmatrix}1.00&0.75\\ 0.75&1.25\end{pmatrix}. \]
With one factor, \(\Sigma=\lambda\lambda'+\Psi\) gives one equation for each of the three distinct entries:
\[ \sigma_{11}=\lambda_1^2+\psi_1=1.00,\qquad \sigma_{22}=\lambda_2^2+\psi_2=1.25,\qquad \sigma_{12}=\lambda_1\lambda_2=0.75 . \]
There are four unknowns, and the covariance fixes only the product \(\lambda_1\lambda_2\). Pick any \(\lambda_1\): then \(\lambda_2=0.75/\lambda_1\), and the two variances give \(\psi_1=1.00-\lambda_1^2\) and \(\psi_2=1.25-\lambda_2^2\). Every such pair fits \(\Sigma\) exactly, as long as neither unique variance is negative, which requires \(\lambda_1\le1\) and \(\lambda_2\le\sqrt{1.25}\). So \(\lambda_1\) can lie anywhere between \(0.75/\sqrt{1.25}=0.67\) and 1:
f2 <- function(x, d = 2) formatC(x, format = "f", digits = d)
fig_crit_curve <- function(panels = c("two", "three")) {
s11 <- crit_Sigma[1, 1]; s22 <- crit_Sigma[2, 2]; s12 <- crit_Sigma[1, 2]
ratio <- crit_Sigma[1, 3] / crit_Sigma[2, 3]
curve_ok <- tibble(l1 = seq(s12 / sqrt(s22), sqrt(s11), length.out = 200)) |> mutate(l2 = s12 / l1)
curve_out <- bind_rows(tibble(l1 = seq(0.56, s12 / sqrt(s22), length.out = 60), part = "a"),
tibble(l1 = seq(sqrt(s11), 1.32, length.out = 60), part = "b")) |> mutate(l2 = s12 / l1)
base <- function(title, subtitle) ggplot() +
geom_path(data = curve_out, aes(l1, l2, group = part), colour = "#bbbbbb", linetype = "22", linewidth = 0.8) +
geom_path(data = curve_ok, aes(l1, l2), colour = col_f, linewidth = 1.6) +
coord_equal(xlim = c(0.4, 1.3), ylim = c(0.4, 1.3)) +
labs(title = title, subtitle = subtitle,
x = expression("critic 1's loading " * lambda[1]), y = expression("critic 2's loading " * lambda[2])) +
theme(plot.title = element_text(size = 14, face = "bold"), plot.subtitle = element_text(size = 11))
p1 <- base("Two critics", "every point on the purple curve fits the covariance matrix") +
geom_segment(data = crit_two, aes(l1, l2, xend = lx, yend = ly), colour = "grey55", linewidth = 0.4) +
geom_point(data = crit_two, aes(l1, l2), size = 2.8, colour = "#2c3e50") +
geom_label(data = crit_two, aes(lx, ly, label = story, hjust = hj), size = 3.8, colour = "#2c3e50",
label.size = 0, label.padding = unit(0.1, "lines"), fill = "white") +
annotate("text", x = 1.27, y = 0.53, label = "dashed: a negative\nquirk variance", hjust = 1, size = 3.4,
colour = "grey45", lineheight = 0.9)
p2 <- base("A third critic", "a line from her covariances crosses the curve once") +
geom_abline(slope = 1 / ratio, intercept = 0, colour = col_third, linewidth = 1.1) +
geom_point(data = crit_two, aes(l1, l2), size = 2, colour = "#bbbbbb") +
annotate("point", x = crit_three["l1"], y = crit_three["l2"], size = 4, colour = col_third) +
annotate("text", x = crit_three["l1"] + 0.07, y = crit_three["l2"], hjust = 0, size = 3.8, colour = "#2c3e50",
label = sprintf("λ₁ = %s, λ₂ = %s", f2(crit_three["l1"]), f2(crit_three["l2"]))) +
annotate("text", x = 0.55, y = 0.52, hjust = 0, size = 3.8, colour = col_third,
label = "the third critic's line:\nλ₁ / λ₂ = σ₁₃ / σ₂₃", lineheight = 0.9)
if (identical(panels, "two")) p1 else if (identical(panels, "three")) p2 else p1 + p2
}
# draw the figure
fig_crit_curve("two")
The four stories of Section 6.1 are four points on the purple curve. “Critic 1 never errs” (\(\psi_1=0\)) is its right end: then \(\sigma_{11}=\lambda_1^2\), so \(\lambda_1=1.00\) and \(\lambda_2=0.75/\lambda_1=0.75\). “Critic 2 never errs” (\(\psi_2=0\)) is its left end: then \(\sigma_{22}=\lambda_2^2\), so \(\lambda_2=\sqrt{1.25}=1.12\) and \(\lambda_1=0.75/1.12=0.67\). “Equally reliable” and “equal noise” lie in between. The covariance matrix cannot choose between them: this is the number the data leave open, and the slider of Section 6.1 moves along this curve. On the dashed parts of the curve, one of the unique variances would be negative, which is impossible.
6.3.2 A third critic pins it down
Now a third critic rates the same restaurants. She adds three entries to \(\Sigma\), her variance \(\sigma_{33}=1.00\) and her covariances \(\sigma_{13}=0.45\) and \(\sigma_{23}=0.60\), but only two unknowns, \(\lambda_3\) and \(\psi_3\). Her covariances are products of loadings as well, \(\sigma_{13}=\lambda_1\lambda_3\) and \(\sigma_{23}=\lambda_2\lambda_3\). Dividing one by the other cancels her own loading:
\[ \frac{\lambda_1}{\lambda_2}=\frac{\sigma_{13}}{\sigma_{23}}=\frac{0.45}{0.60} =0.75 . \]
In the figure this is a straight line through the origin, and it crosses the curve exactly once:
f2 <- function(x, d = 2) formatC(x, format = "f", digits = d)
fig_crit_curve <- function(panels = c("two", "three")) {
s11 <- crit_Sigma[1, 1]; s22 <- crit_Sigma[2, 2]; s12 <- crit_Sigma[1, 2]
ratio <- crit_Sigma[1, 3] / crit_Sigma[2, 3]
curve_ok <- tibble(l1 = seq(s12 / sqrt(s22), sqrt(s11), length.out = 200)) |> mutate(l2 = s12 / l1)
curve_out <- bind_rows(tibble(l1 = seq(0.56, s12 / sqrt(s22), length.out = 60), part = "a"),
tibble(l1 = seq(sqrt(s11), 1.32, length.out = 60), part = "b")) |> mutate(l2 = s12 / l1)
base <- function(title, subtitle) ggplot() +
geom_path(data = curve_out, aes(l1, l2, group = part), colour = "#bbbbbb", linetype = "22", linewidth = 0.8) +
geom_path(data = curve_ok, aes(l1, l2), colour = col_f, linewidth = 1.6) +
coord_equal(xlim = c(0.4, 1.3), ylim = c(0.4, 1.3)) +
labs(title = title, subtitle = subtitle,
x = expression("critic 1's loading " * lambda[1]), y = expression("critic 2's loading " * lambda[2])) +
theme(plot.title = element_text(size = 14, face = "bold"), plot.subtitle = element_text(size = 11))
p1 <- base("Two critics", "every point on the purple curve fits the covariance matrix") +
geom_segment(data = crit_two, aes(l1, l2, xend = lx, yend = ly), colour = "grey55", linewidth = 0.4) +
geom_point(data = crit_two, aes(l1, l2), size = 2.8, colour = "#2c3e50") +
geom_label(data = crit_two, aes(lx, ly, label = story, hjust = hj), size = 3.8, colour = "#2c3e50",
label.size = 0, label.padding = unit(0.1, "lines"), fill = "white") +
annotate("text", x = 1.27, y = 0.53, label = "dashed: a negative\nquirk variance", hjust = 1, size = 3.4,
colour = "grey45", lineheight = 0.9)
p2 <- base("A third critic", "a line from her covariances crosses the curve once") +
geom_abline(slope = 1 / ratio, intercept = 0, colour = col_third, linewidth = 1.1) +
geom_point(data = crit_two, aes(l1, l2), size = 2, colour = "#bbbbbb") +
annotate("point", x = crit_three["l1"], y = crit_three["l2"], size = 4, colour = col_third) +
annotate("text", x = crit_three["l1"] + 0.07, y = crit_three["l2"], hjust = 0, size = 3.8, colour = "#2c3e50",
label = sprintf("λ₁ = %s, λ₂ = %s", f2(crit_three["l1"]), f2(crit_three["l2"]))) +
annotate("text", x = 0.55, y = 0.52, hjust = 0, size = 3.8, colour = col_third,
label = "the third critic's line:\nλ₁ / λ₂ = σ₁₃ / σ₂₃", lineheight = 0.9)
if (identical(panels, "two")) p1 else if (identical(panels, "three")) p2 else p1 + p2
}
# draw the figure
fig_crit_curve("three")
Multiplying two of the covariances and dividing by the third gives each loading directly. For critic 1,
\[ \frac{\sigma_{12}\,\sigma_{13}}{\sigma_{23}}=\frac{(\lambda_1\lambda_2)(\lambda_1\lambda_3)}{\lambda_2\lambda_3}=\lambda_1^2, \qquad\text{so}\qquad \lambda_1=\sqrt{\frac{0.75\times0.45}{0.60}}=0.75 , \]
and in the same way \(\lambda_2=\sqrt{\sigma_{12}\sigma_{23}/\sigma_{13}}=1.00\) and \(\lambda_3=\sqrt{\sigma_{13}\sigma_{23}/\sigma_{12}}=0.60\). The diagonal then gives the unique variances: \(\psi_1=1-0.75^2=0.4375\), \(\psi_2=1.25-1=0.25\) and \(\psi_3=1-0.60^2=0.64\).
Count the numbers. Three critics give six numbers in \(\Sigma\) (three variances and three covariances), and the model has six unknowns (three loadings and three unique variances). Six equations, six unknowns and one solution: the model is just identified. Only the signs are a convention: turning every loading negative, which means measuring quality upside down, fits equally well.
A factor needs at least three variables. The third critic’s covariances with the first two tell how much of their ratings is quality and how much is quirks.
The third critic also shows what a regression gets wrong. Regressing critic 2’s rating on critic 1’s gives the slope \(\sigma_{12}/\sigma_{11}=0.75\), the story “critic 1 never errs”, which treats critic 1’s rating as the quality itself. But her quirks blur her rating, and the slope comes out too flat. It equals the ratio of the loadings, \(\lambda_2/\lambda_1=\sigma_{23}/\sigma_{13}=1.33\), times critic 1’s communality \(\lambda_1^2/\sigma_{11}=0.56\). In econometrics this is the errors-in-variables problem, and the third critic is an instrumental variable.
6.3.3 Impossible answers: Heywood cases
With three variables the solution is exact, but nothing guarantees that it makes sense. Suppose critics 2 and 3 agreed much less than they do, with the covariance \(\sigma_{23}=0.25\) instead of \(0.60\), and everything else as before. (This is still a valid covariance matrix.) The formulas above then give critic 1 the common part
\[ \lambda_1^2=\frac{\sigma_{12}\,\sigma_{13}}{\sigma_{23}}=\frac{0.75\times0.45}{0.25} =1.35 , \]
which is larger than her whole variance, \(\sigma_{11}=1.00\). Her unique variance would have to be \(\psi_1=1.00-1.35=-0.35\). In shares of each critic’s rating variance, her communality would be 1.35 and her uniqueness −0.35:
mns <- function(s) sub("^-", "\u2212", s)
f2 <- function(x, d = 2) formatC(x, format = "f", digits = d)
fig_heywood <- function() {
d <- heywood_tab |> mutate(case = factor(case, levels = unique(case)), xi = match(critic, crit_names), u = 1 - h)
w <- 0.3
ggplot(d) +
geom_rect(aes(xmin = xi - w, xmax = xi + w, ymin = 0, ymax = h, fill = "communality h (quality)")) +
geom_rect(data = filter(d, u >= 0), aes(xmin = xi - w, xmax = xi + w, ymin = h, ymax = 1,
fill = "uniqueness 1 − h (quirks)")) +
geom_hline(yintercept = 1, linetype = "22", colour = "grey30") +
geom_text(data = filter(d, u >= 0), aes(xi, 1.07, label = sprintf("1 − h = %s", f2(u))), size = 4.2,
colour = "#2c3e50") +
geom_segment(data = filter(d, u < 0), aes(x = xi + w + 0.09, xend = xi + w + 0.09, y = h, yend = 1),
colour = "#c0392b", linewidth = 1, arrow = arrow(length = unit(0.2, "cm"), type = "closed")) +
geom_text(data = filter(d, u < 0), aes(xi + w + 0.17, h, label = sprintf("1 − h = %s\nimpossible", mns(f2(u)))),
hjust = 0, vjust = 1, size = 4.2, colour = "#c0392b", lineheight = 0.9) +
scale_fill_manual(values = c(`communality h (quality)` = col_f, `uniqueness 1 − h (quirks)` = "#c9c9c9"), name = NULL) +
scale_x_continuous(breaks = 1:3, labels = crit_names[1:3]) +
scale_y_continuous(limits = c(0, 1.58), breaks = seq(0, 1.5, 0.5), expand = c(0, 0)) +
facet_wrap(~ case) +
labs(x = NULL, y = "share of the critic's rating variance",
caption = "dashed line: the whole variance of each rating") +
theme(legend.position = "top", strip.text = element_text(size = 12, face = "bold"),
panel.grid.major.x = element_blank(), axis.text.x = element_text(size = 12))
}
# draw the figure
fig_heywood()
A variance cannot be negative, so no one-factor model reproduces these covariances. A solution with a negative or
zero unique variance is called a Heywood case (Heywood 1931). It says that the model does not fit, or that the
sample is too small to estimate it well. Estimation software stops at the boundary and reports a unique variance of
almost zero: factanal() does not let a uniqueness fall below 0.005, so a reported 0.005 signals a Heywood case. Section 6.8 meets such a case.
Why does it happen here? With one factor, each covariance is the product of two loadings. Critics 2 and 3 now barely agree, so quality must play only a small part in their ratings. For critic 1 to agree as closely as she does with both of them, quality would then have to explain more than all of her rating variance.
A second factor removes the contradiction. Suppose critic 1 judges both the food and the service, critic 2 only the food and critic 3 only the service, and food and service are correlated 0.30 (the curved arrow). These two factors reproduce the changed covariances exactly, with positive quirk variances:
sub_digit <- function(i) chartr("0123456789", "\u2080\u2081\u2082\u2083\u2084\u2085\u2086\u2087\u2088\u2089", as.character(i))
f2 <- function(x, d = 2) formatC(x, format = "f", digits = d)
fig_path <- function(model = c("critics", "tests", "heywood")) {
model <- match.arg(model)
phi <- NA
if (model == "critics") {
vars <- tibble(lab = crit_names, x = c(1, 2.45, 3.9, 5.35), psi = crit_psi, idx = 1:4)
facs <- tibble(lab = "quality", x = mean(vars$x), col = col_f)
arr <- tibble(from = 1, to = 1:4, lam = crit_lam)
} else if (model == "tests") {
vars <- tibble(lab = tests_items, x = c(1, 2.2, 3.4, 4.9, 6.1, 7.3), psi = 1 - tests_h2, idx = 1:6)
facs <- tibble(lab = c("verbal", "math"), x = c(2.2, 6.1), col = c(col_verb, col_math))
arr <- tibble(from = rep(1:2, each = 3), to = 1:6, lam = c(tests_P[1:3, 1], tests_P[4:6, 2]))
phi <- tests_Phi[1, 2]
} else { # the two-factor story behind the Heywood case: critic 1 in the middle
L <- heywood_two$L
vars <- tibble(lab = crit_names[c(2, 1, 3)], x = c(1, 2.6, 4.2), psi = heywood_two$psi[c(2, 1, 3)], idx = c(2, 1, 3))
facs <- tibble(lab = c("food", "service"), x = c(1.8, 3.4), col = c(col_verb, col_math))
arr <- tibble(from = c(1, 1, 2, 2), to = c(1, 2, 2, 3), lam = c(L[2, 1], L[1, 1], L[1, 2], L[3, 2]))
phi <- heywood_two$phi
}
yf <- 2.45; yv <- 1; yu <- -0.1; rf <- 0.45; ru <- 0.2; bw <- 0.52; bh <- 0.22
circle <- function(x0, y0, r, id) tibble(t = seq(0, 2 * pi, length.out = 100), x = x0 + r * cos(t),
y = y0 + r * sin(t), id = id)
fc <- purrr::map2_dfr(facs$x, seq_len(nrow(facs)), ~ circle(.x, yf, rf, .y))
uc <- purrr::map2_dfr(vars$x, seq_len(nrow(vars)), ~ circle(.x, yu, ru, .y))
a <- arr |> mutate(fx = facs$x[from], vx = vars$x[to], dx = vx - fx, dy = (yv + bh) - yf, len = sqrt(dx^2 + dy^2),
x0 = fx + rf * dx / len, y0 = yf + rf * dy / len, x1 = vx, y1 = yv + bh,
lx = x0 + 0.6 * (x1 - x0), ly = y0 + 0.6 * (y1 - y0), col = facs$col[from])
p <- ggplot() +
geom_polygon(data = fc, aes(x, y, group = id, colour = facs$col[id]), fill = "#f6f3fa", linewidth = 1) +
geom_text(data = facs, aes(x, yf, label = lab, colour = col), size = 4.6, fontface = "bold") +
geom_segment(data = a, aes(x0, y0, xend = x1, yend = y1, colour = col), linewidth = 0.9,
arrow = arrow(length = unit(0.18, "cm"), type = "closed")) +
geom_label(data = a, aes(lx, ly, label = f2(lam), colour = col), size = 3.9, label.size = 0,
label.padding = unit(0.12, "lines"), fill = "white") +
geom_rect(data = vars, aes(xmin = x - bw, xmax = x + bw, ymin = yv - bh, ymax = yv + bh),
fill = "white", colour = "#2c3e50", linewidth = 0.8) +
geom_text(data = vars, aes(x, yv, label = lab), size = 3.9, colour = "#2c3e50") +
geom_segment(data = vars, aes(x, yu + ru, xend = x, yend = yv - bh), colour = "grey45", linewidth = 0.7,
arrow = arrow(length = unit(0.15, "cm"), type = "closed")) +
geom_polygon(data = uc, aes(x, y, group = id), fill = "#f2f2f2", colour = "grey45", linewidth = 0.7) +
geom_text(data = vars, aes(x, yu, label = paste0("u", sub_digit(idx))), size = 3.8, colour = "grey25") +
geom_text(data = vars, aes(x, yu - ru - 0.16, label = paste0("\u03c8 = ", f2(psi))), size = 3.6, colour = "grey30") +
scale_colour_identity() + coord_equal(clip = "off") + theme_void()
if (!is.na(phi)) { # the correlation of two factors, as a curved double arrow
xs <- facs$x[1] + rf * cos(pi / 5); xe <- facs$x[2] - rf * cos(pi / 5); ys <- yf + rf * sin(pi / 5)
p <- p + annotate("curve", x = xs, y = ys, xend = xe, yend = ys, curvature = -0.3, colour = "grey35",
linewidth = 0.8, arrow = arrow(length = unit(0.16, "cm"), type = "closed", ends = "both")) +
annotate("label", x = mean(facs$x), y = ys + 0.3 * (xe - xs) / 2 + 0.02, label = f2(phi),
size = 3.9, colour = "grey25", label.size = 0, fill = "white")
}
p
}
# draw the figure
fig_path("heywood")
Critic 1 agrees with critic 2 through the food and with critic 3 through the service, while critics 2 and 3 share only the weak link between food and service. One factor is too few for these covariances, and forcing them into one ends in a Heywood case. With three variables no test can tell, though: one factor is just identified (df = 0), and two factors are not identified, so this is one of many two-factor stories that fit. The Heywood case is the only warning. Everitt and Hothorn (Section 5.5) show a Heywood case with the correlations that Spearman (1904) found between children’s marks in Classics, French and English.
Check your understanding
- With two critics and one factor, the covariance matrix fixes
- both loadings
- only the product \(\lambda_1\lambda_2\) of the loadings
- only the unique variances
- nothing at all
- A third critic with \(\sigma_{13}=0.45\) and \(\sigma_{23}=0.60\) fixes the ratio \(\lambda_1/\lambda_2\) at
- 0.75
- 1.33
- 0.27
- nothing: the ratio stays open
- With three variables and one factor, the model is just identified because
- the correlation matrix has three entries
- six numbers in \(\Sigma\) meet six unknowns
- the loadings are all equal
- the unique variances are zero
- A Heywood case is an estimate with
- a loading of zero
- a negative or zero unique variance
- more factors than variables
- a correlation of one
Answers
1 b. 2 a. 3 b. 4 b.6.4 Four critics: a restriction to test
6.4.1 Only the factor creates covariance
A fourth critic adds four numbers to \(\Sigma\), her variance and three covariances, but again only two unknowns. Now \(\Sigma\) holds 10 numbers and the model has 8 unknowns, so two numbers are left over. The model restricts \(\Sigma\): not every covariance matrix of four critics can be written as \(\lambda\lambda'+\Psi\). Here is the split for the four critics of the path diagram:
f2 <- function(x, d = 2) formatC(x, format = "f", digits = d)
fig_crit_split <- function() {
heat <- function(M, title) {
d <- as_tibble(as.table(M), .name_repair = ~ c("r", "c", "v")) |>
mutate(r = factor(r, levels = rev(crit_names)), c = factor(c, levels = crit_names))
ggplot(d, aes(c, r, fill = v)) + geom_tile(colour = "white", linewidth = 0.8) +
geom_text(aes(label = ifelse(abs(v) < 1e-9, "0", f2(v)), colour = v > 0.7), size = 4) +
scale_colour_manual(values = c(`TRUE` = "white", `FALSE` = "black"), guide = "none") +
scale_fill_gradient(low = col_heat["low"], high = col_heat["high"], limits = c(0, 1.3), guide = "none") +
coord_equal() + labs(title = title, x = NULL, y = NULL) +
theme(axis.text.x = element_text(angle = 35, hjust = 1), panel.grid = element_blank(),
plot.title = element_text(size = 13, face = "bold", hjust = 0.5))
}
common <- outer(crit_lam, crit_lam); dimnames(common) <- dimnames(crit_Sigma)
unique_ <- diag(crit_psi); dimnames(unique_) <- dimnames(crit_Sigma)
sym <- function(s) wrap_elements(grid::textGrob(s, gp = grid::gpar(fontsize = 30, col = "#2c3e50")))
heat(crit_Sigma, "covariance matrix Σ") + sym("=") + heat(common, "quality: λλ′") + sym("+") +
heat(unique_, "quirks: Ψ") + plot_layout(nrow = 1, widths = c(1, 0.12, 1, 0.12, 1))
}
# draw the figure
fig_crit_split()
Every entry off the diagonal comes from quality alone, \(\sigma_{ij}=\lambda_i\lambda_j\), and the quirks add only to the diagonal. So the six covariances are built from just four numbers. Pair up the four critics in the three possible ways and multiply:
\[ \sigma_{12}\sigma_{34}=\sigma_{13}\sigma_{24}=\sigma_{14}\sigma_{23}=\lambda_1\lambda_2\lambda_3\lambda_4 . \]
Here \(0.75\times0.54=0.45\times0.90 =0.675\times0.60=0.405\). These two equalities are the restrictions, Spearman’s tetrad conditions. A covariance matrix that violates them cannot come from one factor. A tetrad is a group of four: each condition ties together the covariances of four variables, and with more variables every group of four must satisfy them. Two or more factors restrict \(\Sigma\) in other ways, and the likelihood ratio test of Section 6.5 checks all the restrictions at once, whatever their form.
6.4.2 Counting restrictions
The same count works for any number of variables \(p\) and factors \(k\).
- \(\Sigma\) holds \(p(p+1)/2\) numbers: \(p\) variances and \(p(p-1)/2\) covariances.
- The model has \(pk\) loadings and \(p\) unique variances. With two or more factors, though, the factors can be turned without changing \(\Sigma\) (Section 6.6). A turn of \(k\) factors has \(k(k-1)/2\) angles, which the data cannot fix, so they do not count as unknowns.
The difference is the number of restrictions, the degrees of freedom of the model:
\[ \text{df}=\frac{p(p+1)}{2}-\Big(pk+p-\frac{k(k-1)}{2}\Big)=\frac{(p-k)^2-(p+k)}{2} . \]
(Multiply out both sides to check.) For two critics, \(\text{df}=-1\): one number short, the free parameter. For three, \(\text{df}=0\): just identified. For four, \(\text{df}=2\): the two tetrad conditions. A positive count means that the model can be tested with data:
efa_df <- function(p, k) ((p - k)^2 - (p + k)) / 2
fig_efa_count <- function(pmax = 10, kmax = 4) {
d <- expand_grid(p = 2:pmax, k = 1:kmax) |> filter(k < p) |>
mutate(df = efa_df(p, k),
status = factor(case_when(df < 0 ~ "not identified", df == 0 ~ "just identified", TRUE ~ "testable"),
levels = c("not identified", "just identified", "testable")))
ggplot(d, aes(p, k, fill = status)) + geom_tile(colour = "white", linewidth = 1) +
geom_text(aes(label = df), size = 4.2, colour = "#2c3e50") +
scale_fill_manual(values = c(`not identified` = "#f4c7c3", `just identified` = "#fde9b8", testable = "#cfe8d4"),
name = NULL) +
scale_x_continuous(breaks = 2:pmax, expand = c(0, 0)) + scale_y_continuous(breaks = 1:kmax, expand = c(0, 0)) +
coord_equal() +
labs(x = "number of variables p", y = "number of factors k",
subtitle = "number in each tile: covariances left over after fitting the model (degrees of freedom)") +
theme(panel.grid = element_blank(), legend.position = "top", plot.subtitle = element_text(size = 11))
}
# draw the figure
fig_efa_count()
Factors use up covariances fast. One factor needs at least three variables to be identified and four to be tested. Two factors need at least five, and three factors at least six, or seven to be tested. With the six state indicators, three factors would leave nothing to test.
A non-negative count is needed, but it is not always enough. If the third critic rated at random (\(\lambda_3=0\)), her covariances with the others would be zero, the ratio \(\sigma_{13}/\sigma_{23}\) would be \(0/0\), and the first two critics would be as unidentified as before.
Check your understanding
- How many restrictions does one factor put on the covariance matrix of four critics?
- none
- one
- two
- four
- With six variables, a factor model can be tested with at most
- two factors, since three leave no degrees of freedom
- three factors
- five factors
- any number of factors
- If \(\sigma_{12}\sigma_{34}\) is much larger than \(\sigma_{13}\sigma_{24}\) and \(\sigma_{14}\sigma_{23}\), then
- one factor cannot have produced \(\Sigma\)
- the loadings are all equal
- the model is just identified
- critic 1 never errs
Answers
1 c. 2 a. 3 a.6.5 Estimating and testing with data
6.5.1 A sample of 200 restaurants
So far \(\Sigma\) was known. With data, the sample covariance matrix \(S\) takes its place, and sampling noise breaks the tetrad conditions a little, so that no \(\lambda\lambda'+\Psi\) reproduces \(S\) exactly. Estimation finds the loadings and unique variances whose \(\Lambda\Lambda'+\Psi\) comes closest to \(S\). The test asks whether the remaining gap is larger than sampling noise would produce.
To see how this works, let the four critics rate 200 restaurants, simulated from the path diagram above,
so that we know the truth. R’s factanal() does both steps:
crit_fa <- factanal(crit_X, factors = 1) # crit_X: 200 restaurants rated by the four critics
crit_fa
##
## Call:
## factanal(x = crit_X, factors = 1)
##
## Uniquenesses:
## critic 1 critic 2 critic 3 critic 4
## 0.517 0.160 0.685 0.188
##
## Loadings:
## Factor1
## critic 1 0.695
## critic 2 0.917
## critic 3 0.561
## critic 4 0.901
##
## Factor1
## SS loadings 2.451
## Proportion Var 0.613
##
## Test of the hypothesis that 1 factor is sufficient.
## The chi square statistic is 1.26 on 2 degrees of freedom.
## The p-value is 0.533factanal() works with standardised ratings, so it reports the loadings \(\lambda_i/\sqrt{\sigma_{ii}}\) and the
uniquenesses \(\psi_i/\sigma_{ii}\). The true values are 0.75, 0.89, 0.60 and 0.90 for the loadings and 0.44, 0.20, 0.64 and 0.19 for
the uniquenesses, and the estimates from 200 restaurants are close. “SS loadings” is the sum of the
squared loadings, the common variance of the four critics together, and “Proportion Var” its share of the total
variance, four.
6.5.2 Maximum likelihood
factanal() estimates by maximum likelihood. It assumes that the observations are normal (Section
3.4) and picks the \(\Lambda\) and \(\Psi\) under which the observed sample is most probable. This turns out
to be the same as making the discrepancy
\[ F_{\text{ML}}(\Lambda,\Psi)=\ln|\Lambda\Lambda'+\Psi|+\operatorname{tr}\!\big(S(\Lambda\Lambda'+\Psi)^{-1}\big)-\ln|S|-p \]
as small as possible, where \(|\cdot|\) is the determinant and \(\operatorname{tr}\) the trace (Section
4.2). \(F_{\text{ML}}\) is zero when \(\Lambda\Lambda'+\Psi=S\) and positive otherwise, so it measures how far the
covariance matrix of the model is from that of the sample. There is no formula for the minimum: factanal() searches
for it numerically.
Where the discrepancy FML comes from
Here \(\mathbf x_t\) stands for an observation as measured, not yet centred. Its normal density is \((2\pi)^{-p/2}|\Sigma|^{-1/2}\exp\!\big(-\tfrac12(\mathbf x_t-\mu)'\Sigma^{-1}(\mathbf x_t-\mu)\big)\) (Section 3.4). The observations are independent, so the density of the whole sample is the product of these over \(t=1,\dots,n\). Read as a function of the parameters, it is the likelihood \(L\), and its logarithm is
\[ \ln L=-\frac{np}{2}\ln(2\pi)-\frac n2\ln|\Sigma|-\frac12\sum_{t=1}^n(\mathbf x_t-\mu)'\Sigma^{-1}(\mathbf x_t-\mu) . \]
Whatever \(\Sigma\) is, the sum is smallest, and \(L\) largest, at \(\mu=\bar{\mathbf x}\), the sample mean, so we can set \(\mu=\bar{\mathbf x}\). Each term of the sum is a single number, so it equals its own trace, and a trace does not change when the factors of a product are cycled: \((\mathbf x_t-\bar{\mathbf x})'\Sigma^{-1}(\mathbf x_t-\bar{\mathbf x})=\operatorname{tr}\big(\Sigma^{-1}(\mathbf x_t-\bar{\mathbf x})(\mathbf x_t-\bar{\mathbf x})'\big)\). Summing over \(t\) and using \(\sum_t(\mathbf x_t-\bar{\mathbf x})(\mathbf x_t-\bar{\mathbf x})'=(n-1)S\) turns the sum into \((n-1)\operatorname{tr}(S\Sigma^{-1})\), and with \(n-1\approx n\),
\[ \ln L\approx\text{constant}-\frac n2\Big(\ln|\Sigma|+\operatorname{tr}(S\Sigma^{-1})\Big). \]
So the likelihood is largest where \(\ln|\Sigma|+\operatorname{tr}(S\Sigma^{-1})\) is smallest. Without any restriction on \(\Sigma\), the smallest value, \(\ln|S|+p\), is reached at \(\Sigma=S\). Subtracting it gives \(F_{\text{ML}}\), which is therefore never negative.
6.5.3 Testing the restrictions
If the model is right, the minimum of \(F_{\text{ML}}\) is small: only sampling noise keeps the covariance matrix of the model from matching \(S\). The likelihood ratio test turns this into a test. Its statistic is the minimum of \(F_{\text{ML}}\) times about \(n\) (precisely \(n-1-(2p+5)/6-2k/3\), a small-sample correction). If the model is right, the statistic has approximately a chi-square distribution (Section 3.4.4) with df degrees of freedom, and as for Alaska in Section 3.6.5, a value far out in its tail is surprising. The p-value is the probability, if the model is right, of a statistic at least as large as the one observed. A small p-value says that the gap between the model and the data is larger than sampling noise usually produces.
For the four critics, the statistic is 1.26 on 2 degrees of freedom, with a p-value of 0.533: no evidence against one factor.
Now change the story. Critics 3 and 4 dine together: they visit each restaurant on the same evening and share their bad evenings, so their quirks are correlated (0.5 in the simulation). Their ratings then have more in common than quality, and one factor no longer describes the four critics:
crit_fa2 <- factanal(crit_X2, factors = 1) # crit_X2: critics 3 and 4 dine together
unname(crit_fa2$STATISTIC) # the chi-square statistic, on 2 degrees of freedom
## [1] 20.41691
unname(crit_fa2$PVAL) # its p-value
## [1] 3.685743e-05The statistic jumps to 20.4, with a p-value below 0.0001, and one factor is rejected. The tetrads show where the misfit sits:
f3 <- function(x) formatC(x, format = "f", digits = 3)
crit_tetrads <- function(X) {
S <- cov(X); c(S[1, 2] * S[3, 4], S[1, 3] * S[2, 4], S[1, 4] * S[2, 3])
}
f3 <- function(x) formatC(x, format = "f", digits = 3)
ptxt <- function(p) if (p < 1e-4) "< 0.0001" else if (p < 0.001) paste("=", formatC(p, format = "f", digits = 4)) else paste("=", f3(p))
fig_crit_tetrads <- function() {
lab <- c("s₁₂ · s₃₄", "s₁₃ · s₂₄", "s₁₄ · s₂₃")
d <- bind_rows(
tibble(sample = sprintf("One quality factor\ntest of one factor: p-value %s", ptxt(crit_fa$PVAL)),
prod = lab, v = crit_tetrads(crit_X)),
tibble(sample = sprintf("Critics 3 and 4 dine together\ntest of one factor: p-value %s", ptxt(crit_fa2$PVAL)),
prod = lab, v = crit_tetrads(crit_X2))) |>
mutate(sample = factor(sample, levels = unique(sample)), prod = factor(prod, levels = lab))
ggplot(d, aes(prod, v)) + geom_col(fill = col_f, width = 0.6) +
geom_text(aes(label = f3(v)), vjust = -0.5, size = 4) +
facet_wrap(~ sample) + scale_y_continuous(limits = c(0, 0.55), expand = c(0, 0)) +
labs(x = NULL, y = "product of two sample covariances") +
theme(strip.text = element_text(size = 11.5, face = "bold"), axis.text.x = element_text(size = 12))
}
# draw the figure
fig_crit_tetrads()
With one quality factor, the three products of sample covariances agree, up to sampling noise. (All three also lie a little below the value 0.405 of the model, by chance; the test asks only whether they agree with each other.) When critics 3 and 4 dine together, their covariance \(s_{34}\) contains their shared evenings as well as quality, and the product \(s_{12}s_{34}\) sticks out. The test only says that the model does not fit. The tetrads say a little more: one of the two pairs, critics 1 and 2 or critics 3 and 4, shares more than quality. Which pair it is, the data cannot tell; here we know it from the story. A test that does not reject is no proof either: with fewer restaurants, the shared evenings might have gone unnoticed.
6.5.4 The units do not matter
Suppose critic 1 rated on a 100-point scale instead of a 10-point one, so that all her ratings were ten times larger. Multiplying her equation by ten gives
\[ 10\,x_{t1}=(10\lambda_1)\,f_t+10\,u_{t1}=(10\lambda_1)\,f_t+\big(10\sqrt{\psi_1}\big)\,\varepsilon_{t1} . \]
Everything measured in rating points is ten times as large: her loading, her quirk \(u_{t1}\) and its standard deviation \(\sqrt{\psi_1}\), so her unique variance is a hundred times as large. The shocks measured in standard deviations do not change at all: the quality \(f_t\) and her standardised quirk \(\varepsilon_{t1}=u_{t1}/\sqrt{\psi_1}\) are the same numbers as before, restaurant by restaurant. Only her unique shock in rating points changes: \(10u_{t1}\) is perfectly correlated with the old \(u_{t1}\), but ten times as large.
In general, a change of units multiplies each variable by a positive number, \(x_{ti}\) by \(\alpha_i\), here with \(\alpha=(10,1,1,1)\). With \(\operatorname{diag}(\alpha)\) the diagonal matrix with \(\alpha_1,\dots,\alpha_p\) on its diagonal, the structural form of Section 6.2 becomes
\[ \operatorname{diag}(\alpha)\,\mathbf x_t=\big(\operatorname{diag}(\alpha)\,A\big)\,\boldsymbol\varepsilon_t =\begin{pmatrix}\operatorname{diag}(\alpha)\Lambda & \operatorname{diag}(\alpha)\Psi^{1/2}\end{pmatrix} \boldsymbol\varepsilon_t . \]
The change of units multiplies row \(i\) of \(A\) by \(\alpha_i\) and leaves the shocks \(\boldsymbol\varepsilon_t\), the factors and the standardised unique shocks, exactly as they were. The new \(A\) still has a diagonal block, so the rescaled variables follow a factor model driven by the same shocks, with loadings \(\operatorname{diag}(\alpha)\Lambda\) and unique variances \(\operatorname{diag}(\alpha)\,\Psi\operatorname{diag}(\alpha)\).
The estimates rescale in the same way. The covariance matrix of the rescaled ratings is
\(\operatorname{diag}(\alpha)\,S\,\operatorname{diag}(\alpha)\), and each candidate \(\Sigma=\Lambda\Lambda'+\Psi\) for
the original ratings corresponds to the candidate \(\operatorname{diag}(\alpha)\,\Sigma\operatorname{diag}(\alpha)\) for
the rescaled ones. The two fit equally well. The discrepancy depends on the two matrices only through \(\Sigma^{-1}S\),
since \(F_{\text{ML}}=\operatorname{tr}(\Sigma^{-1}S)-\ln|\Sigma^{-1}S|-p\), and the rescaling turns \(\Sigma^{-1}S\) into
\(\operatorname{diag}(\alpha)^{-1}\,\Sigma^{-1}S\,\operatorname{diag}(\alpha)\), which has the same trace and the same
determinant. So the best fit to the rescaled ratings is the rescaled best fit. Here is the check, with the fit of
factanal() written in the critics’ own units:
F_ml <- function(S, Sigma) { SiS <- solve(Sigma, S); sum(diag(SiS)) - log(det(SiS)) - nrow(S) }
S <- cov(crit_X); sdv <- sqrt(diag(S))
lam <- crit_fa$loadings[, 1] * sdv # the estimated loadings, in the critics' own units
psi <- crit_fa$uniquenesses * sdv^2 # the estimated unique variances, in the same units
alpha <- c(10, 1, 1, 1) # critic 1 on a ten times wider scale
c(original = F_ml(S, lam %o% lam + diag(psi)),
rescaled = F_ml(diag(alpha) %*% S %*% diag(alpha), (alpha * lam) %o% (alpha * lam) + diag(alpha^2 * psi)))
## original rescaled
## 0.006407872 0.006407872Both discrepancies are 0.00641. Multiplied by \(n-1-(2p+5)/6-2k/3=196.2\), this is the test statistic 1.26 of the four critics.
So factor analysis by maximum likelihood is scale-invariant. A change of units multiplies the estimated loadings
of variable \(i\) by \(\alpha_i\) and its estimated unique variance by \(\alpha_i^2\), as in the model, and leaves
everything without units unchanged: the fit, the test, the loadings and uniquenesses of the standardised variables
that factanal() reports, and the estimated factors (Section 6.7). That is why the covariance matrix and the correlation matrix give the
same answer, and why factanal() can standardise the variables before it fits, and work with the correlation matrix,
without losing anything.
PCA is not scale-invariant. It looks for the directions of largest variance, and a change of units changes them (Section 4.5), so the components themselves change, not just their units. With critic 1 on the 100-point scale, her rating has most of the variance, and the first principal component is almost her rating alone:
pc_old <- prcomp(crit_X) # PCA of the original ratings
pc_new <- prcomp(crit_X %*% diag(alpha)) # critic 1 on the 100-point scale
# abs(): the sign of a component is arbitrary
round(abs(pc_new$rotation[, 1]), 2) # the weights of the new first component
## [1] 0.99 0.07 0.04 0.06
abs(cor(pc_old$x[, 1], pc_new$x[, 1])) # its correlation with the old first component
## [1] 0.8086944The new first component has a correlation of only 0.81 with the old one. It is a different variable, not the old component in new units. The figure puts the two methods side by side:
pct <- function(x, d = 0) paste0(formatC(100 * x, format = "f", digits = d), "%")
fig_units <- function() {
alpha <- c(10, 1, 1, 1); X10 <- crit_X %*% diag(alpha)
pc <- function(X) { p <- prcomp(X); (p$rotation[, 1] * p$sdev[1])^2 / apply(X, 2, var) } # share kept by PC 1
h <- function(X) 1 - factanal(X, factors = 1)$uniquenesses # communalities
lv <- c("original ratings", "critic 1 on a 100-point scale")
pn <- c("PCA: share kept by the first component", "Factor analysis: communality")
d <- bind_rows(
tibble(panel = pn[1], critic = crit_names, v = pc(crit_X), when = lv[1]),
tibble(panel = pn[1], critic = crit_names, v = pc(X10), when = lv[2]),
tibble(panel = pn[2], critic = crit_names, v = h(crit_X), when = lv[1]),
tibble(panel = pn[2], critic = crit_names, v = h(X10), when = lv[2])) |>
mutate(panel = factor(panel, levels = unique(panel)), when = factor(when, levels = lv))
dodge <- position_dodge(width = 0.78)
ggplot(d, aes(critic, v, fill = when)) +
geom_col(position = dodge, width = 0.72) +
geom_text(aes(label = pct(v)), position = dodge, vjust = -0.35, size = 3.5, colour = "#2c3e50") +
facet_wrap(~ panel) +
scale_fill_manual(values = c("#bdbdbd", col_a1), name = NULL) +
scale_y_continuous(limits = c(0, 1.12), breaks = seq(0, 1, 0.25), labels = scales::percent, expand = c(0, 0)) +
labs(x = NULL, y = "share of the critic's rating variance") +
theme(legend.position = "top", strip.text = element_text(size = 12, face = "bold"),
panel.grid.major.x = element_blank())
}
# draw the figure
fig_units()
The intuition is in what each method explains. Factor analysis splits each variance into a common and a unique part. Rescaling a variable multiplies both parts by the same number, so the shares do not move, and neither do the factor, the fit or the test. PCA looks for the largest variance, and a variable whose numbers are ten times larger has a hundred times the variance, so it takes over the first component. That is why PCA is usually applied to the correlation matrix, as for the states (Section 6.8), while factor analysis gives the same answer either way.
Check your understanding
- The discrepancy \(F_{\text{ML}}\) is zero when
- the covariance matrix of the model, \(\Lambda\Lambda'+\Psi\), equals \(S\)
- all loadings are zero
- the test rejects the model
- the data are standardised
- The one-factor test for the four critics gives a p-value of 0.533. This means that
- the one-factor model is proven
- the gap between the model and the data is no larger than sampling noise usually produces
- the loadings are all 0.533
- one factor is rejected
- If critic 1 rates on a ten times wider scale, maximum likelihood
- gives her a larger standardised loading
- multiplies her loading by ten and leaves the standardised solution unchanged
- changes the test statistic
- needs another factor
- With critic 1 on the 100-point scale, the quality \(f_t\) of each restaurant
- is ten times as large
- moves towards critic 1’s rating, as the first principal component does
- is the same as before, and her loading is ten times as large
- is perfectly correlated with the old quality, but has variance 100
Answers
1 a. 2 b. 3 b. 4 c.6.6 Two factors: the rotation returns
6.6.1 Six tests, two abilities
This section turns to a different example with different variables: the test scores of students. A school gives 200 students six tests, three verbal tests (reading, vocabulary and grammar) and three mathematics tests (arithmetic, algebra and geometry). The six test scores are the observed variables, so \(p=6\). Behind them are two abilities, the students’ verbal ability and their mathematical ability. Nobody observes an ability directly: the abilities are latent, or unobserved, variables, the \(k=2\) common factors of the model, just as the quality of a restaurant was seen only through the critics’ ratings. We want to estimate the abilities from the six observed scores. That takes two steps: first the loadings, which say how strongly each test depends on each ability, and then each student’s abilities, the factor scores of Section 6.7.
Students who are strong in one ability tend to be strong in the other, so the two abilities are correlated, here with correlation 0.5. The scores are simulated from this path diagram, where, as before, circles are unobserved and boxes are observed:
sub_digit <- function(i) chartr("0123456789", "\u2080\u2081\u2082\u2083\u2084\u2085\u2086\u2087\u2088\u2089", as.character(i))
f2 <- function(x, d = 2) formatC(x, format = "f", digits = d)
fig_path <- function(model = c("critics", "tests", "heywood")) {
model <- match.arg(model)
phi <- NA
if (model == "critics") {
vars <- tibble(lab = crit_names, x = c(1, 2.45, 3.9, 5.35), psi = crit_psi, idx = 1:4)
facs <- tibble(lab = "quality", x = mean(vars$x), col = col_f)
arr <- tibble(from = 1, to = 1:4, lam = crit_lam)
} else if (model == "tests") {
vars <- tibble(lab = tests_items, x = c(1, 2.2, 3.4, 4.9, 6.1, 7.3), psi = 1 - tests_h2, idx = 1:6)
facs <- tibble(lab = c("verbal", "math"), x = c(2.2, 6.1), col = c(col_verb, col_math))
arr <- tibble(from = rep(1:2, each = 3), to = 1:6, lam = c(tests_P[1:3, 1], tests_P[4:6, 2]))
phi <- tests_Phi[1, 2]
} else { # the two-factor story behind the Heywood case: critic 1 in the middle
L <- heywood_two$L
vars <- tibble(lab = crit_names[c(2, 1, 3)], x = c(1, 2.6, 4.2), psi = heywood_two$psi[c(2, 1, 3)], idx = c(2, 1, 3))
facs <- tibble(lab = c("food", "service"), x = c(1.8, 3.4), col = c(col_verb, col_math))
arr <- tibble(from = c(1, 1, 2, 2), to = c(1, 2, 2, 3), lam = c(L[2, 1], L[1, 1], L[1, 2], L[3, 2]))
phi <- heywood_two$phi
}
yf <- 2.45; yv <- 1; yu <- -0.1; rf <- 0.45; ru <- 0.2; bw <- 0.52; bh <- 0.22
circle <- function(x0, y0, r, id) tibble(t = seq(0, 2 * pi, length.out = 100), x = x0 + r * cos(t),
y = y0 + r * sin(t), id = id)
fc <- purrr::map2_dfr(facs$x, seq_len(nrow(facs)), ~ circle(.x, yf, rf, .y))
uc <- purrr::map2_dfr(vars$x, seq_len(nrow(vars)), ~ circle(.x, yu, ru, .y))
a <- arr |> mutate(fx = facs$x[from], vx = vars$x[to], dx = vx - fx, dy = (yv + bh) - yf, len = sqrt(dx^2 + dy^2),
x0 = fx + rf * dx / len, y0 = yf + rf * dy / len, x1 = vx, y1 = yv + bh,
lx = x0 + 0.6 * (x1 - x0), ly = y0 + 0.6 * (y1 - y0), col = facs$col[from])
p <- ggplot() +
geom_polygon(data = fc, aes(x, y, group = id, colour = facs$col[id]), fill = "#f6f3fa", linewidth = 1) +
geom_text(data = facs, aes(x, yf, label = lab, colour = col), size = 4.6, fontface = "bold") +
geom_segment(data = a, aes(x0, y0, xend = x1, yend = y1, colour = col), linewidth = 0.9,
arrow = arrow(length = unit(0.18, "cm"), type = "closed")) +
geom_label(data = a, aes(lx, ly, label = f2(lam), colour = col), size = 3.9, label.size = 0,
label.padding = unit(0.12, "lines"), fill = "white") +
geom_rect(data = vars, aes(xmin = x - bw, xmax = x + bw, ymin = yv - bh, ymax = yv + bh),
fill = "white", colour = "#2c3e50", linewidth = 0.8) +
geom_text(data = vars, aes(x, yv, label = lab), size = 3.9, colour = "#2c3e50") +
geom_segment(data = vars, aes(x, yu + ru, xend = x, yend = yv - bh), colour = "grey45", linewidth = 0.7,
arrow = arrow(length = unit(0.15, "cm"), type = "closed")) +
geom_polygon(data = uc, aes(x, y, group = id), fill = "#f2f2f2", colour = "grey45", linewidth = 0.7) +
geom_text(data = vars, aes(x, yu, label = paste0("u", sub_digit(idx))), size = 3.8, colour = "grey25") +
geom_text(data = vars, aes(x, yu - ru - 0.16, label = paste0("\u03c8 = ", f2(psi))), size = 3.6, colour = "grey30") +
scale_colour_identity() + coord_equal(clip = "off") + theme_void()
if (!is.na(phi)) { # the correlation of two factors, as a curved double arrow
xs <- facs$x[1] + rf * cos(pi / 5); xe <- facs$x[2] - rf * cos(pi / 5); ys <- yf + rf * sin(pi / 5)
p <- p + annotate("curve", x = xs, y = ys, xend = xe, yend = ys, curvature = -0.3, colour = "grey35",
linewidth = 0.8, arrow = arrow(length = unit(0.16, "cm"), type = "closed", ends = "both")) +
annotate("label", x = mean(facs$x), y = ys + 0.3 * (xe - xs) / 2 + 0.02, label = f2(phi),
size = 3.9, colour = "grey25", label.size = 0, fill = "white")
}
p
}
# draw the figure
fig_path("tests")
Each test is designed to measure one ability, and in the simulation each test does: no arrow runs from verbal ability to a mathematics test or from mathematical ability to a verbal test. Real tests are rarely that clean, since a word problem in algebra also draws on reading, but the simulation keeps the example simple. Keep in mind what the analysis below is told: the scores and the number of factors, but not which test is which.
The factor model of this chapter has uncorrelated factors, and the correlated factors of the diagram fit into it. With a correlation matrix \(\Phi\) for the factors, the covariance matrix is \(\Sigma=\Lambda\Phi\Lambda'+\Psi\), and \(\Lambda\Phi\Lambda'=(\Lambda\Phi^{1/2})(\Lambda\Phi^{1/2})'\), with \(\Phi^{1/2}\) the symmetric root of \(\Phi\). So the same \(\Sigma\) also comes from uncorrelated factors, with loadings \(\Lambda\Phi^{1/2}\). In these loadings every test loads on both factors, although in the diagram it depends on one ability only. Reading, for example, has the loading 0.8 on verbal ability, and with uncorrelated factors the loadings \(0.8\times(0.97, 0.26)=(0.77, 0.21)\). So the estimates below show small loadings on the other factor as well. The analysis starts with uncorrelated factors, and Section 6.6.5 brings the correlation back.
Do the data reveal two factors? Test one factor, then two:
sapply(1:2, function(k) factanal(tests_X, factors = k)$PVAL) # p-values for one and for two factors
## objective objective
## 8.605531e-11 8.108667e-01One factor is rejected (statistic 66.2 on 9 degrees of freedom, p-value below 0.0001), and two factors are not (1.6 on 4 degrees of freedom, p-value of 0.811). This is the usual way to choose the number of factors: start with one, and add factors until the test no longer rejects or no degrees of freedom are left (Everitt and Hothorn, Section 5.6). With many observations the test finds even small, unimportant gaps, so how readable the factors are counts as well.
6.6.2 Every turn fits the data
With two factors, each test has two loadings, \((\lambda_{i1},\lambda_{i2})\), a point in the plane. Turning the factors means new factors \(\tilde{\mathbf f}_t=Q'\mathbf f_t\) for a rotation matrix \(Q\), with new loadings \(\tilde\Lambda=\Lambda Q\), so that \(\tilde\Lambda\tilde{\mathbf f}_t=\Lambda QQ'\mathbf f_t=\Lambda\mathbf f_t\). This is the argument of Section 3.7, applied to the common factors only. The new factors are still uncorrelated with variance one, \(\operatorname{Var}(Q'\mathbf f_t)=Q'Q=I\), and the covariance matrix does not change:
\[ \tilde\Lambda\tilde\Lambda'=\Lambda QQ'\Lambda'=\Lambda\Lambda' . \]
Drag the slider to turn the factors:
varimax_crit <- function(L) { L2 <- (L / sqrt(rowSums(L^2)))^2; sum(colMeans(L2^2) - colMeans(L2)^2) }
f3 <- function(x) formatC(x, format = "f", digits = 3)
tests_turn <- function(deg) tests_L0 %*% rotation_matrix(deg * pi / 180)
fig_tests_rotate <- function(step = 2) {
angs <- sort(unique(c(seq(-90, 90 - step, by = step), round(tests_vm_deg))))
cols <- ifelse(tests_group == "verbal", col_verb, col_math)
frames <- purrr::map(angs, function(a) {
L <- tests_turn(a)
list(pts = tibble(x = L[, 1], y = L[, 2], lab = tests_items, col = cols, k = a,
pos = c("middle right", "bottom left", "top left", "middle right", "top left", "middle left")),
seg = tibble(x = as.vector(rbind(0, L[, 1], NA)), y = as.vector(rbind(0, L[, 2], NA)), k = a),
txt = tibble(x = 0, y = 0, k = a,
txt = sprintf("Turning the factors changes no correlation and no communality.<br>varimax criterion: %s",
f3(varimax_crit(L)))))
})
pts <- bind_rows(purrr::map(frames, "pts")); seg <- bind_rows(purrr::map(frames, "seg"))
txt <- bind_rows(purrr::map(frames, "txt"))
circ <- tibble(t = seq(0, 2 * pi, length.out = 200), x = cos(t), y = sin(t))
jump <- function(lab, a) list(label = lab, method = "animate",
args = list(list(as.character(a)), list(mode = "immediate",
frame = list(duration = 0, redraw = TRUE), transition = list(duration = 0))))
txt_panel <- plot_ly() |>
add_trace(data = txt, x = ~x, y = ~y, frame = ~k, text = ~txt, type = "scatter", mode = "text",
textfont = list(size = 12, color = "#2c3e50"), hoverinfo = "skip", showlegend = FALSE)
main <- plot_ly() |>
add_trace(data = circ, x = ~x, y = ~y, type = "scatter", mode = "lines",
line = list(color = "#dddddd", width = 1, dash = "dash"), hoverinfo = "skip", showlegend = FALSE) |>
add_trace(data = seg, x = ~x, y = ~y, frame = ~k, type = "scatter", mode = "lines",
line = list(color = "#bbbbbb", width = 1.5), hoverinfo = "skip", showlegend = FALSE) |>
add_trace(data = pts, x = ~x, y = ~y, frame = ~k, text = ~lab, type = "scatter", mode = "markers+text",
textposition = ~pos, marker = list(color = ~col, size = 9),
textfont = list(size = 11, color = ~col), hoverinfo = "skip", showlegend = FALSE)
subplot(txt_panel, main, nrows = 2, heights = c(0.1, 0.9), margin = 0.01, titleX = TRUE, titleY = TRUE) |>
layout(xaxis = list(visible = FALSE, range = c(-1, 1), fixedrange = TRUE),
yaxis = list(visible = FALSE, range = c(-1, 1), fixedrange = TRUE),
xaxis2 = list(title = "loading on factor 1", range = c(-1.15, 1.15), zeroline = TRUE,
zerolinecolor = "#cccccc"),
yaxis2 = list(title = "loading on factor 2", range = c(-1.15, 1.15), scaleanchor = "x2", zeroline = TRUE,
zerolinecolor = "#cccccc"),
margin = list(t = 50)) |>
animation_opts(frame = 120, transition = 0, redraw = TRUE) |>
animation_slider(currentvalue = list(prefix = "factors turned by ", suffix = "°")) |>
animation_button(label = "Play") |>
finalize_animation(list(jump("as estimated", 0), jump("varimax", round(tests_vm_deg))),
start_frame = "0", prefix = "factors turned by ", suffix = "°")
}
# draw the figure
fig_tests_rotate()The six points turn together around the origin. Their distances from the origin stay the same, and so do the angles between them. The squared distance of test \(i\) from the origin is its communality, \(h_i=\lambda_{i1}^2+\lambda_{i2}^2\), and the inner product of two points is the correlation of the two tests, \(\sigma_{ij}=\lambda_{i1}\lambda_{j1}+\lambda_{i2}\lambda_{j2}\). So no correlation and no communality changes, and every turn fits the data equally well.
This is the rotation problem of the Introduction, now confined to the common factors. The unique shocks cannot be turned, because each must keep moving only its own variable. Two factors can be turned by one angle. Three factors need three angles (roll, pitch and yaw, Section 5.2), and \(k\) factors need \(k(k-1)/2\). These are the angles subtracted in the count of Section 6.4.
The computer still has to report one turn. factanal() chooses it much as PCA would: the first factor carries as much
of the common variance as it can, and the second as much of the rest (after each variable is divided by the standard
deviation of its unique shock). That is the frame “as estimated”. The first factor loads on all six tests, a
general factor, and the second is a contrast, negative for the verbal tests and positive for the mathematics
tests. It describes the correlations correctly, but it hides the two abilities.
6.6.3 Simple structure and varimax
Which turn should we report? Thurstone’s (1947) answer is simple structure: each variable should load mainly on one factor, so that each factor can be read off from a few variables. Kaiser’s (1958) varimax criterion makes this precise. For each factor, take the squared loadings of the \(p\) variables and compute their variance across the variables. This variance is large when the squared loadings are either near zero or large, and small when they are all middling. Varimax turns the factors until the sum of these variances, the varimax criterion
\[ \sum_{l=1}^k\Bigg[\frac1p\sum_{i=1}^p\Big(\frac{\lambda_{il}}{\sqrt{h_i}}\Big)^4-\bigg(\frac1p\sum_{i=1}^p\Big(\frac{\lambda_{il}}{\sqrt{h_i}}\Big)^2\bigg)^2\Bigg], \]
is as large as possible. Dividing each loading by \(\sqrt{h_i}\), the square root of the variable’s communality, makes every variable count equally (Kaiser’s normalisation, the default in R).
The slider of Section 6.6.2 shows the criterion above the plot, for every turn. As estimated, it is 0.055. The button “varimax” turns the factors by \(-34^\circ\), where the criterion reaches its maximum, 0.363: the verbal tests then lie close to one axis and the mathematics tests close to the other. (A turn of \(56^\circ\) gives the same maximum. It is the same solution, with the two factors swapped and one of them reversed in sign.) After the varimax turn, the verbal tests load 0.84, 0.64 and 0.55 on the first factor and the mathematics tests 0.74, 0.63 and 0.53 on the second, and the cross-loadings are small, between 0.12 and 0.28. The first factor is verbal ability, the second mathematical ability:
tests_fv <- factanal(tests_X, factors = 2) # varimax is the default rotation
print(tests_fv$loadings, cutoff = 0)
##
## Loadings:
## Factor1 Factor2
## reading 0.842 0.206
## vocabulary 0.638 0.172
## grammar 0.552 0.194
## arithmetic 0.278 0.744
## algebra 0.137 0.635
## geometry 0.122 0.532
##
## Factor1 Factor2
## SS loadings 1.532 1.349
## Proportion Var 0.255 0.225
## Cumulative Var 0.255 0.4806.6.4 The data find the groups, we name them
factanal() was never told which test is which. It found the two groups from the correlations alone: the three
verbal tests are more correlated with each other than with the mathematics tests, and the same holds for the
mathematics tests. So the points of the verbal tests lie close together in the plane of loadings, and so do those of
the mathematics tests, and varimax turns the axes until each passes through one group. What the data cannot supply
is the names. That the first factor is verbal ability we know only because the tests that load on it are reading,
vocabulary and grammar. The states in Section 6.8 work the same way:
varimax finds groups of indicators, and the names come from what the indicators measure.
Confirmatory factor analysis (Chapter 8) goes the other way round. There the analyst says in advance which variable loads on which factor, by setting the other loadings to zero, and the data only estimate the rest. Those zeros also remove the freedom to turn the factors.
6.6.5 Correlated factors: promax
Varimax keeps the factors uncorrelated: their axes stay at right angles. But the two abilities go together, and no pair of perpendicular axes can pass through both groups of tests. An oblique rotation lets the factors correlate. The model becomes \(\mathbf x_t=\Lambda\mathbf f_t+\mathbf u_t\) with \(\operatorname{Var}(\mathbf f_t)=\Phi\), the correlation matrix of the factors, so that \(\Sigma=\Lambda\Phi\Lambda'+\Psi\). Promax (Hendrickson and White 1964) starts from varimax and lets the axes tilt towards the groups of tests:
f0 <- function(x) formatC(x, format = "f", digits = 0, big.mark = ",")
mns <- function(s) sub("^-", "\u2212", s)
fig_tests_axes <- function() {
pts <- tibble(x = tests_L0[, 1], y = tests_L0[, 2], lab = tests_items, g = tests_group)
Qv <- rotation_matrix(tests_vm_deg * pi / 180) # columns: the varimax factors, in the estimated coordinates
axes_df <- function(D, labs) tibble(x = 0, y = 0, xend = D[1, ], yend = D[2, ], lab = labs, g = c("verbal", "math"),
lx = 1.04 * D[1, ], ly = 1.04 * D[2, ], # names just beyond the tips
hj = (1 - D[1, ]) / 2, vj = (1 - D[2, ]) / 2)
# The six points are the same in all three panels, so only the first panel names them.
panel <- function(D, labs, title, subtitle, named = FALSE) {
ax <- axes_df(D, labs)
avoid <- bind_rows(purrr::map_dfr(seq(0.04, 1.2, by = 0.04), function(s) # points along the arrows,
tibble(x = s * D[1, ], y = s * D[2, ], lab = "", g = c("verbal", "math"))),
tibble(x = ax$lx + 0.12 * D[1, ], y = ax$ly + 0.12 * D[2, ], lab = "", g = ax$g)) # and names
ggplot() + axes0 +
geom_segment(data = ax, aes(x, y, xend = xend, yend = yend, colour = g), linewidth = 1.1,
arrow = arrow(length = unit(0.2, "cm"), type = "closed")) +
geom_text(data = ax, aes(lx, ly, label = lab, colour = g, hjust = hj, vjust = vj), size = 4, fontface = "bold") +
geom_point(data = pts, aes(x, y, colour = g), size = 2.4) +
(if (named) geom_text_repel(data = bind_rows(pts, avoid), aes(x, y, label = lab, colour = g), size = 3.6, seed = 1,
box.padding = 0.3, point.padding = 0.15, force = 3, max.iter = 1e5,
min.segment.length = 0.3, max.overlaps = Inf)) +
scale_colour_manual(values = c(verbal = col_verb, math = col_math), guide = "none") +
coord_equal(xlim = c(-0.45, 1.45), ylim = c(-0.7, 1.25)) +
labs(title = title, subtitle = subtitle, x = "loading on factor 1 (as estimated)",
y = "loading on factor 2 (as estimated)") +
theme(plot.title = element_text(size = 13, face = "bold"), plot.subtitle = element_text(size = 11))
}
panel(diag(2), c("factor 1", "factor 2"), "As estimated", "a general factor and a contrast", named = TRUE) +
panel(Qv, c("verbal", "math"), "Varimax", sprintf("turned by %s°, still at right angles", mns(f0(tests_vm_deg)))) +
panel(t(tests_pm$axes), c("verbal", "math"), "Promax",
sprintf("axes through the two groups, %s° apart", f0(tests_pm_angle)))
}
# draw the figure
fig_tests_axes()
The three panels show the same six points, the loadings as estimated (named in the first panel), with three choices of axes. Promax puts the two axes 60° apart, which corresponds to a factor correlation of \(\cos 60^\circ=0.50\), the value used in the simulation. The promax loadings of a test are its coordinates along the tilted axes, each read off parallel to the other axis. Its cross-loading then almost vanishes, between -0.06 and 0.07. The main loadings are 0.87, 0.65 and 0.55 for the verbal tests and 0.76, 0.68 and 0.56 for the mathematics tests, close to the true 0.8, 0.7 and 0.6:
tests_fp <- factanal(tests_X, factors = 2, rotation = "promax")
tests_fp # loadings, factor correlations and the test
##
## Call:
## factanal(x = tests_X, factors = 2, rotation = "promax")
##
## Uniquenesses:
## reading vocabulary grammar arithmetic algebra geometry
## 0.249 0.563 0.658 0.369 0.579 0.702
##
## Loadings:
## Factor1 Factor2
## reading 0.867
## vocabulary 0.652
## grammar 0.549
## arithmetic 0.761
## algebra 0.676
## geometry 0.565
##
## Factor1 Factor2
## SS loadings 1.487 1.360
## Proportion Var 0.248 0.227
## Cumulative Var 0.248 0.474
##
## Factor Correlations:
## Factor1 Factor2
## Factor1 1.000 0.504
## Factor2 0.504 1.000
##
## Test of the hypothesis that 2 factors are sufficient.
## The chi square statistic is 1.59 on 4 degrees of freedom.
## The p-value is 0.811With correlated factors, the loadings are still the weights in \(\mathbf x_t=\Lambda\mathbf f_t+\mathbf u_t\), the
pattern. They are no longer the correlations between the variables and the factors, the structure
\(\operatorname{Cov}(\mathbf x_t,\mathbf f_t)=\Lambda\Phi\), because each variable is also correlated with a factor
through the other factor. In the figure, the structure is what a perpendicular projection onto each tilted axis would
read off. And the common variance of test \(i\) is now the \(i\)-th diagonal entry of \(\Lambda\Phi\Lambda'\), no
longer the sum of its squared loadings. So the “SS loadings” and “Proportion Var” that factanal() prints for promax
are not shares of the variance.
Rotation changes the description, not the fit. Every turn and every tilt gives the same covariance matrix, the same communalities and the same test. Choosing a rotation is choosing how to describe the factors, just as PCA chose \(A\) for convenience (Section 4.8). The names verbal and mathematical fit here because we know what each test asks. With real data, the names are interpretations.
Check your understanding
- Turning the two factors of the six tests by 30° changes
- the loadings
- the correlations between the tests
- the communalities
- the test statistic
- Varimax prefers loadings that are
- all equal
- either near zero or large
- all positive
- as small as possible
- Promax differs from varimax in that it
- lets the factors correlate
- fits the data better
- changes the unique variances
- needs more factors
- How many angles does a turn of three factors have?
- one
- two
- three
- six
- To find the verbal and the mathematical factor,
factanal()needs to be told- which tests are verbal and which are mathematics tests
- only the scores and the number of factors: the groups show up in the correlations
- the correlation between the two factors
- the names of the factors
Answers
1 a. 2 b. 3 a. 4 c. 5 b.6.7 Factor scores
6.7.1 Parameters, but not shocks
So far the chapter has estimated the parameters of the model, the loadings and the unique variances. With three or more critics, the covariance matrix pins them down (Section 6.3). The shocks are another matter: the quality of each restaurant, and the quirks behind each rating.
In the earlier chapters, the parameters gave the shocks for free. There, \(\mathbf x_t=A\boldsymbol\varepsilon_t\) had as many shocks as variables, so \(A\) was square. Once \(A\) was chosen, it could be undone, \(\boldsymbol\varepsilon_t=A^{-1}\mathbf x_t\), and every shock followed exactly from the data. The PCA scores \(\mathbf f_t=\Gamma'\mathbf x_t\) are an example (Section 4.2). Whether a matrix can be undone depends on its shape:
- More rows than columns, that is, more variables than shocks. Then \(A\) can still be undone, as long as no column is a combination of the others: the matrix \((A'A)^{-1}A'\) does it, because \((A'A)^{-1}A'A=I\). If the four critics had no quirks, for example, each rating would be \(x_{ti}=\lambda_if_t\), \(A\) would be the single column \((\lambda_1,\dots,\lambda_4)'\), and any one rating would reveal the quality exactly, \(f_t=x_{ti}/\lambda_i\).
- More columns than rows, that is, more shocks than variables. Then no matrix undoes \(A\), because different shocks produce the same data.
The factor model is of the second kind. Its \(A=\begin{pmatrix}\Lambda&\Psi^{1/2}\end{pmatrix}\) has \(p\) rows and \(k+p\) columns (Section 6.2). The four critics give four ratings, but there are five shocks: the quality and the four quirks. Whatever quality a restaurant has, the quirks can make up the difference. For any value of \(f_t\), the quirks \(u_{ti}=x_{ti}-\lambda_if_t\) reproduce the four ratings exactly. The left panel shows this for one restaurant: pick any quality on the horizontal axis, and the four lines give the quirks the critics would have needed that evening.
f2 <- function(x, d = 2) formatC(x, format = "f", digits = d)
crit_weights <- function(m) { l <- crit_lam[1:m]; p <- crit_psi[1:m]; (l / p) / (1 + sum(l^2 / p)) }
fig_crit_anyquality <- function(t = crit_pick) {
x <- crit_X[t, ]; tau <- sum(crit_lam^2 / crit_psi)
f_hat <- sum(crit_weights(4) * x); sd_f <- sqrt(1 / (1 + tau)); f_true <- crit_d$quality[t]
fs <- seq(-1.5, 3.5, length.out = 401)
cols <- setNames(c(col_a1, col_a2, col_third, "#16a085"), crit_names)
quirks <- purrr::map_dfr(1:4, function(i) tibble(f = fs, u = x[i] - crit_lam[i] * fs, critic = crit_names[i]))
ends <- quirks |> group_by(critic) |> slice_tail(n = 1) |> ungroup() |> arrange(u)
for (j in 2:nrow(ends)) ends$u[j] <- max(ends$u[j], ends$u[j - 1] + 0.3) # keep the labels apart
p1 <- ggplot(quirks, aes(f, u, colour = critic)) +
geom_hline(yintercept = 0, colour = "grey70") +
annotate("text", x = -1.5, y = 0.12, label = "no quirk", hjust = 0, vjust = 0, size = 3.4, colour = "grey45") +
geom_line(linewidth = 1.1) +
geom_text(data = ends, aes(label = critic), hjust = 0, nudge_x = 0.08, size = 3.6, show.legend = FALSE) +
scale_colour_manual(values = cols, guide = "none") +
scale_x_continuous(limits = c(-1.5, 4.4), breaks = -1:3) +
labs(title = "Every quality fits the four ratings",
subtitle = "the quirk each critic would need, for each quality",
x = "quality of the restaurant", y = "quirk needed")
dens <- tibble(f = fs, d = dnorm(fs, f_hat, sd_f))
top <- max(dens$d)
p2 <- ggplot(dens, aes(f, d)) +
geom_area(fill = col_f, alpha = 0.2) + geom_line(colour = col_f, linewidth = 1.1) +
geom_vline(xintercept = f_hat, colour = col_f, linetype = "22") +
geom_vline(xintercept = f_true, colour = "#2c3e50") +
annotate("text", x = f_hat + 0.08, y = top * 1.08, hjust = 0, size = 3.7, colour = col_f,
label = sprintf("factor score %s", f2(f_hat))) +
annotate("text", x = f_true - 0.08, y = top * 1.08, hjust = 1, size = 3.7, colour = "#2c3e50",
label = sprintf("true quality %s", f2(f_true))) +
scale_x_continuous(limits = c(-1.5, 3.5), breaks = -1:3) +
scale_y_continuous(limits = c(0, top * 1.15), expand = c(0, 0)) +
labs(title = "But some qualities are more plausible",
subtitle = "how likely each quality is, with the quirks it needs",
x = "quality of the restaurant", y = "plausibility (density)")
p1 + p2
}
# draw the figure
fig_crit_anyquality()
So the ratings never pin down a restaurant’s quality. They only make some values more plausible than others, because large quirks are unlikely. The right panel weighs each quality by how likely it is, together with the quirks it needs (with normal shocks). The plausible qualities form a bell curve. Its peak is not where the four quirks average zero, for two reasons: a quirk counts more against a quality when it belongs to a critic whose quirks are usually small, and a quality far above the average restaurant is itself unlikely. The next subsection finds the peak. The true quality, which we know only because the data are simulated, lies inside the curve but not at its centre.
In a factor model the parameters are identified, but the shocks are not: \(A\) has more columns than rows, so it has no inverse. The factors can only be estimated, and the estimates are called factor scores.
6.7.2 Estimating quality from four ratings
Here is the idea for one factor and the four critics, with the loadings and unique variances of the model. It finds the centre of the bell curve.
- Each critic’s rating, divided by her loading, measures the quality with an error: \[x_{ti}/\lambda_i=f_t+u_{ti}/\lambda_i .\] The error has variance \(\psi_i/\lambda_i^2\), which is small for a critic with a large loading and small quirks.
- Average the four measurements, and give each a weight proportional to its precision \(\lambda_i^2/\psi_i\), one over its error variance. These weights make the error of the average as small as possible. With the total precision \(\tau=\sum_i\lambda_i^2/\psi_i\) (tau), the average is \[\hat f^{\,B}_t=\frac1\tau\sum_i\frac{\lambda_i^2}{\psi_i}\cdot\frac{x_{ti}}{\lambda_i}=\frac1\tau\sum_i\frac{\lambda_i}{\psi_i}\,x_{ti}.\] Its error, \(\frac1\tau\sum_i(\lambda_i/\psi_i)\,u_{ti}\), has variance \(\frac1{\tau^2}\sum_i(\lambda_i^2/\psi_i^2)\,\psi_i=1/\tau\). This is Bartlett’s score (Bartlett 1937), hence the \(B\).
- \(\hat f^{\,B}_t\) is quality plus an error, and quality has variance one, so \(\operatorname{Var}(\hat f^{\,B}_t)=1+1/\tau\). The regression of quality on \(\hat f^{\,B}_t\) has the slope \(\operatorname{Cov}(f_t,\hat f^{\,B}_t)/\operatorname{Var}(\hat f^{\,B}_t)=1/(1+1/\tau)=\tau/(1+\tau)\), so the best prediction of quality shrinks \(\hat f^{\,B}_t\) towards zero, the average quality: \[\hat f_t=\frac{\tau}{1+\tau}\,\hat f^{\,B}_t=\sum_i w_i\,x_{ti},\qquad w_i=\frac{\lambda_i/\psi_i}{1+\tau}.\] This is the regression score, the centre of the bell curve in the figure above.
The weights of the four critics are 0.15, 0.36, 0.08 and 0.43. Critic 4 counts most (loading 0.90, quirk variance 0.19) and critic 3 least (0.60 and 0.64). With \(k\) factors the same idea gives \(\hat{\mathbf f}_t=\Lambda'\Sigma^{-1}\mathbf x_t\), the regression of the factors on the variables: its coefficients are \(\Sigma^{-1}\operatorname{Cov}(\mathbf x_t,\mathbf f_t)\), the matrix version of a covariance over a variance, and \(\operatorname{Cov}(\mathbf x_t,\mathbf f_t)=\operatorname{Cov}(\Lambda\mathbf f_t+\mathbf u_t,\mathbf f_t)=\Lambda\). (With correlated factors, \(\operatorname{Cov}(\mathbf x_t,\mathbf f_t)=\Lambda\Phi\), and the scores become \(\hat{\mathbf f}_t=\Phi\Lambda'\Sigma^{-1}\mathbf x_t\).)
The scores do not depend on the units (Section 6.5.4). With critic 1 on the 100-point scale, her loading is ten times and her unique variance a hundred times as large. So her precision \(\lambda_1^2/\psi_1\) and the total precision \(\tau\) stay the same, and her weight \(w_1=(\lambda_1/\psi_1)/(1+\tau)\) becomes ten times smaller. That exactly offsets her ten times larger rating, and every restaurant gets the same score as before: the scores estimate the same quality \(f_t\). With \(k\) factors, \(\Lambda'\Sigma^{-1}\) becomes \(\Lambda'\Sigma^{-1}\operatorname{diag}(\alpha)^{-1}\), with the same effect.
6.7.3 The scores are never exact
How well do the scores track the true quality? The regression score is Bartlett’s score times a number, so both have the same squared correlation with quality:
\[ \rho^2=\frac{\operatorname{Cov}(f_t,\hat f^{\,B}_t)^2}{\operatorname{Var}(f_t)\operatorname{Var}(\hat f^{\,B}_t)} =\frac{1}{1+1/\tau}=\frac{\tau}{1+\tau} . \]
With critic 1 alone, \(\rho^2=0.56\), her communality. Each further critic adds her precision to \(\tau\) and moves \(\rho^2\) towards one:
crit_weights <- function(m) { l <- crit_lam[1:m]; p <- crit_psi[1:m]; (l / p) / (1 + sum(l^2 / p)) }
crit_reliability <- function(m) { tau <- sum(crit_lam[1:m]^2 / crit_psi[1:m]); tau / (1 + tau) }
f2 <- function(x, d = 2) formatC(x, format = "f", digits = d)
fig_crit_scores <- function() {
d <- purrr::map_dfr(1:4, function(m) {
lab <- sprintf("%s\nρ² = %s", c("critic 1 alone", "critics 1 and 2", "critics 1 to 3", "all four critics")[m],
f2(crit_reliability(m)))
tibble(est = drop(crit_X[, 1:m, drop = FALSE] %*% crit_weights(m)), true = crit_d$quality, panel = lab)
}) |> mutate(panel = factor(panel, levels = unique(panel)))
ggplot(d, aes(est, true)) + geom_abline(slope = 1, intercept = 0, colour = col_f, linetype = "22") +
geom_point(alpha = 0.35, size = 1.2, colour = "#2c3e50") +
facet_wrap(~ panel, nrow = 1) + coord_equal(xlim = c(-3, 3), ylim = c(-3, 3)) +
labs(x = "estimated quality (factor score)", y = "true quality") +
theme(strip.text = element_text(size = 11, face = "bold"))
}
# draw the figure
fig_crit_scores()
Even with all four critics, \(\rho^2=0.91\), not one: a restaurant with good ratings may simply have caught its critics on good evenings. More critics push \(\rho^2\) closer to one, but never all the way. This is factor indeterminacy: with more shocks than variables, the data never pin down the factors exactly (Section 6.7.1). Everitt and Hothorn (Section 5.8) consider it a more damaging problem than the rotation.
In practice the loadings and unique variances are estimated, and factanal() computes the scores from the estimates:
crit_fs <- factanal(crit_X, factors = 1, scores = "regression")
head(round(crit_fs$scores, 2), 3) # the first three restaurants
## Factor1
## [1,] -0.40
## [2,] -0.02
## [3,] 0.54
cor(crit_fs$scores, crit_d$quality)^2 # how well the scores track the true quality
## [,1]
## Factor1 0.8863885The estimated scores track the simulated quality with a squared correlation of
0.89, close to the 0.91 of the model.
scores = "Bartlett" gives Bartlett’s scores instead. With one factor they are the regression scores times
\((1+\tau)/\tau\), so they track quality equally well.
Check your understanding
- In the regression score, a critic’s weight is proportional to
- her loading
- her loading divided by her unique variance
- the variance of her ratings
- one, the same for every critic
- Even with all four critics, the scores track quality with \(\rho^2=0.91\), because
- the sample is small
- there are more shocks than ratings, so quality and quirks cannot be fully separated
- the loadings were estimated
- the model is wrong
- Unlike factor scores, PCA scores
- are exact functions of the data
- have variance one
- are always positive
- need a rotation
- In \(\mathbf x_t=A\boldsymbol\varepsilon_t\), the shocks can be computed exactly from the data when \(A\)
- has more columns than rows
- is square and invertible, or has more rows than columns and no column is a combination of the others
- has a diagonal block
- never
Answers
1 b. 2 b. 3 a. 4 b.6.8 The US states
The simulated critics and test scores were built to fit a factor model. Real data need not. Take the six state indicators of Chapter 2, with the 50 states as observations: income, illiteracy, life expectancy, the murder rate, the high-school graduation rate and the number of days with frost.
X <- state.x77[, c("Income", "Illiteracy", "Life Exp", "Murder", "HS Grad", "Frost")]
factanal(X, factors = 1)$PVAL # one factor
## objective
## 3.872699e-07
fa2 <- factanal(X, factors = 2) # two factors, varimax
fa2$PVAL
## objective
## 0.0004735598
print(fa2$loadings, cutoff = 0)
##
## Loadings:
## Factor1 Factor2
## Income 0.141 0.683
## Illiteracy -0.644 -0.500
## Life Exp 0.744 0.332
## Murder -0.989 -0.133
## HS Grad 0.381 0.833
## Frost 0.513 0.237
##
## Factor1 Factor2
## SS loadings 2.373 1.594
## Proportion Var 0.396 0.266
## Cumulative Var 0.396 0.661
round(fa2$uniquenesses, 3)
## Income Illiteracy Life Exp Murder HS Grad Frost
## 0.514 0.336 0.336 0.005 0.161 0.681One factor loads 0.48 on income, -0.89 on illiteracy, 0.74 on life expectancy, -0.81 on murder, 0.72 on graduation and 0.63 on frost: a general factor, much like the well-being index of the first principal component (Section 4.5). But the test rejects it (statistic 47.0 on 9 degrees of freedom, p-value below 0.0001). Two factors are rejected as well (20.1 on 4 degrees of freedom, p-value of 0.0005). Three factors leave no degrees of freedom (Section 6.4). Here they happen to reproduce the correlations exactly, so nothing is left to test. This is common with real data. The model is an approximation, and the test finds the gap.
Here are the two varimax factors all the same, as a description, next to the first two principal components of the same six indicators (Section 4.5). The components come from the correlation matrix, as in Chapter 4, because the indicators are measured in different units; the factors need no such choice (Section 6.5.4). Both panels show loadings (Section 4.2.5): the arrow of an indicator has as its coordinates how far one standard deviation of the first and of the second component, or factor, moves the standardised indicator. An arrow that reached the dashed circle would have all of its variance in the plane.
loading_panel <- function(L, pos, col, title, subtitle, what) {
d <- tibble(var = rownames(L), x = L[, 1], y = L[, 2]) |> left_join(pos, by = "var")
circ <- tibble(t = seq(0, 2 * pi, length.out = 200), x = cos(t), y = sin(t))
ggplot() + axes0 +
geom_path(data = circ, aes(x, y), colour = "#dddddd", linetype = "22") +
geom_segment(data = d, aes(0, 0, xend = x, yend = y), colour = col, linewidth = 1,
arrow = arrow(length = unit(0.2, "cm"), type = "closed")) +
geom_text(data = d, aes(x + dx, y + dy, label = var, hjust = hj, vjust = vj), size = 3.7, colour = "#2c3e50") +
coord_equal(xlim = c(-1.2, 1.2), ylim = c(-1.2, 1.2)) +
labs(title = title, subtitle = subtitle, x = paste("loading on", what, "1"), y = paste("loading on", what, "2")) +
theme(plot.title = element_text(colour = col, face = "bold"))
}
fig_states_pca_fa <- function() {
# where each label goes, relative to its arrow's tip: offset (dx, dy) and alignment (hj, vj)
pos_pca <- tribble(~var, ~dx, ~dy, ~hj, ~vj,
"Income", 0.03, 0.05, 0, 0,
"Illiteracy", 0, -0.07, 0.5, 1,
"LifeExp", 0.05, 0, 0, 0.5,
"Murder", 0, 0.06, 0.5, 0,
"HSGrad", 0.05, 0.02, 0, 0.5,
"Frost", 0.04, -0.05, 0, 1)
pos_fa <- tribble(~var, ~dx, ~dy, ~hj, ~vj,
"Income", -0.04, 0.04, 1, 0.5,
"Illiteracy", 0, -0.07, 0.5, 1,
"LifeExp", 0.06, 0.03, 0, 0.5,
"Murder", 0, -0.07, 0.5, 1,
"HSGrad", 0, 0.07, 0.5, 0,
"Frost", 0.05, -0.08, 0, 1)
loading_panel(st_pca_A, pos_pca, col_third, "PCA", "two components, correlation matrix", "component") +
loading_panel(st_L, pos_fa, col_f, "Factor analysis", "two factors, turned by varimax", "factor")
}
# draw the figure
fig_states_pca_fa()
In the right panel, the first factor is dominated by the murder rate (loading -0.99), with life expectancy
(0.74), illiteracy (-0.64) and frost (0.51). The second
factor is graduation (0.83) and income (0.68), with illiteracy
(-0.50). The uniqueness of murder is 0.005, the smallest value
that factanal() allows: the estimate has hit the boundary, a Heywood case (Section 6.3.3). With a
lower bound of 0.0001 instead (control = list(lower = 0.0001)), the estimate drops to 0.0001 as well. The first factor is then almost the murder rate itself,
and the other variables load on it through their correlations with murder.
In the left panel, the first component contrasts illiteracy and murder with life expectancy, graduation, frost and income, and the second is mainly income. The two fans of arrows are much alike, but turned against each other: varimax has picked the turn that puts one axis through murder and the other through graduation and income. Neither description is more true than the other, since both summarise the same correlations. The arrows have different lengths, though, and Section 6.9 shows what the lengths mean. Given the rejected tests and the Heywood case, these two factors are a description, not a discovery. Everitt and Hothorn (Section 5.9) show two real examples that fit better: life expectancies by country, age and sex, and drug use by American college students.
Check your understanding
- For the states, the test of two factors gives a p-value of 0.0005, and three factors have no degrees of freedom. So
- two factors fit well
- the test rejects two factors, and with three factors nothing is left to test
- the test rejects three factors
- one factor fits
- The uniqueness of murder, 0.005, means that
- murder is unrelated to the factors
- the estimate hit the boundary: the first factor is almost the murder rate itself
- murder has the smallest variance of the six indicators
- the model fits perfectly
Answers
1 b. 2 b.6.9 Factor analysis and PCA
Both methods describe many variables by a few, and with small unique variances they give similar answers (Everitt and Hothorn, Section 5.10). But they are different models:
| PCA | Factor analysis | |
|---|---|---|
| Shocks | \(p\), as many as variables | \(k\) common factors and \(p\) unique shocks |
| Restriction on \(A\) | perpendicular arrows, ordered by length | each unique shock moves one variable |
| What it explains | the variances | the covariances |
| A change of units | changes the components | rescales the loadings and unique variances, but not the factors (maximum likelihood) |
| Scores | exact, \(\mathbf f_t=\Gamma'\mathbf x_t\) | estimated, never exact |
| One more component or factor | the first ones stay the same | all factors can change |
| A test of the model | none | yes, if \(\text{df}>0\) |
The states of Section 6.8 show these differences at work, starting with the second-to-last row. With one factor, the loadings of income, illiteracy, life expectancy, murder, graduation and frost are 0.48, -0.89, 0.74, -0.81, 0.72 and 0.63. The first column of the two-factor solution as estimated, before varimax, is different: 0.24, -0.71, 0.79, -1.00, 0.51 and 0.54. The first principal component has the loadings 0.59, -0.89, 0.79, -0.83, 0.81 and 0.66, whether one component is kept or two.
The biggest difference is in what counts as common. Each indicator is standardised, so its variance is one, and each method splits this variance in two parts:
- PCA: the part that its first two components keep, and the rest, which the other four components carry.
- Factor analysis: the part that the two factors explain, the communality, and the unique variance, which belongs to the indicator alone.
The bars show the two splits for each indicator. Each coloured part is split once more, into the first component or factor (dark) and the second (light). These are the squared loadings, and their total is the squared length of the indicator’s arrow in Section 6.8. Turning the factors, for instance by varimax, moves the line between the dark and the light part, but not the total, so the totals at the end of the bars do not depend on the turn.
pct <- function(x, d = 0) paste0(formatC(100 * x, format = "f", digits = d), "%")
fig_fa_pca <- function() {
light <- function(col) grDevices::colorRampPalette(c(col, "white"))(5)[3]
fills <- c(pca1 = col_third, pca2 = light(col_third), fa1 = col_f, fa2 = light(col_f), rest = "#e6e6e6")
labs_m <- c(pca1 = "PCA: first component", pca2 = "PCA: second component",
fa1 = "factor analysis: first factor (varimax)", fa2 = "factor analysis: second factor (varimax)",
rest = "the rest of the indicator's variance")
ord <- st_share$var[order(st_share$fa, decreasing = TRUE)] # bottom to top: the largest unique variance on top
pos <- tibble(var = ord, y = seq_along(ord))
w <- 0.36 # height of each bar; PCA above, factor analysis below
bars <- st_share |> left_join(pos, by = "var") |>
tidyr::pivot_longer(c(pca1, pca2, fa1, fa2), names_to = "part", values_to = "share") |>
mutate(method = substr(part, 1, nchar(part) - 1), yc = ifelse(method == "pca", y + 0.2, y - 0.2)) |>
group_by(var, method) |> mutate(x0 = cumsum(share) - share, x1 = cumsum(share)) |> ungroup()
tots <- bars |> group_by(var, method, yc) |> summarise(total = sum(share), .groups = "drop") |>
mutate(lab = ifelse(total > 0.99, pct(total, 1), pct(total)))
ggplot() +
geom_rect(data = distinct(bars, var, method, yc), aes(xmin = 0, xmax = 1, ymin = yc - w / 2, ymax = yc + w / 2,
fill = "rest")) +
geom_rect(data = bars, aes(xmin = x0, xmax = x1, ymin = yc - w / 2, ymax = yc + w / 2, fill = part)) +
geom_text(data = tots, aes(x = total, y = yc, label = lab, colour = method), hjust = -0.15, size = 3.9,
fontface = "bold", show.legend = FALSE) +
scale_fill_manual(values = fills, labels = labs_m, breaks = names(labs_m), name = NULL) +
scale_colour_manual(values = c(pca = col_third, fa = col_f)) +
scale_x_continuous(labels = scales::percent, breaks = seq(0, 1, 0.25), limits = c(0, 1.1), expand = c(0, 0)) +
scale_y_continuous(breaks = pos$y, labels = pos$var, expand = c(0.02, 0.02)) +
guides(fill = guide_legend(ncol = 2, byrow = TRUE)) +
labs(x = "share of the indicator's variance", y = NULL) +
theme(legend.position = "top", panel.grid.major.y = element_blank(), panel.grid.minor.y = element_blank())
}
# draw the figure
fig_fa_pca()
Together, the two components keep 76% of the total variance of the six indicators, and the two factors explain 66%. The difference is largest for frost and income, the indicators with the largest unique variances (0.68 and 0.51). PCA keeps 60% of the variance of frost and 86% of that of income, while the factor model counts only 32% and 49% as common. PCA looks for the directions of largest variance, and part of an indicator’s unique variance lies along them, so the components take it in. Factor analysis sets it apart. For graduation and life expectancy the factor model claims a little more than PCA, and for murder almost all of the variance, because of the Heywood case.
With real data, the true common parts are unknown. In the simulated six tests, where they are known, PCA claims too much for every test: two principal components keep between 58% and 74% of each test’s variance, while the true common parts lie between 36% and 64%. And both methods are pointless if the variables are almost uncorrelated, because then there is nothing in common to find.
Check your understanding
- For frost, two principal components keep 60% of the variance and two factors explain 32%, because
- the components also take in part of the unique variance of frost
- frost is the most reliable indicator
- PCA uses the covariance matrix
- the factor model ignores frost
- Which of the two methods can be tested against the data?
- PCA
- factor analysis, when the model has positive degrees of freedom
- both
- neither
Answers
1 a. 2 b.6.10 Summary
- A factor model writes each variable as loadings times a few common factors, plus a unique shock: \(x_{ti}=\lambda_{i1}f_{t1}+\dots+\lambda_{ik}f_{tk}+u_{ti}\), or \(\mathbf x_t=\Lambda\mathbf f_t+\mathbf u_t\), so that \(\Sigma=\Lambda\Lambda'+\Psi\). Only the common factors create covariance. In the structural form \(\mathbf x_t=A\boldsymbol\varepsilon_t\) it has \(k+p\) shocks, and the unique shocks fill a diagonal block of \(A\).
- With one factor, two variables fix only the product of their loadings. A third variable pins the loadings down (just identified), and a fourth adds two testable restrictions, the tetrad conditions. In general the model has \(\text{df}=\tfrac12\big[(p-k)^2-(p+k)\big]\) restrictions.
- A negative or zero unique variance is a Heywood case: the model does not fit, or the sample is too small.
- Maximum likelihood finds the \(\Lambda\Lambda'+\Psi\) closest to \(S\), and the likelihood ratio test asks whether the remaining gap is more than sampling noise. A change of units rescales the loadings and unique variances, and leaves the factors, the fit and the test as they were (scale invariance).
- With two or more factors, the factors can be turned without changing the fit. Varimax picks the turn with the simplest structure, and promax also lets the factors correlate. Rotation changes the description, not the fit. The data find the groups of variables, such as the verbal and the mathematics tests, but the names of the factors come from what we know about the variables.
- Here the data choose the turn, so the analysis is exploratory. Theory can instead fix loadings in advance, for example a zero where a test should not depend on an ability. That makes it confirmatory (Chapter 8).
- The parameters are identified, but the shocks are not: \(A\) has more columns than rows, so it has no inverse. Factor scores estimate the factors. Each variable counts in proportion to its loading over its unique variance, and the scores are never exact (factor indeterminacy).
- For the states, the tests reject one and two factors, and two factors give a Heywood case. A factor model is an approximation, and its factors are interpretations.
- PCA explains the variances and mixes the unique variances into its components. Factor analysis explains the covariances and sets the unique variances apart.
A factor model explains the covariances by a few common factors, and keeps each variable’s own noise apart.
6.10.1 Further reading
- Everitt and Hothorn (2011), An Introduction to Applied Multivariate Analysis with R, Chapter 5: Spearman’s example and the Heywood case, scale invariance, principal factor and maximum likelihood estimation, the test for the number of factors, rotation, factor scores, two examples (life expectancies, and drug use by American college students), and the comparison with PCA.
- Spearman (1904), “General intelligence, objectively determined and measured”, the origin of the one-factor model.
- Thurstone (1947), Multiple Factor Analysis, on several factors and simple structure.
- Kaiser (1958) on varimax, and Hendrickson and White (1964) on promax.
- Lawley and Maxwell (1971), Factor Analysis as a Statistical Method, on maximum likelihood and the test.
- Bartholomew, Knott and Moustaki (2011), Latent Variable Models and Factor Analysis: A Unified Approach, a modern treatment that includes factor scores.