sf {survMisc}R Documentation

survival (or hazard) function based on e and n.

Description

survival (or hazard) function based on e and n.

Usage

sf(x, ...)

## Default S3 method:
sf(x, ..., what = c("S", "H"), SCV = FALSE, times = NULL)

## S3 method for class 'ten'
sf(x, ..., what = c("S", "H"), SCV = FALSE, times = NULL, reCalc = FALSE)

## S3 method for class 'stratTen'
sf(x, ..., what = c("S", "H"), SCV = FALSE, times = NULL, reCalc = FALSE)

## S3 method for class 'numeric'
sf(
  x,
  ...,
  n = NULL,
  what = c("all", "S", "Sv", "H", "Hv"),
  SCV = FALSE,
  times = NULL
)

Arguments

x

One of the following:

default

A numeric vector of events status (assumed sorted by time).

numeric

Vectors of events and numbers at risk (assumed sorted by time).

ten

A ten object.

stratTen

A stratTen object.

...

Additional arguments (not implemented).

what

See return, below.

SCV

Include the Squared Coefficient of Variation, which is calcluated using the mean \bar{x} and the variance \sigma_x^2:

SCV_x = \frac{\sigma_x^2}{\bar{x}^2}

This measure of dispersion is also referred to as the 'standardized variance' or the 'noise'.

times

Times for which to calculate the function.
If times=NULL (the default), times are used for which at least one event occurred in at least one covariate group.

reCalc

Recalcuate the values?
If reCalc=FALSE (the default) and the ten object already has the calculated values stored as an attribute, the value of the attribute is returned directly.

n

Number at risk.

Value

A data.table which is stored as an attribute of the ten object.
If what="s", the survival is returned, based on the Kaplan-Meier or product-limit estimator. This is 1 at t=0 and thereafter is given by:

\hat{S}(t) = \prod_{t \leq t_i} (1-\frac{e_i}{n_i} )

If what="sv", the survival variance is returned.
Greenwoods estimtor of the variance of the Kaplan-Meier (product-limit) estimator is:

Var[\hat{S}(t)] = [\hat{S}(t)]^2 \sum_{t_i \leq t} \frac{e_i}{n_i (n_i - e_i)}

If what="h", the hazard is returned, based on the the Nelson-Aalen estimator. This has a value of \hat{H}=0 at t=0 and thereafter is given by:

\hat{H}(t) = \sum_{t \leq t_i} \frac{e_i}{n_i}

If what="hv", the hazard variance is returned.
The variance of the Nelson-Aalen estimator is given by:

Var[\hat{H}(t)] = \sum_{t_i \leq t} \frac{e_i}{n_i^2}

If what="all" (the default), all of the above are returned in a data.table, along with:
Survival, based on the Nelson-Aalen hazard estimator H, which is:

\hat{S_{na}}=e^{H}

Hazard, based on the Kaplan-Meier survival estimator S, which is:

\hat{H_{km}} = -\log{S}

Examples

data("kidney", package="KMsurv")
k1 <- ten(Surv(time=time, event=delta) ~ type, data=kidney)
sf(k1)
sf(k1, times=1:10, reCalc=TRUE)
k2 <- ten(with(kidney, Surv(time=time, event=delta)))
sf(k2)
## K&M. Table 4.1A, pg 93.
## 6MP patients
data("drug6mp", package="KMsurv")
d1 <- with(drug6mp, Surv(time=t2, event=relapse))
(d1 <- ten(d1))
sf(x=d1$e, n=d1$n, what="S")

data("pbc", package="survival")
t1 <- ten(Surv(time, status==2) ~ log(bili) + age + strata(edema), data=pbc)
sf(t1)

## K&M. Table 4.2, pg 94.
data("bmt", package="KMsurv")
b1 <- bmt[bmt$group==1, ] # ALL patients
t2 <- ten(Surv(time=b1$t2, event=b1$d3))
with(t2, sf(x=e, n=n, what="Hv"))
## K&M. Table 4.3, pg 97.
sf(x=t2$e, n=t2$n, what="all")


[Package survMisc version 0.5.6 Index]