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.19599987  0.05424262  0.08649091 -0.00648150  0.17157462 -0.10021096 
#> 
#> Scale= 0.5485944 
#> 
#> Loglik(model)= -38   Loglik(intercept only)= -40.9
#> 	Chisq= 5.72 on 5 degrees of freedom, p= 0.335 
#> n= 100