Skip to contents

buckley_james() fits the accelerated failure time model \(\log T = x^\top \beta + \varepsilon\) without assuming a distribution for the errors \(\varepsilon\). Starting from the least squares fit of the log times, it repeats two steps until \(\beta\) settles:

Usage

buckley_james(
  formula,
  data,
  weights,
  subset,
  na.action = stats::na.omit,
  max_iter = 200,
  tol = 1e-06,
  n_boot = NULL,
  conf_level = 0.95
)

Arguments

formula

A formula with a right-censored Surv() response on the left and the covariates on the right, such as Surv(time, status) ~ age + sex. Factors are coded with treatment contrasts. The model always has an intercept.

data

A data frame holding the variables in formula.

weights

Optional case weights, a column of data or a numeric vector. They weight the residual curve and the least squares fits.

subset

An optional expression selecting the rows of data to use.

na.action

What to do with rows that have missing values. The default drops them.

max_iter

The largest number of iterations. The default is 200.

tol

The convergence tolerance on the largest change in a coefficient. The default is 1e-6.

n_boot

The number of bootstrap resamples for the standard errors. The default, NULL, gives none, and the standard errors are NA.

conf_level

The confidence level, between 0 and 1. The default is 0.95.

Value

A buckley_james object. Use coef() or as.data.frame() for the coefficients and predict() for the linear predictors and survival curves. The object also holds std_error, iterations, converged, n, n_event, and with n_boot, boot (the coefficients of each resample, one row each).

Details

  1. The residual \(e_i = \log T_i - x_i^\top \beta\) of a censored subject is only known to exceed its observed value. It's replaced by its expected value given that, under the Kaplan-Meier curve of the residuals.

  2. \(\beta\) is refit by least squares to these filled-in log times.

The largest residual is taken as an event when the residual curve is fit, so the curve drops to 0 and the expected values are defined. The iterations sometimes settle into a cycle between two values rather than a single one. When the estimates two steps apart agree to within tol, the average of the last two is taken as converged.

With no censoring, the fit is the least squares fit of the log times, after one step. The model has no closed-form standard errors. With n_boot, they come from refitting to n_boot resamples of the rows, drawn with R's random number generator (use set.seed() to make them reproducible).

Examples

lung <- data.frame(
  time = c(306, 455, 1010, 210, 883, 1022, 310, 361, 218, 166, 170, 654, 728, 71, 567, 144,
    613, 707, 61, 88),
  status = c(2, 2, 1, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 1, 2, 2, 2, 2),
  age = c(74, 68, 56, 57, 60, 74, 68, 71, 53, 61, 57, 68, 68, 60, 57, 67, 70, 63, 56, 57),
  sex = c(1, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 1)
)

fit <- buckley_james(Surv(time, status) ~ age + sex, data = lung)
fit
#> <buckley_james> Surv(time, status) ~ age + sex
#> n = 20, events = 16, iterations = 13, converged = yes
#> 
#>             estimate std_error statistic p_value
#> (Intercept)  1.22572        NA        NA      NA
#> age          0.07266        NA        NA      NA
#> sex          0.07563        NA        NA      NA

# Bootstrap standard errors
set.seed(1)
booted <- buckley_james(Surv(time, status) ~ age + sex, data = lung, n_boot = 50)
as.data.frame(booted)
#>          term   estimate  std_error statistic    p_value     conf_low conf_high
#> 1 (Intercept) 1.22571660 2.14863095  0.570464 0.56836303 -2.985522668 5.4369559
#> 2         age 0.07265749 0.03763571  1.930546 0.05353918 -0.001107155 0.1464221
#> 3         sex 0.07562934 0.57225143  0.132161 0.89485693 -1.045962851 1.1972215