Skip to contents

lambda(t | x) = lambda_0(t) exp(x' beta), fitted by Newton-Raphson on the partial likelihood with Efron's tie handling – the default in survival::coxph, and materially better than Breslow's when ties are common, as they are whenever follow-up is recorded in whole days. The baseline hazard is left unspecified, which is the point of the model; exp(beta) is a hazard ratio assumed constant over time.

Usage

morie_cox_ph(time, event, X, ties = "efron", max_iter = 50, tol = 1e-09)

morie_cox_partial_loglik(time, event, X, beta, ties = "efron")

morie_survival_cox(time, event, X, ties = "efron", max_iter = 50, tol = 1e-09)

Arguments

time

follow-up times

event

1 for an event, 0 for censored

X

covariate matrix

ties

"efron" or "breslow"

max_iter, tol

iteration controls

beta

coefficient vector at which to evaluate the likelihood

Value

list with coef, se, z, p_value, hazard_ratio, loglik and the likelihood-ratio test

Examples

# X must vary AMONG THE EVENTS: if every event shares one covariate
# value, or X is a linear function of the event times, the partial
# likelihood has no unique maximum and the Hessian is singular.
morie_cox_ph(time = c(1, 2, 3, 4, 5, 6, 7, 8),
             event = c(0, 1, 0, 1, 1, 0, 1, 0),
             X = c(0, 1, 0, 0, 1, 1, 0, 1))
#> $coef
#> [1] -0.4442129
#> 
#> $se
#> [1] 1.019836
#> 
#> $z
#> [1] -0.435573
#> 
#> $p_value
#> [1] 0.6631466
#> 
#> $hazard_ratio
#> [1] 0.6413289
#> 
#> $vcov
#>          [,1]
#> [1,] 1.040065
#> 
#> $loglik
#> [1] -5.540542
#> 
#> $loglik_null
#> [1] -5.63479
#> 
#> $lr_statistic
#> [1] 0.1884957
#> 
#> $lr_p_value
#> [1] 0.6641716
#> 
#> $n
#> [1] 8
#> 
#> $n_events
#> [1] 4
#> 
#> $ties
#> [1] "efron"
#>