Tutorials › Nonlinear Mixed-Effects Models (NLME) › Indexing Between-Occasion Random Effects

Between-Subject, Between-Occasion and Residual Variability · Tutorial 117 of 797

Indexing Between-Occasion Random Effects

Specify which observations share an occasion effect, how it combines with a subject effect in an individual parameter, and what assumptions that indexing implies.

Intermediate 10 min read

What You'll Learn

  • Define subject and occasion indices for repeated treatment periods.
  • Write an individual parameter equation combining a subject effect and an occasion effect.
  • State the independence assumptions for occasion effects within and between subjects.
  • Determine which records share an occasion effect and which receive separate effects.
  • Derive log-scale variances and covariances implied by the indexing.
  • Distinguish occasion-level variability from fixed period effects and residual error.

Why Occasion Indexing Matters

When a subject receives treatment in more than one period, an individual parameter may vary both persistently between subjects and from one occasion to another within the same subject. For example, a subject may have generally high clearance, while their clearance during one treatment period differs from their own usual level. A model needs separate random-effect indices to represent those two patterns.

The index is not bookkeeping alone. It determines which records share a random effect, which effects are distinct, and therefore which observations are linked by the model. An occasion effect assigned separately to every concentration measurement represents something different from an effect shared by all measurements in a treatment period.

Definition: Let \(i\) index subjects and \(j\) index occasions (such as treatment periods) within subject \(i\). A subject-level random effect, written \(\eta_i\), is shared across that subject’s occasions. An occasion-level random effect, written \(\kappa_{ij}\), is shared by records from subject \(i\) on occasion \(j\), but may differ on another occasion. A record-level residual is associated with an individual observation, rather than being shared across the occasion.

Here, “occasion” means a study-defined period in which the model treats parameter deviations as shared. It does not automatically mean a dose, a sampling time, or a calendar day. The study design and the scientific interpretation determine the occasion boundaries. If a subject has several observations in one treatment period, those observations ordinarily use the same \(\kappa_{ij}\).

Parameter Equation and Assumptions

Consider a positive individual parameter \(P_{ij}\), such as clearance, for subject \(i\) during occasion \(j\). Let \(P_{\mathrm{typ}}\) be its typical value and let \(g_{ij}\) be a specified positive covariate multiplier. A common log-normal parameterization is:

$$ P_{ij}=P_{\mathrm{typ}}g_{ij}\exp(\eta_i+\kappa_{ij}). $$

The covariate multiplier can be omitted when there are no covariates in the equation. On the log scale, the same equation is:

$$ \log\left(\frac{P_{ij}}{P_{\mathrm{typ}}g_{ij}}\right)=\eta_i+\kappa_{ij}. $$

This equation assigns a stable deviation \(\eta_i\) to subject \(i\), then adds the deviation \(\kappa_{ij}\) for that subject’s particular occasion. Exponentiation ensures that the resulting parameter remains positive. A different occasion-level parameterization may be appropriate for a different model, but the indices must still reflect which records share each effect.

For the scalar occasion effect in this tutorial, assume:

  • \(\eta_i\) has mean zero and variance \(\omega_{\mathrm{sub}}^2\); \(\kappa_{ij}\) has mean zero and variance \(\omega_{\mathrm{occ}}^2\).
  • Occasion effects are independent across distinct occasions, and effects belonging to different subjects are independent.
  • Subject effects are independent across subjects and independent of all occasion effects.
  • Covariates and the typical parameter are treated as fixed when describing the random-effect distribution.

A normal specification is often used: \(\eta_i\sim N(0,\omega_{\mathrm{sub}}^2)\) and \(\kappa_{ij}\sim N(0,\omega_{\mathrm{occ}}^2)\), with the stated independence. These are modeling assumptions, not consequences of the indices themselves. In particular, using different indices does not prove independence; independence must be specified. This scalar equation does not address correlation between occasion effects on different parameters.

Worked Example: Combining Subject and Occasion Effects

Suppose a hypothetical model has \(P_{\mathrm{typ}}=8.00\) L/h and no covariate multiplier. For subject 1, let \(\eta_1=0.10\), with \(\kappa_{11}=0.05\) in period 1 and \(\kappa_{12}=-0.08\) in period 2. Calculate the individual parameter in each period.

For period 1, the subject and occasion effects add on the log scale:

$$ P_{11}=8.00\exp(0.10+0.05) =8.00\exp(0.15) \approx 9.294\ \text{L/h}. $$

For period 2, the subject effect is unchanged, but the occasion effect has its own index and value:

$$ P_{12}=8.00\exp(0.10-0.08) =8.00\exp(0.02) \approx 8.162\ \text{L/h}. $$

The same \(\eta_1\) appears in both periods because it represents the subject’s persistent deviation. The two \(\kappa\) values differ because they represent occasion-specific deviations. These are hypothetical parameter calculations, not estimates from observed data.

What the Indices Imply

With the covariate multiplier held fixed, define the log-scale deviation \(Z_{ij}=\log(P_{ij}/(P_{\mathrm{typ}}g_{ij}))\). Then \(Z_{ij}=\eta_i+\kappa_{ij}\). The variance for one occasion follows from adding independent random variables:

$$ \operatorname{Var}(Z_{ij}) =\operatorname{Var}(\eta_i)+\operatorname{Var}(\kappa_{ij}) =\omega_{\mathrm{sub}}^2+\omega_{\mathrm{occ}}^2. $$

For two different occasions \(j\ne l\) of the same subject, the subject effect is shared, while the occasion effects are independent. Thus:

$$ \operatorname{Cov}(Z_{ij},Z_{il}) =\operatorname{Cov}(\eta_i+\kappa_{ij},\eta_i+\kappa_{il}) =\omega_{\mathrm{sub}}^2. $$

The covariance is not zero: the shared subject effect links the two occasions. For different subjects, all the random effects in the two expressions are independent under the assumptions above, so the corresponding covariance is zero. This derivation shows directly why the subject index must be reused across occasions and why the occasion index must change.

These are log-scale statements. They should not be reported as the variance or covariance of \(P_{ij}\) on its natural scale. Exponentiation changes the distribution and its moments. The log-scale result is useful here because it follows directly from the specified parameter equation.

Worked Example: Covariance for Two Periods

Suppose the hypothetical log-scale variances are \(\omega_{\mathrm{sub}}^2=0.04\) and \(\omega_{\mathrm{occ}}^2=0.09\). For one subject, calculate the variance of the log parameter in either period, the covariance between periods 1 and 2, and their correlation.

The variance in one period is the sum of the two independent contributions:

$$ \operatorname{Var}(Z_{i1})=0.04+0.09=0.13. $$

Between different periods of the same subject, only the shared subject effect contributes to the covariance:

$$ \operatorname{Cov}(Z_{i1},Z_{i2})=0.04. $$

Both periods have variance \(0.13\), so their correlation is:

$$ \operatorname{Corr}(Z_{i1},Z_{i2}) =\frac{0.04}{\sqrt{0.13(0.13)}} =\frac{0.04}{0.13} \approx 0.3077. $$

Thus, under these assumptions, the two log parameters have a positive correlation of about 0.308 because they share a subject effect. The occasion effects increase the variance within each period but, being independent across periods, do not add to the between-period covariance.

Assigning Effects to Records

A practical way to construct the indexing is to make a record-to-occasion map before writing the parameter equation. Every record from the same subject and same model-defined occasion receives the same pair of indices \((i,j)\). A new occasion for that subject receives a new \(j\), while the subject index \(i\) stays the same. Observation time may still appear in the structural model, but it does not create a new occasion effect by itself.

Worked Example: Several Samples Within Each Period

Suppose subject 4 has concentration samples at 1, 4, and 8 hours in treatment period 1, and samples at 1, 4, and 8 hours in period 2. The model uses one clearance parameter per subject and period, with \(\eta_4=0.06\), \(\kappa_{41}=-0.03\), and \(\kappa_{42}=0.02\). Let \(P_{\mathrm{typ}}=10.0\) L/h, with no covariate multiplier.

All three period-1 samples use the same individual clearance:

$$ P_{41}=10.0\exp(0.06-0.03) =10.0\exp(0.03) \approx 10.305\ \text{L/h}. $$

All three period-2 samples use a different occasion effect but the same subject effect:

$$ P_{42}=10.0\exp(0.06+0.02) =10.0\exp(0.08) \approx 10.833\ \text{L/h}. $$

The six observations do not receive six independent \(\kappa\) values. The three observations in each period share one occasion effect, so the parameter used for the samples in that period is consistent. If an observation-level residual is also modeled, it is a separate contribution at the observation level.

Occasion Labels, Period Effects, and Alternatives

The occasion index is generally local to the subject: \(\kappa_{i1}\) means the effect for subject \(i\)’s first modeled occasion, and \(\kappa_{i2}\) means the effect for that subject’s second modeled occasion. The label \(j=1\) need not mean the same calendar dates for every subject. If the design has a systematic difference between treatment periods—for example, a population-average period 2 shift—that pattern should be represented explicitly in the model, such as with a fixed period term. A zero-mean occasion random effect describes subject-specific deviations around the modeled typical value; it does not by itself encode an average period trend.

The principal alternatives answer different questions. A subject-only effect allows an individual deviation that persists across that subject’s periods, but does not allow an additional period-specific deviation. An occasion effect adds that within-subject variation. A residual term addresses observation-level deviations rather than a parameter shift shared across a period. A fixed period effect represents a systematic average difference between designated periods, rather than random deviations among subjects and occasions. These components should not be substituted for one another merely because they all can contribute to differences in recorded concentrations.

An occasion random effect is useful when the scientific model calls for a period-level change in an individual parameter, and when the design and observations provide information to support that component. Its existence in an equation does not guarantee that its variance can be estimated precisely. Sparse data, few occasions, or weak information about the parameter may make the occasion contribution difficult to distinguish from other sources of variability. Detailed design-based identification is a separate question.

Diagnostics and Common Indexing Errors

Check the mapping from records to indices before interpreting a model. A useful diagnostic table includes subject, occasion, observation time, and the occasion-effect label used for that record. Verify that records within a defined occasion share one label, that different occasions for the same subject receive different labels, and that subject effects remain constant across that subject’s occasions. Then inspect whether the occasion definition matches the study protocol and scientific question.

  • Giving each sample a new occasion index: this makes the supposed occasion effect vary between measurements within a period. The correction is to assign one index to the whole defined occasion.
  • Changing the subject index across periods: this removes the shared subject deviation and treats repeated periods as unrelated subjects. Keep \(i\) fixed for the same subject.
  • Reusing one occasion index for all periods of a subject: this forces the occasion deviation to persist across periods. Give each distinct modeled occasion its own \(j\).
  • Treating a random occasion effect as a fixed period trend: a zero-mean random effect does not specify a nonzero average difference between periods. Include a fixed period term when a systematic mean shift is part of the model.

A further practical warning concerns unequal or missing periods. Indices should follow the model-defined occasions, not simply the order of rows in a data file. If a planned period is missing, do not renumber a later observed period in a way that changes its scientific meaning or accidentally assigns it another period’s effect.

Key takeaway: In \(P_{ij}=P_{\mathrm{typ}}g_{ij}\exp(\eta_i+\kappa_{ij})\), the repeated subject index \(i\) encodes a persistent individual deviation, while \(j\) identifies the occasion-specific deviation shared by records from that occasion. The model’s independence assumptions and the record-to-occasion map together determine the implied dependence.

Check Your Understanding

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

  1. Subject 8 has four samples in period 1 and three in period 2. How many subject effects and occasion effects appear in the parameter equation for these records?
  2. Under the stated model, what is the covariance between the log parameters for two different occasions of the same subject?
  3. Suppose a data file gives two occasions for subject 3, but the second occasion appears first in the file. Should its occasion index be assigned from row order? Explain.
  4. Which model component represents a systematic average difference between treatment periods: a zero-mean occasion random effect or a fixed period term?

Solutions. (1) There is one subject effect, \(\eta_8\), shared across both periods, and two occasion effects, \(\kappa_{81}\) and \(\kappa_{82}\). Each effect is reused for all samples in its period. (2) The covariance is \(\omega_{\mathrm{sub}}^2\): the subject effect is shared, and the distinct occasion effects are independent. (3) No. Assign the occasion index according to the model-defined period, not file-row order, so that the effect remains attached to the intended occasion. (4) A fixed period term represents a systematic average difference; the zero-mean occasion random effect represents occasion-specific deviations around the modeled mean.