Description Usage Arguments Details Value References See Also Examples
View source: R/add_ci_survreg.R
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.
1 2 |
df |
A data frame of new data on which to form predictions and confidence intervals. |
fit |
An object of class |
alpha |
A number between 0 and 1. 1 - |
names |
|
yhatName |
A string. Name of the vector of predictions. The
default name is |
... |
Additional arguments. |
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.
A dataframe, df, with predicted expected values and
level 1 - alpha level confidence levels attached.
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)
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.
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"))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.