add_pi.survreg {ciTools} | R Documentation |
Prediction Intervals for Accelerated Failure Time Models
Description
This function is one of the methods for add_pi
, and is
called automatically when add_pi
is used on a fit
of
class survreg
.
Usage
## S3 method for class 'survreg'
add_pi(
df,
fit,
alpha = 0.05,
names = NULL,
yhatName = "median_pred",
nSims = 10000,
method = "naive",
...
)
Arguments
df |
A data frame of new data. |
fit |
An object of class |
alpha |
A real number between 0 and 1. Controls the confidence level of the interval estimates. |
names |
|
yhatName |
A string. Name of the predictions vector. |
nSims |
A positive integer. Determines the number of bootstrap
replicates if |
method |
A string. Determines the method used to calculate
prediction intervals. Must be one of either |
... |
Additional arguments. |
Details
add_pi.survreg
creates prediction intervals for the survival
time $T$ conditioned on the covariates of the survreg
model. In simple terms, this function calculates error bounds
within which one can expect to observe a new survival time. Like
other parametric survival methods in ciTools
, prediction
intervals are limited to unweighted lognormal, exponential,
weibull, and loglogistic AFT models.
Two methods are available for creating prediction intervals, the
"naive" method (Meeker and Escobar, chapter 8) and a simulation
method that implements a parametric bootstrap routine. The "naive"
method calculates quantiles of the fitted survival time
distribution to determine prediction intervals. The parametric
bootstrap method simulates new survival times from the conditional
survival time distribution, taking into account the uncertainty in
the regression coefficients. The bootstrap method is similar to the
one implemented in add_pi.glm
.
Note: Due to a limitation, the Surv
object must be specified in
survreg
function call. See the examples section for one way
to do this.
Note: add_pi.survreg
cannot inspect the convergence of
fit
. Poor maximum likelihood estimates will result in poor
prediction intervals. Inspect any warning messages given from
survreg
.
Value
A dataframe, df
, with predicted medians, upper and lower
prediction bounds attached.
References
For a discussion prediction intervals of accelerated failure time models: Meeker, William Q., and Luis A. Escobar. Statistical methods for reliability data. John Wiley & Sons, 2014. (Chapter 8)
See Also
add_ci.survreg
for confidence intervals for
survreg
objects, add_probs.survreg
for
conditional survival probabilities of survreg
objects, and
add_quantile.survreg
for survival time quantiles
of survreg
objects.
Examples
## Define a data set.
df <- survival::stanford2
## remove a covariate with missing values.
df <- df[, 1:4]
## next, create the Surv object inside the survreg call:
fit <- survival::survreg(survival::Surv(time, status) ~ age + I(age^2),
data = df, dist = "lognormal")
add_pi(df, fit, alpha = 0.1, names = c("lwr", "upr"))
## Try a different model:
fit2 <- survival::survreg(survival::Surv(time, status) ~ age + I(age^2),
data = df, dist = "weibull")
add_pi(df, fit2, alpha = 0.1, names = c("lwr", "upr"))