Title: | Kernel Estimation of Hazard Function in Survival Analysis |
---|---|
Description: | Producing kernel estimates of the unconditional and conditional hazard function for right-censored data including methods of bandwidth selection. |
Authors: | Iveta Selingerova [aut, cre], Marie Langrova [ctb] |
Maintainer: | Iveta Selingerova <[email protected]> |
License: | GPL (>= 2) |
Version: | 0.1.0 |
Built: | 2024-11-27 06:43:10 UTC |
Source: | CRAN |
Kernel estimate of (unconditional) hazard function for right-censored data. Options include two methods for bandwidth selection.
khazard(times, delta, h = NULL, t = NULL, t.length = 100, tmin = NULL, tmax = NULL, kernel = "epanechnikov", type = "interior", parallel = FALSE, value = "CVML", h.method = "crossval", optim.method = "optimize", tol = ifelse(h.method == "crossval", 10^(-6), 1), run = 2, ...)
khazard(times, delta, h = NULL, t = NULL, t.length = 100, tmin = NULL, tmax = NULL, kernel = "epanechnikov", type = "interior", parallel = FALSE, value = "CVML", h.method = "crossval", optim.method = "optimize", tol = ifelse(h.method == "crossval", 10^(-6), 1), run = 2, ...)
times |
vector of observed times |
delta |
vector of censoring indicator. 0 - censored, 1 - uncensored (dead) |
h |
bandwidth (scalar or vector). If missing, h is found using some bandwidth selection method. |
t |
vector of time points at which estimate is evaluated |
t.length |
number of grid points |
tmin , tmax
|
minimum/maximum values for grid |
kernel |
kernel function, possible values are: "epanechnikov" (default), "gaussian", "rectangular", "quartic". |
type |
Type of kernel estimate. Possible types are: "exterior", "interior" (default). |
parallel |
allows parallel computation. Default is FALSE. |
value |
If h parameter is vector, this option controls output values. If "CVML" (default), the crossvalidation or log-likelihood values only are calculated. If "hazard", the hazard functions only are calculated. If "both" the crossvalidation or log-likelihood values and hazard function are calculated. |
h.method |
method for bandwidth selection. Possible methods are: "crossval" (default), "maxlike". |
optim.method |
method for numerical optimization of the crossvalidation or log-likelihood function. Possible methods are: "optimize" (default), "ga". |
tol |
the desired accuracy of optimization algorithm |
run |
the number of consecutive generations without any improvement in the best fitness value before the GA is stopped. |
... |
additional arguments of GA algorithm |
External type of kernel estimator is defined as the ratio of kernel estimator of the subdensity of the uncensored observations to the survival function of the observable time. Internal type of kernel estimator is based on a convolution of the kernel function with a nonparametric estimator of the cumulative hazard function (Nelson-Aalen estimator).
Returns an object of class 'khazard' which is a list with fields
time.points |
vector of time points at which estimate is evaluated |
hazard |
data frame of time points, hazard function values and bandwidth |
h |
bandwidth |
CVML |
value of crossvalidation or log-likelihood at h |
details |
description of used methods |
GA.result |
output of ga, object of class ga-class |
Selingerova, I., Dolezelova, H., Horova, I., Katina, S., and Zelinka, J. (2016). Survival of Patients with Primary Brain Tumors: Comparison of Two Statistical Approaches. PloS one, 11(2), e0148733.
library(survival) fit<-khazard(times = lung$time,delta = lung$status-1)
library(survival) fit<-khazard(times = lung$time,delta = lung$status-1)
Kernel estimate of conditional hazard function for right-censored data with one covariate. Options include two methods for bandwidth selection.
khazardcond(times, delta, covariate, h = NULL, t = NULL, x = NULL, tx = NULL, t.length = 100, x.length = 100, tmin = NULL, tmax = NULL, xmin = NULL, xmax = NULL, kernel = "epanechnikov", type = "interior", type.w = "nw", parallel = FALSE, h.method = "crossval", optim.method = "ga", tol = ifelse(h.method == "crossval", 10^(-6), 1), run = 2, ...)
khazardcond(times, delta, covariate, h = NULL, t = NULL, x = NULL, tx = NULL, t.length = 100, x.length = 100, tmin = NULL, tmax = NULL, xmin = NULL, xmax = NULL, kernel = "epanechnikov", type = "interior", type.w = "nw", parallel = FALSE, h.method = "crossval", optim.method = "ga", tol = ifelse(h.method == "crossval", 10^(-6), 1), run = 2, ...)
times |
vector of observed times |
delta |
vector of censoring indicator. 0 - censored, 1 - uncensored (dead) |
covariate |
vector of covariate |
h |
bandwidth vector of length 2, first element is bandwidth for time and second for covariate. If missing, h is found using some bandwidth selection method. |
t |
vector of time points at which estimate is evaluated |
x |
vector of covariate points at which estimate is evaluated |
tx |
data frame of t and x at which estimate is evaluated |
t.length |
number of grid points of time |
x.length |
number of grid points of covariate |
tmin , tmax
|
minimum/maximum values for grid of time |
xmin , xmax
|
minimum/maximum values for grid of covariate |
kernel |
kernel function, possible values are: "epanechnikov" (default), "gaussian", "rectangular", "quartic". |
type |
Type of kernel estimate. Possible types are: "exterior", "interior" (default). |
type.w |
Type of weights. Default are Nadaraya-Watson weights. |
parallel |
allows parallel computation. Default is FALSE. |
h.method |
method for bandwidth selection. Possible methods are: "crossval" (default), "maxlike". |
optim.method |
method for numerical optimization of the crossvalidation or log-likelihood function. Possible methods are: "ga"(default). |
tol |
the desired accuracy of optimization algorithm |
run |
the number of consecutive generations without any improvement in the best fitness value before the GA is stopped. |
... |
additional arguments of GA algorithm |
External type of kernel estimator is defined as the ratio of kernel estimator of the conditional subdensity of the uncensored observations to the conditional survival function of the observable time. Internal type of kernel estimator is based on a convolution of the kernel function with a nonparametric estimator of the cumulative conditional hazard function.
Returns an object of class 'khazardcond' which is a list with fields
time.points |
vector of time points at which estimate is evaluated |
covariate.points |
vector of covariate points at which estimate is evaluated |
hazard |
matrix of hazard function values on grid or data.frame of time and covariate points and appropriate hazard values if hx is defined |
h |
bandwidth vector |
CVML |
value of crossvalidation or log-likelihood at h |
details |
description of used methods |
GA.result |
output of ga, object of class ga-class |
Selingerova, I., Dolezelova, H., Horova, I., Katina, S., and Zelinka, J. (2016). Survival of Patients with Primary Brain Tumors: Comparison of Two Statistical Approaches. PloS one, 11(2), e0148733.
library(survival) fit<-khazardcond(times = lung$time,delta = lung$status-1,covariate = lung$age,h=c(200,20))
library(survival) fit<-khazardcond(times = lung$time,delta = lung$status-1,covariate = lung$age,h=c(200,20))
Plot of kernel hazard estimate from an object of class khazard
## S3 method for class 'khazard' plot(x, h = NULL, ylim, type, xlab, ylab, main, ...)
## S3 method for class 'khazard' plot(x, h = NULL, ylim, type, xlab, ylab, main, ...)
x |
Object of class khazard |
h |
bandwidth for which hazard function estimate will be plot if x$h is vector |
ylim |
Limits for the y axis. |
type |
type argument for plot. |
xlab |
Label for the x axis. |
ylab |
Label for the y axis. |
main |
Title of plot. |
... |
Additional arguments. |
library(survival) fit<-khazard(times = lung$time,delta = lung$status-1) plot(fit) fit<-khazard(times = lung$time,delta = lung$status-1,h=c(100,150,200,250), value="both") plot(fit,h=200)
library(survival) fit<-khazard(times = lung$time,delta = lung$status-1) plot(fit) fit<-khazard(times = lung$time,delta = lung$status-1,h=c(100,150,200,250), value="both") plot(fit,h=200)
Plot of kernel conditional hazard estimate from an object of class khazardcond
## S3 method for class 'khazardcond' plot(x, type = "persp", zlim, xlab, ylab, zlab, main, ...)
## S3 method for class 'khazardcond' plot(x, type = "persp", zlim, xlab, ylab, zlab, main, ...)
x |
Object of class khazardcond |
type |
type of plot. Possible types are: "persp" (default), "persp3d", "contour". |
zlim |
Limits for the z axis. |
xlab |
Label for the x axis. |
ylab |
Label for the y axis. |
zlab |
Label for the z axis. |
main |
Title of plot. |
... |
Additional arguments. |
library(survival) fit<-khazardcond(times = lung$time,delta = lung$status-1,covariate = lung$age,h=c(200,20)) plot(fit)
library(survival) fit<-khazardcond(times = lung$time,delta = lung$status-1,covariate = lung$age,h=c(200,20)) plot(fit)