I'm finding it difficult to settle on a method in the literature on how to deal with exposure time of being on a drug(s) (or not) on a future outcome. Let's say my outcome is death and I have longitudinal drug data:

person_id | first_prescription_date | duration_drug_months | drug_type | study_start_date | study_end_date | status
1         | 2012-01-06              |          6           |   Drug C  |    2010-01-01    |   2020-12-31   |   0
2         | 2011-08-27              |         10           |   Drug C  |    2010-01-01    |   2019-09-01   |   1
2         | 2012-03-01              |          8           |   Drug B  |    2010-01-01    |   2019-09-01   |   1
3         | NA                      |          0           |  No Drug  |    2010-01-01    |   2020-12-31   |   0
4         | 2010-08-10              |          2           |   Drug A  |    2010-01-01    |   2016-10-23   |   1
4         | 2014-11-30              |         12           |   Drug C  |    2010-01-01    |   2016-10-23   |   1
5         | 2011-05-29              |         24           |   Drug B  |    2010-01-01    |   2020-12-31   |   0
5         | 2014-03-27              |          4           |   Drug A  |    2010-01-01    |   2020-12-31   |   0
6         | NA                      |          0           |  No Drug  |    2010-01-01    |   2013-12-12   |   1

There is only 1 row of data where the participant has never been given a drug, and there is a row for each drug a person has been given that includes which drug, when they were first prescribed and the duration. the status column indicates survival.

I know that I could just record a binary outcome of whether a drug was taken, or even a proportion of time spent exposed to drug over the study period, but even the second method does not take into account when they were exposed.

This paper discusses the many approaches and pitfalls https://onlinelibrary.wiley.com/doi/full/10.1002/pds.4372 of using this kind of data - but I'm still not left with a conclusive path. Does anyone have any suggestions? I am using R so any packages that could help would be great. I have used the survival package often but never but sequential data.


1 Answer 1


This is more a matter of applying your understanding of the subject matter than of statistical analysis per se.

Here's the statistical analysis aspect. If you are using a proportional hazards survival model, like a Cox regression, then the hazard for each individual at risk at each event time in the data set is modeled as a function of the covariate values in place at that event time. Values of the covariate at earlier times are only considered at their own corresponding event times, not at later times.

When you have a time-varying exposure to a drug, you thus have to construct a covariate for the model that will translate that time-varying exposure into a value that will represent the association with hazard precisely at a each time point while at risk. If it's the current exposure, then use the current exposure as a time-varying covariate. If it's whether the individual was ever exposed to the drug (which seems unlikely), then use a binary exposed/not indicator that changes at the first time the drug was used. If it's some aspect of the history of the drug exposure over time, construct a covariate that makes sense biologically; for example, something like the average drug exposure over the prior week or prior month or prior year, or some other weighting with respect to time (depending on the type of drug).

There is thus no single answer to your question. The answer depends on your understanding of the subject matter. What's critical is that your drug-exposure covariate, evaluated at any point in time, takes a value that's associated with the hazard of an event precisely at that corresponding point in time, given the nature of the drug and the type of event you are studying.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.