predict.akritas: Predict method for Akritas Estimator

Description Usage Arguments Details Value References Examples

View source: R/akritas.R

Description

Predicted values from a fitted Akritas estimator.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
## S3 method for class 'akritas'
predict(
  object,
  newdata,
  times = NULL,
  lambda = 0.5,
  type = c("survival", "risk", "all"),
  distr6 = FALSE,
  ...
)

Arguments

object

(akritas(1))
Object of class inheriting from "akritas".

newdata

(data.frame(1))
Testing data of data.frame like object, internally is coerced with stats::model.matrix(). If missing then training data from fitted object is used.

times

(numeric())
Times at which to evaluate the estimator. If NULL (default) then evaluated at all unique times in the training set.

lambda

(numeric(1))
Bandwidth parameter for uniform smoothing kernel in nearest neighbours estimation. The default value of 0.5 is arbitrary and should be chosen by the user. If lambda = 1 then internally survival::survfit is called to fit the Kaplan-Meier estimator.

type

(numeric(1))
Type of predicted value. Choices are survival probabilities over all time-points in training data ("survival") or a relative risk ranking ("risk"), which is the mean cumulative hazard function over all time-points, or both ("all").

distr6

(logical(1))
If FALSE (default) and type is "survival" or "all" returns data.frame of survival probabilities, otherwise returns a distr6::VectorDistribution().

...

ANY
Currently ignored.

Details

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.

Value

A numeric if type = "risk", a distr6::VectorDistribution() (if distr6 = TRUE) and type = "survival"; a data.frame 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".

References

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

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
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)

mlr3learners/mlr3learners.proba documentation built on Aug. 9, 2020, 12:50 a.m.