add_ci.survreg: Confidence Intervals for the Mean Survival Time of...

Description Usage Arguments Details Value References See Also Examples

View source: R/add_ci_survreg.R

Description

This function is one of the methods for add_ci, and is called automatically when add_ci is used on a fit of class survreg.

Usage

1
2
## S3 method for class 'survreg'
add_ci(df, fit, alpha = 0.1, names = NULL, yhatName = "mean_pred", ...)

Arguments

df

A data frame of new data on which to form predictions and confidence intervals.

fit

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

alpha

A number between 0 and 1. 1 - alpha is the confidence level of the intervals.

names

NULL or a string of length 2. If NULL, quantiles automatically will be named by add_quantile, otherwise, they will be named names.

yhatName

A string. Name of the vector of predictions. The default name is mean_pred.

...

Additional arguments.

Details

add_ci.survreg calculates confidence intervals for the mean survival time of several accelerated failure time (AFT) models including exponential, lognormal, weibull, and loglogistic models. AFT models must be fit with the survreg function in the survival package. Confidence intervals are formed parametrically via the Delta method.

add_ci.survreg will compute confidence intervals for the following mean survival time point estimates:

Exponential: E[Y|X] = \exp{Xβ}

Weibull: E[Y|X] = \exp{Xβ}Γ(1 + σ)

Lognormal: E[Y|X] = \exp{Xβ + \frac{σ^2}{2}}

Loglogistic: E[Y|X] = \exp{Xβ}Γ(1 + σ)(1 - σ)

Traditionally, survival time predictions are made with the median survival time. For forming confidence intervals for the median survival time (or any quantile of the survival time distribution), see add_quantile.survreg.

Note: The expected survival time of a loglogistic model with scale >= 1 does not exist. Otherwise, expected survival times exist for each of the four AFT models considered in add.ci_survreg.

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_ci.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 expected values and level 1 - alpha level confidence levels attached.

References

For descriptions of the log-location scale models supported: Meeker, William Q., and Luis A. Escobar. Statistical methods for reliability data. John Wiley & Sons, 2014. (Chapter 4)

For a description of the multivariate Delta method: Meeker, William Q., and Luis A. Escobar. Statistical methods for reliability data. John Wiley & Sons, 2014. (Appendix B.2)

See Also

add_quantile.survreg for quantiles of the survival time distribution of survreg objects, add_pi.survreg for prediction intervals of survreg objects, and add_probs.survreg for survival probabilities of survreg objects.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
## 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_ci(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_ci(df, fit2, alpha = 0.1, names = c("lwr", "upr"))

ciTools documentation built on Jan. 13, 2021, 7 a.m.