## 1 Introduction

Simulations and Monte Carlo methods serve an important role in modern statistical research. They allow for an examination of the performance of statistical methods in settings in which analytic and mathematical derivations may not be feasible. A key element in any statistical simulation is the existence of an appropriate data-generating process: one must be able to simulate data from an underlying statistical model.

Time-to-event outcomes occur frequently in the biomedical literature. In the medical literature, the Cox proportional hazards regression model is the most common approach for examining the effect of explanatory variables on time-to-event outcomes. Using this model, one is modeling the effect of explanatory variables on the hazard of the outcome. Prior studies have described methods to simulate data from a Cox proportional hazards model [1, 2]. Use of these data-generating processes allows for the examination of the performance of the Cox proportional hazards regression model in different settings.

Two advantages of the Cox proportional hazards regression model are its abilities to incorporate time-varying covariate effects and time-varying covariates [3, 4]. The former refers to a variable that is measured at baseline and whose value remains fixed over the duration of follow-up; however, the effect of this variable on the hazard of the outcome is allowed to change over the duration of follow-up. The latter refers to a variable whose value itself changes over the duration of follow-up. Examples of time-varying covariates in biomedical research include the receipt of an organ transplant, cumulative dosage of radiation or of a pharmaceutical agent, and compliance or adherence with a medication intended for chronic use. In the first example, receipt of an organ transplant is a dichotomous exposure or treatment. Subjects may change their exposure status from unexposed to exposed at most once during the follow-up interval. Once exposed, a subject remains exposed for the duration of follow-up. In the second example, cumulative dosage of radiation or to a pharmaceutical agent is a continuous time-varying covariate, whose value is nondecreasing over time. In the third example, current medication use also represents a dichotomous exposure. However, subjects may move both from unexposed to exposed and from exposed to unexposed during the course of follow-up. Thus, subjects may both initiate and discontinue treatment, and this pattern may be repeated during the course of follow-up. Throughout the remainder of the manuscript, we focus on simulating data in the presence of time-varying covariates and do not consider time-varying covariate effects. Correctly accounting for time-varying covariates is important because it allows one to avoid the issue of survivor-treatment or immortal-time bias [5-8]. Given a cohort study in which treatment or exposure occurs at some point during follow-up, this bias can occur when the analyst treats the exposure as being known and fixed at baseline. In so doing, the time until the application of the exposure is termed ‘immortal-time’, because by definition the exposed subject could not have died prior to the application of the exposure. Beyersmann *et al.* demonstrated that the biased hazard ratio will always be less than the true hazard ratio [6].

To conduct simulations of the performance of different statistical methods for use in settings with time-varying covariates, there is a need to describe data-generating processes for the Cox proportional hazard model in the presence of time-varying covariates. The paper is structured as follows. In Section 2, we present previous work on generating survival times to simulate Cox proportional hazards models with fixed or time-invariant covariates. These are covariates whose values are fixed at baseline and which do not subsequently change over the duration of follow-up. In Section 3, we extend these results to settings in which there is a time-varying covariate. We consider the case of the Cox-exponential model, the Cox–Weibull model, and the Cox–Gompertz model. In Section 4, we present an application of these methods to investigate the statistical power to detect as statistically significant the effect of different types of time-varying covariates on the hazard of an outcome. Finally, in Section 5 we summarize our findings and place them in the context of the existing literature.