adelie.glm.cox#
- adelie.glm.cox(start: ndarray, stop: ndarray, status: ndarray, *, weights: ndarray | None = None, tie_method: str = 'efron', dtype: float32 | float64 | None = None)[source]#
Creates a Cox GLM family object.
The Cox GLM family specifies the loss function as:
\[\begin{split}\begin{align*} \ell(\eta) &= -\sum\limits_{i=1}^n w_i \delta_i \eta_i +\sum\limits_{i=1}^n \overline{w}_i \delta_i A_i(\eta) \\ A_i(\eta) &= \log\left( \sum\limits_{k \in R(t_i)} w_k e^{\eta_k} - \sigma_i \sum\limits_{k \in H(t_i)} w_k e^{\eta_k} \right) \end{align*}\end{split}\]where
\[\begin{split}\begin{align*} R(u) &= \{i : u \in (s_i, t_i]\} \\ H(u) &= \{i : t_i = u, \delta_i = 1\} \\ \overline{w}_i &= \frac{\sum_{k \in H(t_i)} w_k}{\sum_{k \in H(t_i)} 1_{w_k > 0}} 1_{\delta_i = 1, w_i > 0} \end{align*}\end{split}\]Here, \(\delta\) is the status (
1
for event,0
for censored) vector, \(s\) is the vector of start times, \(t\) is the vector of stop times, \(R(u)\) is the at-risk set at time \(u\), \(H(u)\) is the set of ties at event time \(u\), \(\overline{w}\) is the vector of average weights within ties with positive weights, \(\sigma\) is the correction scale for tie-breaks, which is determined by the type of correction method (Breslow or Efron). Note that \(\overline{w}_i\) and \(A_i(\eta)\) are only well-defined whenever \(\delta_i=1\), which is not an issue in the computation of \(\ell(\eta)\).- Parameters:
- start(n,) ndarray
Start time vector \(s\).
- stop(n,) ndarray
Stop time vector \(t\).
- status(n,) ndarray
Status vector \(\delta\).
- weights(n,) ndarray, optional
Observation weights \(W\). Weights are normalized such that they sum to
1
. Default isNone
, in which case, it is set tonp.full(n, 1/n)
.- tie_methodstr, optional
The tie-breaking method that determines the scales \(\sigma\). It must be one of the following:
"efron"
"breslow"
Default is
"efron"
.- dtypeUnion[float32, float64], optional
The underlying data type. If
None
, it is inferred fromstatus
, in which casestatus
must have an underlying data type ofnumpy.float32
ornumpy.float64
. Default isNone
.
- Returns:
- glm
Cox GLM object.