[R] Assessing calibration of Cox model with time-dependent coefficients
Max Shell
archerrish at gmail.com
Wed Jan 17 17:24:15 CET 2018
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]]
More information about the R-help
mailing list