Skip to contents

Convenience wrapper around robust_survreg_with_surv_object that builds the Surv object from separate response and censoring vectors first. See that function for the full description of the warm-start-then-random-restart fitting strategy used to make survreg converge reliably even from poor or near-singular starting points.

Usage

robust_survreg(
  y,
  dead,
  cov_matrix_or_vector,
  dist = "weibull",
  num_max_iter = 50
)

Arguments

y

The (possibly right-censored) response vector (event/censoring time).

dead

The event indicator (1 if the event was observed/uncensored, 0 if right-censored at y).

cov_matrix_or_vector

The design matrix (or a single covariate vector) of predictors, excluding the intercept (one is added by the internal ~ . formula).

dist

The parametric AFT distribution family passed to survreg (default "weibull"); see that function's dist argument for the full list of supported families.

num_max_iter

Maximum number of random-restart attempts if the direct fit fails or does not converge (default 50); see robust_survreg_with_surv_object.

Value

The fitted survreg model object, or NULL if no attempt converged to a fit with no NA coefficients within num_max_iter tries.

Examples

X = matrix(rnorm(500), 100, 5)
y = runif(100)
dead = rbinom(100, 1, 0.5)
robust_survreg(y, dead, X)
#> Call:
#> survival::survreg(formula = surv_reg_formula, data = cov_matrix_or_vector_data_frame, 
#>     dist = dist, init = init_vals, control = survival::survreg.control(maxiter = 100, 
#>         rel.tolerance = 1e-09, outer.max = 10))
#> 
#> Coefficients:
#> (Intercept)          X1          X2          X3          X4          X5 
#> -0.19571750  0.01275635 -0.11617006  0.06711751 -0.13339645 -0.07923421 
#> 
#> Scale= 0.6604212 
#> 
#> Loglik(model)= -43.2   Loglik(intercept only)= -45.6
#> 	Chisq= 4.75 on 5 degrees of freedom, p= 0.447 
#> n= 100