Skip to contents

Creates a family object for univariate Cox regression, compatible with GLM‐style interfaces. Only the log link is supported, yielding the usual Cox partial‐likelihood formulation.

Usage

cox(link = "log")

Arguments

Character string; link function for the Cox model. Only "log" is supported (default).

Value

A family object (a list with class "family") containing:

family

Always "cox".

link

Link name, "log".

linkfun

Function transforming mu to eta.

linkinv

Inverse link, mapping eta to mu.

mu.eta

Derivative of linkinv.

variance

Variance function (returns 1).

dev.resids

Deviance residuals (zeros).

aic

AIC placeholder (returns -2).

validmu, valideta

Validation functions (always TRUE).

dispersion

Always 1.

Details

This "family" object provides the minimal set of functions required for use with IRLS‐based routines and log-likelihood calculations:

  • linkfun and linkinv implement the log link.

  • mu.eta provides the derivative of the inverse link.

  • variance, dev.resids, and aic are placeholders (not used in Cox but needed for compatibility).

Examples

# Create the Cox family object
fam <- cox(link = "log")
stopifnot(fam$family == "cox")
# Check that linkinv(exp(eta)) == exp(eta)
eta <- c(0, 1, -1)
all.equal(fam$linkinv(eta), exp(eta))
#> [1] TRUE