Code
set.seed(20262)
n <- 300
age <- runif(n, 22, 60)
educ <- 4 + 0.12 * age + rnorm(n, sd = 2.5)
income <- 8 + 0.09 * educ + 0.03 * age - 0.0002 * age^2 + rnorm(n, sd = 0.4)
full <- coef(lm(income ~ educ + age + I(age^2)))[["educ"]]
r1 <- resid(lm(income ~ age + I(age^2)))
r2 <- resid(lm(educ ~ age + I(age^2)))
fwl <- coef(lm(r1 ~ r2))[["r2"]]
c(multiple = full, fwl = fwl, difference = full - fwl)
#> multiple fwl difference
#> 9.522945e-02 9.522945e-02 1.526557e-16