add_probs.survreg {ciTools}R Documentation

Confidence Intervals for the Survivor Function of Accelerated Failure Time Models

Description

This function is one of the methods of add_probs and is automatically called when an object of class survreg is passed to add_probs.

Usage

## S3 method for class 'survreg'
add_probs(
  df,
  fit,
  q,
  name = NULL,
  yhatName = "median_pred",
  comparison = "<",
  confint = TRUE,
  alpha = 0.05,
  ...
)

Arguments

df

A data frame of new data.

fit

An object of class survreg. Predictions are made with this object.

q

A double. A quantile of the survival time distribution. In survival applications this is the time of event.

name

NULL or a string. If NULL, probabilities automatically will be named by add_probs(), otherwise, the probabilities will be named name in the returned data frame.

yhatName

A string. Name of the vector of predictions.

comparison

A character vector of length one. If comparison = "<", then Pr(Y|X < q) is calculated. If comparison = ">", the survivor function at time q is calculated.

confint

A logical. If TRUE, confidence intervals for the estimated probabilities will be calculated and appended to df.

alpha

A number. Control the confidence level of the confidence intervals if confint = TRUE.

...

Additional arguments.

Details

Confidence intervals may be produced for estimated probabilities of accelerated failure time models. Presently, confidence intervals may be computed for lognormal, weibull, exponential, and loglogistic failure time models. If comparison = "<", confidence intervals are made for the probability that a failure will be observed before q. Similarly, if comparison = ">", confidence intervals will be formed for the probability that a unit fails after q. In the survival literature, comparison = ">" corresponds to estimating the survivor function, S(q).

Confidence intervals are produced parametrically via the Delta Method. Simulations show that under a mild to moderate amount of censoring, this method performs adequately.

The logistic transformation is applied to ensure that confidence interval bounds lie between 0 and 1.

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_probs.survreg cannot inspect the convergence of fit. Poor maximum likelihood estimates will result in poor confidence intervals. Inspect any warning messages given from survreg.

Value

A dataframe, df, with predicted medians, probabilities, and confidence intervals for predicted probabilities attached.

References

For the logistic transformation of estimated probabilities and error bounds: Meeker, William Q., and Luis A. Escobar. Statistical methods for reliability data. John Wiley & Sons, 2014. (Chapter 8)

For a discussion of forming confidence intervals for survival probabilities: Harrell, Frank E. Regression modeling strategies. Springer, 2015. (Chapter 17)

See Also

add_ci.survreg for confidence intervals for survreg objects, add_pi.survreg for prediction intervals of survreg objects, and add_quantile.survreg for response 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")
## Calculate the level 0.75 quantile wit CIs for that quantile
add_probs(df, fit, q = 500, name = c("Fhat", "lwr", "upr"))

## Try a weibull model for the same data:
fit2 <- survival::survreg(survival::Surv(time, status) ~ age + I(age^2),
                          data = df, dist = "weibull")
## Calculate the level 0.75 quantile with CIs for the quantile
add_probs(df, fit2, q = 500, name = c("Fhat", "lwr", "upr"))



[Package ciTools version 0.6.1 Index]