# Need help understand likelihood in survival analysis

I really appreciate it if you could help me understand the likelihood in a survival model with a time varying covariate. To be more clear, let's first start with a survival analysis with fixed covariates. In this case:

$$L_i = \lambda_i^{\delta_i}(t) * S_i(t)$$

where, $L_i$ is the likelihood contribution of the $i^{th}$ subject, $\lambda_i$ is the hazard function, $S_i$ is the survival function, and $\delta_i$ is the event indicator (1: if event observed, 0: if subject got censored). We know:

$$\lambda(t) = \frac{f(t)}{S(t)}$$

So I guess, I can re-write $L_i$ as:

$$L_i = \lambda_i^{\delta_i}(t) * S_i(t) = (\frac{f_i(t)}{S_i(t)})^{\delta_i} * S_i(t) = {f_i(t)}^{\delta_i} {S_i(t)}^{1 - \delta_i}$$

So based on the formula above:

1. if event observed (i.e. $\delta_i = 1$) ---> $L_i = f_i(t)$

2. if subject got censored (i.e. $\delta_i = 0$) ---> $L_i = S_i(t)$

Now what if our survival analysis included time varying covariate? Are formula above still valid?

They are, you just need to specify $\lambda$ and $S$ correctly.
Assuming proportional hazards, in a Cox-type model you would have $$\lambda_i(t) = \lambda_0(t) \exp(\beta x_i(t))$$ and corresponding survival $$S_i(t) = \exp\left(-\int_0^t \lambda_i(s) ds \right).$$ and then the density is $$f_i(t) = \lambda_i(t) S_i(t)$$ as before.
In general, the likelihood contribution of an exactly observed time is $P(T = t)/dt = f(t)$ (density) and of a right-censored observation is $P(T \geq t) = S(t)$ ("survival").