Tutorials › Econometrics (Graduate) › Random-Intercept Covariance and Its GLS Form

Generalized Least Squares · Tutorial 150 of 952

Random-Intercept Covariance and Its GLS Form

Learn how a shared random intercept induces within-unit covariance and how its covariance matrix determines the GLS estimator.

Intermediate 12 min read

What You'll Learn

  • State conditional assumptions for a random-intercept error structure
  • Derive the covariance between two observations in the same unit
  • Distinguish within-unit covariance from between-unit covariance
  • Construct and invert the random-intercept covariance block
  • Write the GLS estimator and its conditional variance
  • Interpret the intraclass correlation and GLS weighting

Why a Shared Intercept Changes the Covariance

When several observations come from the same unit, they may share an unobserved unit-level influence. A school, for example, may have a persistent feature affecting every student observed there; a firm may have a persistent feature affecting each of its recorded years. If that shared influence is represented by a random intercept, observations from one unit are correlated even when their observation-specific errors are not. The resulting covariance is structured, not diagonal, and GLS uses that structure in its weighting.

The key is to distinguish the shared component from the observation-specific component, and to state their assumptions conditional on the regressors. Unconditional independence alone does not in general justify conditional covariance calculations.

Model and Conditional Assumptions

Index units by \(i=1,\ldots,G\), and observations within unit \(i\) by \(j=1,\ldots,T_i\). Let \(x_{ij}\) be a \(k\)-vector of regressors, and write the model as

$$ y_{ij}=x_{ij}'\beta+u_i+\varepsilon_{ij}. $$

Here \(\beta\) is the common coefficient vector, \(u_i\) is the random intercept shared by all observations in unit \(i\), and \(\varepsilon_{ij}\) is the observation-specific error. Let \(X\) denote the full design matrix. For the covariance formulas below, assume conditional on \(X\) that

  • \(E(u_i\mid X)=0\), \(E(\varepsilon_{ij}\mid X)=0\), \(\operatorname{Var}(u_i\mid X)=\sigma_u^2\), and \(\operatorname{Var}(\varepsilon_{ij}\mid X)=\sigma_\varepsilon^2\), where the variances do not depend on \(i\) or \(j\);
  • the \(u_i\)'s are conditionally independent across units, and the \(\varepsilon_{ij}\)'s are conditionally independent across observations and units;
  • the two error components are conditionally independent of one another.

These assumptions imply the conditional cross-covariances used below are zero. They also give \(E(y_{ij}\mid X)=x_{ij}'\beta\). The covariance structure does not require normally distributed errors. For GLS, suppose the variance components are known, \(\sigma_\varepsilon^2>0\), and \(\sigma_u^2\geq 0\). The positive observation-specific variance ensures each covariance block is positive definite.

Definition: A random-intercept error structure has an error \(u_i+\varepsilon_{ij}\), where \(u_i\) is common to observations in unit \(i\) and \(\varepsilon_{ij}\) is specific to one observation. Under the stated conditional assumptions, its covariance is nonzero for two distinct observations in the same unit and zero for observations in different units.

Deriving the Within-Unit and Between-Unit Covariances

For an observation, the two error components are conditionally independent and have conditional mean zero. Thus its conditional variance is

$$ \operatorname{Var}(u_i+\varepsilon_{ij}\mid X) =\sigma_u^2+\sigma_\varepsilon^2. $$

For two different observations \(j\ne \ell\) from the same unit, the shared \(u_i\) appears in both errors. The observation-specific errors have zero conditional covariance, and the cross-covariances between \(u_i\) and either observation-specific error are zero by conditional independence. Therefore,

$$ \operatorname{Cov}(u_i+\varepsilon_{ij},u_i+\varepsilon_{i\ell}\mid X) =\operatorname{Var}(u_i\mid X) =\sigma_u^2. $$

For observations from distinct units \(i\ne r\), the shared components are different unit effects, and all relevant cross-unit and cross-component conditional covariances are zero. Hence

$$ \operatorname{Cov}(u_i+\varepsilon_{ij},u_r+\varepsilon_{r\ell}\mid X)=0. $$

The correlation between two distinct observations in the same unit is consequently

$$ \rho=\frac{\sigma_u^2}{\sigma_u^2+\sigma_\varepsilon^2}. $$

This is the intraclass correlation under this model. It is the fraction of the marginal error variance attributable to the shared unit component; it is not the correlation between the regressors and the outcome.

Worked Example: Calculating Covariances and Correlation

Suppose a hypothetical panel has \(\sigma_u^2=3\) score-units squared and \(\sigma_\varepsilon^2=5\) score-units squared. Find the variance of one observation, the covariance of two distinct observations in the same unit, the covariance of observations in different units, and the within-unit correlation.

The variance of one observation is the sum of the component variances: \(3+5=8\) score-units squared. Two different observations in the same unit share only the random intercept, so their covariance is \(3\) score-units squared. Observations in different units have covariance \(0\) under the conditional independence assumptions.

The within-unit correlation is \(\rho=3/(3+5)=3/8=0.375\). Thus, in this hypothetical model, two observations from the same unit have correlation \(0.375\), while their marginal error variance is \(8\) score-units squared.

The Covariance Matrix for One Unit

Stack the \(T_i\) outcomes in unit \(i\) into \(y_i\), and define \(\mathbf{1}_{T_i}\) as a \(T_i\)-vector of ones. The error vector is \(u_i\mathbf{1}_{T_i}+\varepsilon_i\). Its conditional covariance block is

$$ V_i=\operatorname{Var}(u_i\mathbf{1}_{T_i}+\varepsilon_i\mid X) =\sigma_\varepsilon^2 I_{T_i} +\sigma_u^2\mathbf{1}_{T_i}\mathbf{1}_{T_i}'. $$

The identity-matrix term contributes \(\sigma_\varepsilon^2\) to each diagonal entry. The matrix of ones contributes \(\sigma_u^2\) to every entry, including the diagonal. Thus the diagonal entries are \(\sigma_\varepsilon^2+\sigma_u^2\), and the off-diagonal entries are \(\sigma_u^2\). Across all units, conditional independence gives the block-diagonal covariance matrix \(V=\operatorname{diag}(V_1,\ldots,V_G)\).

For example, if \(T_i=3\), \(\sigma_\varepsilon^2=4\), and \(\sigma_u^2=2\), then

$$ V_i= \begin{pmatrix} 6&2&2\\ 2&6&2\\ 2&2&6 \end{pmatrix}. $$

The diagonal value \(6\) is the variance of one observation; each off-diagonal value \(2\) is the covariance of two distinct observations in that unit.

Inverting the Covariance Block

The inverse is needed to construct GLS. The rank-one form of \(V_i\) gives a direct expression:

$$ V_i^{-1} =\frac{1}{\sigma_\varepsilon^2} \left[ I_{T_i} -\frac{\sigma_u^2}{\sigma_\varepsilon^2+T_i\sigma_u^2} \mathbf{1}_{T_i}\mathbf{1}_{T_i}' \right]. $$

To verify it, set \(a=\sigma_\varepsilon^2\), \(b=\sigma_u^2\), and \(J=\mathbf{1}_{T_i}\mathbf{1}_{T_i}'\). Since \(J^2=T_iJ\), multiply \(aI+bJ\) by \(a^{-1}(I-cJ)\), where \(c=b/(a+T_i b)\). The product is

$$ (aI+bJ)a^{-1}(I-cJ) =I+\left(\frac{b}{a}-c-\frac{b}{a}cT_i\right)J =I. $$

The coefficient of \(J\) vanishes because \(c(1+T_i b/a)=b/a\). This verifies the inverse. In the numerical block above, the formula gives \(V_i^{-1}=0.25I_3-0.05J\), with diagonal entries \(0.20\) and off-diagonal entries \(-0.05\). Multiplication by \(V_i\) gives the identity matrix.

Worked Example: Building a Covariance Block and Its Inverse

For a hypothetical unit with three observations, let \(\sigma_\varepsilon^2=4\) and \(\sigma_u^2=2\), both in squared outcome-units. The covariance block has diagonal \(4+2=6\) and off-diagonal \(2\):

$$ V_i= \begin{pmatrix} 6&2&2\\ 2&6&2\\ 2&2&6 \end{pmatrix}. $$

Using the inverse formula, the coefficient on \(J\) inside the brackets is \(2/(4+3(2))=0.2\). Therefore \(V_i^{-1}=0.25(I_3-0.2J)=0.25I_3-0.05J\), or

$$ V_i^{-1}= \begin{pmatrix} 0.20&-0.05&-0.05\\ -0.05&0.20&-0.05\\ -0.05&-0.05&0.20 \end{pmatrix}. $$

For a check, the first diagonal entry of \(V_iV_i^{-1}\) is \(6(0.20)+2(-0.05)+2(-0.05)=1\); its first off-diagonal entry is \(6(-0.05)+2(0.20)+2(-0.05)=0\). The other entries follow by symmetry.

The Corresponding GLS Estimator

Stack the observations and regressors across units as \(y\) and \(X\), so that \(y=X\beta+v\), with \(\operatorname{Var}(v\mid X)=V\). If \(V\) is known and \(X\) has full column rank, the GLS estimator is

$$ \hat{\beta}_{GLS} =(X'V^{-1}X)^{-1}X'V^{-1}y. $$

Its conditional expectation is \(\beta\), and its conditional covariance matrix is

$$ \operatorname{Var}(\hat{\beta}_{GLS}\mid X) =(X'V^{-1}X)^{-1}. $$

Indeed, substituting \(y=X\beta+v\) into the estimator gives \(\hat{\beta}_{GLS}=\beta+(X'V^{-1}X)^{-1}X'V^{-1}v\). Taking the conditional expectation uses \(E(v\mid X)=0\), yielding \(\beta\). For the covariance, substitute \(\operatorname{Var}(v\mid X)=V\); the middle matrix simplifies because \(V^{-1}VV^{-1}=V^{-1}\). The resulting covariance is \((X'V^{-1}X)^{-1}\).

The inverse covariance downweights directions in the data with larger error variance. Because observations in a unit share a component, they do not contribute as much independent information about \(\beta\) as the same number of uncorrelated observations would. The exact effect on coefficients depends on the regressors and on the unit sizes.

Worked Example: GLS for a Unit-Intercept-Only Model

Consider a hypothetical intercept-only model \(y_{ij}=\beta+u_i+\varepsilon_{ij}\), with known variances \(\sigma_u^2=\sigma_\varepsilon^2=1\). There are three units: unit 1 has observations \(2,4\); unit 2 has observation \(5\); and unit 3 has observations \(6,8\). Their sizes are \(2,1,2\), and their sample means are \(3,5,7\). Find the GLS estimate of \(\beta\).

For an intercept-only model, the GLS estimate can be written as a weighted mean of the unit means:

$$ \hat{\beta}_{GLS} =\frac{\sum_{i=1}^G w_i\bar{y}_i}{\sum_{i=1}^G w_i}, \qquad w_i=\frac{T_i}{\sigma_\varepsilon^2+T_i\sigma_u^2}. $$

To see the weight, the contribution of unit \(i\) to \(1'V_i^{-1}1\) is \(T_i/(\sigma_\varepsilon^2+T_i\sigma_u^2)\), by the inverse formula. The contribution to \(1'V_i^{-1}y_i\) is that same weight multiplied by \(\bar y_i\). Thus the GLS ratio above follows from the estimator formula.

The weights are \(w_1=2/(1+2)=2/3\), \(w_2=1/(1+1)=1/2\), and \(w_3=2/(1+2)=2/3\). Substitution gives

$$ \hat{\beta}_{GLS} =\frac{(2/3)(3)+(1/2)(5)+(2/3)(7)} {2/3+1/2+2/3} =\frac{55/6}{11/6}=5. $$

The GLS estimate is \(5\) outcome-units. It combines unit means using weights determined by both the number of observations and the shared-intercept variance, rather than treating every observation as independent information.

Interpretation and a Common Pitfall

The random-intercept structure is useful when theory or design suggests a common unobserved unit influence and when the conditional assumptions are credible. Its covariance matrix makes that dependence explicit, allowing GLS to use it when estimating regression coefficients. The structure alone does not establish that a random-intercept model is appropriate, nor does it make regressors exogenous: the conditional mean assumption \(E(v\mid X)=0\) remains essential for the stated GLS expectation.

  • Pitfall: using unconditional independence to claim conditional zero covariance. It is not generally valid to say that errors are independent without specifying the conditioning set, then infer the required conditional covariances. A regressor can be related to error components in a way that changes their conditional dependence.
  • Correction: State conditional independence given \(X\), as assumed here, or directly impose the zero conditional cross-covariances used in deriving \(V\). Then compute every covariance conditional on \(X\).
  • Pitfall: placing \(\sigma_u^2\) only on the diagonal. The unit effect appears in every observation from that unit, so it contributes to both variances and within-unit covariances.
  • Correction: Add \(\sigma_u^2\) to every entry of the unit block and add \(\sigma_\varepsilon^2\) only to its diagonal.

In particular, treating all observations as independent would discard the off-diagonal covariance and generally produce a different estimator and an incorrect model-based covariance calculation. GLS uses the full block structure; it does not simply multiply each observation by one independent-observation weight.

Key takeaway: Under conditional mean-zero and conditional independence assumptions, the random intercept produces \(V_i=\sigma_\varepsilon^2I_{T_i}+\sigma_u^2\mathbf{1}_{T_i}\mathbf{1}_{T_i}'\). Its block inverse supplies the weights in GLS, while the common component explains why observations within a unit carry correlated rather than independent errors.

Check Your Understanding

Use the conditional assumptions and formulas in this tutorial to answer the following.

  1. If \(\sigma_u^2=2\) and \(\sigma_\varepsilon^2=6\), what are the marginal error variance and the covariance of two distinct observations from the same unit?
  2. Why is the conditional covariance between observations from different units zero under the stated assumptions?
  3. For a unit with \(T_i=4\), write the diagonal and off-diagonal entries of \(V_i\) in terms of the two variance components.
  4. State the full-rank and variance conditions needed for the displayed GLS estimator and its conditional covariance formula.
  5. Explain why unconditional independence by itself need not establish zero conditional covariance given \(X\).
Clinical Biostats