# Computing Time-Dependent Covariates

In certain situations, you would want to compute a Cox Regression model but the proportional
hazards assumption does not hold. That is, hazard ratios change across time; the values of one (or
more) of your covariates are different at different time points. In such cases, you need to use an
extended Cox Regression model, in which you can specify **time-dependent covariates**.

To analyze such a model, you must first define the time-dependent covariate. To facilitate this,
a 'system variable' that represents time is available. This variable is called *T_.* You can
use this variable to define time-dependent covariates in two general ways:

- To test the proportional hazards assumption with respect to a particular covariate or estimate
an extended Cox regression model that allows nonproportional hazards, you need to define
time-dependent covariate as a function of the time variable
*T_*and the covariate in question. A common example would be the simple product of the time variable and the covariate, but more complex functions can be specified as well. Testing the significance of the coefficient of the time-dependent covariate tells whether the proportional hazards assumption is reasonable. - Some variables can have different values at different time periods but aren't systematically
related to time. In such cases, you need to define a
**segmented time-dependent covariate**, which can be done by using**logical expressions**. Logical expressions take the value 1 if true and 0 if false. Using a series of logical expressions, you can create your time-dependent covariate from a set of measurements. For example, if you have blood pressure that is measured once a week for the four weeks of your study (identified as*BP1*to*BP4*), you can define the time-dependent covariate as (*T_*< 1) **BP1*+ (*T_*>= 1 &*T_*< 2) **BP2*+ (*T_*>= 2 &*T_*< 3) **BP3*+ (*T_*>= 3 &*T_*< 4) **BP4*. You notice that exactly one of the terms in parentheses are equal to 1 for any specific case and the rest will all equal 0. To sum up, this function means that if time is less than one week, use*BP1*; if it is more than one week but less than two weeks, use*BP2*, and so on.

In the Compute Time-Dependent Covariate dialog box, you can use the function-building controls to build the expression for a time-dependent covariate, or you can enter it directly in the Name text area. Note that string constants must be enclosed in quotation marks or apostrophes, and numeric constants must be typed in American format, with the dot as the decimal delimiter. Any resulting time-dependent covariates need to be included as covariates in your Cox Regression model.