Description Usage Arguments Value Examples
View source: R/survival_kernel_knn.R
Kernel Weighted Kaplan-Meier model for survival
1 2 3 4 5 6 7 8 9 10 11 | kkm(x, ...)
## S3 method for class 'formula'
kkm(formula, data, xtest = NULL, ytest = NULL, ...)
## Default S3 method:
kkm(x, y, xtest = NULL, ytest = NULL,
return.train.prediction = FALSE || is.null(xtest), scaled = TRUE,
k = min(30, nrow(x)), times = y[as.logical(y[, 2]), 1],
type = c("kaplan-meier", "nelson-aalen"), kernel = "rbfdot",
kpar = "automatic")
|
x |
Design matrix (NO intercept) |
... |
Further argument passed to internal functions |
formula |
Model formula |
data |
Data frame |
xtest |
If the 'formula-data' format used, 'xtest' is a data frame of the test set. If the 'x-y' method called, 'xtest' is the design matrix of the test set |
ytest |
(optional) Survival outcome for testset |
y |
Reponse vector of 'Surv' object |
scaled |
Logical value indicating if to standardize x, y |
k |
Number of nearest neighbour used. Default to 'nrow(x)' which seems the best |
times |
Times to evaluate survival probabilities. Currently no used. All unique event times in training are used |
type |
Type of estimator, either 'Kaplan-meier' or 'nelson-aalen' |
kernel |
String or 'kernel' object (see kernlab::gausspr) |
kpar |
A list of Kernel parameters or 'automatic' if a radial kernel specified |
A 'kkm' object
1 2 3 4 5 6 7 8 9 | library(survival);
data(pbc, package = 'randomForestSRC');
pbc <- na.omit(pbc);
i.tr <- sample(nrow(pbc), 100);
kkm.pred <- kkm(Surv(days, status) ~., data = pbc[i.tr, ], xtest = pbc[-i.tr, ], kernel = 'laplacedot', kpar = list(sigma = 0.1));
# concordance index if using 30th event time
survConcordance(Surv(days, status) ~ I(1 - kkm.pred$test.predicted.survival[, 30]), data = pbc[-i.tr, ])$concordance
plot(kkm.pred, subset = sample(length(i.tr), 10), lwd = 2)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.