| Resp {tramME} | R Documentation |
Response objects
Description
Response objects to represent censored and truncated observations
Usage
Resp(
cleft,
cright,
tleft,
tright,
bounds = c(-Inf, Inf),
open_lwr_bnd = TRUE,
tol = sqrt(.Machine$double.eps)
)
## S3 method for class 'Resp'
R(object, ...)
## S3 method for class 'Resp'
print(x, ...)
## S3 method for class 'Resp'
x[i, j, drop = FALSE]
## S3 method for class 'Resp'
is.na(x)
## S3 method for class 'Resp'
length(x)
## S3 method for class 'Resp'
format(x, ...)
Arguments
cleft |
A vector of left borders of censoring intervals |
cright |
A vector of right borders of censoring intervals |
tleft |
A vector of left truncation values |
tright |
A vector of right truncation values |
bounds |
An optional numeric vector of two elements ( |
open_lwr_bnd |
Logical; if |
tol |
Tolerance level. |
object |
A |
... |
Optional arguments |
x |
A |
i |
Row index (typically the only index) |
j |
Column index (typically missing) |
drop |
If |
Details
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.
Value
A Resp object or a Surv object
Methods (by generic)
-
R(Resp): ConvertingRespobjects toresponse(frommlt) objects (seeR) -
print(Resp): Print method for theRespclass -
[: SubsettingRespobjects -
is.na(Resp): Missing values -
length(Resp): Length of aRespobject -
format(Resp):formatmethod for aRespobject
Warning
This function is experimental and currently limited to continuous outcome types. It may be subject to change.
Examples
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)