Tutorials › Population Pharmacokinetics › Coding Occasion Effects In Repeated-Dose Data

Random-Effect Structure and Error Models · Tutorial 142 of 599

Coding Occasion Effects In Repeated-Dose Data

Learn to map dose and concentration records to subject-specific occasions, specify interoccasion random effects, and recognize covariance errors caused by incorrect indexing.

Intermediate 9 min read

What You'll Learn

  • Define an occasion as a scientifically meaningful within-subject PK period, not as an individual observation or dose event.
  • Construct a subject–occasion key that keeps occasion effects specific to the correct subject and period.
  • Write a repeated-dose random-effects model with interindividual and interoccasion terms.
  • Derive the covariance implied by correct occasion coding and compare it with common coding errors.
  • Diagnose mismatches between the intended occasion structure and the data or model implementation.

Why Occasion Coding Matters

Repeated-dose PK data often contain several profiles or treatment periods for the same subject. A subject-level random effect represents features shared across that subject’s records; an interoccasion random effect represents additional variation shared by records from the same subject during one occasion. The occasion index is therefore not just a convenient label. It determines which records share a random effect and, in turn, the covariance structure implied by the model.

An occasion should correspond to a scientifically meaningful period in the design and data. It might be a planned PK profile period or a treatment period with a defined set of dose and sample records. It is not automatically one dose, one sample, or one calendar day. The protocol, dosing history, sampling schedule, and modeling objective determine the appropriate boundaries. In a repeated-dose regimen, for example, multiple doses can occur during one PK occasion; assigning a new occasion number to every dose would describe a different random-effects structure.

Definition: For subject \(i\), an occasion \(j\) is a defined within-subject period to which the relevant dose and observation records belong. The occasion index identifies that period within the subject. A record-level occasion assignment maps each record to exactly one subject–occasion pair.

The same local label, such as 1 or 2, can be reused for different subjects. What must be unique is the pair \((i,j)\), not the number \(j\) by itself. Thus subject 12’s occasion 1 and subject 25’s occasion 1 are distinct groups. This is the central practical rule for coding interoccasion effects.

Model and Covariance Implied by the Indices

Consider one positive PK parameter, such as clearance, with a subject-level effect and an occasion-level effect. On the log scale, write the parameter for subject \(i\) on occasion \(j\) as follows:

$$ \log(\theta_{ij})=\log(\theta_{\mathrm{pop}})+\eta_i+\kappa_{ij} $$

Here \(\theta_{\mathrm{pop}}\) is the population typical value, \(\eta_i\) is the interindividual random effect, and \(\kappa_{ij}\) is the interoccasion random effect. For this basic model, assume that the effects have mean zero, are normally distributed, and are mutually independent across subjects and occasions:

$$ \eta_i\sim N(0,\omega_{\mathrm{IIV}}), \qquad \kappa_{ij}\sim N(0,\omega_{\mathrm{IOV}}) $$

The \(\omega\) quantities are variances on the log-parameter scale. In particular, one \(\kappa_{ij}\) is shared by every record assigned to subject \(i\), occasion \(j\). It is not a new draw for every sample within that occasion. The independence assumption here is a simplifying specification for illustrating the coding structure; it is not guaranteed by the data. The model also assumes that the chosen occasion boundaries are meaningful and that the effects are adequately represented by the specified distributions.

Let \(Z_{ij}=\log(\theta_{ij})-\log(\theta_{\mathrm{pop}})\) denote the combined random contribution for that subject and occasion. If two records belong to the same subject and occasion, their combined contributions are the same random quantity, \(\eta_i+\kappa_{ij}\). If they belong to the same subject but different occasions, they share \(\eta_i\) but have different occasion effects.

$$ \operatorname{Var}(Z_{ij})=\omega_{\mathrm{IIV}}+\omega_{\mathrm{IOV}} $$
$$ \operatorname{Cov}(Z_{ij},Z_{ik})= \begin{cases} \omega_{\mathrm{IIV}}+\omega_{\mathrm{IOV}}, & j=k\\ \omega_{\mathrm{IIV}}, & j\ne k \end{cases} $$

For different subjects, the covariance is zero under the stated independence assumptions. These expressions describe covariance in the log-parameter random contributions. The resulting covariance among observed concentrations also depends on the structural PK model and residual error; it is not generally equal to these expressions.

Deriving the Same-Subject Covariance

The covariance result follows directly from the model and makes clear why the indices matter. For two different occasions \(j\) and \(k\) in the same subject,

$$ \begin{aligned} \operatorname{Cov}(Z_{ij},Z_{ik}) &=\operatorname{Cov}(\eta_i+\kappa_{ij},\eta_i+\kappa_{ik})\\ &=\operatorname{Var}(\eta_i) +\operatorname{Cov}(\eta_i,\kappa_{ik}) +\operatorname{Cov}(\kappa_{ij},\eta_i) +\operatorname{Cov}(\kappa_{ij},\kappa_{ik})\\ &=\omega_{\mathrm{IIV}}+0+0+0\\ &=\omega_{\mathrm{IIV}}. \end{aligned} $$

The zero terms follow from the assumed independence of subject and occasion effects and the independence of different occasion effects. When \(j=k\), both terms include the same \(\kappa_{ij}\), so its variance contributes as well. If the occasion index is accidentally shared across subjects, or changes at every observation, those equalities no longer describe the intended groups.

Worked Example: Assigning Occasion Indices to PK Records

Suppose a hypothetical study has two subjects. Each has two planned PK profile periods, and each period includes a dose record and three concentration records. The occasion effect is intended to represent variation shared by the dose and concentrations within one profile period.

For subject A, assign occasion 1 to all records in the first profile and occasion 2 to all records in the second. Do the same for subject B. A compact key is the pair (subject, occasion): (A, 1), (A, 2), (B, 1), and (B, 2). All four keys are distinct even though the local occasion numbers are reused.

For example, the dose record and all three concentrations in subject A’s first profile receive (A, 1). The four records in subject A’s second profile receive (A, 2). Subject B’s first profile receives (B, 1), not (A, 1), despite having the same local occasion number.

This assignment gives each subject a shared \(\eta_i\), while each of the four subject–occasion groups receives its own \(\kappa_{ij}\). It does not create a new occasion effect for each of the 16 records. Nor does it make the occasion-1 effect common to both subjects.

How a Correct Index Determines Covariance

For a numerical illustration, suppose a hypothetical model has \(\omega_{\mathrm{IIV}}=0.09\) and \(\omega_{\mathrm{IOV}}=0.04\) on the log-clearance scale. Consider three log-clearance contributions from one subject: two records in occasion 1 and one record in occasion 2. Under the model, the first two records share both \(\eta_i\) and \(\kappa_{i1}\); the third shares \(\eta_i\) but has \(\kappa_{i2}\).

Worked Example: Covariance for Two Occasions

The variance for each record’s combined contribution is \(0.09+0.04=0.13\). The covariance between the two occasion-1 records is also \(0.13\), because both random effects are shared. The covariance between either occasion-1 record and the occasion-2 record is \(0.09\), because only the subject effect is shared. Thus the covariance matrix is:

$$ \begin{pmatrix} 0.13 & 0.13 & 0.09\\ 0.13 & 0.13 & 0.09\\ 0.09 & 0.09 & 0.13 \end{pmatrix} $$

For example, the covariance between the first and third records is \(\operatorname{Cov}(\eta_i+\kappa_{i1},\eta_i+\kappa_{i2})=0.09+0+0+0=0.09\). The covariance matrix has this form because of the specified grouping, not because the records happened to be adjacent in the data file.

Common Coding Errors and Their Consequences

An occasion variable can look plausible in a data table and still encode the wrong model. Check the grouping key used by the model, not only the values displayed in a column.

  • Using a global occasion number as the random-effect group. If every subject’s occasion 1 shares one random effect, the model induces covariance between different subjects. That is not the intended subject-specific interoccasion effect.
  • Giving every record a new occasion number. This makes observations within one PK period receive different occasion effects. It removes the intended shared occasion contribution from their covariance and makes the model’s occasion-level variation operate at the record level instead.
  • Starting a new occasion at every dose. This is wrong when several doses belong to one defined profile period. It can be appropriate only if the scientific occasion definition actually treats each dose period as distinct and the data support that interpretation.
  • Failing to reset local numbering for a subject. A label such as 1 or 2 is not itself a unique occasion identifier. If an implementation requires a unique grouping value, use a subject–occasion key or equivalent nested structure.
  • Assigning samples and doses inconsistently. If samples from one profile are assigned to one occasion but the dose records governing that profile are assigned elsewhere, the random effect may no longer apply to the structural prediction those doses generated.

Worked Example: What Global Occasion Coding Changes

Use the hypothetical variance values from the preceding example. Suppose two subjects each have occasions 1 and 2, but the model mistakenly gives all subjects’ occasion-1 records the same random effect \(\kappa_1\), and all occasion-2 records the same \(\kappa_2\). Then the combined terms are \(Z_{ij}=\eta_i+\kappa_j\), rather than \(\eta_i+\kappa_{ij}\).

For two different subjects on occasion 1, the covariance becomes \(\operatorname{Cov}(\eta_1+\kappa_1,\eta_2+\kappa_1)=0+0+0+0.04=0.04\). The subjects have acquired a shared occasion effect, which is unintended if occasions are meant to be subject-specific. For one subject across occasions 1 and 2, the covariance remains \(0.09\) under the assumed independent effects. The error is therefore not merely a relabeling: it changes which records share random variation.

If the intended occasion effect is independent across subjects, use \(\kappa_{ij}\) with the pair \((i,j)\) as the random-effect grouping unit. Reusing the number 1 as a displayed local occasion label is fine; using it alone as a global random-effect identifier is not.

Worked Example: Giving Each Sample Its Own Occasion Effect

Suppose one subject has two concentration samples in the same occasion, and each record is mistakenly assigned a distinct occasion effect. With \(\omega_{\mathrm{IIV}}=0.09\), \(\omega_{\mathrm{IOV}}=0.04\), the model-implied covariance between their log-parameter contributions becomes \(0.09\): only \(\eta_i\) is shared. Under the intended coding, both records share \(\kappa_{ij}\), so the covariance is \(0.09+0.04=0.13\).

The variance of each individual contribution is \(0.13\) in either coding. The difference is the off-diagonal covariance: the incorrect record-level grouping reduces it from \(0.13\) to \(0.09\). Consequently, the model no longer represents the extra occasion-level variation as common to the period’s records. This calculation is for the random contributions to log clearance, not a claim that the observed concentrations have those same variances.

Practical Checks, Alternatives, and Limits

Before fitting the model, inspect whether the occasion assignment matches the design. Useful checks include counting distinct subject–occasion pairs, listing the records in each pair, and verifying that all dose and concentration records intended to share an effect have the same key. Also confirm that no key unintentionally combines records from different subjects or separates records within one period. These are checks of model construction; they do not establish that the assumed random-effects distribution is correct.

The appropriate alternative depends on the scientific question. A model with only \(\eta_i\) allows subject-to-subject heterogeneity but no additional occasion-level random variation. A model with \(\eta_i+\kappa_{ij}\) allows a subject’s parameter to vary across occasions while retaining a subject-level contribution shared across them. A fixed occasion indicator instead estimates a specified systematic difference among labeled periods; it does not, by itself, represent a distribution of subject-specific occasion deviations. A record-specific random effect has a different grouping and should not be used as a substitute for an occasion effect.

These structures are not interchangeable coding options. They answer different questions and imply different covariance patterns. Choice among them should reflect the design and scientific aim, not merely which variable is easiest to generate. An occasion random effect also cannot automatically distinguish every possible source of within-subject change; unmodeled design features or systematic differences may be represented poorly by a mean-zero random effect.

The basic formulation here assumes independent occasion effects with a common variance and independent subject effects. It treats the occasion boundaries as already defined and does not address unequal numbers of occasions, correlation between interindividual and interoccasion effects, or time trends across occasions. Those require additional modeling decisions. Further, if a subject has only one occasion, the data do not provide within-subject contrasts across occasions for that subject; the existence of a coded occasion effect alone does not create information about its variance.

Key takeaway: Interoccasion effects belong to subject–occasion groups. Assign the same effect to all records intended to share a period, keep that effect distinct across subjects, and verify that the resulting covariance matches the scientific model.

Check Your Understanding

Answer each question, then compare with the solutions below.

  1. Two subjects both have a local occasion labeled 1. Should those records share one interoccasion random effect? Explain.
  2. For one subject, two records are in the same occasion. If \(\omega_{\mathrm{IIV}}=0.06\) and \(\omega_{\mathrm{IOV}}=0.02\), what is the covariance of their combined log-parameter contributions under the basic model?
  3. What covariance is implied between two different occasions of one subject under the same model, assuming the occasion effects are independent?
  4. Why can assigning a new occasion effect to every concentration sample misrepresent the intended model?

Solutions. (1) No. The random-effect group is the pair (subject, occasion), so the same local label for different subjects denotes distinct effects. (2) The records share both effects, so the covariance is \(0.06+0.02=0.08\) on the log-parameter scale. (3) They share only the subject effect, so the covariance is \(0.06\). (4) It gives records in one intended period different occasion effects, removing the shared occasion contribution from their covariance; an occasion effect is meant to apply to the subject–occasion group, not to an individual row.

Clinical Biostats