Why Timing Is Part of the Covariate
A co-medication history is not just a list of drug names. For a longitudinal PK analysis, the relevant question is often whether a concomitant drug was being taken at a particular time, or how much of it had been taken over a specified period. A subject can therefore have different covariate values at different concentration samples or dosing events. Treating the subject as simply “exposed” or “unexposed” discards that change and can assign the wrong exposure to observations.
The central task is to turn recorded medication episodes into a time-indexed covariate and to apply one timing rule consistently. That rule must specify what counts as active use at a boundary, which time window an exposure summary covers, and how the result is matched to dose and sample records. These are data-construction decisions: they do not, by themselves, establish a drug effect or describe its biological time course.
Represent the Medication History as Time Intervals
Begin by representing each medication episode with a start time and a stop time, using the same time scale as the PK data. For example, records might use elapsed hours from the first PK dose. The episode also needs a clearly identified exposure quantity, such as recorded dose in milligrams. Prescribed dates and doses are not necessarily the same as actual administration dates and doses; use the record type that matches the intended covariate and describe it accurately.
A convenient convention is that an episode from \(s\) to \(e\) is active on the half-open interval \([s,e)\): it is active at \(s\), but not at \(e\). Thus \(Z_i(t)=1\) when \(s\leq t<e\), and \(Z_i(t)=0\) otherwise. The convention makes adjacent episodes unambiguous: an episode ending at hour 12 is not active at hour 12, while a new episode beginning at hour 12 is active then. If the source data imply different boundary rules, use a rule appropriate to those records and document it.
Medication histories are often recorded as calendar dates rather than exact times. In that case, a date may not determine whether the drug was taken before a sample collected that day. Do not create artificial precision by silently treating a date-only start or stop as an exact timestamp. Establish a defensible convention, retain indicators of uncertainty where possible, and assess the consequences if the timing ambiguity could affect interpretation.
Worked Example: Constructing an Active-Use Indicator
Hypothetical data. A subject’s PK time origin is the first study dose at 08:00 on Day 1. The medication record shows a co-medication episode from hour 6 through hour 30, and a second episode from hour 42 through hour 60. Under the half-open interval convention, construct the active-use indicator at PK samples collected at hours 5, 6, 18, 30, 42, and 60.
For an episode \([s,e)\), the indicator is 1 if \(s\leq t<e\). With two episodes, it is 1 if either interval contains \(t\):
At hour 5, neither interval has started, so \(Z_i(5)=0\). At hour 6, the first interval begins, so \(Z_i(6)=1\). At hour 18, the first interval is active, so \(Z_i(18)=1\). At hour 30, it has ended and the second has not started, so \(Z_i(30)=0\). At hour 42, the second interval begins, so \(Z_i(42)=1\). At hour 60, it has ended, so \(Z_i(60)=0\).
The resulting values, in the same order as the samples, are \(0,1,1,0,1,0\). The boundary convention determines the values at hours 30 and 60; omitting it could produce inconsistent coding across records or analysts.
Choose the Exposure Summary Before Matching Times
An active-use indicator is useful when the scientific question concerns recorded use at a particular time, but it does not distinguish a small dose from a large one or brief use from sustained use. Other covariates can summarize dose or duration. They answer different questions, so the definition should specify units, the time window, and how incomplete records are handled. Common constructions include:
- Active use: \(Z_i(t)=1\) during recorded medication episodes and 0 otherwise. This does not encode dose amount.
- Recent dose amount: the sum of recorded doses administered during a stated look-back window, for example the preceding 24 hours, in milligrams.
- Average dose rate: the total recorded dose in a window divided by its duration, such as milligrams per hour. This is not the same as an instantaneous dose.
- Fraction of a window exposed: the exposed duration within the window divided by the full window duration, a dimensionless quantity from 0 to 1.
For example, a recent-dose measure with a 24-hour look-back window can be defined by summing the recorded doses whose administration times fall within that window. State whether the window is \((t-24,t]\), \([t-24,t)\), or another interval. This detail matters for a dose recorded exactly at a boundary. If administration times and episode start-stop times are both available, do not assume they encode the same information: an episode may describe intended or continuous use, whereas administrations record discrete dose events.
Worked Example: Calculating Recent Dose and Dose Rate
Hypothetical data. A subject has recorded co-medication administrations of 10 mg at hour 2, 10 mg at hour 14, and 5 mg at hour 25. Define the recent-dose covariate at hour 26 as the total dose in the look-back interval \((2,26]\), and define average dose rate as that total divided by the 24-hour window duration.
The interval is open at hour 2, so the dose administered exactly at hour 2 is excluded. The doses at hours 14 and 25 are included. Therefore:
The average dose rate over the window is:
The result is a 15 mg dose total in the specified window and a rate of 0.625 mg/h. Neither value is the subject’s dose at hour 26. If the window instead included hour 2, the total would be 25 mg and the rate would be \(25/24=1.042\) mg/h. This difference is why the window endpoints must be stated.
Align Covariates With PK Observations and Doses
Let \(t_{ij}\) be the time of concentration observation \(j\) for subject \(i\). If the covariate is intended to describe recorded exposure at sampling, evaluate it at that time: attach \(Z_i(t_{ij})\) or the chosen window summary to the concentration record. Do not copy a single subject-level value to all samples if the recorded medication status changes during follow-up.
PK dosing records also have times, say \(d_{ik}\) for dose event \(k\). A covariate used to characterize the subject at a dose event should be evaluated at the dose time according to a stated convention. When a dose and a co-medication start or stop share a timestamp, record ordering or an explicit tie rule is needed. For example, a pre-dose value can be defined from information immediately before the PK dose; a value at the timestamp under the half-open interval convention includes a co-medication episode starting at that time. These conventions should not be mixed without justification.
A useful way to think about alignment is as a lookup operation. First construct the covariate as a function of time from medication records; then evaluate that function at every required PK time. The same medication timeline can consequently supply values at concentration times and dose times, while the two sets of records remain distinct. If the chosen covariate uses a look-back window, the lookup is based on the window ending at the relevant PK time, not merely on whether an episode overlaps that instant.
Worked Example: Fraction of a Window With Recorded Use
Hypothetical data. A co-medication is recorded as active from hour 4 through hour 10. A concentration sample is collected at hour 16. Define the duration-based covariate as the fraction of the preceding 12 hours during which the medication was active. Use the half-open convention for the episode and the window \([4,16)\).
The 12-hour window is \([16-12,16)=[4,16)\). The active portion is \([4,10)\), with duration \(10-4=6\) hours. The exposed fraction is therefore:
The covariate value attached to the sample is 0.5, meaning that recorded use covered half of the defined look-back window. It does not mean the medication was active at the sample instant: at hour 16, the recorded episode has ended, so the current-use indicator is 0. The two covariates summarize different aspects of the same history.
Justification for Duration-Based Summaries
For a binary active-use process, a duration-based summary is the time average of the indicator over the window. This follows directly from the definition of an indicator: it contributes 1 for each unit of time exposed and 0 for each unit not exposed. Integrating it therefore gives exposed duration.
If use is active for 6 hours of a 12-hour window, the integral is 6 hours and \(F_W(t)=6/12=0.5\). Because \(Z_i(u)\) is either 0 or 1 and the integration interval has length \(W\), \(0\leq F_W(t)\leq1\). For episode records, the integral is calculated by adding the lengths of the intersections between each active episode and the look-back window. Overlapping records must not cause the same time to be counted twice for a binary indicator; use the union of active intervals.
Diagnostics, Alternatives, and Limitations
Before using a constructed covariate, inspect it against the medication timeline and PK records. A small table of subject, sample or dose time, covariate value, and the source interval or doses used makes many errors visible. Check that indicators are only 0 or 1, duration fractions lie between 0 and 1, dose totals are nonnegative, and units are consistent. Plotting the time-varying covariate alongside concentration and dose times can reveal implausible jumps, accidental gaps, or values that appear before the recorded medication begins.
The main alternatives are not interchangeable. A subject-level “ever exposed” indicator is simple but ignores when exposure occurred. A current-use indicator preserves timing but ignores dose and duration. A recent-dose total retains an amount over a specified window but depends on accurate administration records and endpoint choices. A duration fraction summarizes time covered but treats all active hours equally and ignores dose size. Choose the simplest representation that answers the intended question, and retain its full definition.
Time-varying covariates also have limits. Medication records can be incomplete, retrospective, or recorded at a coarser time resolution than PK samples. Recorded use does not guarantee that a dose was taken, and a binary indicator does not represent concentration of the co-medication in the body. A windowed summary is a constructed exposure proxy, not a direct measurement of pharmacologic effect. Further, a covariate can change at a time that is biologically implausible as an immediate change in the PK process. The timing and functional relationship between co-medication and PK parameters require separate scientific justification; coding alone cannot supply it.
Practical Construction Sequence
Express co-medication starts, stops, administrations, PK doses, and concentration samples on a common time scale with explicit units.
Choose active use, dose amount, dose rate, or duration fraction. State the data source, time window, units, and endpoint convention.
Apply the interval rule, resolve or flag ambiguous boundaries, and verify that overlapping active intervals are handled consistently.
Evaluate the covariate at each concentration time and, when needed, each dosing time. Keep the alignment convention explicit for coincident events.
Check values, units, boundaries, and plots against the source history before fitting a longitudinal model.
Check Your Understanding
Use the stated conventions in each problem. Solutions are provided after the questions.
- An episode is recorded on \([8,20)\). What are the active-use indicator values at hours 8, 19, and 20?
- A 10-hour look-back window ends at hour 30 and uses \((20,30]\). Doses were administered at hours 20, 24, and 30 in amounts of 5 mg, 8 mg, and 2 mg. What is the recent-dose total?
- A 6-hour window contains 1.5 hours of recorded active use. What is the duration fraction?
- Why can a current-use indicator and a recent-dose total have different values for the same sample time?
- A sample was collected at hour 15, but the co-medication began at hour 18. Should the hour-15 sample be labelled exposed under a current-use rule?
Solutions. (1) The values are 1, 1, and 0: the start is included and the stop is excluded. (2) The hour-20 dose is excluded because the window is open at 20; the other two are included, so the total is \(8+2=10\) mg. (3) The fraction is \(1.5/6=0.25\), or 25% of the window. (4) Current use asks whether exposure is active at the sample time, whereas a recent-dose total sums administrations in a prior window; past doses can contribute after current use has ended. (5) No. Under a current-use rule, the episode has not begun at hour 15, so the sample’s indicator is 0.