File: sf.Rd

package info (click to toggle)
r-cran-survmisc 0.5.6-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 504 kB
  • sloc: makefile: 5
file content (139 lines) | stat: -rwxr--r-- 4,242 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/sf.R
\name{sf}
\alias{sf}
\alias{sf.default}
\alias{sf.ten}
\alias{sf.stratTen}
\alias{strat.Ten}
\alias{sf.numeric}
\title{\bold{s}urvival (or hazard) \bold{f}unction
based on \eqn{e} and \eqn{n}.}
\usage{
sf(x, ...)

\method{sf}{default}(x, ..., what = c("S", "H"), SCV = FALSE, times = NULL)

\method{sf}{ten}(x, ..., what = c("S", "H"), SCV = FALSE, times = NULL, reCalc = FALSE)

\method{sf}{stratTen}(x, ..., what = c("S", "H"), SCV = FALSE, times = NULL, reCalc = FALSE)

\method{sf}{numeric}(
  x,
  ...,
  n = NULL,
  what = c("all", "S", "Sv", "H", "Hv"),
  SCV = FALSE,
  times = NULL
)
}
\arguments{
\item{x}{One of the following:
 \describe{
  \item{default}{A numeric vector of events status (assumed sorted by time).}
  \item{numeric}{Vectors of events and numbers at risk (assumed sorted by time).}
  \item{ten}{A \code{ten} object.}
  \item{stratTen}{A \code{stratTen} object.}
}}

\item{...}{Additional arguments (not implemented).}

\item{what}{See return, below.}

\item{SCV}{Include the \bold{S}quared \bold{C}oefficient of
\bold{V}ariation, which is calcluated using
the mean \eqn{\bar{x}}{mean(x)} and
the variance \eqn{\sigma_x^2}{var(x)}:
 \deqn{SCV_x = \frac{\sigma_x^2}{\bar{x}^2}}{
       SCV[x] = var(x) / mean(x)^2}
This measure of \emph{dispersion} is also referred to as
the 'standardized variance' or the 'noise'.}

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

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

\item{n}{Number at risk.}
}
\value{
A {data.table} which is stored as an attribute of
the \code{ten} object. 
\cr
If \code{what="s"}, the \bold{s}urvival is returned, based on the
Kaplan-Meier or product-limit estimator.
This is \eqn{1} at \eqn{t=0} and thereafter is given by:
\deqn{\hat{S}(t) = \prod_{t \leq t_i} (1-\frac{e_i}{n_i} )}{
      S[t] = prod (1 - e[t]) / n[t] }

If \code{what="sv"}, the \bold{s}urvival \bold{v}ariance is returned.
\cr
Greenwoods estimtor of the variance of the
Kaplan-Meier (product-limit) estimator is:
\deqn{Var[\hat{S}(t)] = [\hat{S}(t)]^2 \sum_{t_i \leq t}
                        \frac{e_i}{n_i (n_i - e_i)}}{
      Var(S[t]) = S[t]^2 sum e[t] / (n[t] * (n[t] - e[t]))}

If \code{what="h"}, the \bold{h}azard is returned,
based on the the Nelson-Aalen estimator.
This has a value of \eqn{\hat{H}=0}{H=0} at \eqn{t=0}
and thereafter is given by:
\deqn{\hat{H}(t) = \sum_{t \leq t_i} \frac{e_i}{n_i}}{
      H[t] = sum(e[t] / n[t])}

If \code{what="hv"}, the \bold{h}azard \bold{v}ariance is returned.
\cr
The variance of the Nelson-Aalen estimator is given by:
\deqn{Var[\hat{H}(t)] = \sum_{t_i \leq t} \frac{e_i}{n_i^2}}{
      Var(H[t]) = sum(e / n^2)}

If \code{what="all"} (the default), \emph{all} of the above
are returned in a \code{data.table}, along with:
\cr
Survival, based on the Nelson-Aalen hazard estimator \eqn{H}, 
which is:
 \deqn{\hat{S_{na}}=e^{H}}{
       S[t] = exp(H[t])}
Hazard, based on the Kaplan-Meier survival estimator \eqn{S},
which is:
 \deqn{\hat{H_{km}} = -\log{S}}{
       H[t] = -log(S[t])}
}
\description{
\bold{s}urvival (or hazard) \bold{f}unction
based on \eqn{e} and \eqn{n}.
}
\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")

}
\keyword{survival}