Skip to main content

Hierarchical Regression: Does Beauty Predict Teaching Evaluations?

Hierarchical (blockwise) regression in R with real data: do better-looking instructors get better evaluations? R² change, F-change, order effects, APA reporting.

The question: does beauty matter over and above everything else?

At the end of every term, students at the University of Texas at Austin rated their courses from 1 (very unsatisfactory) to 5 (excellent). For 463 courses taught between 2000 and 2002, economists Daniel Hamermesh and Amy Parker also asked six students to rate the physical appearance of each instructor from their photograph. Their question: do better-looking instructors get better evaluations (Hamermesh & Parker, 2005)?

A simple correlation is not enough to answer it. Beauty might go together with other things that also affect evaluations: age, gender, the kind of course, the size of the class. The real question is one of incremental validity:

Does beauty predict teaching evaluations over and above who the instructor is and what they teach?

Hierarchical regression answers exactly this kind of question. We enter the predictors in blocks, in an order decided in advance, and after each block we ask how much more of the variance of the outcome the model explains. That increase is the R² change, \(\Delta R^2\), and the F-change test tells us whether it is larger than chance.

The predictor of interest goes in last, so it gets credit only for what the earlier blocks cannot explain. If beauty still adds something after everything else, that is strong evidence that it matters on its own.

A note on the name. “Hierarchical” here means the order in which blocks of predictors enter the model. It has nothing to do with hierarchical linear models, also called multilevel or mixed models, which are for data nested in groups (students in schools, courses in instructors). Those have their own tutorial: Multilevel Models. We will meet the nesting issue in section 8, because these data have it too.

Code
library(AER)        # the data: TeachingRatings
library(ggplot2)
library(patchwork)  # put plots together
library(car)        # vif(): checks multicollinearity
library(sandwich)   # vcovCL(): cluster-robust standard errors (section 8)
library(lmtest)     # coeftest() and waldtest() with those standard errors
library(ggfortify)  # needed by rwf's report_regression() for its diagnostic plots (section 7)

1. The data

Code
data("TeachingRatings", package = "AER")
tr <- TeachingRatings
c(courses = nrow(tr), instructors = length(unique(tr$prof)))
    courses instructors 
        463          94 
Variable Meaning
eval The course’s average evaluation, from 1 (very unsatisfactory) to 5 (excellent)
beauty The instructor’s appearance, rated by six students from a photograph and averaged, shifted to a mean of 0
gender, minority, native, age The instructor: female or male, from a minority (non-Caucasian) or not, native English speaker or not, age in years
tenure Is the instructor on the tenure track?
division An upper-division course, or a lower-division one (mainly large first- and second-year courses)
credits A single-credit elective (yoga, aerobics, dance) or a regular course
allstudents The number of students enrolled
prof Which of the 94 instructors taught the course

We code each yes/no variable as a 0/1 dummy with a clear name, so that every coefficient says what it compares. Age goes in decades, so that its coefficient is not a tiny number per year. Class size is very skewed (8 to 581 students), so we use its base-2 logarithm: one unit more means twice as many students.

Code
d <- data.frame(
  eval           = tr$eval,
  female         = as.integer(tr$gender == "female"),   # 1 = female instructor
  minority       = as.integer(tr$minority == "yes"),    # 1 = minority (non-Caucasian)
  non_native     = as.integer(tr$native == "no"),       # 1 = not a native English speaker
  age            = tr$age / 10,                         # in decades: +1 = ten years older
  tenure_track   = as.integer(tr$tenure == "yes"),      # 1 = on the tenure track
  lower_division = as.integer(tr$division == "lower"),  # 1 = lower-division course
  single_credit  = as.integer(tr$credits == "single"),  # 1 = single-credit elective
  log2_size      = log2(tr$allstudents),                # +1 = class twice as large
  beauty         = tr$beauty,
  prof           = tr$prof)

round(sapply(d[, 1:10], function(x) c(mean = mean(x), sd = sd(x), min = min(x), max = max(x))), 2)
     eval female minority non_native  age tenure_track lower_division single_credit log2_size beauty
mean 4.00   0.42     0.14       0.06 4.84         0.78           0.34          0.06      5.15   0.00
sd   0.55   0.49     0.35       0.24 0.98         0.41           0.47          0.23      1.22   0.79
min  2.10   0.00     0.00       0.00 2.90         0.00           0.00          0.00      3.00  -1.45
max  5.00   1.00     1.00       1.00 7.30         1.00           1.00          1.00      9.18   1.97

For the dummies, the mean is the share of courses with a 1: for example, 42% of the courses were taught by women and 6% were single-credit electives. The average evaluation is 4.00 (SD = 0.55): students were generally satisfied.

Hierarchical regression compares models fitted to the same people. If some variables had missing values, each model would drop different rows and the R² values would not be comparable. These data have none, but in your own data remove incomplete rows first, e.g. d <- na.omit(d[, variables_of_all_blocks]).


2. Look at the data

Code
r_beauty <- cor(d$beauty, d$eval)
p1 <- ggplot(d, aes(beauty, eval)) +
  geom_point(colour = "#0082c8", alpha = 0.5, size = 1.8) +
  geom_smooth(method = "lm", formula = y ~ x, colour = "#E74C3C", fill = "#E74C3C", alpha = 0.15) +
  labs(title = sprintf("Better-looking instructors get somewhat better evaluations (r = %.2f)", r_beauty),
       x = "beauty rating (0 = average)", y = "course evaluation (1 to 5)")

predictors <- c("female", "minority", "non_native", "age", "tenure_track",
                "lower_division", "single_credit", "log2_size", "beauty")
cors <- data.frame(predictor = factor(predictors, levels = rev(predictors)),
                   with_eval = sapply(d[predictors], cor, y = d$eval))
p2 <- ggplot(cors, aes(with_eval, predictor, fill = with_eval > 0)) +
  geom_col() +
  geom_vline(xintercept = 0) +
  scale_fill_manual(values = c(`TRUE` = "#0082c8", `FALSE` = "#E74C3C"), guide = "none") +
  labs(title = "Correlation of each predictor with the evaluation", x = "correlation", y = NULL)
p1 / p2

Plot: 2. Look at the data

Beauty correlates 0.19 with the evaluations, so it explains \(r^2\) = 3.6% of their variance on its own. Single-credit electives get the best evaluations; female, non-native and tenure-track instructors, and larger classes, get lower ones. Several of these predictors also correlate with beauty, which is why we need a model that holds them constant.


3. The plan: three blocks, chosen in advance

Step Block Predictors Why here
1 Who the instructor is female, minority, non_native, age Fixed before any teaching starts, so nothing else can cause them
2 The job and the course tenure_track, lower_division, single_credit, log2_size What and whom they teach, and on which contract
3 Appearance beauty The predictor of interest: entered last, so it must explain something the first two blocks cannot

The order comes from theory and the research question, decided before looking at the results. Common rules: background variables and things that come first in time go first, control variables go before the predictors of interest, and the predictor whose added value you want to test goes last.

This is the opposite of stepwise regression, where the computer adds or drops predictors according to their p values. Stepwise selection capitalizes on chance, and its p values and R² are too optimistic. In hierarchical regression you decide the order, and the data only answer the question you asked.


4. Fit the three models and test each step

Code
m0 <- lm(eval ~ 1, data = d)                                                        # no predictors: R² = 0
m1 <- lm(eval ~ female + minority + non_native + age, data = d)                     # step 1
m2 <- update(m1, . ~ . + tenure_track + lower_division + single_credit + log2_size) # step 2: + block 2
m3 <- update(m2, . ~ . + beauty)                                                    # step 3: + beauty

update(m1, . ~ . + ...) means: the same model as m1, with these predictors added.

The formulas

For a model with \(k\) predictors fitted to \(n\) cases:

  • R², the share of the variance of the outcome the model explains: \(R^2 = 1 - \dfrac{RSS}{TSS}\), where \(RSS = \sum (y_i - \hat y_i)^2\) is what the model leaves unexplained and \(TSS = \sum (y_i - \bar y)^2\) is the total.
  • Adjusted R² corrects R² for the number of predictors, since adding any predictor, even pure noise, raises R² a little: \(R^2_{adj} = 1 - (1 - R^2)\dfrac{n - 1}{n - k - 1}\)
  • R² change from a smaller model (1) to a larger one (2): \(\Delta R^2 = R^2_2 - R^2_1\)
  • F-change, the test of \(\Delta R^2\), where \(\Delta k\) is the number of predictors added and \(k_2\) the number in the larger model:

\[F = \frac{\Delta R^2 / \Delta k}{(1 - R^2_2) / (n - k_2 - 1)}, \qquad \text{with } \Delta k \text{ and } n - k_2 - 1 \text{ degrees of freedom}\]

The top is the variance explained by the new block, per predictor added. The bottom is the variance still unexplained, per remaining degree of freedom. If the new block were useless, the two would be about equal and \(F\) would be close to 1.

  • Effect size of the change, Cohen’s \(f^2 = \dfrac{\Delta R^2}{1 - R^2_2}\): about .02 is small, .15 medium and .35 large (Cohen, 1988).

The steps by hand

Code
n <- nrow(d)
models <- list(m0, m1, m2, m3)
k_of <- function(m) length(coef(m)) - 1                     # number of predictors
steps <- do.call(rbind, lapply(2:4, function(i) {
  small <- models[[i - 1]]; big <- models[[i]]
  r2_small <- summary(small)$r.squared
  r2_big   <- summary(big)$r.squared
  delta    <- r2_big - r2_small
  dk       <- k_of(big) - k_of(small)
  df2      <- n - k_of(big) - 1
  F_change <- (delta / dk) / ((1 - r2_big) / df2)
  data.frame(step = i - 1, k = k_of(big), r2 = r2_big, adj_r2 = summary(big)$adj.r.squared,
             delta_r2 = delta, F_change = F_change, df1 = dk, df2 = df2,
             p = pf(F_change, dk, df2, lower.tail = FALSE), f2 = delta / (1 - r2_big))
}))
steps$block <- c("1: who the instructor is", "2: + the job and the course", "3: + beauty")
format(steps[, c("block", "k", "r2", "adj_r2", "delta_r2", "F_change", "df1", "df2", "p", "f2")], digits = 3)
                        block k     r2 adj_r2 delta_r2 F_change df1 df2        p     f2
1    1: who the instructor is 4 0.0527 0.0444   0.0527     6.37   4 458 5.40e-05 0.0556
2 2: + the job and the course 8 0.1268 0.1114   0.0741     9.63   4 454 1.76e-07 0.0848
3                 3: + beauty 9 0.1726 0.1562   0.0458    25.10   1 453 7.81e-07 0.0554
Code
bars <- data.frame(model = factor(rep(steps$block, 1:3), levels = steps$block),
                   block = factor(c(steps$block[1], steps$block[1:2], steps$block[1:3]), levels = steps$block),
                   value = c(steps$delta_r2[1], steps$delta_r2[1:2], steps$delta_r2[1:3]))
ggplot(bars, aes(model, value, fill = block)) +
  geom_col(width = 0.65, position = position_stack(reverse = TRUE)) +
  geom_text(data = steps, aes(x = block, y = r2, label = sprintf("R² = %.3f\nΔR² = %.3f", r2, delta_r2)),
            inherit.aes = FALSE, vjust = -0.3, size = 3.2, lineheight = 0.9) +
  scale_fill_manual(values = c("#95A5A6", "#f39c12", "#E74C3C"), labels = c("block 1", "block 2", "beauty")) +
  scale_y_continuous(limits = c(0, 0.22), labels = scales::percent) +
  labs(title = "Variance of the evaluations explained, step by step", x = NULL, y = "R²", fill = NULL)

The steps by hand

Step by step:

  1. Who the instructor is explains 5.3% of the variance of the evaluations, F(4, 458) = 6.37, p < .001.
  2. The job and the course add another 7.4%, F(4, 454) = 9.63, p < .001.
  3. Beauty adds 4.6% more, F(1, 453) = 25.1, p < .001, \(f^2\) = 0.055, a small effect by Cohen’s labels. Beauty predicts evaluations even after all eight other predictors have had their say.

Altogether the model explains 17.3% (adjusted 15.6%). Most of what makes a course well rated is not in these data, which is normal for something as complex as teaching.

The same tests with anova()

R compares nested models with anova(). Comparing each pair gives exactly the F-change of the table above, the value SPSS reports:

Code
anova(m0, m1)
Analysis of Variance Table

Model 1: eval ~ 1
Model 2: eval ~ female + minority + non_native + age
  Res.Df    RSS Df Sum of Sq     F    Pr(>F)    
1    462 142.24                                 
2    458 134.74  4     7.495 6.369 5.401e-05 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Code
anova(m1, m2)
Analysis of Variance Table

Model 1: eval ~ female + minority + non_native + age
Model 2: eval ~ female + minority + non_native + age + tenure_track + 
    lower_division + single_credit + log2_size
  Res.Df    RSS Df Sum of Sq      F   Pr(>F)    
1    458 134.74                                 
2    454 124.21  4    10.537 9.6287 1.76e-07 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Code
anova(m2, m3)
Analysis of Variance Table

Model 1: eval ~ female + minority + non_native + age + tenure_track + 
    lower_division + single_credit + log2_size
Model 2: eval ~ female + minority + non_native + age + tenure_track + 
    lower_division + single_credit + log2_size + beauty
  Res.Df    RSS Df Sum of Sq      F    Pr(>F)    
1    454 124.21                                  
2    453 117.69  1     6.521 25.101 7.813e-07 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

How to read it: Res.Df and RSS are the residual degrees of freedom and the residual sum of squares of each model. Df is the number of predictors added, Sum of Sq how much the residual sum of squares went down, and F and Pr(>F) are the F-change and its p value.

You will often see all the models in one call:

Code
anova(m1, m2, m3)
Analysis of Variance Table

Model 1: eval ~ female + minority + non_native + age
Model 2: eval ~ female + minority + non_native + age + tenure_track + 
    lower_division + single_credit + log2_size
Model 3: eval ~ female + minority + non_native + age + tenure_track + 
    lower_division + single_credit + log2_size + beauty
  Res.Df    RSS Df Sum of Sq      F    Pr(>F)    
1    458 134.74                                  
2    454 124.21  4    10.537 10.140 7.201e-08 ***
3    453 117.69  1     6.521 25.101 7.813e-07 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

The last line is the same, but the F for step 2 is now 10.14 instead of 9.63. With several models, anova() divides every comparison by the unexplained variance of the largest model (here m3), not of the model at that step. Both are valid tests. The pairwise version matches the F-change formula and SPSS; say which one you report.

One predictor: ΔR² is its squared semipartial correlation

When a step adds a single predictor, two shortcuts hold:

  • \(\Delta R^2\) equals the squared semipartial correlation \(sr^2\): the squared correlation between the outcome and the part of beauty that the other eight predictors cannot predict.
  • The F-change equals the square of beauty’s t value in the final model.
Code
beauty_unique <- resid(lm(beauty ~ female + minority + non_native + age + tenure_track +
                            lower_division + single_credit + log2_size, data = d))   # beauty, minus what the others predict
t_beauty <- summary(m3)$coefficients["beauty", "t value"]
c(delta_r2 = steps$delta_r2[3], semipartial_squared = cor(d$eval, beauty_unique)^2,
  F_change = steps$F_change[3], t_squared = t_beauty^2)
           delta_r2 semipartial_squared            F_change           t_squared 
         0.04584582          0.04584582         25.10107854         25.10107854 

So \(\Delta R^2\) for a single predictor is the share of the variance of the evaluations that only beauty explains.


5. The final model: what the coefficients say

Code
summary(m3)

Call:
lm(formula = eval ~ female + minority + non_native + age + tenure_track + 
    lower_division + single_credit + log2_size + beauty, data = d)

Residuals:
     Min       1Q   Median       3Q      Max 
-1.79974 -0.32825  0.06023  0.36077  1.00752 

Coefficients:
               Estimate Std. Error t value Pr(>|t|)    
(Intercept)     4.56028    0.19305  23.622  < 2e-16 ***
female         -0.19736    0.05125  -3.851 0.000135 ***
minority       -0.18051    0.07674  -2.352 0.019088 *  
non_native     -0.25068    0.10669  -2.350 0.019223 *  
age            -0.03082    0.02690  -1.146 0.252578    
tenure_track   -0.04029    0.06250  -0.645 0.519515    
lower_division  0.03468    0.05536   0.626 0.531317    
single_credit   0.55316    0.11686   4.734 2.95e-06 ***
log2_size      -0.05876    0.02053  -2.862 0.004411 ** 
beauty          0.15948    0.03183   5.010 7.81e-07 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 0.5097 on 453 degrees of freedom
Multiple R-squared:  0.1726,    Adjusted R-squared:  0.1562 
F-statistic:  10.5 on 9 and 453 DF,  p-value: 8.218e-15

How to read the output

Part Meaning
Estimate \(b\): the change in the evaluation for one unit more of the predictor, holding all the other predictors constant. For a 0/1 dummy, the difference between the two groups
Std. Error How uncertain the estimate is
t value Estimate / Std. Error
Pr(>|t|) The chance of a t this large if the true effect were 0
Residual standard error The typical distance of an evaluation from the model’s prediction, in evaluation points
Multiple R-squared, Adjusted R-squared R² and adjusted R² of the final model, as in our table
F-statistic Tests all nine predictors together against the model with none
  • (Intercept) is the predicted evaluation when every predictor is 0: a male, native, non-minority instructor aged 0, teaching one student. It is needed for the predictions but means nothing by itself.
  • beauty: 0.159 points per unit of beauty. One standard deviation of beauty (0.79) is worth 0.13 points, and the gap between the least and the best-looking instructor in the data is 0.55 points, about one standard deviation of the evaluations.
  • female: courses taught by women are rated 0.20 points lower than comparable courses taught by men.
  • single_credit: single-credit electives are rated 0.55 points higher.
  • log2_size: each doubling of the class costs 0.06 points.
  • non_native and minority instructors are rated 0.25 and 0.18 points lower; age, tenure track and division add nothing once the rest is held constant.

These are associations in observational data. Better-looking people may also be more confident or more practiced speakers, so the coefficient says that beauty predicts evaluations, not that it causes them.

Standardized coefficients

The b’s are in different units (decades, doublings of the class, rating points), so they cannot be compared with each other. A standardized coefficient \(\beta\) puts every predictor in standard deviations: \(\beta = b \cdot \dfrac{SD_x}{SD_y}\), the change in the evaluation, in SDs, for one SD more of the predictor.

Code
sd_ratio <- sapply(d[predictors], sd) / sd(d$eval)
ci <- confint(m3)[predictors, ]
betas <- data.frame(predictor = factor(predictors, levels = rev(predictors)),
                    b = coef(m3)[predictors], beta = coef(m3)[predictors] * sd_ratio,
                    low = ci[, 1] * sd_ratio, high = ci[, 2] * sd_ratio)
round(betas[, -1], 3)
                    b   beta    low   high
female         -0.197 -0.176 -0.266 -0.086
minority       -0.181 -0.112 -0.206 -0.018
non_native     -0.251 -0.108 -0.198 -0.018
age            -0.031 -0.054 -0.148  0.039
tenure_track   -0.040 -0.030 -0.122  0.062
lower_division  0.035  0.030 -0.063  0.123
single_credit   0.553  0.234  0.137  0.331
log2_size      -0.059 -0.129 -0.217 -0.040
beauty          0.159  0.227  0.138  0.316
Code
ggplot(betas, aes(beta, predictor)) +
  geom_vline(xintercept = 0, linetype = "dashed") +
  geom_errorbar(aes(xmin = low, xmax = high), width = 0.25, colour = "grey40") +
  geom_point(aes(colour = predictor == "beauty"), size = 3) +
  scale_colour_manual(values = c(`TRUE` = "#E74C3C", `FALSE` = "#0082c8"), guide = "none") +
  labs(title = "Standardised coefficients of the final model, with 95% CIs",
       x = "β (SDs of evaluation per SD of the predictor)", y = NULL)

Standardised – Standardized coefficients

Beauty (\(\beta\) = 0.23) and single-credit electives (\(\beta\) = 0.23) are the strongest predictors. For 0/1 dummies, a “one SD change” is an odd idea, so many authors report \(\beta\) only for continuous predictors and \(b\) for dummies.


6. The order matters

What if we had entered beauty first? Its share would then be its squared correlation with the evaluations. Entered last, it is its squared semipartial correlation. Here is that comparison for every predictor:

Code
full_r2 <- summary(m3)$r.squared
order_tab <- do.call(rbind, lapply(predictors, function(v) {
  alone   <- summary(lm(reformulate(v, "eval"), data = d))$r.squared            # entered first: r²
  without <- summary(update(m3, as.formula(paste(". ~ . -", v))))$r.squared
  data.frame(predictor = v, entered_first = alone, entered_last = full_r2 - without)   # entered last: sr²
}))
format(order_tab, digits = 2)
       predictor entered_first entered_last
1         female        0.0224      0.02708
2       minority        0.0059      0.01011
3     non_native        0.0200      0.01008
4            age        0.0027      0.00240
5   tenure_track        0.0168      0.00076
6 lower_division        0.0132      0.00072
7  single_credit        0.0553      0.04093
8      log2_size        0.0126      0.01496
9         beauty        0.0357      0.04585
Code
# (a) the same total R², credited differently in two orders
b1 <- lm(eval ~ beauty, data = d)
b2 <- update(b1, . ~ . + female + minority + non_native + age)
orders <- data.frame(
  order = factor(rep(c("planned order:\nbackground, course, beauty", "beauty first:\nbeauty, background, course"), each = 3),
                 levels = c("planned order:\nbackground, course, beauty", "beauty first:\nbeauty, background, course")),
  block = factor(rep(c("block 1: background", "block 2: course", "beauty"), 2),
                 levels = c("block 1: background", "block 2: course", "beauty")),
  value = c(steps$delta_r2,
            summary(b2)$r.squared - summary(b1)$r.squared, full_r2 - summary(b2)$r.squared, summary(b1)$r.squared),
  entry = c(1, 2, 3, 2, 3, 1))                     # the step at which each block enters: stacked in that order
pa <- ggplot(orders, aes(order, value, fill = block, group = entry)) +
  geom_col(width = 0.6, position = position_stack(reverse = TRUE)) +
  geom_text(aes(label = sprintf("%.3f", value)), position = position_stack(vjust = 0.5, reverse = TRUE), size = 3.2) +
  scale_fill_manual(values = c("#95A5A6", "#f39c12", "#E74C3C")) +
  scale_y_continuous(labels = scales::percent) +
  coord_flip() +
  labs(title = "(a) The same total R², credited differently", x = NULL, y = "R²", fill = NULL) +
  theme(legend.position = "bottom")

# (b) each predictor entered first (r²) and last (sr²)
order_tab$predictor <- factor(order_tab$predictor, levels = rev(predictors))
pb <- ggplot(order_tab, aes(y = predictor)) +
  geom_segment(aes(x = entered_first, xend = entered_last, yend = predictor), colour = "grey60", linewidth = 1) +
  geom_point(aes(x = entered_first, colour = "entered first (r²)"), size = 3) +
  geom_point(aes(x = entered_last, colour = "entered last (sr²)"), size = 3) +
  scale_colour_manual(values = c("entered first (r²)" = "#0082c8", "entered last (sr²)" = "#E74C3C")) +
  scale_x_continuous(labels = scales::percent) +
  labs(title = "(b) Variance each predictor explains, entered first or last",
       x = "share of the variance of the evaluations", y = NULL, colour = NULL) +
  theme(legend.position = "bottom")
pa / pb

6. The order matters

Two things happen:

  • Shared variance shrinks a predictor’s share. Tenure track explains 1.7% of the variance alone, but only 0.1% when entered last. What it explains, the other predictors explain too: tenure-track instructors rarely teach the well-rated single-credit electives (r = -0.29) and teach larger classes (r = 0.16). In hierarchical regression shared variance goes to the block that enters first. Division shows the same, because the single-credit electives are lower-division courses (r = 0.33), and so does native language.
  • Suppression enlarges it. Beauty explains 3.6% alone, but 4.6% entered last. Better-looking instructors are more often women (r = 0.13), teach somewhat larger classes (r = 0.07) and fewer single-credit electives (r = -0.08): all of these go with lower evaluations, so they hide part of beauty’s effect in the simple correlation. Holding them constant uncovers it. Gender, minority and class size grow for similar reasons.

That is why the order must be decided before the analysis and reported with the results: with correlated predictors, the credit each block gets depends on where it enters. The total R² does not change (panel a). Entering the predictor of interest last is the conservative choice: it gets credit only for what nothing else explains.


7. Checking the assumptions

The F-change tests and the standard errors assume that the residuals have constant variance, are roughly normal, contain no extreme cases with undue influence, and are independent of each other; that the relationships are linear; and that the predictors are not too strongly correlated. report_regression() of the rwf package collects the usual checks for an lm model: diagnostic plots, standardized coefficients, VIFs, an outlier test and more. It also prints a long text report, which we capture here, and keep only the parts we need:

Code
set.seed(1)    # its Durbin-Watson test uses random resampling
invisible(capture.output(diag_m3 <- report_regression(m3, plot_diagnostics = TRUE)))

Diagnostics – 7. Checking the assumptions

Panel What to look for Here
Residuals vs Fitted No curve and no funnel shape Flat, but the residuals are cut off at the top: no course can be rated above 5
Normal Q-Q Points on the line A longer lower tail: a few courses were rated much lower than predicted
Scale-Location A flat line: constant variance Roughly flat
Cook’s distance No case far above the others (values above 1 are a concern) The largest is 0.05
Residuals vs Leverage, Cook’s dist vs Leverage No case with both high leverage and a large residual None
Code
data.frame(predictor = predictors, vif = round(diag_m3$vif$vif, 2), tolerance = round(diag_m3$vif$tolerance, 2))
       predictor  vif tolerance
1         female 1.14      0.88
2       minority 1.25      0.80
3     non_native 1.15      0.87
4            age 1.24      0.81
5   tenure_track 1.20      0.84
6 lower_division 1.22      0.82
7  single_credit 1.34      0.75
8      log2_size 1.11      0.90
9         beauty 1.12      0.89
Code
diag_m3$outlier_test   # the most extreme studentized residual, with a Bonferroni-corrected p value
    rstudent            p   bonf.p signif cutoff
99 -3.591951 0.0003642181 0.168633  FALSE   0.05
  • Multicollinearity: the VIF (variance inflation factor) says how much a coefficient’s variance grows because the predictor correlates with the others. All are below 1.4, far from the usual warning level of 5 to 10.
  • Outliers: the most extreme residual is not significant after the Bonferroni correction (bonf.p = 0.17).
  • Normality: the skew comes from the ceiling at 5. With 463 cases, the tests of the coefficients are robust to it.

The assumption that these plots cannot check is independence, and these data break it.


8. A caveat: 463 courses, but only 94 instructors

Each instructor taught between 1 and 13 of the courses, and their beauty rating is the same in all of them. The plot shows every course as a point and joins the courses of the same instructor:

Code
ggplot(d, aes(beauty, eval, group = prof)) +
  geom_line(colour = "grey70") +
  geom_point(colour = "#0082c8", alpha = 0.6, size = 1.6) +
  labs(title = "Each vertical strip is one instructor and their courses",
       x = "beauty rating of the instructor", y = "course evaluation")

Clusters – 8. A caveat: 463 courses, but only 94 instructors

Courses of the same instructor are rated alike. The share of the unexplained variance that lies between instructors, the intraclass correlation of the residuals, is:

Code
d$residual <- resid(m3)
ri <- nlme::lme(residual ~ 1, random = ~ 1 | prof, data = d)   # residuals: instructor part + course part
vc <- as.numeric(nlme::VarCorr(ri)[, "Variance"])
icc <- vc[1] / sum(vc)
avg_courses <- n / length(unique(d$prof))
c(icc = icc, courses_per_instructor = avg_courses, design_effect = 1 + (avg_courses - 1) * icc)
                   icc courses_per_instructor          design_effect 
             0.4029194              4.9255319              2.5816729 

About 40% of what the model cannot explain is about who teaches the course. For a predictor that is constant within each instructor, like beauty, the 463 courses then carry about as much information as \(463 / \text{design effect} \approx\) 179 independent ones. Ordinary standard errors ignore this and are too small.

A quick fix is cluster-robust standard errors, which allow the residuals of the same instructor to be correlated:

Code
vc_cl <- vcovCL(m3, cluster = ~ prof)       # courses clustered within instructors
coeftest(m3, vcov = vc_cl)

t test of coefficients:

                Estimate Std. Error t value  Pr(>|t|)    
(Intercept)     4.560279   0.329307 13.8481 < 2.2e-16 ***
female         -0.197364   0.081033 -2.4356 0.0152523 *  
minority       -0.180507   0.099964 -1.8057 0.0716264 .  
non_native     -0.250676   0.138765 -1.8065 0.0715068 .  
age            -0.030815   0.042703 -0.7216 0.4708948    
tenure_track   -0.040289   0.099384 -0.4054 0.6853830    
lower_division  0.034684   0.085926  0.4036 0.6866606    
single_credit   0.553162   0.155306  3.5618 0.0004074 ***
log2_size      -0.058757   0.035080 -1.6750 0.0946289 .  
beauty          0.159481   0.048566  3.2838 0.0011036 ** 
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Code
se_compare <- data.frame(b = coef(m3), se_ordinary = sqrt(diag(vcov(m3))), se_cluster = sqrt(diag(vc_cl)),
                         p_ordinary = summary(m3)$coefficients[, 4], p_cluster = coeftest(m3, vcov = vc_cl)[, 4])
round(se_compare, 3)
                    b se_ordinary se_cluster p_ordinary p_cluster
(Intercept)     4.560       0.193      0.329      0.000     0.000
female         -0.197       0.051      0.081      0.000     0.015
minority       -0.181       0.077      0.100      0.019     0.072
non_native     -0.251       0.107      0.139      0.019     0.072
age            -0.031       0.027      0.043      0.253     0.471
tenure_track   -0.040       0.063      0.099      0.520     0.685
lower_division  0.035       0.055      0.086      0.531     0.687
single_credit   0.553       0.117      0.155      0.000     0.000
log2_size      -0.059       0.021      0.035      0.004     0.095
beauty          0.159       0.032      0.049      0.000     0.001

The coefficients stay the same; the standard errors grow, for beauty from 0.032 to 0.049, close to what the design effect predicted (\(\sqrt{2.58}\) = 1.61 times larger). Beauty is still significant (p = 0.001), but minority (p = 0.072), non-native (p = 0.072) and class size (p = 0.095) are no longer significant at .05.

The F-change tests can be redone the same way with a Wald test, using the cluster-robust variance of the larger model:

Code
waldtest(m1, m2, vcov = vcovCL(m2, cluster = ~ prof))   # step 2
Wald test

Model 1: eval ~ female + minority + non_native + age
Model 2: eval ~ female + minority + non_native + age + tenure_track + 
    lower_division + single_credit + log2_size
  Res.Df Df      F    Pr(>F)    
1    458                        
2    454  4 6.3341 5.757e-05 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Code
waldtest(m2, m3, vcov = vc_cl)                          # step 3: beauty
Wald test

Model 1: eval ~ female + minority + non_native + age + tenure_track + 
    lower_division + single_credit + log2_size
Model 2: eval ~ female + minority + non_native + age + tenure_track + 
    lower_division + single_credit + log2_size + beauty
  Res.Df Df      F   Pr(>F)   
1    454                      
2    453  1 10.783 0.001104 **
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Beauty’s robust F = 10.78 is its robust t squared (3.28²), against 25.1 with ordinary standard errors. The R² changes stay as they were; only their tests change.

Cluster-robust errors fix the standard errors, but they do not model the instructors. A multilevel model with a random intercept for each instructor does both, and also tells how much instructors differ: see the Multilevel Models tutorial.


9. Reporting the results in APA style

A hierarchical regression report (APA 7th edition) gives the order of the blocks and why, R², \(\Delta R^2\) and the F-change of every step, and the coefficients of the final model. We collect the numbers from the R objects:

Code
f2d  <- function(x) formatC(x, format = "f", digits = 2)
nz   <- function(x, d = 2) sub("^(-?)0", "\\1", formatC(x, format = "f", digits = d))   # no leading zero
pval <- function(p) if (p < .001) "< .001" else paste("=", nz(p, 3))
s3   <- summary(m3)$coefficients
cl   <- coeftest(m3, vcov = vc_cl)

Method (data analysis):

Course evaluations were analyzed with a three-step hierarchical regression. Instructor characteristics (gender, minority status, native English, age) were entered in Step 1, job and course characteristics (tenure track, lower division, single-credit course, class size as the base-2 logarithm of enrollment) in Step 2, and the instructor’s beauty rating in Step 3, so that beauty was credited only with variance not explained by the other predictors. Because the 463 courses were taught by 94 instructors, we also report standard errors clustered by instructor. Analyses were conducted in R (Version 4.6.2; R Core Team, 2026) with the sandwich and lmtest packages.

Results:

Instructor characteristics explained 5.3% of the variance in evaluations, R² = .05, F(4, 458) = 6.37, p < .001. Job and course characteristics explained an additional 7.4%, ΔR² = .07, F(4, 454) = 9.63, p < .001. Adding beauty in Step 3 increased the explained variance by a further 4.6%, ΔR² = .05, F(1, 453) = 25.10, p < .001, f² = .06. In the final model, R² = .17, adjusted R² = .16, more attractive instructors received higher evaluations, b = 0.16, SE = 0.03, β = .23, p < .001: one standard deviation of beauty was associated with 0.13 points higher evaluations on the 5-point scale. The effect remained significant with standard errors clustered by instructor, SE = 0.05, p = .001.

Table 1

Hierarchical Regression Predicting Course Evaluations

Predictor Step 1 b (SE) Step 2 b (SE) Step 3 b (SE) Step 3 β
Female -0.20 (0.05)*** -0.19 (0.05)*** -0.20 (0.05)*** -.18
Minority -0.05 (0.08) -0.17 (0.08)* -0.18 (0.08)* -.11
Non-native English -0.31 (0.11)** -0.24 (0.11)* -0.25 (0.11)* -.11
Age (decades) -0.06 (0.03)* -0.07 (0.03)* -0.03 (0.03) -.05
Tenure track -0.07 (0.06) -0.04 (0.06) -.03
Lower division 0.04 (0.06) 0.03 (0.06) .03
Single-credit course 0.48 (0.12)*** 0.55 (0.12)*** .23
Class size (log2) -0.06 (0.02)** -0.06 (0.02)** -.13
Beauty 0.16 (0.03)*** .23
R² .05 .13 .17
ΔR² .05 .07 .05
F for ΔR² 6.37*** 9.63*** 25.10***

Note. N = 463 courses taught by 94 instructors. F for ΔR² has 4 and 458, 4 and 454, and 1 and 453 degrees of freedom in Steps 1 to 3. Ordinary standard errors; with standard errors clustered by instructor, beauty remains significant (p = .001), while minority, non-native English and class size do not (p = .072 or above). * p < .05. ** p < .01. *** p < .001.

Points to remember:

  • Give the order of the blocks and the reason for it, decided before the analysis.
  • Report R² for every step, and for every block \(\Delta R^2\) with its F-change, degrees of freedom and p; an effect size such as \(f^2\) for the step of interest helps.
  • Say which F you report when you use anova() with more than two models (section 4).
  • Report the coefficients of the final model (and, if useful, of every step, as in Table 1), with b, SE and, for continuous predictors, β.
  • Say how you handled any dependence in the data, such as several observations per person or group.
  • Cite R and the packages; citation() and citation("sandwich") in R give the exact references.

10. Summary

What it answers Does a predictor (or block) explain variance over and above others: incremental validity
How Enter blocks in an order fixed in advance by theory; test each step with ΔR² and its F-change
ΔR² \(R^2_2 - R^2_1\); for a single predictor, its squared semipartial correlation
F-change \(F = \dfrac{\Delta R^2 / \Delta k}{(1 - R^2_2) / (n - k_2 - 1)}\); in R, anova(m1, m2) for each pair
Effect size \(f^2 = \Delta R^2 / (1 - R^2_2)\): .02 small, .15 medium, .35 large
The order matters Shared variance goes to the block that enters first; suppression can make a later predictor explain more. Put the predictor of interest last
Not stepwise You choose the order, not the p values
Same cases Every model must use the same rows: remove missing values first
Dependence Several observations per person or group: cluster-robust SEs (sandwich::vcovCL) or a multilevel model
Here Beauty added 4.6% of explained variance after eight other predictors; one SD of beauty ≈ 0.13 evaluation points

References

Cohen, J. (1988). Statistical power analysis for the behavioral sciences (2nd ed.). Lawrence Erlbaum.

Cohen, J., Cohen, P., West, S. G., & Aiken, L. S. (2003). Applied multiple regression/correlation analysis for the behavioral sciences (3rd ed.). Lawrence Erlbaum.

Fox, J., & Weisberg, S. (2019). An R companion to applied regression (3rd ed.). Sage.

Hamermesh, D. S., & Parker, A. (2005). Beauty in the classroom: Instructors’ pulchritude and putative pedagogical productivity. Economics of Education Review, 24(4), 369–376.

Kleiber, C., & Zeileis, A. (2008). Applied econometrics with R. Springer.

Zeileis, A., Köll, S., & Graham, N. (2020). Various versatile variances: An object-oriented implementation of clustered covariances in R. Journal of Statistical Software, 95(1), 1–36.

See also

  • rwf: the R package behind report_regression() on this page