survQDiff is an R package that implements graphical procedures for evaluating overall and subject-specific incremental values from new predictors with censored event time data, as described in:
Uno H, Cai T, Tian L, Wei LJ. Graphical procedures for evaluating overall and subject-specific incremental values from new predictors with censored event time data. Biometrics. 2011 Dec;67(4):1389–96. doi:10.1111/j.1541-0420.2011.01568.x
The package provides:
- Local linear quantile regression (
loc.qreg,loc.qreg.opt) with automatic bandwidth selection via k-fold cross-validation - Inverse probability of censoring weighting (
WGT.FUN,Ghat.FUN) for handling censored survival data - Cox model risk estimation (
Est.HR.FUN) for extracting predicted event probabilities and linear predictors - Plotting utilities (
shade) for visualizing conditional quantile bands
Install directly from GitHub using devtools:
# install.packages("devtools")
devtools::install_github("uno1lab/survQDiff")Or using pak:
# install.packages("pak")
pak::pkg_install("uno1lab/survQDiff")library(survQDiff)
library(survival)
# Prepare data (PBC dataset from the survival package)
D <- subset(pbc, select = c("time", "status", "age", "albumin",
"edema", "protime", "bili"))
D <- D[!is.na(rowMeans(D)), ]
D$status <- as.numeric(D$status == 2)
t0 <- 365 * 5 # 5-year prediction horizon
# Fit Cox models (with and without a new biomarker)
ft1 <- Est.HR.FUN(as.matrix(D), t0) # full model
ft0 <- Est.HR.FUN(as.matrix(D[, -7]), t0) # reduced model
# Compute IPCW weights
Wi <- WGT.FUN(D[, c("time", "status")], t0)
# Transform predictions to log-log scale
xx <- log(-log(pmin(ft0$risk, 0.9999)))
yy <- log(-log(pmin(ft1$risk, 0.9999)))
# Fit local median regression for cases (subjects with events)
case <- cbind(xx, yy, Wi)[D$status == 1 & Wi > 0, ]
fit <- loc.qreg.opt(case, tau = 0.5, bw.ini = var(xx),
mykern = "gauss", kfold = 5)
# Plot
plot(exp(-exp(fit$ft)), type = "l", xlab = "P1", ylab = "Median D")See vignette("qsmooth-pbc-example", package = "survQDiff") for a full worked example reproducing the figures from the paper.
citation("survQDiff")Uno H, Cai T, Tian L, Wei LJ (2011). Graphical procedures for evaluating
overall and subject-specific incremental values from new predictors with
censored event time data. Biometrics, 67(4), 1389-1396.
doi:10.1111/j.1541-0420.2011.01568.x
GPL-3. See LICENSE for details.