Tutorials › Multivariate Statistics (Graduate) › Worked Example: Two Outcomes With Shared Predictors

Multivariate Regression Models · Tutorial 308 of 975

Worked Example: Two Outcomes With Shared Predictors

Work through a complete two-outcome regression with shared predictors, from the design matrix to the residual covariance estimates.

Intermediate 11 min read

What You'll Learn

  • Write a two-response regression using one design matrix shared by both outcomes
  • Calculate the coefficient matrix from the least-squares normal equations
  • Compute fitted responses, residuals, and the residual SSCP matrix
  • Distinguish the maximum-likelihood and unbiased estimates of the error covariance
  • Interpret residual variances, covariance, and correlation in context

Why Fit Two Outcomes Together?

In many studies, each subject has several measured outcomes and the same predictors are relevant to each. For example, a clinical study might relate treatment group and baseline severity to both systolic and diastolic blood pressure. A shared-predictor regression gives a compact way to estimate the two outcome-specific coefficient sets while retaining their residual covariance in a single matrix.

The shared design matrix does not force the outcomes to have the same coefficients. It means only that the same predictor columns are used for each response. The coefficient matrix has one column per outcome, and the residual sum-of-squares-and-cross-products matrix records both the residual variation of each outcome and their residual covariation.

Definition: In a two-response multivariate linear regression with \(n\) observations and \(p\) predictor columns, write \(Y\) for the \(n\times 2\) response matrix, \(X\) for the \(n\times p\) design matrix, \(B\) for the \(p\times 2\) coefficient matrix, and \(\mathcal{E}\) for the \(n\times 2\) error matrix. The model is \(Y=XB+\mathcal{E}\). The \(i\)th row of \(\mathcal{E}\), denoted \(\varepsilon_i\), is a row vector with mean zero and covariance \(\Sigma=E[\varepsilon_i'\varepsilon_i]\), a \(2\times 2\) matrix. For covariance calculations, assume the errors from distinct observations are independent and have this common covariance.

For the model considered here, \(X\) includes a column of ones for the intercept and one or more columns for shared predictors. If \(X\) has full column rank, the least-squares estimate is \(\hat B=(X'X)^{-1}X'Y\). As in the earlier material on multivariate OLS, the regression is computed for each response; the matrix notation displays the two fits together.

How the Shared-Design Estimate Arises

Least squares chooses \(B\) to minimize the total squared residuals across both responses. Equivalently, it minimizes the trace of the residual cross-product matrix:

$$ Q(B)=\operatorname{tr}\{(Y-XB)'(Y-XB)\}. $$

Let \(\hat B=(X'X)^{-1}X'Y\) and \(\Delta=B-\hat B\). Then \(Y-XB=(Y-X\hat B)-X\Delta\), and \(X'(Y-X\hat B)=0\) by the normal equations. Expanding the trace therefore gives

$$ Q(B)=Q(\hat B)+\operatorname{tr}(\Delta'X'X\Delta). $$

Because \(X'X\) is positive definite when \(X\) has full column rank, the added term is nonnegative and is zero only when \(\Delta=0\). Thus \(\hat B\) is the unique least-squares estimate. The same \(X\) appears in both response columns, but each column of \(\hat B\) is estimated from its corresponding response values.

Theorem: If \(X\) is fixed and has full column rank, the least-squares coefficient estimate in \(Y=XB+\mathcal{E}\) is \(\hat B=(X'X)^{-1}X'Y\). The fitted response matrix is \(\hat Y=X\hat B\), the residual matrix is \(R=Y-\hat Y\), and the residual SSCP matrix is \(S_R=R'R\).

Worked Example: Fitting Two Outcomes With One Predictor

Worked Example: Fitting Two Outcomes With One Predictor

Suppose five subjects have predictor values \(x=-2,-1,0,1,2\). The two outcomes are \(Y_1\) and \(Y_2\), recorded in the table. Fit a regression with an intercept and the shared predictor \(x\); then calculate its fitted values, residual SSCP, and covariance estimates.

Subject\(x\)\(Y_1\)\(Y_2\)
1-278
2-162
301211
41100
52154

1. Set up the matrices. Use an intercept column followed by the predictor column:

$$ X= \begin{pmatrix} 1&-2\\ 1&-1\\ 1&0\\ 1&1\\ 1&2 \end{pmatrix}, \qquad Y= \begin{pmatrix} 7&8\\ 6&2\\ 12&11\\ 10&0\\ 15&4 \end{pmatrix}. $$

2. Calculate the coefficient matrix. The predictor values sum to zero and their squared values sum to \(10\), so

$$ X'X= \begin{pmatrix} 5&0\\ 0&10 \end{pmatrix}. $$

The outcome column sums are \(50\) and \(25\). The predictor-weighted sums are \(\sum_i x_iY_{i1}=20\) and \(\sum_i x_iY_{i2}=-10\). Thus

$$ X'Y= \begin{pmatrix} 50&25\\ 20&-10 \end{pmatrix}, \qquad \hat B=(X'X)^{-1}X'Y = \begin{pmatrix} 10&5\\ 2&-1 \end{pmatrix}. $$

The first row gives the estimated intercepts, \(10\) for \(Y_1\) and \(5\) for \(Y_2\). The second row gives the estimated slopes, \(2\) and \(-1\). For a one-unit increase in \(x\), the fitted mean of \(Y_1\) increases by \(2\), while that of \(Y_2\) decreases by \(1\).

3. Calculate fitted values and residuals. The fitted outcome values are \(10+2x_i\) and \(5-x_i\). Subtracting these fitted values from the observed values gives

$$ \hat Y= \begin{pmatrix} 6&7\\ 8&6\\ 10&5\\ 12&4\\ 14&3 \end{pmatrix}, \qquad R=Y-\hat Y= \begin{pmatrix} 1&1\\ -2&-4\\ 2&6\\ -2&-4\\ 1&1 \end{pmatrix}. $$

4. Calculate the residual SSCP matrix. The diagonal entries are the residual sums of squares for the two outcomes; the off-diagonal entries are their residual cross-products:

$$ S_R=R'R = \begin{pmatrix} 1^2+(-2)^2+2^2+(-2)^2+1^2& 1(1)+(-2)(-4)+2(6)+(-2)(-4)+1(1)\\ 1(1)+(-2)(-4)+2(6)+(-2)(-4)+1(1)& 1^2+(-4)^2+6^2+(-4)^2+1^2 \end{pmatrix} = \begin{pmatrix} 14&30\\ 30&70 \end{pmatrix}. $$

The matrix is symmetric, as a cross-product matrix must be. Its positive determinant, \(14(70)-30^2=80\), also confirms that this particular SSCP matrix is positive definite.

From Residual SSCP to Error Covariance

Two covariance estimates commonly accompany this fit. Under independent, mean-zero errors with common covariance \(\Sigma\), and with \(X\) fixed and full rank, the Gaussian maximum-likelihood estimate is \(S_R/n\). The unbiased estimate is \(S_R/(n-p)\). Here \(n-p\) is the residual degrees of freedom, because \(p\) coefficient rows, including the intercept, have been fitted for each outcome.

Theorem: Under the stated independent-error assumptions, if \(X\) has full column rank and \(M=I-X(X'X)^{-1}X'\), then \(R=M\mathcal{E}\) and \(E[R'R]=(n-p)\Sigma\). Therefore \(S_R/(n-p)\) is unbiased for \(\Sigma\). If, in addition, the errors are jointly Gaussian and the relevant covariance maximum exists, the maximum-likelihood estimate is \(S_R/n\).

To verify the expectation, note that \(M\) is symmetric and idempotent, \(R=M\mathcal{E}\), and \(R'R=\mathcal{E}'M\mathcal{E}\). Since the rows \(\varepsilon_i\) of \(\mathcal{E}\) are row vectors, expansion gives

$$ E[R'R] = \sum_{i,j}M_{ij}E[\varepsilon_i'\varepsilon_j]. $$

For \(i\ne j\), independence and zero means give \(E[\varepsilon_i'\varepsilon_j]=0\). For \(i=j\), \(E[\varepsilon_i'\varepsilon_i]=\Sigma\). Consequently,

$$ E[R'R] = \sum_i M_{ii}\Sigma = \operatorname{tr}(M)\Sigma = (n-p)\Sigma. $$

The last equality follows because \(M\) is a projection of rank \(n-p\), so its trace is \(n-p\). Dividing the expectation by \(n-p\) proves unbiasedness. Under Gaussian errors, maximizing the likelihood over the mean coefficients first gives the residual matrix \(R\); maximizing over the common covariance then gives \(R'R/n\), provided a nonsingular maximizing covariance exists. \(\square\)

Worked Example: Calculating Both Covariance Estimates

Continue with the fitted regression above. There are \(n=5\) observations and \(p=2\) design columns, so the residual degrees of freedom are \(5-2=3\). The maximum-likelihood estimate is

$$ \hat\Sigma_{\mathrm{ML}} = \frac{S_R}{n} = \frac{1}{5} \begin{pmatrix} 14&30\\ 30&70 \end{pmatrix} = \begin{pmatrix} 2.8&6\\ 6&14 \end{pmatrix}. $$

The unbiased estimate is

$$ \hat\Sigma_{\mathrm{unb}} = \frac{S_R}{n-p} = \frac{1}{3} \begin{pmatrix} 14&30\\ 30&70 \end{pmatrix} = \begin{pmatrix} 14/3&10\\ 10&70/3 \end{pmatrix}. $$

The estimates differ because the maximum-likelihood divisor is \(n=5\), whereas the unbiased divisor is the residual degrees of freedom, \(3\). Both have positive determinant: the first has determinant \(2.8(14)-6^2=3.2\), and the second has determinant \((14/3)(70/3)-10^2=80/9\). In this fit, both are valid positive-definite covariance matrices.

Worked Example: Interpreting the Residual Covariance

Use the unbiased covariance estimate from the fitted model to describe residual variation after accounting for \(x\). Its diagonal entries estimate the residual variances: \(14/3\) for \(Y_1\), and \(70/3\) for \(Y_2\). Its off-diagonal entry, \(10\), estimates the covariance between the two outcomes’ errors.

The corresponding estimated residual correlation is obtained by dividing the covariance by the product of the estimated residual standard deviations:

$$ \hat\rho = \frac{10}{\sqrt{(14/3)(70/3)}} = \frac{10}{\sqrt{980/9}} = \frac{30}{14\sqrt{5}} = \frac{15}{7\sqrt{5}} \approx 0.958. $$

Thus, in this small data set, observations with a residual above the fitted value for one outcome tend also to have a residual above the fitted value for the other. This is a statement about residual association after fitting the shared predictor; it does not say that one outcome causes the other. The estimate is based on only three residual degrees of freedom, so it should not be treated as a precise description of a broader population.

Common Mistake: Mixing Up the Matrix Dimensions

A frequent error is to treat the row error \(\varepsilon_i\) as a column vector when expanding \(\mathcal{E}'M\mathcal{E}\). Here \(\varepsilon_i\) is a \(1\times 2\) row. The product \(\varepsilon_i'\varepsilon_j\) is therefore a \(2\times 2\) matrix, as required in the SSCP expansion. In contrast, \(\varepsilon_i\varepsilon_j'\) is a scalar and cannot be added as a term in that \(2\times 2\) sum. Keeping the row-vector convention consistent also gives \(\Sigma=E[\varepsilon_i'\varepsilon_i]\).

Another easy mistake is to divide the SSCP by the wrong quantity without naming the target. Dividing by \(n\) gives the Gaussian maximum-likelihood covariance estimate; dividing by \(n-p\) gives the unbiased covariance estimate under the stated error assumptions. Neither divisor should be substituted for the other without saying which estimate is being reported.

Key takeaway: With shared predictors, one design matrix produces a coefficient column for each response. The residual SSCP matrix then summarizes both outcome-specific residual sums of squares and their cross-product; dividing it by \(n\) or by \(n-p\) yields, respectively, the maximum-likelihood or unbiased error covariance estimate under the conditions stated above.

Check Your Understanding

Use the definitions and calculations above to check your understanding.

  1. For \(n\) observations, two responses, and an intercept plus two predictors, what are the dimensions of \(X\), \(Y\), and \(B\)?
  2. In the worked fit, what does the second row of \(\hat B\) say about the change in each fitted outcome for a one-unit increase in \(x\)?
  3. Why is \(R'R\) a \(2\times 2\) matrix, and what does each type of entry represent?
  4. Under the stated assumptions, why does the unbiased covariance estimate use \(n-p\) rather than \(n\)?
  5. For row-vector errors \(\varepsilon_i\), which product, \(\varepsilon_i'\varepsilon_j\) or \(\varepsilon_i\varepsilon_j'\), has the dimensions needed in the SSCP expansion?
Clinical Biostats