Learn R Programming

pcoxtime (version 1.0.4)

predictRisk.pcoxtime: Extract predictions from pcoxtime model

Description

Extract event probabilities from the fitted model.

Usage

# S3 method for pcoxtime
predictRisk(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).

Details

For survival outcome, the function predicts the risk, \(1 - S(t|x)\), where \(S(t|x)\) is the survival chance of an individual characterized by \(x\).

Examples

Run this code
# NOT RUN {
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
)
r1 <- predictRisk(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
)
r2 <- predictRisk(pfit2, newdata = veteran[1:80,], times = 10)
plot(r1, r2, xlim=c(0,1), ylim=c(0,1)
	, xlab = "Penalized predicted survival chance at 10"
	, ylab="Unpenalized predicted survival chance at 10"
)

# }

Run the code above in your browser using DataLab