Tutorials › Joint Modeling of Longitudinal and Time-to-Event Data › Why Plugging In Estimated Random Effects Is Not Marginalization

The Basic Joint Model · Tutorial 158 of 697

Why Plugging In Estimated Random Effects Is Not Marginalization

See how random-effect integration forms the observed-data likelihood, why evaluating the event contribution at an estimated effect can differ, and how to check numerical integration.

Advanced 12 min read

What You'll Learn

  • Write a subject-level joint likelihood by integrating over the random-effect distribution.
  • Express that likelihood as a marker-data density times an event contribution averaged over the marker-updated random-effect distribution.
  • Work through numerical comparisons between integration and plug-in evaluation.
  • Identify assumptions that justify the likelihood factorization and integration.
  • Diagnose when a plug-in approximation may be especially misleading and compare it with numerical integration methods.
  • Check when integration and plug-in evaluation coincide and when they do not.

Why the Random Effect Must Be Integrated Out

A shared random effect links a subject’s repeated marker measurements to that subject’s event process. It is latent: the data provide information about its value, but do not reveal it exactly. A fitted or predicted random effect, such as a posterior mean or mode, summarizes that information with one number. Replacing the random effect by that number is not the same operation as averaging the likelihood over its distribution.

This distinction matters because the observed-data likelihood describes the probability density of the data actually observed when the random effect is unobserved. It must account for the possible random-effect values that could have produced those data. A plug-in calculation instead evaluates a conditional contribution at one selected value. The two can be close in some settings, but there is no general equality and no general direction to the difference.

Definition: Let \(b_i\) be subject \(i\)'s latent random effect, with density \(f_b(b_i;\theta)\). Write \(y_i=(y_{i1},\ldots,y_{in_i})\) for the observed marker measurements, \(T_i\) for the observed event or censoring time, and \(\delta_i\) for the event indicator. If the marker measurements and event time are conditionally independent given \(b_i\) and the covariates, the subject's observed-data likelihood contribution is $$ L_i(\theta)=\int A_i(b_i;\theta)B_i(b_i;\theta)f_b(b_i;\theta)\,db_i, $$ where \(A_i(b_i;\theta)=\prod_{j=1}^{n_i} f(y_{ij}\mid b_i;\theta)\) is the conditional marker-data contribution, and \(B_i(b_i;\theta)=\lambda_i(T_i\mid b_i;\theta)^{\delta_i}S_i(T_i\mid b_i;\theta)\) is the event-time contribution. Here \(S_i(t\mid b_i;\theta)\) is the conditional survival function and \(\lambda_i(t\mid b_i;\theta)\) is the conditional hazard.

This expression uses the usual event-time likelihood for an observed event or right censoring. It assumes the event and marker models are correctly specified, the random-effect distribution is correctly specified, and the event and marker processes are conditionally independent given the shared random effect and covariates. It also assumes censoring is conditionally independent in the sense required for the event-time contribution to be used, and that the marker observation process is ignorable under the model. Subjects are treated as independent conditional on the model parameters. Covariates are conditioned on throughout. If entry is delayed, the appropriate risk-set conditioning must also be included.

The key point is that \(b_i\) is not observed. The likelihood contribution therefore averages the product \(A_i(b_i;\theta)B_i(b_i;\theta)\) over the random-effect distribution. It does not first estimate \(b_i\), then behave as though that estimate were the true value.

How the Marker Data Update the Averaging Distribution

The marker observations inform which random-effect values are plausible for a subject. Define the marginal marker-data density $$ f_Y(y_i;\theta)=\int A_i(b_i;\theta)f_b(b_i;\theta)\,db_i. $$ Provided this density is positive, the random-effect density conditional on the marker data is $$ p(b_i\mid y_i;\theta)=\frac{A_i(b_i;\theta)f_b(b_i;\theta)}{f_Y(y_i;\theta)}. $$ Substituting this expression into the subject likelihood gives an equivalent identity: $$ L_i(\theta)=f_Y(y_i;\theta)\int B_i(b_i;\theta)p(b_i\mid y_i;\theta)\,db_i. $$ Thus the event contribution is averaged over the distribution of \(b_i\) updated by the marker data. A plug-in calculation replaces this average by \(B_i(\widehat b_i)\), where \(\widehat b_i\) might be a posterior mean, posterior mode, or another subject-specific prediction. In general, $$ \int B_i(b_i;\theta)p(b_i\mid y_i;\theta)\,db_i \ne B_i(\widehat b_i;\theta). $$ Even if \(\widehat b_i\) is a posterior mean, an average of a nonlinear function is not generally that function evaluated at the average.

The identity also clarifies what is being averaged. The random-effect distribution in the original likelihood is updated by the marker data through \(A_i\). The event information is then included through \(B_i\). This is a likelihood calculation, not a procedure for declaring a predicted random effect observed. If the random-effect distribution is updated using the event outcome as well, multiplying by the event contribution again would count that outcome twice.

A Small Exact Example

Worked Example: Two Possible Random-Effect Values

Consider a deliberately simple hypothetical subject whose random effect is \(b\in\{0,1\}\), with prior probabilities \(P(b=0)=P(b=1)=0.5\). Suppose the observed marker data have conditional densities \(A(0)=0.4\) and \(A(1)=0.8\), in inverse marker units. The subject is censored at time \(T\), and the conditional survival probabilities are \(S(T\mid 0)=0.5\) and \(S(T\mid 1)=0.2\). Find the integrated contribution and compare it with a plug-in calculation using the posterior mode.

The marginal marker-data density is $$ f_Y(y)=0.5(0.4)+0.5(0.8)=0.60. $$ Bayes’ rule gives posterior weights \(P(b=0\mid y)=0.20/0.60=1/3\) and \(P(b=1\mid y)=0.40/0.60=2/3\). The posterior mode is therefore \(b=1\).

Direct integration over the two possible values gives $$ L=0.5(0.4)(0.5)+0.5(0.8)(0.2)=0.10+0.08=0.18. $$ Equivalently, the posterior average of the survival probability is $$ E\{S(T\mid b)\mid y\}=(1/3)(0.5)+(2/3)(0.2)=0.30, $$ so \(f_Y(y)E\{S(T\mid b)\mid y\}=0.60(0.30)=0.18\), as it should.

The plug-in calculation instead gives \(0.60S(T\mid\widehat b)=0.60(0.2)=0.12\), which differs from \(0.18\). The discrepancy is not caused by arithmetic: the plug-in calculation keeps only the posterior mode, while the integrated likelihood retains both random-effect values and their posterior weights. This discrete example is chosen for transparent arithmetic; the same distinction applies when \(b\) has a continuous distribution.

Numerical Integration Versus a Plug-In Value

With a continuous random effect, integration is usually evaluated numerically. The following hypothetical calculations report the outputs of quadrature under a fitted joint model. The tables show posterior quadrature weights and the corresponding conditional event contributions. They make explicit which quantity is averaged; the fitted model supplies the nodes and the conditional contributions at those nodes.

Worked Example: A Censored Subject and a Survival Contribution

For a hypothetical censored subject, suppose the marginal marker-data density is \(f_Y(y)=0.6516\) in inverse marker units. Quadrature over the random effect conditional on the marker data gives the following survival contributions:

Posterior quadrature weightConditional survival contributionWeighted contribution
0.2000.1000000.020000
0.5000.2000000.100000
0.3000.3207930.096238
Total0.216238

The integrated likelihood contribution is the marker density times this posterior average: $$ L=0.6516(0.216238)\approx 0.1409. $$ Suppose the fitted random-effect value used for a plug-in calculation yields conditional survival \(0.22645\). The corresponding product is $$ 0.6516(0.22645)=0.14755482\approx 0.1476. $$ The plug-in result is not the integrated likelihood. It evaluates survival at one estimated value rather than averaging survival over the random-effect distribution updated by the marker data.

The difference can also be written as a difference between an expectation and a function evaluation. If \(\widehat b_i=E(b_i\mid y_i)\), then the plug-in survival is \(S_i(T_i\mid E(b_i\mid y_i))\), while the integrated contribution uses \(E\{S_i(T_i\mid b_i)\mid y_i\}\). For a nonlinear survival function, these quantities need not agree. A posterior mode is a different summary from the posterior mean, but replacing the integral with either summary has the same basic limitation.

Worked Example: Integrating the Full Event Contribution

For a second hypothetical subject, suppose the marginal marker-data density is \(0.22645\) in inverse marker units. The subject's event contribution is \(B(b)=\lambda(T\mid b)^{\delta}S(T\mid b)\), so the example can represent either an observed event or censoring. Posterior quadrature gives:

Posterior quadrature weightConditional event contributionWeighted contribution
0.2500.30000.07500
0.5000.40000.20000
0.2500.49960.12490
Total0.39990

Using the displayed rounded inputs, the integrated contribution is $$ 0.22645(0.3999)=0.090557355\approx 0.09056. $$ With the less-rounded model quantities, the corresponding value is approximately \(0.09055\). If the event contribution at a fitted random-effect value is \(0.4246\), the plug-in product is $$ 0.22645(0.4246)=0.09615067\approx 0.09615. $$ These are different likelihood contributions: the first averages the conditional event contribution over the random effect given the marker data; the second evaluates it at one fitted value.

What Can Go Wrong, and How to Check

There is no universal rule that the plug-in contribution is too large or too small. The difference depends on the shape of \(B_i(b_i;\theta)\) over the random-effect values that remain plausible after observing the marker data. Curvature, asymmetry, and posterior spread all matter. When the conditional contribution is convex or concave over a relevant range, Jensen’s inequality can sometimes describe the direction of the difference for a posterior-mean plug-in, but it does not provide a general direction when the function changes curvature or a different estimate is used.

Useful checks focus on the integration itself and on the uncertainty that a plug-in hides:

  • Check numerical stability. Increase the number of quadrature nodes or compare with another integration method. Material changes in the likelihood indicate inadequate numerical accuracy.
  • Inspect the conditional contribution across plausible random effects. A large change in \(B_i(b_i;\theta)\) over the posterior distribution is a warning that a single value may be a poor summary for this calculation.
  • Check the random-effect distribution and model assumptions. Integration is only as credible as the specified distribution and conditional-independence assumptions. Numerical accuracy cannot repair a misspecified model.
  • Keep the data used for updating straight. A distribution conditional on marker data alone differs from one conditional on both marker and event data. If the event data have already updated the distribution, do not multiply by their contribution again.

A plug-in analysis can be a useful approximation or a descriptive calculation, especially when posterior uncertainty is small and the conditional contribution varies little across plausible values. It is not, however, a substitute for the observed-data likelihood when fitting the joint model. Common alternatives for evaluating the integral include Gaussian quadrature, adaptive quadrature, and Monte Carlo integration. These methods approximate the integral itself; they do not replace it by a single estimated random effect. Their accuracy and computational cost differ, particularly as the dimension of the random effect grows.

The practical limitation of integration is computational: higher-dimensional random effects and complex conditional models can make accurate evaluation expensive. That limitation motivates efficient numerical methods, not a change in the statistical meaning of the likelihood. The central comparison is therefore between a well-evaluated integral and a one-value approximation, not between two equivalent ways of writing the same likelihood.

Key takeaway: When a random effect is latent, the observed-data likelihood averages the conditional marker and event contributions over its distribution. A fitted or predicted random effect is a summary of that distribution, not the distribution itself; evaluating at the summary generally does not perform marginalization.

Check Your Understanding

Answer each question, then compare your reasoning with the solutions below.

  1. In the subject likelihood, what role does the marker-data contribution play in the distribution used to average the event contribution?
  2. Suppose a subject has marginal marker density \(0.50\), and the event contribution is \(0.20\) or \(0.60\) at two random-effect values with posterior weights \(0.75\) and \(0.25\). Calculate the integrated contribution.
  3. Why does using the posterior mean of a random effect not generally make the plug-in event contribution equal to its posterior average?
  4. Name two conditions under which plug-in evaluation and integration can agree.
  5. If the numerical likelihood changes substantially when the number of quadrature nodes is increased, what should be checked before interpreting the result?

Solutions. 1. The marker-data contribution updates the random-effect distribution: the averaging density is proportional to the marker likelihood times the prior random-effect density. 2. The posterior average event contribution is \(0.75(0.20)+0.25(0.60)=0.30\), so the integrated contribution is \(0.50(0.30)=0.15\). 3. The event contribution is generally nonlinear, so its average need not equal its value at the average random effect. 4. They agree if the random-effect distribution conditional on the data is degenerate at the plug-in value, or if the event contribution is constant over its support. They can also agree for an affine event contribution evaluated at the posterior mean. 5. Check quadrature accuracy and node placement, and compare with a suitable alternative numerical integration method; also verify that the model and its assumptions are correctly specified.

Clinical Biostats