## The function is currently defined as
setMethod("plot", signature(x="stpm2", y="missing"),
function(x,y,newdata,type="surv",
xlab="Time",line.col=1,ci.col="grey",
add=FALSE,ci=TRUE,rug=TRUE,
var=NULL,...) {
y <- predict(x,newdata,type=type,var=var,grid=TRUE,se.fit=TRUE)
ylab <- switch(type,hr="Hazard ratio",hazard="Hazard",surv="Survival",
sdiff="Survival difference",hdiff="Hazard difference")
xx <- attr(y,"newdata")
xx <- xx[,ncol(xx)]
if (!add) matplot(xx, y, type="n", xlab=xlab, ylab=ylab, ...)
if (ci) polygon(c(xx,rev(xx)), c(y[,2],rev(y[,3])), col=ci.col, border=NA)
lines(xx,y[,1],col=line.col)
if (rug) {
Y <- x@y
eventTimes <- Y[Y[,ncol(Y)]==1,ncol(Y)-1]
rug(eventTimes)
}
})
Run the code above in your browser using DataLab