The AFT models from Stata's streg
can handle time-varying covaraites. In particular, the manual states that
streg
is suitable only for data that have beenstset
. Bystsetting
your data, you define the variables_t0
,_t
, and_d
, which serve as the trivariate response variable $(t_0, t, d)$. Each response corresponds to a period under observation, $(t_0, t]$, resulting in either failure $(d = 1)$ or right-censoring $(d = 0)$ at time $t$. As a result,streg
is appropriate for data exhibiting delayed entry, gaps, time-varying covariates, and even multiple-failure data.
The question is how this actually works? Suppose that I use a log-normal distribution. Then the density and survival function without time-varying covariates is
$$ \begin{align*} f(t\mid \vec x)&= \frac 1{t\sigma\sqrt{2\pi}}\exp\left(- \frac{(\log t - \vec x^\top\vec\beta)^2}{2\sigma^2}\right) \\ S(t \mid \vec x) &= 1 - \Phi\left( \frac{\log t - \vec x^\top\vec\beta}{\sigma} \right) \end{align*} $$
and the hazard is given by $\lambda (t\mid\vec x) = f(t\mid\vec x)S(t \mid \vec x)^{-1}$. This is fairly easy to interpret as it states that $\log T \mid \vec x$ is normally distributed with mean $\vec x^\top\vec\beta$ and variance $\sigma^2$.
What I presume that what streg
does is the following: Suppose that $\vec x(t)$ is the time-varying covariates which is modeled as having jumps as is typical. Then the
assumptions is the the hazards is given by $\lambda (t\mid\vec x(t)) = f(t\mid\vec x(t))S(t \mid \vec x(t))^{-1}$. Is this correct? If not, how does streg
handle the time-varying covariates?
Given EdM's answer, the model is in counting process setup like I state above. Thus, suppose that we look at left-truncation time $t_i$ with covariate $\vec x_i$. Let
$$ D(t, \vec x) = \Phi\left( \frac{\log t - \vec x^\top\vec\beta}{\sigma} \right) $$
Then the density, CDF, and survival function are:
$$ \begin{align*} f(t\mid\vec x_i, t_i) &= \begin{cases} \frac{f(t\mid \vec x_i)}{S(t_i \mid \vec x_i)} & t \geq t_i \\ 0 & t < t_i \end{cases} \\ F(t \mid \vec x_i, t_i) &= \begin{cases} \frac{D(t, \vec x_i) - D(t_i, \vec x_i)}{S(t_i \mid \vec x_i)} & t \geq t_i \\ 0 & t < t_i \end{cases} \\ &= \begin{cases} \frac{D(t, \vec x_i) - D(t_i, \vec x_i)}{1 - D(t_i, \vec x_i)} & t \geq t_i \\ 0 & t < t_i \end{cases} \\ S(t\mid\vec x_i, t_i) &= 1 - F(t \mid \vec x_i, t_i) = \begin{cases} \frac{1 - D(t, \vec x_i)}{1 - D(t_i, \vec x_i)} & t \geq t_i \\ 1 & t < t_i \end{cases} \\ &= \begin{cases} \frac{S(t, \vec x_i)}{S(t_i, \vec x_i)} & t \geq t_i \\ 1 & t < t_i \end{cases} \end{align*} $$
Thus, the hazard is
$$ \lambda(t\mid \vec x_i, t_i) = \frac{f(t\mid\vec x_i, t_i)}{S(t\mid\vec x_i, t_i)} = \frac{f(t\mid\vec x_i)}{S(t\mid\vec x_i)} = \lambda(t \mid \vec x_i) $$
as I stated in my question.
The distribution of the survival time is not that obvious I guess but I figure that it is best expressed in terms of the hazards. In particular, suppose that covariates are given by:
$$ \vec x(t) = \begin{cases} \vec x_1 & t < t_1 \\ \vec x_2 & t_1 \leq t < t_2 \\ \vdots & \vdots \\ \vec x_k & t_{k - 1} \leq t < t_k \end{cases} $$
for some $k \geq 1$. Then the hazard is
$$ \lambda(t \mid \vec x(t)) = \begin{cases} \lambda(t\mid \vec x_1) & t < t_1 \\ \lambda(t\mid \vec x_2) & t_1 \leq t < t_2 \\ \vdots & \vdots \\ \lambda(t\mid \vec x_k) & t_{k - 1} \leq t < t_k \end{cases} $$