sf: *s*urvival (or hazard) *f*unction based on e and n.

Description Usage Arguments Value Examples

View source: R/sf.R

Description

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

Usage

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

A ten object.

A stratTen object.

...

Additional arguments (not implemented).

n

Number at risk.

what

See return, below.

SCV

Include the Squared Coefficient of Variation, which is calcluated using the mean mean(x) and the variance var(x):

SCV[x] = var(x) / mean(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.

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:

S[t] = prod (1 - e[t]) / n[t]

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

Var(S[t]) = S[t]^2 sum e[t] / (n[t] * (n[t] - e[t]))

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

H[t] = sum(e[t] / n[t])

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

Var(H[t]) = sum(e / n^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:

S[t] = exp(H[t])

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

H[t] = -log(S[t])

Examples

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

survMisc documentation built on May 2, 2019, 5:14 p.m.