2
$\begingroup$

I would really appreciate if someone can help me figure this out as I have been working on it for few days now and I don't know what I'm missing that it's not working. Basically, my goal is to sample survival times from a weibull distribution when I have a time-varying covariate in my model. My problem is when I fit a Cox PH model to my simulated data, I can't get the coefficients I used to simulate my data.

Here is how I simulate data. Perhaps there is something fundamental missing from my reasoning as I had checked the code over and over again and there is no error with the code:

Suppose $t \sim Weibull(\tau, \lambda_i)$ where $\lambda_i = \beta_0 + \beta_1 X_i(t)$

$X_i(t)$ is my time varying covariate and is basically of the form:

$$X_i(t) = \alpha^{(0)}_i + \alpha^{(1)}_i t + \alpha^{(2)}_i t^2$$

$\alpha$ coefficients above are indexed by i as every subject has it's own trajectory for X(t)

As I said, $t \sim Weibull(\tau, \lambda)$. I use the parameterization below for weibull:

$$f(t|\tau, \lambda_i) = \tau t^{\tau - 1} exp(\lambda_i - exp(\lambda_i) t^\tau)$$

From this, I can easily get survival function as: $$S(t|\tau, \lambda_i) = 1-F(t | \tau, \lambda_i) = exp(-exp(\lambda_i) t^{\tau})$$

where: $X_i(t) = \alpha^{(0)}_i + \alpha^{(1)}_i t + \alpha^{(2)}_i t^2$

Ok, here is what I do. For every subject:

1) I randomly sample $u \sim uniform(0,1)$

2) I then set $u = S(t|\tau, \lambda_i)$ where: $$S(t|\tau, \lambda_i) = exp(-exp(\beta_0 + \beta_1 X_i(t)) t^{\tau})$$ where $$X_i(t) = \alpha^{(0)}_i + \alpha^{(1)}_i t + \alpha^{(2)}_i t^2$$

3) I then simply find the root (t) in $u = S(t|\tau, \lambda_i)$ and call it my survival time.

Am I missing something? does this make sense? If so, how come when I fit my CoxPH model, I cannot get back my true $\beta_1$ where I used to simulate data?

$\endgroup$
1
$\begingroup$

Ok, after thinking for a few days, I think I now have the answer. The process above is wrong and the reason and here is the reason:

Consider the survival function as: $$S(t | \tau, \lambda_i) = exp(-exp(\beta_0 + \beta_1 X_i(t)) t^\tau)$$

I consider $\lambda = \beta_0 + \beta_1 X_i(t)$ where $\lambda$ is the scale parameter in my representation of Weibull distribution (not be confused with hazard!). So:

$$S(t | \tau, \lambda_i) = exp(-exp(\lambda_i) t^\tau)$$

Of course, it's obvious that $\lambda_i$ is a function of time. Let's look at the derivative of S(t|...) with respect to t in order to see how S(t|...) changes over time: $$\frac{dS(t | \tau, \lambda_i)}{dt} = S(t|\tau, \lambda_i) \times (- \tau t^{\tau - 1} exp(\lambda_i) - \frac{d\lambda_i}{dt} exp(\lambda_i)t^{\tau}) $$

the issue is $\frac{d\lambda_i}{dt}$ is non-zero as $\lambda_i$ is a function of time!

| cite | improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.