xmin, xmax: Censoring bounds. If xmin != xmax, x must be NA.
tmin, tmax: Truncation bounds. May vary per observation.
w: Case weights
.data: A data frame or numeric vector.
tmin_new: New truncation minimum
tmax_new: New truncation maximum
.partial: Enable partial truncation of censored observations? This could potentially create inconsistent data if the actual observation lies outside of the truncation bounds but the censoring interval overlaps.
accident: accident time (unquoted, evaluated in .data)
delay: reporting delay (unquoted, evaluated in .data)
time: evaluation time (unquoted, evaluated in .data)
.truncate: Should claims reported after time be silently discarded? If there are claims reported after time and .truncate is FALSE, an error will be raised.
Returns
trunc_obs : A trunc_obs tibble with columns x, xmin, xmax, tmin and tmax describing possibly interval-censored observations with truncation
as_trunc_obs returns a trunc_obs tibble.
truncate_obs returns a trunc_obs tibble with possibly fewer observations than .data and updated truncation bounds.
repdel_obs returns a trunc_obs tibble corresponding to the reporting delay observations of each claim. If .truncate is FALSE, the result is guaranteed to have the same number of rows as .data.
Details
Uncensored observations must satisfy tmin <= xmin = x = xmax <= tmax. Censored observations must satisfy tmin <= xmin < xmax <= tmax and x = NA.
Examples
N <-100x <- rexp(N,0.5)# Random, observation dependent truncation intervalstmin <- runif(N,0,1)tmax <- tmin + runif(N,1,2)oob <- x < tmin | x > tmax
x <- x[!oob]tmin <- tmin[!oob]tmax <- tmax[!oob]# Number of observations after truncationN <- length(x)# Randomly interval censor 30% of observationscens <- rbinom(N,1,0.3)==1Lxmin <- x
xmax <- x
xmin[cens]<- pmax(tmin[cens], floor(x[cens]))xmax[cens]<- pmin(tmax[cens], ceiling(x[cens]))x[cens]<-NAtrunc_obs(x, xmin, xmax, tmin, tmax)as_trunc_obs(c(1,2,3))as_trunc_obs(data.frame(x =1:3, tmin =0, tmax =10))as_trunc_obs(data.frame(x = c(1,NA), xmin = c(1,2), xmax = c(1,3)))truncate_obs(1:10, tmin_new =2.0, tmax_new =8.0)