parametric() fits a Weibull, exponential, log-normal, or log-logistic distribution to
right-censored survival times by maximum likelihood. It gives one fit for the whole sample, or
one per group when the right-hand side of the formula names grouping variables.
Arguments
- formula
A formula with a right-censored
Surv()response on the left and either1or the grouping variables on the right, such asSurv(time, status) ~ 1orSurv(time, status) ~ sex.- data
A data frame holding the variables in
formula.- weights
Optional case weights, a column of
dataor a numeric vector.- subset
An optional expression selecting the rows of
datato use.- na.action
What to do with rows that have missing values. The default drops them.
- dist
The error distribution:
"weibull"(the default),"exponential","lognormal","loglogistic", or"gengamma"(the generalized gamma).- conf_level
The confidence level, between 0 and 1. The default is
0.95.
Value
A parametric object. Use as.data.frame() for the parameter table, predict() for
the survival, cumulative hazard, hazard, and density at given times, quantile(),
median(), mean(), and rmst() for summaries of the survival time, and logLik(),
AIC(), and BIC() to compare distributions (see also compare_distributions()).
Details
Each distribution is the intercept-only aft() model, \(\log T = \mu + \sigma \varepsilon\),
reported in its usual parameters:
Weibull:
shape\(1 / \sigma\) andscale\(\exp(\mu)\), with \(S(t) = \exp(-(t / \mathrm{scale})^{\mathrm{shape}})\).Exponential:
rate\(\exp(-\mu)\), with \(S(t) = \exp(-\mathrm{rate} \cdot t)\).Log-normal:
muandsigma, the mean and standard deviation of \(\log T\).Log-logistic:
alpha\(\exp(\mu)\) (the median) andbeta\(1 / \sigma\) (the shape), with \(S(t) = 1 / (1 + (t / \alpha)^\beta)\).
Standard errors come from the delta method. Confidence limits for the positive parameters are
built on the log scale, and those for the log-normal mu on the plain scale.
Examples
lung <- data.frame(
time = c(306, 455, 1010, 210, 883, 1022, 310, 361, 218, 166, 170, 654, 728, 71, 567),
status = c(2, 2, 1, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2),
sex = c(1, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, 2, 2, 1, 1)
)
fit <- parametric(Surv(time, status) ~ 1, data = lung)
fit
#> <parametric> Surv(time, status) ~ 1
#> Weibull distribution. n = 15, events = 13
#>
#> param estimate std_error conf_low conf_high
#> shape 1.377 0.3112 0.884 2.144
#> scale 567.845 115.9282 380.587 847.241
#>
#> Log-likelihood: -94.1265, AIC: 192.253
predict(fit, times = c(100, 365))
#> strata time estimate std_error conf_low conf_high
#> 1 all 100 0.9125327 0.05416478 0.7216198 0.9746478
#> 2 all 365 0.5803199 0.10496895 0.3520660 0.7530196
median(fit)
#> strata time std_error conf_low conf_high
#> 1 all 435.1298 96.60564 281.604 672.3554
# One log-normal fit per group
parametric(Surv(time, status) ~ sex, data = lung, dist = "lognormal")
#> <parametric> Surv(time, status) ~ sex
#> Log-normal distribution. n = 15, events = 13
#>
#> strata sex param estimate std_error conf_low conf_high
#> sex=1 1 mu 5.9161 0.3031 5.322 6.5101
#> sex=1 1 sigma 0.9812 0.2429 0.604 1.5938
#> sex=2 2 mu 6.1747 0.1840 5.814 6.5353
#> sex=2 2 sigma 0.3679 0.1301 0.184 0.7357
#>
#> Log-likelihood: -91.3606, AIC: 190.721