Tutorials › Nonlinear Mixed-Effects Models (NLME) › A Scalar Worked Example of FO Bias

The Marginal Likelihood and Its Approximations · Tutorial 149 of 797

A Scalar Worked Example of FO Bias

Calculate exact and first-order marginal means and variances for scalar nonlinear predictions, and assess how curvature and random-effect variance shape their differences.

Advanced 12 min read

What You'll Learn

  • Set up a scalar nonlinear prediction with a normal random effect and independent additive residual error.
  • Derive exact marginal moments for an exponential prediction.
  • Calculate first-order marginal moments by linearizing at zero.
  • Quantify mean and variance differences using hypothetical values and units.
  • Recognize how curvature can reverse the direction of mean bias.
  • Identify diagnostics, limitations, and alternatives to the first-order approximation.

Why Compare Exact and First-Order Moments?

A first-order approximation replaces a nonlinear individual prediction with its tangent at the typical random-effect value, zero. That can make the marginal calculation simple, but the tangent need not capture how the prediction changes over the full distribution of random effects. The difference matters: even if the random effect has mean zero, a curved prediction can have a marginal mean different from its value at zero, and its marginal variance can differ from the variance implied by the tangent.

Here the comparison is made for a single scalar random effect. This isolates the effect of nonlinearity and makes it possible to calculate both sets of moments directly. The first-order calculation follows the linearization used in the earlier material on the First-Order Approximation; the emphasis here is the numerical size and direction of its moment discrepancies.

Definition: Let \(\eta\sim N(0,\omega^2)\) be a scalar random effect and let \(f(\eta)\) be a scalar prediction. With additive residual error, write \(Y=f(\eta)+\epsilon\), where \(\epsilon\sim N(0,\sigma^2)\) is independent of \(\eta\). The exact marginal mean and exact marginal variance are \(E[Y]\) and \(\operatorname{Var}(Y)\), averaging over both sources of variation. The first-order (FO) moments are obtained by replacing \(f(\eta)\) with its first-order Taylor expansion at \(\eta=0\).

For a differentiable prediction, the FO expansion is \(f(\eta)\approx f(0)+f'(0)\eta\). Since \(E[\eta]=0\), the resulting FO moments are

$$ E_{\mathrm{FO}}[Y]=f(0), \qquad \operatorname{Var}_{\mathrm{FO}}(Y)=\{f'(0)\}^2\omega^2+\sigma^2. $$

These are moments of the linearized model, not generally the exact moments of the nonlinear model. The additive residual variance appears in both calculations because the residual is independent of the random effect.

An Exponential Prediction: Exact Moments and Their Derivation

Consider the positive prediction \(f(\eta)=A\exp(\eta)\), where \(A>0\) has the units of the prediction and \(\eta\) is dimensionless. This form corresponds, for example, to a typical concentration multiplied by an individual-specific log-scale effect. Assume \(\eta\sim N(0,\omega^2)\), with \(\omega^2>0\), and independent additive residual error with variance \(\sigma^2\).

The normal moment-generating identity \(E[\exp(t\eta)]=\exp(t^2\omega^2/2)\) gives the exact moments. Applying it first with \(t=1\), and then with \(t=2\), yields the mean and the second moment of \(f(\eta)\). Subtracting the squared mean gives the variance:

$$ E[Y]=A\exp\left(\frac{\omega^2}{2}\right), \qquad \operatorname{Var}(Y) =A^2\left\{\exp(2\omega^2)-\exp(\omega^2)\right\}+\sigma^2. $$

The FO calculation uses \(f(0)=A\) and \(f'(0)=A\), so its moments are \(E_{\mathrm{FO}}[Y]=A\) and \(\operatorname{Var}_{\mathrm{FO}}(Y)=A^2\omega^2+\sigma^2\). For any \(\omega^2>0\), the exact mean is greater than \(A\). The exact random-effect variance is also greater than the FO random-effect variance in this example: with \(w=\omega^2\), their difference is \(A^2\{\exp(2w)-\exp(w)-w\}>0\). To see the inequality, set \(x=\exp(w)>1\); then \(\exp(2w)-\exp(w)=x(x-1)\), which exceeds \(w\) for \(w>0\), as also follows from the positive higher-order terms in its expansion about zero.

Worked Example: Exact and FO Moments at Moderate Variability

Suppose a hypothetical concentration prediction is \(Y=10\exp(\eta)+\epsilon\) mg/L, where \(\eta\sim N(0,0.36)\) and \(\epsilon\sim N(0,1)\) mg/L is independent of \(\eta\). Thus \(A=10\) mg/L, \(\omega^2=0.36\), and \(\sigma^2=1\;(\mathrm{mg/L})^2\).

The exact marginal mean is

$$ E[Y]=10\exp(0.36/2) =10\exp(0.18) =10(1.1972) =11.97\ \mathrm{mg/L}. $$

The exact marginal variance is

$$ \operatorname{Var}(Y) =10^2\{\exp(0.72)-\exp(0.36)\}+1 =100(2.0544-1.4333)+1 =63.11\;(\mathrm{mg/L})^2. $$

For FO, \(f(0)=10\) mg/L and \(f'(0)=10\) mg/L per unit of \(\eta\). Therefore

$$ E_{\mathrm{FO}}[Y]=10\ \mathrm{mg/L},\qquad \operatorname{Var}_{\mathrm{FO}}(Y)=10^2(0.36)+1 =37.00\;(\mathrm{mg/L})^2. $$

In this hypothetical case, FO underestimates the exact mean by \(1.972\) mg/L and the exact variance by \(26.11\;(\mathrm{mg/L})^2\). These comparisons concern moments, not a claim that the exact marginal distribution is normal.

Why Curvature Determines the Mean Discrepancy

A short Taylor argument explains why a zero-mean random effect does not guarantee that the marginal mean equals \(f(0)\). If \(f\) is twice differentiable near zero, its local expansion includes a quadratic term:

$$ f(\eta)\approx f(0)+f'(0)\eta+\frac{1}{2}f''(0)\eta^2. $$

Taking expectations and using \(E[\eta]=0\) and \(E[\eta^2]=\omega^2\) gives the local approximation

$$ E[f(\eta)]\approx f(0)+\frac{1}{2}f''(0)\omega^2. $$

Thus, when curvature is positive near zero, the local second-order contribution raises the mean above the value at zero; when curvature is negative, it lowers it. This is a local justification, not an exact formula for an arbitrary \(f\): higher-order terms and behavior away from zero can matter, particularly when the random-effect variance is large.

Worked Example: A Smaller Random-Effect Variance

Use the same exponential form, but suppose a hypothetical prediction has \(A=8\) mg/L, \(\omega^2=0.04\), and independent residual standard deviation \(\sigma=0.5\) mg/L. The exact mean is

$$ E[Y]=8\exp(0.04/2) =8\exp(0.02) =8(1.0202) =8.162\ \mathrm{mg/L}. $$

The exact total variance and the FO total variance are, respectively,

$$ \begin{aligned} \operatorname{Var}(Y) &=8^2\{\exp(0.08)-\exp(0.04)\}+0.5^2\\ &=64(1.0833-1.0408)+0.25 =2.969\;(\mathrm{mg/L})^2,\\ \operatorname{Var}_{\mathrm{FO}}(Y) &=8^2(0.04)+0.25 =2.810\;(\mathrm{mg/L})^2. \end{aligned} $$

FO gives a mean of \(8\) mg/L, so its mean is \(0.1616\) mg/L below the exact mean. The variance discrepancy is smaller than in the preceding example, but it remains: FO is low by \(0.1585\;(\mathrm{mg/L})^2\). This is consistent with the smaller \(\omega^2\), not a guarantee that the discrepancy will be negligible for every prediction or data set.

Curvature Can Also Make FO Miss Variability

A particularly clear failure occurs when the derivative at zero is small even though \(f(\eta)\) changes appreciably over the random-effect distribution. Consider the positive prediction \(f(\eta)=A\exp(-\eta^2/2)\). Its derivative at zero is zero, so FO treats the prediction as constant and attributes no random-effect variance to it. But a nonconstant function of a random variable can have positive variance even when its slope at one point is zero.

Worked Example: Zero Slope at the Expansion Point

Let a hypothetical prediction be \(Y=10\exp(-\eta^2/2)+\epsilon\) mg/L, with \(\eta\sim N(0,0.25)\) and independent \(\epsilon\sim N(0,0.25)\) mg/L. Here the residual variance is \(0.25\;(\mathrm{mg/L})^2\). Completing the square in the normal density gives \(E[\exp(-a\eta^2)]=(1+2a\omega^2)^{-1/2}\) for \(a\geq0\). Applying this identity with \(a=1/2\) and \(a=1\) gives

$$ \begin{aligned} E[Y]&=\frac{10}{\sqrt{1+0.25}} =\frac{10}{\sqrt{1.25}} =8.944\ \mathrm{mg/L},\\ \operatorname{Var}(Y) &=10^2\left\{\frac{1}{\sqrt{1+2(0.25)}}-\frac{1}{1+0.25}\right\}+0.25\\ &=100(0.8165-0.8000)+0.25 =1.900\;(\mathrm{mg/L})^2. \end{aligned} $$

At zero, \(f(0)=10\) mg/L and \(f'(0)=0\). FO therefore gives a mean of \(10\) mg/L and variance \(0.25\;(\mathrm{mg/L})^2\), counting only the residual variance. Here FO overestimates the marginal mean and substantially underestimates the total variance. The example demonstrates why the direction of the mean discrepancy depends on curvature and why a local slope alone may not represent variation across the random-effect distribution.

Diagnostics, Alternatives, and Limits

In a scalar calculation, exact moments provide a direct benchmark when the prediction and random-effect distribution permit analytic integration. In more complicated models, compare the FO prediction and its slope at zero with the prediction over plausible random-effect values. A wide spread, marked curvature, or a derivative near zero despite substantial variation in predictions signals that the local linearization may be inadequate. Sensitivity of calculated moments to increasing \(\omega^2\) is also informative: nonlinear discrepancies often become more consequential as more random-effect probability lies away from the expansion point.

There are important limits to what the moment comparison establishes. For the exponential example, \(f(\eta)\) is lognormal, but adding independent normal residual error does not generally produce a normal marginal distribution. Matching a mean and variance alone does not determine the marginal likelihood. Also, exact moments for one scalar prediction do not by themselves quantify parameter-estimation bias in a fitted data set; that depends on the likelihood, design, and estimation procedure.

ApproachWhat it provides hereMain limitation
Exact analytic momentsReference mean and variance when the required integrals are availableClosed forms may not exist for the chosen prediction or full likelihood
FO linearizationSimple moments based on \(f(0)\) and \(f'(0)\)Can miss curvature effects and variation not represented by the local slope
Numerical integrationCan approximate marginal moments or likelihood integrals without a closed formRequires adequate numerical accuracy and may be costly in more complex settings

A common mistake is to reason, “The random effect has mean zero, so the mean prediction must equal the typical prediction.” That would follow for a linear prediction \(f(\eta)=a+b\eta\), but not for a curved \(f\). In the exponential example, \(E[\exp(\eta)]=\exp(\omega^2/2)>1\), so the exact mean exceeds the prediction at zero. In the negative-curvature example, the exact mean is below it. The correction is to average the nonlinear prediction over the random-effect distribution, analytically when possible or with an appropriate integration method, rather than treating a zero-mean input as if it guaranteed an unchanged output mean.

Key takeaway: FO moments come from the prediction and its slope at zero. Exact marginal moments average over the entire random-effect distribution. Nonlinearity can therefore shift the mean and change the variance, with the direction and size depending on the function and the random-effect variance.

Check Your Understanding

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

  1. For \(Y=5\exp(\eta)+\epsilon\), with \(\eta\sim N(0,0.16)\) and independent residual standard deviation \(0.3\) mg/L, calculate the exact and FO means and variances.
  2. For a twice-differentiable \(f\), what local second-order term explains a difference between \(E[f(\eta)]\) and \(f(0)\)?
  3. For \(f(\eta)=A\exp(-\eta^2/2)\), why can FO miss random-effect variance even though it is a first-order approximation?
  4. If the same independent additive residual variance is added to exact and FO calculations, does it remove their variance discrepancy? Explain.

Solutions. (1) The exact mean is \(5\exp(0.08)=5.416\) mg/L; the FO mean is \(5\) mg/L. The exact variance is \(25\{\exp(0.32)-\exp(0.16)\}+0.09=25(1.3771-1.1735)+0.09=5.180\;(\mathrm{mg/L})^2\). The FO variance is \(25(0.16)+0.09=4.090\;(\mathrm{mg/L})^2\). (2) The leading local correction is \(\tfrac12 f''(0)\omega^2\), obtained by taking expectations of the quadratic Taylor expansion. (3) Since \(f'(0)=0\), the FO random-effect variance \(\{f'(0)\}^2\omega^2\) is zero, although \(f(\eta)\) is not constant over the distribution and can have positive variance. (4) No. The same \(\sigma^2\) is added to each total variance, so it cancels in their difference; it does not correct the discrepancy in the random-effect contribution.