rStats.js v1.3.0
    Preparing search index...

    Function coxph

    • Cox proportional hazards regression. Equivalent to R's survival::coxph(). As coxph(Surv(time, status) ~ x [+ strata(strata)], weights, ties, init, robust, cluster, control) for right-censored data, with the values of summary(fit).

      With robust (by default when cluster is given or a case weight is not an integer) the variance is the robust (Lin-Wei sandwich) one, summed over the clusters (each observation its own cluster without cluster), as R: var is the robust variance and naiveVar the model-based one; se (and stdError) stay the model-based standard errors (R's se(coef)), while z, p, the intervals lower/upper, wald and waldtest use the robust ones (robustSe); robscore is the robust score test at init. The likelihood ratio and score tests and the R^2 ignore the clustering.

      Rows with a missing time, status, covariate, weight or stratum are dropped. Times within sqrt(eps) of each other are treated as tied. Covariates whose values all lie in nocenter are not centred; the others are centred by their weighted means, which only shifts the linear predictors. R's warnings (non-convergence, possibly infinite coefficients) are returned in warnings.

      Parameters

      • time: readonly number[]

        Follow-up times.

      • status: readonly number[]

        1 for an event, 0 for a censored time.

      • x: readonly (readonly number[])[]

        The covariate matrix, one row per observation (at least one column).

      • options: CoxphOptions = {}

      Returns CoxphResult

      TypeError if robust is not a boolean. RangeError for invalid arguments, among them an infinite weight and a robust variance with fewer than two clusters.

      const fit = coxph([5, 3, 8, 1, 9, 4], [1, 1, 0, 1, 0, 1], [[1.2], [0.3], [-0.5], [2], [0.7], [0.1]]);
      fit.coefficients; // [1.0324]
      fit.logtest.pValue; // 0.18817