R/as-ped-ic.R
interval_censored.RdInterval-censored (IC) data record the event time of subject \(i\) only up
to an interval \((L_i, R_i]\). pammtools handles such data via
multiple imputation (MI): exact event times are repeatedly drawn from the
model-based conditional distribution and the resulting (exact) data sets are
transformed and re-fit using the standard right-censored PAMM pipeline (see
pamm_ic). The functions documented here implement the
preprocessing building blocks of that workflow.
detect_ic(formula, data)
parse_ic_surv(formula, data, id = "id")
resolve_ic_cut(ic, cut = NULL, max_time = NULL)
ic_event_data(ic, t_imp)
drop_zero_followup(evd, warn = TRUE)
as_ped_ic(data, formula, cut = NULL, max_time = NULL, id = "id", ...)A two-sided formula whose left-hand side is an interval-
censored Surv object.
A data frame containing the variables referenced in
formula.
Name of the subject identifier column. If it does not exist in
data it is created as a row index.
A data frame as returned by parse_ic_surv.
Optional numeric vector of interval cut-points. If NULL
(default) the finite interval endpoints are used.
Optional numeric scalar; cut-points are capped at this value.
Numeric vector of imputed event times (length nrow(ic)).
Ignored for exact and right-censored rows.
A data frame with a .ped_time column (output of
ic_event_data).
Logical; emit a one-time warning when rows are dropped.
Further arguments passed to the data.frame method and
eventually to survSplit.
IC data are specified through the standard survival interface, i.e. a
three-argument response of the form Surv(L, R, type = "interval2").
The four observation types are encoded as usual:
\(L = R\) (known event time).
\(R = \infty\) (event after \(L\)).
\(L = 0\) (event in \((0, R]\)).
\(0 < L < R < \infty\) (event in \((L, R]\)).
detect_ic(): Detect whether formula specifies
interval-censored data. Returns "interval2" for interval-censored
responses and "none" otherwise (right-censored and left-truncated
counting-process responses both return "none" and are handled by the
standard pipeline).
parse_ic_surv(): Parse the interval-censored response into a
tibble of lower/upper bounds and observation type, augmenting data
with the columns ic_L, ic_R and ic_kind (a factor with
levels exact, right, left, interval) and, if
absent, an id column.
resolve_ic_cut(): Resolve a fixed vector of interval cut-points
for the IC transformation. When cut is supplied it is sorted and
de-duplicated; otherwise the unique finite interval endpoints (the
inspection times) are used, capped at max_time. The resolved
cut must be shared across all imputations so that the PED
interval structure is consistent across refits. Note that mgcv's
centering constraints can still make the lpmatrix differ by fit.
ic_event_data(): Build the subject-level data frame of (exact)
event times implied by an imputation. Exact observations keep their event
time; right-censored observations are censored at ic_L; left- and
interval-censored observations take the imputed time t_imp. Returns a
data frame with the response columns .ped_time and .ped_status
ready for split_data via a two-argument Surv.
drop_zero_followup(): Drop subjects with non-positive follow-up time
(e.g.\ right-censored at time 0 with no observed inspection), which carry no
information and would break the interval split. Returns the filtered data.
as_ped_ic(): Transform interval-censored data into an
initial (midpoint-imputed) PED object. Left- and interval-censored event
times are initialised at the interval midpoint (\((L+R)/2\), and
\(R/2\) for left-censored observations); this object is only an
initialiser for pamm_ic and should not be used for inference
on its own. The parsed interval bounds and the resolved cut-points are
attached as the "ic" and "breaks" attributes.