Closed ya0 closed 1 year ago
Will take a look, though please note that flexsurv
uses the AFT parameterisation of the Weibull distribution which is:
$$ f(x) = \left(\frac{a}{b}\right) \left( \frac{x}{b} \right)^{a-1} exp\left( { -\left( \frac{x}{b} \right)^a}\right) $$
Here we have implemented the PH parameterisation of the Weibull distribution which is:
$$ f(x) = \lambda\gamma x^{\lambda-1} e^{-\lambda x^\gamma} $$
They can be converted between each other as follows:
Parameter | AFT | PH |
---|---|---|
Shape | $a = \gamma$ | $\gamma = a$ |
Scale | $b = \lambda^{-1/\gamma}$ | $\lambda = b^{-a}$ |
(Should note that I don't think the different parameterisations actually have names, I just call them AFT and PH because the former naturally lends itself to the AFT model whilst the latter lends itself to the PH model).
Heya,
Just to say after making a few small tweaks to the code I got the following:
For comparison to flexsurv
# Flexsurv parameters
a = 1.69
b = 9.64
# JMpost parameters
a = gamma = 1.75
b = lambda ^(-1/gamma) = 9.245398
Which seems good enough to me :)
For reference the changes I made were:
Replaced the single 0 covariate with just the intercept term (this is now supported as of #190 ). I think this is most likely the biggest change, by including a 0 covariate you are still forcing the model to estimate a corresponding parameter/scaling coeficient for it and STAN can result in some strange values being sampled when you have an unused parameter. I am 90% sure this is the main reason you were seeing differences
Changed the prior for lambda from prior_lognormal(2,1,init=8)
to prior_lognormal(log(1/200), 1)
your prior was setting a mean of 12.182
which seems very high considering the real value under the PH parameterisation is 0.02.
Removed priors for Beta, this just doesn't do anything now with the intercept only formulation
Thank you a lot. This looks nice. I was unsure how to handle the covariate. This change will surely help, Ill try it out tomorrow. When you say just the intercept that is the formula Surv(..., ...) ~ 1
right?
I am aware of the different formulations of the scale parameter. That is why i focued on comparing the scale paramter. But i forgot to change the prior from my formulation which uses the different i.e. the flexsurv formulation.
Yup intercept only is Surv(...) ~ 1
Let me know if you run into any other issues or need any other help
@ya0 - Let me know if we can close this or not 😄
This worked for the bc
data for me as well! not sure why the zero covariates interfered with the sampling process.
When trying to implement joint models i had some troubles with the survival part. Spesifically the weibull survival model.
I tryed implementing a survival only model and still have some troubles with the parameter estimation.
Here is a minimal reproducible code
I get
comparing to the regression of the package
flexsurv
the parameters seem to a bit off. note the shape parameter is inverted.gives
and
gives
The shape parameter is 1.69 vs 1.37 is off too much. Have i misspecifed something in the jmpost survival model?
graphical comparison: