score_cox: Compute Cox Partial Log-Likelihood Score Vector

View source: R/cox_helpers.R

score_coxR Documentation

Compute Cox Partial Log-Likelihood Score Vector

Description

Gradient of the Cox partial log-likelihood with respect to \boldsymbol{\beta}. Data must be sorted by ascending event time.

Usage

score_cox(X, eta, status, y = NULL, weights = 1)

Arguments

X

Design matrix (N x p), sorted by ascending event time.

eta

Linear predictor vector \mathbf{X}\boldsymbol{\beta}.

status

Event indicator (1 = event, 0 = censored).

y

Optional numeric vector of observed event/censor times, same length and order as eta. When supplied, tied event times are handled with the Breslow approximation. When omitted, the function assumes there are no ties.

weights

Observation weights (default 1).

Details

Under the Breslow approximation, the score is

\mathbf{u} = \sum_g \Bigl[\sum_{i \in D_g} w_i \mathbf{x}_i - d_g^{(w)} \frac{\sum_{j \in R_g} w_j e^{\eta_j}\mathbf{x}_j} {\sum_{j \in R_g} w_j e^{\eta_j}}\Bigr]

where D_g is the tied event set at time t_g, R_g = \{j : t_j \ge t_g\} is the risk set, and d_g^{(w)} = \sum_{i \in D_g} w_i.

Value

Numeric column vector of length p (gradient).


lgspline documentation built on May 8, 2026, 5:07 p.m.