| interp | R Documentation |
Interpolates survival curves (vector or matrix) at new time points using internal C++ interpolation functions. Output can be survival, cumulative distribution, density, hazard or cumulative hazard functions.
interp(
x,
times = NULL,
eval_times = NULL,
method = "const_surv",
output = "surv",
add_times = TRUE,
check = TRUE,
eps = 1e-12,
trim_dups = FALSE
)
x |
( |
times |
( |
eval_times |
( |
method |
( |
output |
( |
add_times |
( |
check |
( |
eps |
( |
trim_dups |
( |
Input must always be survival probabilities. We currently provide three interpolation options:
"const_surv": left-continuous constant interpolation of S(t) (default).
"const_dens"/"linear_surv": linear interpolation of S(t) (equivalent to
piecewise constant interpolation of the density function).
"const_haz"/"exp_surv": exponential interpolation of S(t) (equivalent to
piecewise constant interpolation of the hazard function).
We will provide tables with the interpolation formulas for each method in an upcoming arXiv preprint and link it here.
For constant hazard interpolation ("const_haz"), any right-anchor S(t) values
equal to 0 are internally floored at min(1e-12, S_left) within each interval.
This keeps hazards/densities finite without allowing a local increase in S(t).
A numeric vector or matrix of interpolated values.
x = matrix(c(1, 0.8, 0.6,
1, 0.7, 0.4), nrow = 2, byrow = TRUE)
times = c(0, 8, 13)
eval_times = c(5, 10, 14)
# constant S(t) interpolation
interp(x, times, eval_times)
# linear S(t) interpolation
interp(x, times, eval_times, method = "linear_surv")
# exponential S(t) interpolation (same as `method = "const_haz"`)
interp(x, times, eval_times, method = "exp_surv")
# Cumulative distribution with linear S(t) interpolation
interp(x, times, eval_times, method = "linear_surv", output = "cdf")
# H(t) with linear S(t) interpolation
interp(x, times, eval_times, method = "linear_surv", output = "cumhaz")
# f(t) with constant hazard interpolation
interp(x, times, eval_times, method = "const_haz", output = "density")
# h(t) with constant hazard interpolation
interp(x, times, eval_times, method = "const_haz", output = "hazard")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.