Skip to main content

Multivariate Regression: Two Blood Pressures, One Model

Multivariate linear regression (several outcomes) in R with lm(cbind()), on the systolic and diastolic blood pressure of 3,800 US adults (NHANES 2021-2023): the matrix model by hand, what is the same as separate regressions and what is not, Pillai, Wilks, Hotelling-Lawley and Roy, testing whether a predictor has the same slope on both outcomes, confidence and prediction ellipses, joint against separate tests in small samples, checks, the bootstrap and APA reporting.

The question: two numbers that belong together

Blood pressure is always two numbers, such as 120 over 80. The upper one, systolic, is the pressure when the heart beats; the lower one, diastolic, the pressure between the beats. They are measured together, in the same unit, on the same person.

What goes with a higher blood pressure: age, sex, body weight? And do these raise both numbers, or one more than the other?

We could run two regressions, one for each number. Many papers do. But then three questions cannot be answered:

  1. Does body weight matter for blood pressure as a whole? (one test, not two)
  2. Does it raise the two numbers equally? (a comparison between two regressions)
  3. Once age, sex and weight are known, do the two numbers still go together?

Multivariate regression has several outcomes at once and answers all three. (The word is often used wrongly. Multiple regression has several predictors; multivariate regression has several outcomes.)

Code
library(foreign)   # read.xport(): the SAS transport files of the CDC (comes with R)
library(ggplot2)
library(car)       # Anova(), linearHypothesis() for models with several outcomes

# number formats for the text
f1   <- function(x) formatC(x, format = "f", digits = 1, big.mark = ",")
f2   <- function(x) formatC(x, format = "f", digits = 2, big.mark = ",")
f3   <- function(x) formatC(x, format = "f", digits = 3, big.mark = ",")
# no leading zero
nz <- function(x, d = 2) sub("^(-?)0", "\\1", formatC(x, format = "f", digits = d))
pval <- function(p) if (p < .001) "< .001" else paste("=", nz(p, 3))
num  <- function(x) trimws(format(x, big.mark = ","))
pct  <- function(x, d = 0) paste0(formatC(100 * x, format = "f", digits = d), "%")

1. The data

NHANES, the US health survey, measures blood pressure three times with an automatic device. The files of August 2021 to August 2023 (National Center for Health Statistics, 2024) are free and need no login: blood pressure (BPXO_L), age and sex (DEMO_L), body measures (BMX_L) and a questionnaire about blood pressure (BPQ_L).

Code
nhanes <- function(file) {
  path <- tempfile(fileext = ".xpt")
  download.file(
    paste0("https://wwwn.cdc.gov/Nchs/Data/Nhanes/Public/2021/DataFiles/", file, ".xpt"),
    path,
    mode = "wb",
    quiet = TRUE
  )
  read.xport(path)
}
raw <- merge(nhanes("BPXO_L"), nhanes("DEMO_L")[, c("SEQN", "RIDAGEYR", "RIAGENDR", "RIDEXPRG")])
raw <- merge(raw, nhanes("BMX_L")[, c("SEQN", "BMXBMI")])
raw <- merge(raw, nhanes("BPQ_L")[, c("SEQN", "BPQ150")], all.x = TRUE)

# systolic: mean of the readings (mmHg)
raw$sys <- rowMeans(raw[, paste0("BPXOSY", 1:3)], na.rm = TRUE)
raw$dia <- rowMeans(raw[, paste0("BPXODI", 1:3)], na.rm = TRUE)    # diastolic
adults <- subset(
  raw,
  RIDAGEYR >= 20 &
    RIDAGEYR < 80 &
    is.finite(sys) &
    is.finite(dia) &
    !is.na(BMXBMI) &
    !(RIDEXPRG %in% 1)
)
people <- subset(adults, !(BPQ150 %in% 1)) # not taking blood pressure medicine
c(adults = nrow(adults), without_medicine = nrow(people))
          adults without_medicine 
            5458             3816 
Code
people <- data.frame(
  sys = people$sys,
  dia = people$dia,
  age = (people$RIDAGEYR - 45) / 10, # in decades, centered at 45 years
  male = as.integer(people$RIAGENDR == 1),
  bmi = (people$BMXBMI - 27) / 5, # in steps of 5 kg/m², centered at 27
  years = people$RIDAGEYR
)
round(sapply(people[, c("sys", "dia")], function(v) c(mean = mean(v), sd = sd(v))), 1)
       sys  dia
mean 119.2 74.5
sd    15.9 10.3
Code
cor(people$sys, people$dia)
[1] 0.68687

We keep the 3,816 adults aged 20 to 79 who do not take medicine for blood pressure (the medicine would hide what we look for) and are not pregnant. The two pressures correlate at .69. The predictors are centered and scaled so that the numbers are easy to read: age in steps of ten years from 45, bmi (body mass index, kg/m²) in steps of 5 from 27, and male.


2. Look at the data

Code
long <- data.frame(years = rep(people$years, 2), mmHg = c(people$sys, people$dia),
                   pressure = rep(c("systolic", "diastolic"), each = nrow(people)))
long$pressure <- factor(long$pressure, levels = c("systolic", "diastolic"))

ggplot(long, aes(years, mmHg, colour = pressure)) +
  geom_point(position = position_jitter(width = 0.3, seed = 1), alpha = 0.08, size = 0.7) +
  geom_smooth(method = "loess", formula = y ~ x, se = FALSE, linewidth = 1.1) +
  scale_colour_manual(values = c(systolic = "#eb6834", diastolic = "#2a78d6"), name = NULL) +
  labs(title = "Two blood pressures against age", x = "age (years)", y = "mmHg") +
  theme_bw() + theme(legend.position = "bottom")

Plot: 2. Look at the data

The two numbers do not age in the same way. The systolic pressure rises all life long. The diastolic rises until about 50 and then falls, because the arteries stiffen. One straight line will not do for both, so we give age a square: \(age + age^2\) (see polynomial regression).


3. The model step by step, with formulas

Step 1: one equation per outcome, the same predictors

\[\begin{aligned} \text{sys}_i &= \beta_{01} + \beta_{11}\,\text{age}_i + \beta_{21}\,\text{age}_i^2 + \beta_{31}\,\text{male}_i + \beta_{41}\,\text{bmi}_i + \varepsilon_{i1} \\ \text{dia}_i &= \beta_{02} + \beta_{12}\,\text{age}_i + \beta_{22}\,\text{age}_i^2 + \beta_{32}\,\text{male}_i + \beta_{42}\,\text{bmi}_i + \varepsilon_{i2} \end{aligned}\]

Nothing new so far. The new part is that the two errors of one person may correlate: somebody with a systolic pressure above the expected one probably has a high diastolic, too. The errors of a person come from a bivariate normal distribution with covariance matrix \(\Sigma\):

\[(\varepsilon_{i1}, \varepsilon_{i2}) \sim N(0, \Sigma), \qquad \Sigma = \begin{pmatrix} \sigma_1^2 & \sigma_{12} \\ \sigma_{12} & \sigma_2^2 \end{pmatrix}\]

Step 2: the same in matrices

Put the outcomes side by side in a matrix \(Y\) (one row per person, one column per outcome), the predictors in \(X\), and the coefficients in \(B\) (one column per outcome):

\[Y = XB + E, \qquad \hat B = (X^\top X)^{-1} X^\top Y, \qquad \hat\Sigma = \frac{\hat E^\top \hat E}{n - q}\]

with \(q\) the number of columns of \(X\). The formula of \(\hat B\) works on each column of \(Y\) separately. So the coefficients are exactly those of two separate regressions, and the correlation of the outcomes does not change them.

Code
Y <- as.matrix(people[, c("sys", "dia")])
X <- model.matrix(~ age + I(age^2) + male + bmi, data = people)
n <- nrow(X); q <- ncol(X)
B     <- solve(crossprod(X), crossprod(X, Y))
E     <- Y - X %*% B
Sigma <- crossprod(E) / (n - q)
round(B, 3)
                sys    dia
(Intercept) 114.369 74.857
age           3.434  1.122
I(age^2)      0.077 -0.888
male          7.288  2.419
bmi           0.864  1.870
Code
round(Sigma, 1)
      sys   dia
sys 209.1 102.7
dia 102.7  93.0
Code
cov2cor(Sigma)[1, 2]               # the correlation of the two errors
[1] 0.7365269

Step 3: what is new, the covariance of coefficients of different equations

Two separate regressions give a variance for each coefficient, but nothing about how a coefficient of one equation goes with a coefficient of the other. The multivariate model gives it:

\[\text{Cov}(\hat\beta_{j1}, \hat\beta_{j2}) = \hat\sigma_{12}\,\big[(X^\top X)^{-1}\big]_{jj}\]

This is what is needed for tests across the equations, for example whether the slope of BMI is the same in both.

Step 4: the test of a predictor on all outcomes

For one outcome, an F test compares two sums of squares, that of the hypothesis and that of the errors. For several outcomes the sums of squares become matrices, \(H\) and \(E\), with the sums of cross-products off the diagonal. \(H\) is how much the matrix of errors grows when the predictor is left out:

\[H = E_{\text{without}}^\top E_{\text{without}} - E^\top E\]

Four statistics reduce the two matrices to one number. With the eigenvalues \(\lambda_1, \lambda_2, \dots\) of \(E^{-1}H\):

Statistic Formula Remark
Pillai’s trace \(\sum \frac{\lambda_i}{1 + \lambda_i}\) the most robust (Olson, 1976), the usual choice
Wilks’ lambda \(\prod \frac{1}{1 + \lambda_i}\) the likelihood-ratio test; small is significant
Hotelling–Lawley trace \(\sum \lambda_i\)
Roy’s largest root \(\lambda_1\) powerful when only one direction matters, not robust

For a predictor with one coefficient per outcome there is only one eigenvalue, the four agree, and the F test is exact.

Code
X0  <- X[, colnames(X) != "bmi"]                                     # the model without BMI
E0  <- Y - X0 %*% solve(crossprod(X0), crossprod(X0, Y))
H   <- crossprod(E0) - crossprod(E)
lam <- Re(eigen(solve(crossprod(E), H))$values)[1]
pillai <- lam / (1 + lam)
p_out  <- ncol(Y)
F_bmi  <- (pillai / p_out) / ((1 - pillai) / (n - q - p_out + 1))
c(eigenvalue = lam, pillai = pillai, F = F_bmi, df1 = p_out, df2 = n - q - p_out + 1)
  eigenvalue       pillai            F          df1          df2 
9.810508e-02 8.934034e-02 1.868902e+02 2.000000e+00 3.810000e+03 

4. Fitting the model and reading the output

The outcomes are joined with cbind():

Code
fit <- lm(cbind(sys, dia) ~ age + I(age^2) + male + bmi, data = people)
summary(fit)
Response sys :

Call:
lm(formula = sys ~ age + I(age^2) + male + bmi, data = people)

Residuals:
    Min      1Q  Median      3Q     Max 
-59.373  -9.232  -1.367   7.175  85.734 

Coefficients:
             Estimate Std. Error t value Pr(>|t|)    
(Intercept) 114.36924    0.41270 277.122   <2e-16 ***
age           3.43409    0.15899  21.600   <2e-16 ***
I(age^2)      0.07698    0.09922   0.776    0.438    
male          7.28848    0.47211  15.438   <2e-16 ***
bmi           0.86395    0.17159   5.035    5e-07 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 14.46 on 3811 degrees of freedom
Multiple R-squared:  0.1781,    Adjusted R-squared:  0.1772 
F-statistic: 206.4 on 4 and 3811 DF,  p-value: < 2.2e-16


Response dia :

Call:
lm(formula = dia ~ age + I(age^2) + male + bmi, data = people)

Residuals:
    Min      1Q  Median      3Q     Max 
-34.396  -6.234  -0.832   5.573  60.450 

Coefficients:
            Estimate Std. Error t value Pr(>|t|)    
(Intercept) 74.85706    0.27527 271.941   <2e-16 ***
age          1.12233    0.10604  10.584   <2e-16 ***
I(age^2)    -0.88813    0.06618 -13.421   <2e-16 ***
male         2.41861    0.31490   7.681    2e-14 ***
bmi          1.86964    0.11445  16.336   <2e-16 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 9.646 on 3811 degrees of freedom
Multiple R-squared:  0.1244,    Adjusted R-squared:  0.1235 
F-statistic: 135.4 on 4 and 3811 DF,  p-value: < 2.2e-16

summary() prints two ordinary regressions, “Response sys” and “Response dia”. They are exactly what lm(sys ~ ...) and lm(dia ~ ...) would print:

Code
sys_only <- lm(sys ~ age + I(age^2) + male + bmi, data = people)
all.equal(coef(sys_only), coef(fit)[, "sys"])
[1] TRUE
Code
all.equal(summary(sys_only)$coefficients, summary(fit)[["Response sys"]]$coefficients)
[1] TRUE
Code
b <- coef(fit)
s <- lapply(summary(fit), function(m) m$coefficients)
Predictor Systolic Diastolic In words
ten years more age, at 45 3.4 mmHg 1.1 mmHg three times as much for the upper number
the square of age 0.08 -0.89 the upper number rises in a straight line, the lower one bends down
men against women 7.3 2.4
5 kg/m² more BMI 0.9 1.9 twice as much for the lower number

The highest point of the diastolic curve is at the age where the slope is zero, \(-\beta_{12} / (2\beta_{22})\) decades after 45: 51 years.

The errors go together

The correlation of the residuals is .74. It answers question 3: two people of the same age, sex and BMI differ in both numbers in the same direction. This is the correlation of the two pressures given the predictors. It is even larger than the plain correlation of .69, because after 50 age raises one number and lowers the other, which blurs the link.


5. Testing across the outcomes

Question 1: does a predictor matter for blood pressure as a whole?

Code
joint <- Anova(fit, test.statistic = "Pillai")       # Type II: each predictor given the others
joint

Type II MANOVA Tests: Pillai test statistic
         Df test stat approx F num Df den Df    Pr(>F)    
age       1  0.121792   264.19      2   3810 < 2.2e-16 ***
I(age^2)  1  0.101074   214.19      2   3810 < 2.2e-16 ***
male      1  0.065723   134.01      2   3810 < 2.2e-16 ***
bmi       1  0.089340   186.89      2   3810 < 2.2e-16 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Anova() from car tests each predictor given the others, on both outcomes together. For BMI it gives Pillai’s trace = 0.089, F(2, 3,810) = 186.9, as our hand calculation did. All are clearly significant with 3,816 people. The square of age is the interesting one: for the systolic pressure alone it is not significant (p = .438), and for the pair it is one of the strongest predictors.

(anova(fit) without the A gives sequential tests, in the order of the formula. And the tests of a predictor that appears in two terms, as age does here, should be made together, by comparing with a model without both:)

Code
no_age <- lm(cbind(sys, dia) ~ male + bmi, data = people)
age_test <- anova(fit, no_age, test = "Pillai")
age_test
Analysis of Variance Table

Model 1: cbind(sys, dia) ~ age + I(age^2) + male + bmi
Model 2: cbind(sys, dia) ~ male + bmi
  Res.Df Df Gen.var.  Pillai approx F num Df den Df    Pr(>F)    
1   3811      94.359                                             
2   3813  2  110.465 0.28302   314.09      4   7622 < 2.2e-16 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Question 2: is the slope the same for both outcomes?

The hypothesis is \(\beta_{41} = \beta_{42}\), that is \(\beta_{41} - \beta_{42} = 0\): a contrast between the columns of \(B\). In linearHypothesis() the matrix P combines the outcomes:

Code
P <- matrix(c(1, -1), ncol = 1, dimnames = list(c("sys", "dia"), "sys - dia"))
equal_bmi <- linearHypothesis(fit, "bmi = 0", P = P)
equal_bmi

 Response transformation matrix:
    sys - dia
sys         1
dia        -1

Sum of squares and products for the hypothesis:
          sys - dia
sys - dia  7184.773

Sum of squares and products for error:
          sys - dia
sys - dia  368533.2

Multivariate Tests: 
                 Df test stat approx F num Df den Df     Pr(>F)    
Pillai            1 0.0191228 74.29771      1   3811 < 2.22e-16 ***
Wilks             1 0.9808772 74.29771      1   3811 < 2.22e-16 ***
Hotelling-Lawley  1 0.0194956 74.29771      1   3811 < 2.22e-16 ***
Roy               1 0.0194956 74.29771      1   3811 < 2.22e-16 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Code
# by hand: the difference, and its standard error from the covariance of step 3
XtX_inv <- solve(crossprod(X))
contrast <- function(term) {
  d  <- B[term, "sys"] - B[term, "dia"]
  se <- sqrt((Sigma[1, 1] + Sigma[2, 2] - 2 * Sigma[1, 2]) * XtX_inv[term, term])
  c(difference = d, SE = se, lower = d - qt(0.975, n - q) * se, upper = d + qt(0.975, n - q) * se,
    t = d / se, p = 2 * pt(-abs(d / se), n - q))
}
contrasts <- t(sapply(c("age", "I(age^2)", "male", "bmi"), contrast))
signif(contrasts, 3)
         difference     SE  lower  upper     t        p
age           2.310 0.1080  2.100  2.520 21.40 6.62e-96
I(age^2)      0.965 0.0675  0.833  1.100 14.30 2.95e-45
male          4.870 0.3210  4.240  5.500 15.20 1.63e-50
bmi          -1.010 0.1170 -1.230 -0.777 -8.62 9.70e-18

The slope of BMI is 1.01 mmHg smaller for the systolic than for the diastolic pressure, 95% CI [-1.23, -0.78] for the difference, t = -8.62. (The F of the output is \(t^2\) = 74.3.) Without the covariance term, the standard error would be wrong. Two estimates that come from the same people are not independent:

Code
naive <- sqrt(s[["Response sys"]]["bmi", 2]^2 + s[["Response dia"]]["bmi", 2]^2)
c(
  correct = contrasts["bmi", "SE"],
  as_if_independent = naive,
  ratio = naive / contrasts["bmi", "SE"]
)
          correct as_if_independent             ratio 
        0.1166754         0.2062544         1.7677622 

Treating the two regressions as independent gives a standard error 1.8 times too large.

There is a shorter way to the same test, worth knowing. The difference of the two pressures is a variable of its own, the pulse pressure. A regression of the difference on the predictors gives the difference of the slopes:

Code
pulse <- lm(I(sys - dia) ~ age + I(age^2) + male + bmi, data = people)
round(coef(summary(pulse))["bmi", ], 4)
  Estimate Std. Error    t value   Pr(>|t|) 
   -1.0057     0.1167    -8.6196     0.0000 

6. Two coefficients, one picture: ellipses

A confidence ellipse for the two slopes

A confidence interval for each slope makes a rectangle. But the two estimates are correlated, and the region that contains the true pair with 95% confidence is an ellipse. It is the set of pairs that a joint F test does not reject:

Code
ellipse <- function(centre, V, radius) {          # points on an ellipse around a center
  angle <- seq(0, 2 * pi, length.out = 200)
  t(centre + radius * t(chol(V)) %*% rbind(cos(angle), sin(angle)))
}
V_bmi <- Sigma * XtX_inv["bmi", "bmi"] # 2 x 2 covariance matrix of the two slopes
radius <- sqrt(2 * (n - q) / (n - q - 1) * qf(0.95, 2, n - q - 1))
region <- as.data.frame(ellipse(B["bmi", ], V_bmi, radius)); names(region) <- c("sys", "dia")
ci <- t(sapply(c("sys", "dia"), function(o) {
  B["bmi", o] + c(-1, 1) * qt(0.975, n - q) * sqrt(V_bmi[o, o])
}))

ggplot(region, aes(sys, dia)) +
  annotate(
    "rect",
    xmin = ci["sys", 1],
    xmax = ci["sys", 2],
    ymin = ci["dia", 1],
    ymax = ci["dia", 2],
    fill = "grey80",
    alpha = 0.6
  ) +
  geom_polygon(fill = "#2a78d6", alpha = 0.35) +
  geom_abline(linetype = "dashed", colour = "#eb6834", linewidth = 0.8) +
  annotate("point", x = B["bmi", "sys"], y = B["bmi", "dia"], size = 2.5) +
  annotate("point", x = 0, y = 0, shape = 4, size = 3, stroke = 1.2) +
  coord_cartesian(xlim = c(-0.1, 2.2), ylim = c(-0.1, 2.4)) +
  labs(
    title = "The two slopes of BMI",
    subtitle = "Blue: joint 95% region. Grey: the two separate 95% intervals.\nDashed: equal slopes. Cross: no effect",
    x = "systolic: mmHg per 5 kg/m²",
    y = "diastolic: mmHg per 5 kg/m²"
  ) +
  theme_bw()

A confidence ellipse for the two slopes

The ellipse is far from the cross (no effect on either) and far from the dashed line (equal effects). It leans to the right, because the errors of the two outcomes correlate: if chance made one slope too large, it probably did the same to the other.

A prediction ellipse for one person

For a man of 50 with a BMI of 32 the model predicts a pair. The uncertainty about one person is a 2 × 2 matrix: the errors of the person, plus those of the estimates.

\[\hat y_0 = x_0^\top \hat B, \qquad \text{Cov} = \hat\Sigma\,\big(1 + x_0^\top (X^\top X)^{-1} x_0\big)\]

Code
x0    <- c(1, (50 - 45) / 10, ((50 - 45) / 10)^2, 1, (32 - 27) / 5)      # a man, 50 years, BMI 32
y0    <- drop(x0 %*% B)
V0    <- Sigma * (1 + drop(t(x0) %*% XtX_inv %*% x0))
y0
      sys       dia 
124.25796  79.48445 
Code
pred  <- as.data.frame(ellipse(y0, V0, radius)); names(pred) <- c("sys", "dia")
sides <- sapply(c("sys", "dia"), function(o) y0[[o]] + c(-1, 1) * qt(0.975, n - q) * sqrt(V0[o, o]))

# how many people are inside their own ellipse, and inside their own rectangle?
d2 <- rowSums((E %*% solve(Sigma)) * E) # squared distance from the prediction
inside <- c(
  ellipse = mean(d2 <= radius^2),
  rectangle = mean(
    abs(E[, 1]) <= 1.96 * sqrt(Sigma[1, 1]) & abs(E[, 2]) <= 1.96 * sqrt(Sigma[2, 2])
  )
)
inside
  ellipse rectangle 
0.9365828 0.9203354 
Code
# high above, low below
odd <- c(y0[["sys"]] + 1.5 * sqrt(V0[1, 1]), y0[["dia"]] - 1.5 * sqrt(V0[2, 2]))
d2_odd <- drop(t(odd - y0) %*% solve(V0) %*% (odd - y0))
c(d2 = d2_odd, limit = radius^2)
       d2     limit 
17.079540  5.997752 
Code
ggplot(pred, aes(sys, dia)) +
  annotate(
    "rect",
    xmin = sides[1, "sys"],
    xmax = sides[2, "sys"],
    ymin = sides[1, "dia"],
    ymax = sides[2, "dia"],
    fill = "grey80",
    alpha = 0.5
  ) +
  geom_polygon(fill = "#2a78d6", alpha = 0.3) +
  annotate("point", x = y0[["sys"]], y = y0[["dia"]], size = 2.5) +
  annotate("point", x = odd[1], y = odd[2], colour = "#eb6834", size = 3) +
  annotate(
    "text",
    x = odd[1] + 1,
    y = odd[2] - 2.5,
    label = sprintf("%.0f / %.0f", odd[1], odd[2]),
    colour = "#eb6834",
    hjust = 0,
    size = 3.5
  ) +
  labs(
    title = "95% prediction region for a man of 50 with a BMI of 32",
    subtitle = "Grey: each number by itself. Blue: the pair",
    x = "systolic (mmHg)",
    y = "diastolic (mmHg)"
  ) +
  theme_bw()

A prediction ellipse for one person

The orange point, 146 over 65, is inside both intervals: neither number is unusual. But the combination is: a high upper number with a low lower one is outside the ellipse. Only a model of the pair can see it. Of the people in the data, 93.7% lie inside their ellipse, where 95% was promised, and 92.0% inside their rectangle (two separate 95% intervals hold together less often than one).


7. Joint or separate tests? A small-sample experiment

With 3,816 people everything is significant. The choice of the test matters in small studies. So we make small studies from our data: 5,000 random samples of 100 people, and in each the test of BMI in three ways. The joint test; the two separate tests, “significant if either is”; and the same with the Bonferroni correction (\(p < .025\)).

Code
set.seed(4)
one_study <- function(shuffle) {
  i <- sample(n, 100)
  Xs <- X[i, ]
  Ys <- Y[i, ]
  if (shuffle) {
    Xs[, "bmi"] <- sample(Xs[, "bmi"])
  } # BMI without any relation
  XtXi <- solve(crossprod(Xs))
  Bs <- XtXi %*% crossprod(Xs, Ys)
  Es <- Ys - Xs %*% Bs
  S <- crossprod(Es) / (100 - q)
  p_each <- 2 * pt(-abs(Bs[5, ] / sqrt(diag(S) * XtXi[5, 5])), 100 - q)
  # Hotelling's T², the same as Pillai here
  T2 <- drop(t(Bs[5, ]) %*% solve(S * XtXi[5, 5]) %*% Bs[5, ])
  df2 <- 100 - q - 1
  c(
    joint = pf(T2 * df2 / (2 * (100 - q)), 2, df2, lower.tail = FALSE) < .05,
    either = any(p_each < .05),
    bonferroni = any(p_each < .025),
    joint_only = pf(T2 * df2 / (2 * (100 - q)), 2, df2, lower.tail = FALSE) < .05 &
      !any(p_each < .05)
  )
}
power <- rowMeans(replicate(5000, one_study(FALSE)))
null  <- rowMeans(replicate(5000, one_study(TRUE)))
round(rbind(`BMI as it is` = power, `BMI shuffled (no relation)` = null), 3)
                           joint either bonferroni joint_only
BMI as it is               0.772  0.727      0.630      0.094
BMI shuffled (no relation) 0.054  0.077      0.039      0.017
  • Shuffled BMI should be significant in 5% of the studies. The joint test is, in 5.4%. “Either of the two” is in 7.7%, too often, because it has two chances. Bonferroni has 3.9%.
  • The real BMI is found by the joint test in 77% of the studies, by Bonferroni in 63%. The joint test uses the direction of the effect: BMI moves the two numbers in a way that goes against their usual correlation (the lower one more than the upper), which makes it easier to see.
  • In 9% of the studies the joint test found BMI although neither number was significant by itself.

The opposite can happen too. When an effect goes along with the correlation, or concerns one outcome only, the separate tests can be more powerful. The joint test is the better protection against false findings, and the separate results tell what it found.


8. Checking the assumptions

The assumptions are those of linear regression for each outcome, plus one covariance matrix for everybody and, for small samples, normal errors together. The squared Mahalanobis distance of the residual pairs should follow a \(\chi^2\) distribution with 2 degrees of freedom:

Code
qq <- data.frame(expected = qchisq(ppoints(n), df = 2), observed = sort(d2))
ggplot(qq, aes(expected, observed)) +
  geom_abline(colour = "grey60") +
  geom_point(colour = "#2a78d6", alpha = 0.5) +
  labs(title = "Residual pairs against the bivariate normal distribution",
       x = "expected squared distance (χ², 2 df)", y = "observed squared distance") +
  theme_bw()

Mahalanobis – 8. Checking the assumptions

Code
spread <- sapply(c("sys", "dia"), function(o) {
  tapply(E[, o], cut(people$years, c(19, 39, 59, 79)), sd)
})
round(spread, 1)
         sys  dia
(19,39] 10.8  8.8
(39,59] 14.3 10.0
(59,79] 17.9 10.2

Two assumptions fail. The distances have a long tail: people with very high pressures. And the spread of the systolic errors grows with age, from 10.8 to 17.9 mmHg. With 3,816 people the long tail does not matter for the coefficients, but unequal spread affects the standard errors. The bootstrap of persons needs neither assumption. It resamples whole rows, so the two outcomes of a person stay together:

Code
set.seed(5)
boot <- t(replicate(2000, {
  i <- sample(n, replace = TRUE)
  b <- solve(crossprod(X[i, ]), crossprod(X[i, ], Y[i, ]))
  c(sys = b["bmi", "sys"], dia = b["bmi", "dia"], difference = b["bmi", "sys"] - b["bmi", "dia"])
}))
rbind(model_SE = c(sqrt(diag(V_bmi)), contrasts["bmi", "SE"]), bootstrap_SE = apply(boot, 2, sd))
                   sys       dia          
model_SE     0.1715883 0.1144479 0.1166754
bootstrap_SE 0.1697574 0.1250531 0.1072409
Code
boot_ci <- apply(boot, 2, quantile, c(0.025, 0.975))
round(boot_ci, 2)
       sys  dia difference
2.5%  0.53 1.63      -1.21
97.5% 1.22 2.12      -0.79

The bootstrap standard errors are close to those of the model, and the conclusion about the difference stays: 95% CI [-1.21, -0.79].


9. Things to keep in mind

  • Use it when the outcomes belong together and are to be tested together, or when coefficients are compared between outcomes. For five unrelated outcomes, a joint test answers a question that nobody asked.
  • All equations have the same predictors. If they differ, the estimates of the equations are no longer those of separate regressions, and the model is seemingly unrelated regression.
  • MANOVA is the same model with groups as predictors.
  • The joint test does not say which outcome. After it, look at the coefficients, the ellipse, or contrasts such as \(\beta_{41} - \beta_{42}\). A row of separate tests “protected” by the joint test does not control the error rate in general (Huberty & Morris, 1989).
  • Comparing slopes needs the same unit. Both pressures are in mmHg. For outcomes in different units, “equal slopes” depends on the units; standardize only if that comparison makes sense.
  • Rows with one missing outcome are dropped. A mixed model in long format, or a structural equation model with full information, can use them (see missing data).
  • Repeated measures. The same variable at several times is also a multivariate outcome, but the times are ordered and the covariances have a pattern. See multilevel models.
  • Not the US population. NHANES is a complex sample with weights, which we did not use; we describe the people in the data. Excluding the people on medicine removes those with the highest pressures, mostly older and heavier, and flattens both slopes.
  • Differences between people, not effects. Nobody was assigned to a weight.

10. Reporting the results in APA style

A report (APA 7th edition) needs the outcomes and why they are analyzed together, the multivariate test with its statistic and degrees of freedom, the coefficients of each outcome, and the residual correlation. The numbers come from the R objects:

Code
ci_sys <- confint(sys_only)
ci_dia <- confint(lm(dia ~ age + I(age^2) + male + bmi, data = people))
one_df_F <- function(term) {           # the exact joint test of one predictor
  bj <- B[term, ]; T2 <- drop(t(bj) %*% solve(Sigma * XtX_inv[term, term]) %*% bj)
  c(F = T2 * (n - q - 1) / (2 * (n - q)), pillai = T2 / (T2 + n - q))
}
joint_table <- t(sapply(rownames(B)[-1], one_df_F))
apa_table <- data.frame(
  Predictor = c("Age (10 years, from 45)", "Age squared", "Male", "BMI (5 kg/m², from 27)"),
  sys = paste0(f2(B[-1, "sys"]), " [", f2(ci_sys[-1, 1]), ", ", f2(ci_sys[-1, 2]), "]"),
  dia = paste0(f2(B[-1, "dia"]), " [", f2(ci_dia[-1, 1]), ", ", f2(ci_dia[-1, 2]), "]"),
  diff = paste0(
    f2(contrasts[, "difference"]),
    " [",
    f2(contrasts[, "lower"]),
    ", ",
    f2(contrasts[, "upper"]),
    "]"
  ),
  V = nz(joint_table[, "pillai"], 3),
  F = f1(joint_table[, "F"])
)
df2 <- n - q - 1

Method (data analysis):

Systolic and diastolic blood pressure (mmHg, means of up to three readings) of 3,816 adults of NHANES, August 2021–August 2023, aged 20 to 79 and not taking antihypertensive medication, were analyzed together in a multivariate linear regression on age (linear and squared), sex and body mass index, because they are measured on the same scale and correlate (r = .69). Predictors were tested on both outcomes with Pillai’s trace, and the equality of their coefficients between the outcomes with contrasts. Standard errors were checked with 2,000 bootstrap samples of persons. Analyses were conducted in R (Version 4.6.2; R Core Team, 2026) with the package car (Fox & Weisberg, 2019).

Results:

All predictors were related to the pair of blood pressures (Table 1). Age, linear and squared, was tested jointly, Pillai’s trace = 0.283, approximate F(4, 7,622) = 314.1, p < .001. For BMI, Pillai’s trace = 0.089, F(2, 3,810) = 186.9, p < .001: 5 kg/m² more went with 0.86 mmHg more systolic and 1.87 mmHg more diastolic pressure, and the two slopes differed, difference = -1.01, 95% CI [-1.23, -0.78], t(3,811) = -8.62, p < .001. The model explained 18% of the variance of the systolic and 12% of that of the diastolic pressure, and the residuals correlated at .74.

Table 1

Multivariate Regression of Systolic and Diastolic Blood Pressure

Predictor Systolic, b [95% CI] Diastolic, b [95% CI] Difference [95% CI] Pillai’s trace F(2, 3,810)
Age (10 years, from 45) 3.43 [3.12, 3.75] 1.12 [0.91, 1.33] 2.31 [2.10, 2.52] .122 264.2
Age squared 0.08 [-0.12, 0.27] -0.89 [-1.02, -0.76] 0.97 [0.83, 1.10] .101 214.2
Male 7.29 [6.36, 8.21] 2.42 [1.80, 3.04] 4.87 [4.24, 5.50] .066 134.0
BMI (5 kg/m², from 27) 0.86 [0.53, 1.20] 1.87 [1.65, 2.09] -1.01 [-1.23, -0.78] .089 186.9

Note. N = 3,816. Coefficients in mmHg. Difference: systolic minus diastolic. The F tests concern both outcomes.

Points to remember:

  • Say why the outcomes are analyzed together.
  • Name the multivariate statistic (Pillai’s trace is the safe choice), with F and both degrees of freedom.
  • Report the coefficients of every outcome, and the correlation of the residuals.
  • Compare coefficients between outcomes only with a test that uses their covariance.

11. Summary

When Several continuous outcomes on the same people, with the same predictors, that should be tested or compared together
The model \(Y = XB + E\), with correlated errors, \(\Sigma\)
How (R) fit <- lm(cbind(y1, y2) ~ x1 + x2, data = d)
Same as separate regressions The coefficients, their standard errors and t tests
New Joint tests, contrasts between outcomes, residual correlation, joint regions
Joint tests car::Anova(fit) (each predictor given the others); anova(fit, smaller) for several terms
Between outcomes car::linearHypothesis(fit, "x = 0", P = matrix(c(1, -1))), or regress the difference
Statistics Pillai, Wilks, Hotelling–Lawley, Roy; identical for a predictor with one coefficient
Checks Residual plots for each outcome, Mahalanobis distances, the bootstrap of persons
Related pages Hierarchical regression, generalized least squares, moderation, mediation and SEM

References

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

Huberty, C. J., & Morris, J. D. (1989). Multivariate analysis versus multiple univariate analyses. Psychological Bulletin, 105(2), 302–308. https://doi.org/10.1037/0033-2909.105.2.302

National Center for Health Statistics. (2024). National Health and Nutrition Examination Survey, August 2021–August 2023 [Data set]. https://wwwn.cdc.gov/nchs/nhanes/continuousnhanes/default.aspx?Cycle=2021-2023

Olson, C. L. (1976). On choosing a test statistic in multivariate analysis of variance. Psychological Bulletin, 83(4), 579–586. https://doi.org/10.1037/0033-2909.83.4.579