Closed jintaili closed 4 years ago
Dear jintaili,
The sad truth is that no function in eha can deal with interactions between a stratum variable and covariates. Otherwise, weibreg and friends do work for stratified data, contrary to what you suggest.
Dear Prof Broström,
Thanks for clarifying!
I wanted to introduce a little about my objective. In my data, I observe significant non-proportionality / martingale residuals with respect to many covariates, but overall a very Weibull-like survival function. Therefore I am trying to build a (locally) proportional hazard model with parametric baseline hazard function and time-dependent coefficients.
The reason for choosing a parametric over the Cox model is for ease of prediction. The reasons for choosing time-dependent constant coefficients over other proportionality relaxations is for ease of interpretation.
Currently, I think I have found a work-around within the eha
and survival
framework. Specifically, I have split my data into several episodes, noted by covariate g
, and written the formula in the format of the following:
cutoffs = c(4, 21, 60)
x_train = survSplit(Surv(t_end, event) ~ .,
data, cut = cutoffs,
episode = 'g') %>% data.table()
srv = Surv(tstart, t_end, event)
formula = as.formula('srv ~ I(x1 * (g == 1)) + I(x1 * (g == 2)) + I(x2 * (g == 1)) + I(x2 * (g == 2))')
Then this formula is estimated through the following:
pw = phreg(
formula = formula,
data = x_train,
na.action = getOption("na.action"),
dist = "weibull",
cuts = NULL,
init = rep(0.01, max(x_train$g) * (ncol(x_train) - 5)),
shape = 0,
param = c("canonical", "rate"),
control = list(eps = 1e-04, maxiter = 20, trace = FALSE),
singular.ok = TRUE,
model = FALSE,
x = FALSE,
y = TRUE,
center = TRUE
)
It did seem that I could estimate this model with low numbers of cutoffs
. However, I am not certain if what I am doing is helping me to achieve what I aimed for, nor if this is the state-of-the-art or common practice for that matter. Would appreciate your input on this. In addition, is it possible to predict using phreg
models? Thanks!
Jintai
I guess that your last effort addresses the non-proportionality aspect, but it is not the same as the stratum-covariate interaction in your first message.
Of course you can do predictions, but there are no ready-made prediction function for phreg in eha. You have to write it yourself.
Göran
OK thanks!
Hi! I am trying to estimate a proportional hazard model with time dependent coefficients with Weibull baseline hazard function. I was very happy to find
eha
because of the availability of the functionweibreg()
. However, I have not been able to correctly estimate the model. Specifically, I carried out the following three attempts:This model was not able to finish estimation with the following error message:
I
trace()
d the weibreg function to print outfit
. It seemed like convergence failed:init = rep(0, 4 * (ncol(x_train) - 5))
. This model did not finish either, with warningX matrix deemed to be singular
.I did implement the same calls in
phreg()
, and received error codes 3 and 4 depending on the number of strata I specified. In addition, the documentation did not elaborate on how to specifycontrol
argument. Thanks!