Response objects to represent censored and truncated observations
Resp(
cleft,
cright,
tleft,
tright,
bounds = c(-Inf, Inf),
open_lwr_bnd = TRUE,
tol = sqrt(.Machine$double.eps)
)# S3 method for Resp
R(object, ...)
# S3 method for Resp
print(x, ...)
# S3 method for Resp
[(x, i, j, drop = FALSE)
# S3 method for Resp
is.na(x)
# S3 method for Resp
length(x)
# S3 method for Resp
format(x, ...)
A Resp object or a Surv object
A vector of left borders of censoring intervals
A vector of right borders of censoring intervals
A vector of left truncation values
A vector of right truncation values
An optional numeric vector of two elements (c(a, b))
that denotes the lower and upper boundaries of the outcome.
Logical; if TRUE, the lower boundary of the
outcome is open, and we want to enforce this.
Tolerance level.
A Resp object
Optional arguments
A Resp object
Row index (typically the only index)
Column index (typically missing)
If TRUE the result is coerced to the lowest possible dimension
R(Resp): Converting Resp objects to response (from
mlt) objects (see R)
print(Resp): Print method for the Resp class
[: Subsetting Resp objects
is.na(Resp): Missing values
length(Resp): Length of a Resp object
format(Resp): format method for a Resp object
This function is experimental and currently limited to continuous outcome types. It may be subject to change.
Resp extends the functionality of Surv class
by allowing cases that cannot be defined with it. An example is an
interval-censored outcome with left truncatation (see Examples).
Censored and exactly observed data can be defined similarly to type =
"interval2" objects in Surv. NA values for
left or right censoring borders mean left- or right-censored observations,
respectively. If both borders are NA, the observation is considered
NA by is.na(). Truncation times (tleft and
tright arguments) can be omitted or take NA values, which
means no truncation. If only the censoring intervals are provided, i.e.,
no trunction is present, the function returns a Surv object.
Resp also provides a limited interface between tramME and the
response class (technically, inherits from it) of mlt (see
R), which uses an internal representation that is not
compatible with tramME.
The optional argument open_lwr_bnd can be used to enforce lower
boundaries of the outcome. Left boundaries in the Resp object
(cleft and tleft) that are equal to the first element of
bounds will be increased with one tol value to avoid
downstream numerical problems in mlt. This adjustment is recorded
and reversed when we print the object.
dat <- data.frame(x1 = 1:10, x2 = c(2:10, NA), x3 = c(NA, 0:8))
dat$r <- with(dat, Resp(x1, x2, x3))
dat$r
dat[1:3, ]$r
dat$r[1:3]
is.na(dat$r)
model.frame(r ~ 1, data = dat, na.action = na.omit)
Run the code above in your browser using DataLab