class: center, middle, inverse, title-slide .title[ # Time-varying covariates ] .author[ ### Yue Jiang ] .date[ ### STA 490/690 ] --- ### Re-arrest Today, we'll be thinking about the Rossi et al. data, examining time to re-arrest among a cohort of prisoners released from jail. ```r head(dat) ``` ``` ## id week arrest age mar prio emp_time ## 1 1 20 1 27 not married 3 NA ## 2 2 52 0 40 not married 2 5 ## 3 3 37 1 17 not married 5 28 ## 4 4 52 0 37 not married 2 19 ## 5 5 25 1 20 not married 3 15 ## 6 6 46 1 22 not married 2 2 ``` --- ### Re-arrest and employment .question[ The variable `emp_time` encodes the week at which the subject found employment. NA values mean that they did not successfully find employment (by the time of censoring or re-arrest). Is there an association between time-to-rearrest and whether the individual was employed post-release, controlling for age at release, marital status, and number of prior convictions? The dataset is available on Gradescope (check today's activity). ] --- ### Re-arrest and employment ```r dat$emp <- ifelse(is.na(dat$emp_time), 0, 1) m1 <- coxph(Surv(week, arrest) ~ emp + age + mar + prio, data = dat) round(summary(m1)$coef, 3) ``` ``` ## coef exp(coef) se(coef) z Pr(>|z|) ## emp -0.915 0.401 0.280 -3.270 0.001 ## age -0.092 0.912 0.031 -3.009 0.003 ## marnot married 0.827 2.287 0.599 1.382 0.167 ## prio 0.093 1.098 0.036 2.607 0.009 ``` .question[ What do you think of this analysis? ] --- ### Re-arrest and employment We would like to disentagle employment status as an exposure from arrest as an outcome. .question[ What about an analysis in which we look at a specific time, say two months, and evaluate whether a patient had found employment by two months vs. time to re-arrest (perhaps controlling for those same variables)? Do we need to do anything to modify this analysis? ] --- ### Re-arrest and employment Unfortunately, we run into the same problem - perhaps someone was re-arrested prior to two months. However, this type of conditional analysis *is* able to provide valid estimates that avoid immortal time bias if we make a few modifications: 1. Exclude any patient who experienced the outcome or censoring event within the exposure assessment window 2. *Only* assess employment status within the exposure assessment window .question[ What are some of the strengths and weaknesses of this type of analysis? Is it flexible? What are some conclusions we can make? ] --- ### Re-arrest and employment ```r dat2 <- dat[(dat$week >= 9),] dat2$emp_time[dat2$emp_time >= 9] <- NA dat2$emp <- ifelse(is.na(dat2$emp_time), 0, 1) m2 <- coxph(Surv(week, arrest) ~ emp + age + mar + prio, data = dat2) round(summary(m2)$coef, 3) ``` ``` ## coef exp(coef) se(coef) z Pr(>|z|) ## emp -0.235 0.791 0.262 -0.897 0.370 ## age -0.106 0.899 0.033 -3.197 0.001 ## marnot married 0.825 2.282 0.601 1.372 0.170 ## prio 0.129 1.137 0.037 3.510 0.000 ``` --- ### Re-arrest and employment This type of conditional analysis is called a .vocab[landmark analysis]. It does allow for valid evaluation of time-varying covariates, but loses quite a bit of flexibility and information in doing so. As well, it is a conditional analysis - we are conditioning on potentially restrictive characteristics in our target population. --- ### An aside Suppose at baseline a patient's ejection fraction was 60%, 50% at year 1, 40% at year 2, and they died at year 2.5. .question[ How could these yearly measurements be incorporated? Keep in mind the contribution of each individual at observed failure times `\(t_j\)` to the partial likelihood: `\begin{align*} \frac{\exp(\mathbf{x}_i\boldsymbol\beta)}{\sum_{j \in \mathcal{R}(t_j)}\exp(\mathbf{x}_j\boldsymbol\beta)} \end{align*}` and the product of all such contributions at each failure time. Would it be "not too horrible" to estimate their ejection fraction at year 1.5 as 55%? Year 2.5 as 35%? ]