Tutorials › Pattern-Mixture and Selection Models › Integrating Shared Random Effects From the Joint Law

Factorizations of the Joint Distribution · Tutorial 41 of 499

Integrating Shared Random Effects From the Joint Law

Learn how to integrate a shared random effect out of a joint outcome-and-response model, and how to check and interpret the resulting marginal distribution.

Intermediate 12 min read

What You'll Learn

  • Write the shared-parameter joint law for outcomes, response patterns, and a random effect.
  • Integrate or sum over the random-effect distribution to obtain the marginal joint law.
  • Calculate marginal joint probabilities for discrete outcomes and response patterns.
  • Derive a continuous example using a Gaussian outcome model and a probit response model.
  • Check normalization, numerical integration, and the distinction between integrating random effects and missing outcomes.
  • Compare the resulting marginal law with selection and pattern-mixture factorizations.

Why Integrate Out a Shared Random Effect?

A shared-parameter model represents the association between outcomes and response by giving them a common latent random effect. The random effect may describe an unobserved subject characteristic that influences both the outcome process and the chance or pattern of response. The model is often specified conditionally on that effect, but the marginal law for the outcomes and response pattern is obtained only after averaging over its distribution.

The calculation is straightforward to state but important to interpret: multiply the conditional outcome and response factors specified by the model, weight that product by the random-effect distribution, and integrate over the random effect. The result is a joint distribution for outcomes and response patterns that no longer contains the latent variable.

Definition: Let \(Y\) denote the full outcome vector, \(R\) its response-pattern vector, and \(B\) a shared random effect with density \(h(b)\). Suppose the specified conditional joint law is \(f(y,r\mid b)=f(y\mid b)q(r\mid b)\). The marginal outcome-and-response density or mass function is \(f(y,r)=\int f(y\mid b)q(r\mid b)h(b)\,db\). For a discrete random effect, the integral is replaced by a sum over its possible values. The expression is a density in continuous components and a probability mass in discrete components.

The product \(f(y\mid b)q(r\mid b)\) is the conditional factorization assumed by this model. The integration step itself does not establish that factorization; it takes the specified conditional law as its starting point. For each fixed \(b\), \(f(y\mid b)\) must be a valid outcome density or mass function, and \(q(r\mid b)\) must be a valid response-pattern probability distribution. The mixing distribution \(h\) must also be a valid density or mass function.

For longitudinal data, \(Y\) and \(R\) are vectors. For example, with two visits, \(Y=(Y_1,Y_2)\) and \(R=(R_1,R_2)\), where \(R_j=1\) indicates that \(Y_j\) is observed. The integral produces the joint law of the full outcome vector and response pattern. It does not by itself integrate out unobserved outcomes or produce a likelihood contribution based only on observed data.

The Marginalization Calculation

If \(B\) is discrete, with possible values \(b_1,\ldots,b_K\) and probabilities \(w_k=P(B=b_k)\), the calculation is a finite mixture:

$$ f(y,r)=\sum_{k=1}^{K} f(y\mid b_k)q(r\mid b_k)w_k. $$

If \(B\) is continuous, the corresponding weighted average is an integral:

$$ f(y,r)=\int f(y\mid b)q(r\mid b)h(b)\,db. $$

In either case, the value of \(b\) is not observed in the marginal law. Each possible value contributes according to its probability under the random-effect distribution and the conditional likelihood of the specified \(y\) and \(r\).

Worked Example: A Binary Outcome and Response Indicator

Consider a hypothetical model with a binary outcome \(Y\), a response indicator \(R\), and a two-point shared random effect \(B\). Suppose \(P(B=-1)=0.4\) and \(P(B=1)=0.6\). The conditional probabilities are:

Value of \(B\)\(P(Y=1\mid B)\)\(P(R=1\mid B)\)
-10.20.3
10.80.7

Assume the specified conditional joint law is the product of these outcome and response factors. To find \(P(Y=1,R=1)\), multiply the two conditional probabilities within each random-effect value and then weight by that value's probability:

$$ \begin{aligned} P(Y=1,R=1) &=(0.4)(0.2)(0.3)+(0.6)(0.8)(0.7)\\ &=0.024+0.336\\ &=0.360. \end{aligned} $$

The same calculation for the other three combinations gives \(P(Y=1,R=0)=0.200\), \(P(Y=0,R=1)=0.180\), and \(P(Y=0,R=0)=0.260\). These four marginal joint probabilities sum to \(0.360+0.200+0.180+0.260=1.000\), as required. They imply \(P(Y=1)=0.560\) and \(P(R=1)=0.540\). The joint probability \(0.360\) is not the product \(0.560\times0.540=0.3024\), illustrating that averaging over a shared effect can yield a marginal association even when the conditional law is specified as a product.

Worked Example: Two-Visit Outcomes and Response Patterns

Suppose a hypothetical two-visit study has binary outcomes \(Y=(Y_1,Y_2)\), a response pattern \(R=(R_1,R_2)\), and a shared effect \(B\) that is 0 or 1 with probability 0.5 each. The following tables give valid conditional distributions; rows in each table sum to 1.

Outcome vector \(y\)\(P(Y=y\mid B=0)\)\(P(Y=y\mid B=1)\)
(0,0)0.400.10
(0,1)0.200.20
(1,0)0.300.40
(1,1)0.100.30
Response pattern \(r\)\(P(R=r\mid B=0)\)\(P(R=r\mid B=1)\)
(0,0)0.500.15
(0,1)0.100.10
(1,0)0.250.60
(1,1)0.150.15

For the full outcome vector \(y=(1,0)\) and response pattern \(r=(1,0)\), the marginal joint probability is

$$ \begin{aligned} P(Y=(1,0),R=(1,0)) &=(0.5)(0.30)(0.25)+(0.5)(0.40)(0.60)\\ &=0.0375+0.1200\\ &=0.1575. \end{aligned} $$

This is the probability of that full outcome vector and that response pattern under the model. The response pattern does not redefine the outcome vector in this calculation: even if some components would be unobserved in practice, the calculation here retains the joint law for the full \(Y\) and \(R\).

A Continuous Example and a Short Derivation

For a continuous random effect, marginalization may require evaluating an integral. A useful example also shows how the integral can sometimes be simplified analytically. Suppose \(B\sim N(0,1)\), the outcome satisfies \(Y\mid B=b\sim N(b,1)\), and the response indicator has probit probability \(P(R=1\mid B=b)=\Phi(b)\), where \(\Phi\) is the standard normal cumulative distribution function. Use the specified conditional product for the joint law of \(Y\) and \(R\).

At an outcome value \(y\), the joint density for \(Y=y\) and \(R=1\) is

$$ f(y,R=1)=\int \phi(y-b)\Phi(b)\phi(b)\,db, $$

where \(\phi\) is the standard normal density. To evaluate this at \(y=0\), first combine the prior density of \(B\) and the outcome likelihood. Completing the square gives

$$ \begin{aligned} b^2+(y-b)^2 &=2\left(b-\frac{y}{2}\right)^2+\frac{y^2}{2},\\ B\mid Y=y&\sim N\left(\frac{y}{2},\frac{1}{2}\right). \end{aligned} $$

Thus the integral can be written as \(f_Y(y)E\{\Phi(B)\mid Y=y\}\), where \(f_Y\) is the marginal density of \(Y\). Here \(Y=B+\varepsilon\) with independent \(B,\varepsilon\sim N(0,1)\), so \(Y\sim N(0,2)\). At \(y=0\), \(f_Y(0)=1/\sqrt{4\pi}\approx0.2821\), and \(B\mid Y=0\sim N(0,1/2)\).

For \(Z\sim N(0,1)\) independent of \(B\), \(E\{\Phi(B)\}=P(Z\leq B)\). When \(B\sim N(m,v)\), \(B-Z\sim N(m,v+1)\), so \(P(Z\leq B)=\Phi\left(m/\sqrt{v+1}\right)\). Applying this with \(m=0\) and \(v=1/2\) gives \(E\{\Phi(B)\mid Y=0\}=0.5\). Therefore,

$$ f(0,R=1)=\frac{1}{\sqrt{4\pi}}(0.5)\approx0.1410. $$

This is a joint density at \(Y=0\), not a probability that \(Y\) equals exactly zero; its units are inverse units of \(Y\). By symmetry, \(f(0,R=0)\) is also approximately \(0.1410\), and the two response-specific densities add to \(f_Y(0)\approx0.2821\).

Checks, Alternatives, and Limitations

Several checks help catch errors in derivation or computation:

  • Check the conditional distributions. For each fixed \(b\), the outcome probabilities or density must be valid, and the response probabilities over all patterns must sum to 1.
  • Check marginal normalization. Summing over all discrete outcomes and response patterns, or integrating over continuous components as appropriate, must give 1.
  • Check what was integrated. The calculation above removes \(B\), not missing components of \(Y\). Marginalizing unobserved outcomes is a distinct operation.
  • Check units and type. A result involving continuous outcomes is generally a density, not a point probability. A result for wholly discrete variables is a probability mass.
  • Check numerical integration. If the integral has no closed form, compare quadrature results at increasing accuracy or with an independent numerical method. Instability, a value outside the permitted probability range for a discrete joint mass, or a failed normalization check signals a problem.

The shared-parameter calculation is one way to represent the joint law. The selection factorization orders the joint law around the outcome and response mechanism; the pattern-mixture factorization orders it around response patterns and their outcome distributions. These are alternative ways to express or model a joint distribution, not instructions to omit the integration over \(B\) when the specified shared-parameter model includes it. The earlier material on observed-data likelihood marginalization concerns which unobserved quantities must be removed to form an observed-data likelihood; that is a separate step from deriving the marginal law of \(Y\) and \(R\) over the random effect.

A common mistake is to treat the conditional product as if it were already the marginal joint law: \(f(y,r)=f(y\mid b)q(r\mid b)\). That expression still depends on \(b\), so it is conditional on the latent effect. The correction is to weight by \(h(b)\) and integrate over all possible \(b\). A related mistake is to integrate only the outcome factor or only the response factor and then multiply the two resulting marginal distributions. In general, that loses the shared mixing structure; the correct operation integrates the product.

The marginalization is only as credible as the model used inside the integral. A convenient random-effect distribution or simple conditional response model does not guarantee that the chosen specification is appropriate. The integral may also be difficult to evaluate, and different latent distributions or conditional models can lead to different marginal laws. Numerical accuracy does not resolve uncertainty about those modeling choices.

Key takeaway: Under a specified shared-parameter factorization, the marginal outcome-and-response law is the random-effect-weighted integral of the conditional outcome factor times the conditional response factor. Keep the latent-effect integration distinct from marginalizing missing outcomes.

Check Your Understanding

Answer each question, then compare with the solutions below.

  1. A discrete shared effect has two values with probabilities 0.25 and 0.75. For \(Y=1\), suppose the conditional outcome probabilities are 0.2 and 0.6; for \(R=1\), suppose the conditional response probabilities are 0.5 and 0.8. Under the specified conditional product, calculate \(P(Y=1,R=1)\).
  2. Why must the response probabilities over all response patterns sum to 1 for each fixed value of the shared effect?
  3. In the continuous Gaussian example, what is \(f(0,R=0)\), and why is it a density rather than a probability at \(Y=0\)?
  4. Does integrating over the shared random effect also remove missing components of the full outcome vector? Explain.

Solutions. (1) Weight the two conditional products: \((0.25)(0.2)(0.5)+(0.75)(0.6)(0.8)=0.025+0.360=0.385\). (2) For each fixed effect value, the response-pattern probabilities must form a valid distribution; otherwise the conditional joint law and its marginalization would not be normalized. (3) The response probabilities at \(B=b\) sum to 1, so \(f(0,R=0)=f_Y(0)-f(0,R=1)=0.2821-0.1410\approx0.1410\). Because \(Y\) is continuous, this is a density value with inverse-outcome units, not the probability of the single point \(Y=0\). (4) No. This integration removes \(B\) while retaining the full outcome vector \(Y\); integrating unobserved outcome components is a separate marginalization.

Clinical Biostats