# NOT RUN {
if (require("survival", quietly = TRUE)) {
# examples come from cch documentation
subcoh <- nwtco$in.subcohort
selccoh <- with(nwtco, rel==1|subcoh==1)
ccoh.data <- nwtco[selccoh,]
ccoh.data$subcohort <- subcoh[selccoh]
## central-lab histology
ccoh.data$histol <- factor(ccoh.data$histol,labels=c("FH","UH"))
## tumour stage
ccoh.data$stage <- factor(ccoh.data$stage,labels=c("I","II","III" ,"IV"))
ccoh.data$age <- ccoh.data$age/12 # Age in years
fit.ccP <- cch(Surv(edrel, rel) ~ stage + histol + age, data = ccoh.data,
subcoh = ~subcohort, id= ~seqno, cohort.size = 4028)
tidy(fit.ccP)
# coefficient plot
library(ggplot2)
ggplot(tidy(fit.ccP), aes(x = estimate, y = term)) + geom_point() +
geom_errorbarh(aes(xmin = conf.low, xmax = conf.high), height = 0) +
geom_vline(xintercept = 0)
# compare between methods
library(dplyr)
fits <- data_frame(method = c("Prentice", "SelfPrentice", "LinYing")) %>%
group_by(method) %>%
do(tidy(cch(Surv(edrel, rel) ~ stage + histol + age, data = ccoh.data,
subcoh = ~subcohort, id= ~seqno, cohort.size = 4028,
method = .$method)))
# coefficient plots comparing methods
ggplot(fits, aes(x = estimate, y = term, color = method)) + geom_point() +
geom_errorbarh(aes(xmin = conf.low, xmax = conf.high)) +
geom_vline(xintercept = 0)
}
# }
Run the code above in your browser using DataLab