Predict method for Akritas Estimator
Predicted values from a fitted Akritas estimator.
## S3 method for class 'akritas' predict( object, newdata, times = NULL, lambda = 0.5, type = c("survival", "risk", "all"), distr6 = FALSE, ... )
object |
( |
newdata |
|
times |
|
lambda |
( |
type |
( |
distr6 |
( |
... |
|
This implementation uses a fit/predict interface to allow estimation on unseen data after fitting on training data. This is achieved by fitting the empirical CDF on the training data and applying this to the new data.
A numeric
if type = "risk"
, a distr6::VectorDistribution()
(if distr6 = TRUE
)
and type = "survival"
; a matrix
if (distr6 = FALSE
) and type = "survival"
where
entries are survival probabilities with rows of observations and columns are time-points;
or a list combining above if type = "all"
.
Akritas, M. G. (1994). Nearest Neighbor Estimation of a Bivariate Distribution Under Random Censoring. Ann. Statist., 22(3), 1299–1327. doi: 10.1214/aos/1176325630
if (requireNamespaces(c("distr6", "survival"))) { library(survival) train <- 1:10 test <- 11:20 fit <- akritas(Surv(time, status) ~ ., data = rats[train, ]) predict(fit, newdata = rats[test, ]) # when lambda = 1, identical to Kaplan-Meier fit <- akritas(Surv(time, status) ~ ., data = rats[1:100, ]) predict_akritas <- predict(fit, newdata = rats[1:100, ], lambda = 1)[1, ] predict_km <- survfit(Surv(time, status) ~ 1, data = rats[1:100, ])$surv all(predict_akritas == predict_km) # Use distr6 = TRUE to return a distribution predict_distr <- predict(fit, newdata = rats[test, ], distr6 = TRUE) predict_distr$survival(100) # Return a relative risk ranking with type = "risk" predict(fit, newdata = rats[test, ], type = "risk") # Or survival probabilities and a rank predict(fit, newdata = rats[test, ], type = "all", distr6 = TRUE) }
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.