Forum: help


RE: survival functions in fit function [ Reply ] By: Srini Rajagopalan on 2019-11-27 21:05 | [forum:47214] |
Thank you so much. I really appreciate the help. I was getting a little desperate. |
RE: survival functions in fit function [ Reply ] By: Srini Rajagopalan on 2019-11-26 21:44 | [forum:47213] |
Thank you. I may have more questions on ctree. Let me try it out first. |
RE: survival functions in fit function [ Reply ] By: Torsten Hothorn on 2019-11-27 07:59 | [forum:47201] |
Dear Srini, here is a solution using the trtf package: library("tram") library("trtf") library("survival") data("GBSG2", package = "TH.data") GBSG2$y <- with(GBSG2, Surv(time, cens)) m0 <- Coxph(y ~ horTh, data = GBSG2) m1 <- trafotree(m0, formula = y | horTh ~ pnodes + age + tsize + tgrade + progrec + estrec + menostat, data = GBSG2) ### see page 22 of # vignette("tram", package = "tram") The trick is to explicitly model the log-cumulative baseline hazard function, this makes your life much easier. Best, Torsten |
RE: survival functions in fit function [ Reply ] By: Achim Zeileis on 2019-11-26 21:37 | [forum:47194] |
Yes, the coxph has to be fitted on many subsamples to determine the splits and on a few of them the results are numerically unstable. That's why I mentioned ctree which uses a different split selection algorithm that uses not so much re-fitting. |
RE: survival functions in fit function [ Reply ] By: Srini Rajagopalan on 2019-11-26 20:35 | [forum:47192] |
When I ran the code, it gave 11 warnings. library("partykit") library("survival") coxfit <- function(y, x, start = NULL, weights = NULL, offset = NULL, ...) { if(isTRUE(all.equal(as.numeric(x[,1]), rep.int(1, nrow(x))))) x <- x[, -1, drop = FALSE] coxph(y ~ x, weights = weights, ...) } data("GBSG2", package = "TH.data") GBSG2$time <- GBSG2$time/365 tr <- mob(Surv(time, cens) ~ horTh | pnodes + age + tsize + tgrade + progrec + estrec + menostat, data = GBSG2, fit = coxfit, control = mob_control(alpha = 0.3)) Warning messages: 1: In fitter(X, Y, strats, offset, init, control, weights = weights, ... : Ran out of iterations and did not converge 2: In fitter(X, Y, strats, offset, init, control, weights = weights, ... : Ran out of iterations and did not converge 3: In fitter(X, Y, strats, offset, init, control, weights = weights, ... : Ran out of iterations and did not converge 4: In fitter(X, Y, strats, offset, init, control, weights = weights, ... : Loglik converged before variable 1 ; beta may be infinite. 5: In fitter(X, Y, strats, offset, init, control, weights = weights, ... : Loglik converged before variable 1 ; beta may be infinite. 6: In fitter(X, Y, strats, offset, init, control, weights = weights, ... : Loglik converged before variable 1 ; beta may be infinite. 7: In fitter(X, Y, strats, offset, init, control, weights = weights, ... : Loglik converged before variable 1 ; beta may be infinite. 8: In fitter(X, Y, strats, offset, init, control, weights = weights, ... : Loglik converged before variable 1 ; beta may be infinite. 9: In fitter(X, Y, strats, offset, init, control, weights = weights, ... : Ran out of iterations and did not converge 10: In fitter(X, Y, strats, offset, init, control, weights = weights, ... : Ran out of iterations and did not converge 11: In fitter(X, Y, strats, offset, init, control, weights = weights, ... : Ran out of iterations and did not converge |
RE: survival functions in fit function [ Reply ] By: Srini Rajagopalan on 2019-11-25 17:00 | [forum:47180] |
Thank you so much. I will try it out. |
RE: survival functions in fit function [ Reply ] By: Achim Zeileis on 2019-11-25 08:26 | [forum:47178] |
coxph() can be used as it is associated with an objective function and suitable central limit theorem for the estimated parameters. An example with mob() is included below. See also the "model4you" package that contains an easy-to-use function based on ctree(). library("partykit") library("survival") coxfit <- function(y, x, start = NULL, weights = NULL, offset = NULL, ...) { if(isTRUE(all.equal(as.numeric(x[,1]), rep.int(1, nrow(x))))) x <- x[, -1, drop = FALSE] coxph(y ~ x, weights = weights, ...) } data("GBSG2", package = "TH.data") GBSG2$time <- GBSG2$time/365 tr <- mob(Surv(time, cens) ~ horTh | pnodes + age + tsize + tgrade + progrec + estrec + menostat, data = GBSG2, fit = coxfit, control = mob_control(alpha = 0.3)) |
survival functions in fit function [ Reply ] By: Srini Rajagopalan on 2019-11-25 03:59 | [forum:47175] |
Is it possible to use (survfit(Surv(time,status), data = aml )) or coxph(Surv(time,status) ~ x, data = aml)) in the "fit"function argument in mob? |