Tutorials › Nonlinear Mixed-Effects Models (NLME) › Worked Example: Standard Errors Under Repeated Sampling

Why Mixed-Effects Models · Tutorial 14 of 797

Worked Example: Standard Errors Under Repeated Sampling

Learn to calculate and interpret naive and correlation-adjusted standard errors for balanced repeated measurements, and see how treating correlated samples as independent affects precision.

Beginner 10 min read

What You'll Learn

  • Identify the assumptions behind the balanced repeated-measurement standard-error formula.
  • Calculate an independence-based standard error from the number of measurements and their marginal standard deviation.
  • Adjust that standard error for within-subject correlation using the design effect.
  • Quantify the resulting change in precision and effective sample size.
  • Recognize when the balanced formula is unsuitable and compare it with a subject-level summary.

Why the Standard Error Changes With Repeated Measurements

A standard error describes the sampling variability of an estimator, not the spread of individual measurements. If a concentration is measured several times in each subject, the total number of measurements is not generally the number of independent pieces of information. Measurements from the same subject tend to share subject-specific influences, so their dependence affects the variability of a pooled mean.

The independence-based calculation is still useful as a reference: it shows what the standard error would be if every measurement contributed independent information. The correlation-adjusted calculation accounts for repeated measurements within subjects. The comparison makes the consequence of the independence assumption explicit.

Definition: Suppose \(m\) subjects each contribute \(k\) measurements of the same quantity under the same conditions. Write \(Y_{ij}\) for measurement \(j\) on subject \(i\), where \(i=1,\ldots,m\) and \(j=1,\ldots,k\). The pooled mean is \(\bar{Y}_{..}=(mk)^{-1}\sum_{i=1}^{m}\sum_{j=1}^{k}Y_{ij}\). The marginal standard deviation \(\sigma\) describes the spread of an individual measurement, and the within-subject correlation \(\rho\) describes the correlation between two different measurements from the same subject.

For the formulas in this tutorial, assume that all measurements target the same population mean \(\mu\), have the same marginal variance \(\sigma^2\), and have the same within-subject correlation \(\rho\). Subjects are independent of one another. Within a subject, every pair of distinct measurements has covariance \(\rho\sigma^2\). This is an exchangeable correlation assumption: it treats all within-subject pairs alike. In repeated pharmacokinetic data, the formulas apply to replicate measurements at a common time or under a common condition, not automatically to concentrations at different times that have different expected values.

In the common case of positive within-subject correlation, \(0<\rho\leq 1\). The mathematical lower bound for an exchangeable correlation among \(k\) measurements is \(-1/(k-1)\), but the examples below use positive correlation. In practice, \(\sigma\) and \(\rho\) are often unknown and must be estimated. The calculations below first state their values as known, or as specified plug-in values, so the standard-error arithmetic is clear.

Deriving the Correlation Adjustment

The pooled mean averages \(mk\) measurements, but its variance depends on both the \(mk\) individual variances and the covariances between measurements from the same subject. Since independent subjects have zero cross-subject covariance, the variance of a sum can be calculated subject by subject.

$$ \begin{aligned} \operatorname{Var}(\bar{Y}_{..}) &=\frac{1}{(mk)^2}\sum_{i=1}^{m}\operatorname{Var}\left(\sum_{j=1}^{k}Y_{ij}\right)\\ &=\frac{m}{(mk)^2}\left[k\sigma^2+k(k-1)\rho\sigma^2\right]\\ &=\frac{\sigma^2}{mk}\left[1+(k-1)\rho\right]. \end{aligned} $$

There are \(k\) variance terms for each subject and \(k(k-1)\) ordered covariance terms: each of the \(k\) measurements covaries with the other \(k-1\). This gives the within-subject contribution in the second line. Taking the square root gives the standard error of the pooled mean.

Key result: Under the stated balanced, exchangeable assumptions, the correlation-adjusted standard error of the pooled mean is \(\sigma\sqrt{[1+(k-1)\rho]/(mk)}\). If the \(mk\) measurements are incorrectly treated as independent, the naive standard error is \(\sigma/\sqrt{mk}\). Their ratio is \(\sqrt{1+(k-1)\rho}\), where \(1+(k-1)\rho\) is the design effect.

The result also shows why positive correlation increases the standard error. The design effect is greater than 1 when \(\rho>0\) and \(k>1\). The naive calculation then reports less uncertainty than the correlation-adjusted calculation. When \(\rho=0\), the two standard errors agree; when \(\rho=1\), the repeated measurements within each subject provide no additional independent information about the mean beyond one measurement per subject.

Worked Example: Comparing Standard Errors With Six Subjects

Suppose a hypothetical study measures a concentration four times at the same nominal time in each of six subjects. Assume the marginal standard deviation is \(2.4\) mg/L and the within-subject correlation is \(0.50\). The measurements satisfy the balanced assumptions above, and the values of \(\sigma\) and \(\rho\) are treated as known for this calculation. Find the naive and adjusted standard errors.

There are \(m=6\) subjects, \(k=4\) measurements per subject, and \(mk=24\) measurements in total. Treating all 24 measurements as independent gives

$$ SE_{\text{naive}}=\frac{\sigma}{\sqrt{mk}} =\frac{2.4\ \text{mg/L}}{\sqrt{24}} =\frac{2.4}{4.899}\ \text{mg/L} =0.490\ \text{mg/L}. $$

The design effect is \(1+(k-1)\rho=1+3(0.50)=2.50\). Thus the adjusted standard error is

$$ SE_{\text{adjusted}} =SE_{\text{naive}}\sqrt{2.50} =0.490\sqrt{2.50}\ \text{mg/L} =0.775\ \text{mg/L}. $$

The independence calculation is lower by \(0.775-0.490=0.285\) mg/L. Equivalently, its variance is too small by a factor of \(2.50\) under these assumptions. This is a statement about the standard error of the pooled mean, not a claim that the individual concentration measurements have less spread.

Working From Observed Measurements

Often the marginal standard deviation is not supplied. A common descriptive calculation is to compute the sample standard deviation across the \(mk\) recorded measurements and use it in the naive formula \(s/\sqrt{mk}\). To make the comparison, the same estimate of marginal spread can be used in the correlation-adjusted formula, with a specified or separately estimated \(\rho\). This substitution is a plug-in calculation; it does not account for uncertainty in the estimates of \(\sigma\) or \(\rho\).

Worked Example: Calculating the Naive Standard Error From a Small Data Set

Consider hypothetical replicate concentrations, in mg/L, for three subjects measured three times at the same nominal time:

SubjectMeasurement 1Measurement 2Measurement 3
A81012
B91113
C101214

The grand mean is \(\bar{Y}_{..}=99/9=11\) mg/L. The nine deviations from this mean are \(-3,-1,1,-2,0,2,-1,1,3\) mg/L. Their squared values sum to \(30\) \((\text{mg/L})^2\), so the ordinary sample standard deviation across all nine observations is

$$ s=\sqrt{\frac{30}{9-1}} =\sqrt{3.75} =1.936\ \text{mg/L}. $$

The naive standard error is therefore \(1.936/\sqrt{9}=0.645\) mg/L. For a side-by-side plug-in comparison, suppose the within-subject correlation is specified as \(\rho=0.60\). Here \(k=3\), so the design effect is \(1+2(0.60)=2.20\). The adjusted standard error using the same \(s\) is \(0.645\sqrt{2.20}=0.957\) mg/L.

The adjusted result is larger because it accounts for the stipulated positive within-subject correlation. With only three subjects, the data in this example are not enough to estimate that correlation precisely. The value \(0.60\) is an assumption for illustrating the adjustment, not an estimate established by these nine observations.

There is an additional practical caution: the ordinary sample variance about the pooled mean is not automatically an unbiased estimate of marginal variance under clustering, because the pooled mean itself is estimated from dependent observations. The simple calculation above demonstrates the usual naive plug-in comparison; it should not be taken as a general recommendation for estimating uncertainty from a real clustered data set. In an actual analysis, the method used to estimate variability should respect the subject-level dependence and the study design.

Quantifying the Cost of Assuming Independence

The design effect can be expressed as an equivalent number of independent measurements. If \(\sigma^2\) is the marginal variance, the variance of a mean based on \(n_{\mathrm{eff}}\) independent measurements would be \(\sigma^2/n_{\mathrm{eff}}\). Matching this to the correlated-measurement variance gives

$$ n_{\mathrm{eff}}=\frac{mk}{1+(k-1)\rho}. $$

This is an effective sample size for the variance of this mean under the assumed model. It is not a literal count of subjects, and it is not necessarily the appropriate sample size for every analysis. It summarizes how much information the pooled mean receives relative to the same number of independent measurements.

Worked Example: Effective Sample Size With Strong Correlation

Suppose a hypothetical study has eight subjects, each measured five times at the same nominal time. Let the marginal standard deviation be \(3.0\) mg/L and the within-subject correlation be \(0.75\). The total number of measurements is \(40\), and the design effect is \(1+4(0.75)=4.00\).

The naive standard error is \(3.0/\sqrt{40}=0.474\) mg/L. The adjusted standard error is \(0.474\sqrt{4.00}=0.949\) mg/L, or equivalently \(3.0\sqrt{4/(8\cdot5)}=0.949\) mg/L. The effective sample size is

$$ n_{\mathrm{eff}}=\frac{40}{4.00}=10. $$

Thus, for estimating this pooled mean under these assumptions, the 40 correlated measurements have the same variance as 10 independent measurements with marginal standard deviation \(3.0\) mg/L. The effective sample size exceeds the eight subjects because \(\rho=0.75\) is less than 1: additional measurements still add some information, but substantially less than independent measurements would. Assuming independence would make the standard error appear half as large, since the adjusted-to-naive ratio is \(\sqrt{4}=2\).

When the Formula Applies, and When It Does Not

The balanced formula is most useful when every subject contributes the same number of measurements, those measurements target a common mean, and a single within-subject correlation is a reasonable approximation. If each subject contributes a different number of observations, if the correlation changes with the time gap between measurements, or if measurements at different times have different expected concentrations, the design effect \(1+(k-1)\rho\) does not generally describe the data. In those cases, the covariance structure and the exact estimator matter; a single adjusted multiplier should not be applied without justification.

A useful alternative for balanced data is to calculate a mean for each subject and then average those subject means. Under equal numbers of observations per subject, this gives the same pooled mean. Under the stated covariance assumptions, the variance of one subject's mean is \(\sigma^2[1+(k-1)\rho]/k\). Averaging the \(m\) independent subject means gives variance \(\sigma^2[1+(k-1)\rho]/(mk)\), exactly the result derived above. This provides a subject-level way to understand the same standard error, rather than a different correction.

The equivalence depends on equal numbers of measurements and a common target mean. With unequal numbers of observations, the pooled mean gives greater weight to subjects who contribute more measurements, whereas the average of subject means gives equal weight to subjects. Those estimators need not target the same quantity, and their standard errors need not agree. More flexible approaches can account for unequal sampling and richer dependence, but they require specifying and checking a more detailed model; the balanced formula is not a substitute for that work.

Diagnostics and Common Pitfalls

Before using a correlation adjustment, check whether its assumptions are plausible. Confirm that measurements being combined represent the same target quantity, count the number of observations per subject, and examine subject-specific trajectories or replicate values for evidence of within-subject similarity. Where data permit, estimate or otherwise justify the within-subject correlation. A single assumed value can be useful for a sensitivity calculation, but it should not be presented as a data-supported estimate unless the analysis actually estimates it.

  • Pitfall: counting every sample as an independent observation. The reasoning is that there are \(mk\) recorded values, so the standard error must be \(s/\sqrt{mk}\). The correction is that this formula assumes zero covariance between distinct observations; with positive within-subject correlation, multiply the naive standard error by \(\sqrt{1+(k-1)\rho}\) under the balanced assumptions.
  • Pitfall: treating the design effect as a variance multiplier for the standard error itself. The design effect multiplies the variance. The standard error is multiplied by its square root.
  • Pitfall: using one correlation for observations at different times without checking the target. If expected concentrations change over time, pooling them does not estimate a common-time mean. Define the estimand first and use a dependence structure suited to the observations being combined.
  • Pitfall: assuming more repeats can replace more subjects. Repeats can improve precision when \(\rho<1\), but their marginal contribution shrinks as correlation increases. The effective sample size calculation quantifies this for the pooled mean; it does not imply that a study with few subjects can answer every question as well as a larger study.

A practical sensitivity check is to calculate the adjusted standard error across a plausible range of \(\rho\) values. If the conclusion changes substantially, the analysis depends strongly on the assumed within-subject correlation and that dependence should be reported. The standard error alone also does not address bias from selective sampling, dropout, or a mismatch between the pooled mean and the scientific target.

Key takeaway: For \(m\) subjects with \(k\) balanced repeated measurements, a positive within-subject correlation increases the standard error of the pooled mean by the factor \(\sqrt{1+(k-1)\rho}\), relative to treating all \(mk\) measurements as independent. The adjustment is valid only when the common-mean, balanced-design, and exchangeable-correlation assumptions are reasonable.

Check Your Understanding

Answer each question using the balanced repeated-measurement assumptions stated above. The solutions follow the questions.

  1. Five subjects each contribute three measurements. If \(\rho=0\), what is the design effect, and how do the naive and adjusted standard errors compare?
  2. Four subjects each contribute four measurements, with \(\sigma=2.0\) mg/L and \(\rho=0.50\). Calculate the naive and adjusted standard errors.
  3. For the design in question 2, calculate the effective sample size and interpret it.
  4. Why is the standard error multiplied by the square root of the design effect, rather than by the design effect itself?
  5. Give one reason the balanced formula may be unsuitable for measurements collected at several pharmacokinetic times.

Solutions. (1) The design effect is \(1+(3-1)(0)=1\), so the naive and adjusted standard errors are equal. (2) There are \(4\cdot4=16\) measurements. The naive standard error is \(2.0/\sqrt{16}=0.500\) mg/L. The design effect is \(1+3(0.50)=2.50\), so the adjusted standard error is \(0.500\sqrt{2.50}=0.791\) mg/L. (3) The effective sample size is \(16/2.50=6.40\) independent measurements, in the sense of matching the variance of this mean. (4) The design effect multiplies the variance, and standard error is the square root of variance; therefore its multiplier is the square root of the design effect. (5) Expected concentration can differ by time, so the measurements may not share a common mean; additionally, their correlation may depend on the time separation. Either feature violates assumptions behind the simple balanced formula.

Clinical Biostats