#require(survival)
#require(Iso)
###
# 1. Time-independent covariate with monotone increasing effect
###
# 1.1. Create a test data set 1
test1=list(
time= c(2, 5, 1, 7, 9, 5, 3, 6, 8, 9, 7),
status=c(1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1),
z= c(2, 1, 1, 3, 5, 6, 7, 9, 3, 0, 2)
)
# 1.2. Fit isotonic proportional hazards model
res1 = isoph(Surv(time, status)~z, data=test1, shape="increasing")
# 1.3. Print result
res1
# 1.4 Figure
plot(res1, which=1) #which=1 for psi (default)
plot(res1, which=2) #which=2 for psiexp(psi.hat)
###
# 2. Test 2: Time-dependent covariate with monotone decreasing effect
###
# 2.1. Create a test data set 2
test2=list(
start= c(0, 0, 2, 0, 0, 0, 1, 2, 0, 0, 0, 2),
stop= c(5, 2, 6, 3, 8, 1, 2, 5, 7, 2 ,2, 8),
status=c(1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1),
z= c(1, 2, 1, 3, 5, 3, 1, 3, 2, 8, 5, 7)
)
# 2.2. Fit isotonic proportional hazards model
res2 = isoph(Surv(start,stop,status)~z, data=test2, shape="decreasing")
# 2.3. Print result
res2
# 2.4. Figure
plot(res2, which=1) #which=1 for psi (default)
plot(res2, which=2) #which=2 for psiexp(psi.hat)
###
#3. More arguments for plot.isoph
###
#3.1. removes labels
plot(res2, main=NA, ylab=NA, xlab=NA, lglab=NA)
#3.2. renames labels
plot(res2, main="Iso PH", ylab="Iso", xlab="Cov", lglab="Cov wt obs", lgloc="center", lgcex=1.5)
#3.3. adjust xlim and ylim, with change in line and point
plot(res2, xlim=c(2,4), ylim=c(-2,0), lty=2, lcol=2, lwd=2, pch=3, pcol=4, pcex=1.5)Run the code above in your browser using DataLab