Create a Survival Object
SurvS4.RdCreate a survival object, usually used as a response variable in a model formula.
Arguments
- time
for right censored data, this is the follow up time. For interval data, the first argument is the starting time for the interval.
- x
any R object.
- event
The status indicator, normally 0=alive, 1=dead. Other choices are
TRUE/FALSE(TRUE= death) or 1/2 (2=death). For interval censored data, the status indicator is 0=right censored, 1=event attime, 2=left censored, 3=interval censored. Although unusual, the event indicator can be omitted, in which case all subjects are assumed to have an event.- time2
ending time of the interval for interval censored or counting process data only. Intervals are assumed to be open on the left and closed on the right,
(start, end]. For counting process data,eventindicates whether an event occurred at the end of the interval.- type
character string specifying the type of censoring. Possible values are
"right","left","counting","interval", or"interval2". The default is"right"or"counting"depending on whether thetime2argument is absent or present, respectively.- origin
for counting process data, the hazard function origin. This is most often used in conjunction with a model containing time dependent strata in order to align the subjects properly when they cross over from one strata to another.
Value
An object of class SurvS4 (formerly Surv).
There are methods for print, is.na, and
subscripting survival objects. SurvS4 objects are
implemented as a matrix of 2 or 3 columns.
In the case of is.SurvS4, a logical value
TRUE if x inherits from class
"SurvS4", otherwise a FALSE.
Details
Typical usages are
In theory it is possible to represent interval censored data without a third column containing the explicit status. Exact, right censored, left censored and interval censored observation would be represented as intervals of (a,a), (a, infinity), (-infinity,b), and (a,b) respectively; each specifying the interval within which the event is known to have occurred.
If type = "interval2" then the representation given
above is assumed, with NA taking the place of infinity.
If `type="interval" event must be given.
If event is 0, 1, or 2,
the relevant information is assumed to be contained in
time, the value in time2 is ignored, and the
second column of the result will contain a placeholder.
Presently, the only methods allowing interval
censored data are the parametric models computed by
survreg, so the distinction between
open and closed intervals is unimportant. The distinction
is important for counting process data and the Cox model.
The function tries to distinguish between the use of 0/1
and 1/2 coding for left and right censored data using
if (max(status)==2). If 1/2 coding is used and all
the subjects are censored, it will guess wrong. Use 0/1
coding in this case.
Author
The code and documentation comes from survival.
Slight modifications have been made for conversion to S4 by T. W. Yee.
Also, for "interval" data, as.character.SurvS4() has
been modified to print intervals of the form
(start, end] and not
[start, end] as previously.
(This makes a difference for discrete data, such as for
cens.poisson).
All VGAM family functions beginning with "cen" require
the packaging function Surv to format the input.
Note
The purpose of having SurvS4 in VGAM is so that
the same input can be fed into vglm as functions in
survival such as survreg. The class
name has been changed from "Surv" to "SurvS4"; see
SurvS4-class.
The format J+ is interpreted in VGAM as \(\ge J\).
If type="interval" then these should not be used in VGAM:
(L,U-] or (L,U+].
Examples
with(leukemia, SurvS4(time, status))
#> time status
#> [1,] 9 1
#> [2,] 13 1
#> [3,] 13 0
#> [4,] 18 1
#> [5,] 23 1
#> [6,] 28 0
#> [7,] 31 1
#> [8,] 34 1
#> [9,] 45 0
#> [10,] 48 1
#> [11,] 161 0
#> [12,] 5 1
#> [13,] 5 1
#> [14,] 8 1
#> [15,] 8 1
#> [16,] 12 1
#> [17,] 16 0
#> [18,] 23 1
#> [19,] 27 1
#> [20,] 30 1
#> [21,] 33 1
#> [22,] 43 1
#> [23,] 45 1
#> attr(,"type")
#> [1] "right"
#> attr(,"class")
#> [1] "SurvS4"
class(with(leukemia, SurvS4(time, status)))
#> [1] "SurvS4"