predictSurvProb.pcoxtime: Predict survival probabilities at various time points

View source: R/posthocfuns.R

predictSurvProb.pcoxtimeR Documentation

Predict survival probabilities at various time points

Description

The function extracts the survival probability predictions from a pcoxtime model.

Usage

## S3 method for class 'pcoxtime'
predictSurvProb(object, newdata, times, ...)

Arguments

object

fitted pcoxtime.

newdata

a data frame containing the variables appearing on the right hand side of pcoxtime formula.

times

a vector of times in the range of the response, at which to return the survival probabilities.

...

for future implementations.

Value

a matrix of probabilities with as many rows as the rows of the newdata and as many columns as number of time points (times).

Examples


if (packageVersion("survival")>="3.2.9") {
   data(cancer, package="survival")
} else {
   data(veteran, package="survival")
}
# Penalized
lam <- 0.1
alp <- 0.5
pfit1 <- pcoxtime(Surv(time, status) ~ factor(trt) + karno + diagtime + age + prior
	, data = veteran
	, lambda = lam
	, alpha = alp
)
p1 <- predictSurvProb(pfit1, newdata = veteran[1:80,], times = 10)

# Unpenalized
lam <- 0
alp <- 1
pfit2 <- pcoxtime(Surv(time, status) ~ factor(trt) + karno + diagtime + age + prior
	, data = veteran
	, lambda = lam
	, alpha = alp
)
p2 <- predictSurvProb(pfit2, newdata = veteran[1:80,], times = 10)
plot(p1, p2, xlim=c(0,1), ylim=c(0,1)
	, xlab = "Penalized predicted survival chance at 10"
	, ylab="Unpenalized predicted survival chance at 10"
)


pcoxtime documentation built on May 13, 2022, 1:05 a.m.