[R] Assessing calibration of Cox model with time-dependent coefficients

Bert Gunter bgunter.4567 at gmail.com
Wed Jan 17 19:21:34 CET 2018


1. Please repost in **plain text** as html can get mangled, as here (see
below), on this plain text list.

2. Generally, statistical issues are off topic here. stats.stackexchange.com
is one place to post such questions. Having said that, the intersection of
statistics and (on topic) R coding is often nonempty, so you may wish to
wait to see whether someone here satisfactorily answers your query before
posting on Cross Validated.

Cheers,
Bert



Bert Gunter

"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )

On Wed, Jan 17, 2018 at 8:24 AM, Max Shell <archerrish at gmail.com> wrote:

> I am trying to find methods for testing and visualizing calibration to Cox
> models with time-depended coefficients. I have read this nice article
> <http://journals.sagepub.com/doi/10.1177/0962280213497434>. In this paper,
> we can fit three models:
>
> fit0 <- coxph(Surv(futime, status) ~ x1 + x2 + x3, data = data0) p <-
> log(predict(fit0, newdata = data1, type = "expected")) lp <- predict(fit0,
> newdata = data1, type = "lp") logbase <- p - lp fit1 <- glm(y ~ offset(p),
> family = poisson, data = data1) fit2 <- glm(y ~ lp + offset(logbase),
> family = poisson, data = data1) group <- cut(lp, c(-Inf, quantile(lp, (1:9)
> / 10), Inf)) fit3 <- glm(y ~ -1 + group + offset(p), family = poisson, data
> = data1)
>
> Here,I simplely use data1 <- data0[1:500,]
> First, I get following error when running line 5.
>
> Error in eval(predvars, data, env) : object 'y' not found
>
> So I modifited the code by replacing the y as status looks like this:
>
> fit1 <- glm(status ~ offset(p), family = poisson, data = data1) fit2 <-
> glm(status ~ lp + offset(logbase), family = poisson, data = data1) group <-
> cut(lp, c(-Inf, quantile(lp, (1:9) / 10), Inf)) fit3 <- glm(status ~ -1 +
> group + offset(p), family = poisson, data = data1)
>
> *Is this replacing correct?*
> Second, I try to introduce the time-transform use coxph with ttparament.
>
> My code is:  fit0 <- coxph(Surv(time, status) ~ x1 + x2 + x3 + tt(x3), data
> = data0, function(x, t, ...) x * t) p <- log(predict(fit0, newdata = data1,
> type = "expected")) lp <- predict(fit0, newdata = data1, type = "lp")
> logbase <- p - lp fit1 <- glm(status ~ offset(p), family = poisson, data =
> data1) fit2 <- glm(status ~ lp + offset(logbase), family = poisson, data =
> data1) group <- cut(lp, c(-Inf, quantile(lp, (1:9) / 10), Inf)) fit3 <-
> glm(status ~ -1 + group + offset(p), family = poisson, data = data1)
> My questions is:
>
>    - Is the code above correct?
>    - How to interpret the fit1, fit2, fit3? What's the connection between
>    the three models and the calibration of the Cox model?
>    - How to generate the calibration plot using fit3? The article dose have
>    a section discuss this, but no code is provided.
>
> Thank you!
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/
> posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

	[[alternative HTML version deleted]]



More information about the R-help mailing list