### running these examples with toPdf=FALSE will
### open too many devices to be compatible with R CMD check
### results from these examples can be found in the package source
### under /survMisc/inst/doc/
###
### for log-log plot
if(require(devtools)){
### this package is now archived, so need to install from url
install_url("http://cran.r-project.org/src/contrib/Archive/surv2sample/surv2sample_0.1-2.tar.gz")
library(surv2sample)
data(gastric, package="surv2sample")
dx(coxph(Surv(time/365, event) ~ treatment, data=gastric), file="gasDx.pdf")
}
data(bmt, package="KMsurv")
bmt <- within(bmt, {
z1 <- z1 -28
z2 <- z2- 28
z3 <- z1*z2
z4 <- as.double(group == 2)
z5 <- as.double(group == 3)
z6 <- z8
z7 <- (z7 / 30) - 9
z8 <- z10
})
c1 <- coxph(Surv(t2, d3) ~ z1 + z2 + z3 + z4 + z5 + z6 + z7 + z8,
method="breslow", data=bmt)
dx(c1, file="bmtDx.pdf")
###
data(alloauto, package="KMsurv")
c1 <- coxph(Surv(time,delta) ~ factor(type),
method="breslow", data=alloauto)
dx(c1, file="alloDx.pdf")
### GAM model. Therneau 5.3
data(pbc, package="survival")
w1 <- which(is.na(pbc$protime))
pbc <- pbc[-w1, ]
c1 <- coxph(Surv(time, status==2) ~ age + edema + bili + protime + albumin,
data=pbc, method="breslow")
dx(c1, file="pbcDx.pdf")
### Time dependent covariate. Therneau 6.3
data(veteran, package="survival")
veteran$celltype <- relevel(veteran$celltype, ref="adeno")
c1 <- coxph(Surv(time, status) ~ trt * celltype + karno + diagtime + log(age) + prior,
data=veteran[-1, ])
dx(c1, what="ph", file="vetDx.pdf")
### simple example which doesn't take up too many devices
c1 <- coxph(formula = Surv(time, status == 2) ~ age + log(bili), data=pbc)
dx(c1)
Run the code above in your browser using DataLab