cox: Direct Cox Proportional Hazards Model

coxR Documentation

Direct Cox Proportional Hazards Model

Description

A compact R4VN wrapper around tabsurv() for a final multivariable Cox model.

Usage

cox(
  time,
  event,
  vars,
  data = NULL,
  failure = NULL,
  id = NULL,
  start = NULL,
  strata = NULL,
  cluster = NULL,
  frailty = NULL,
  ph = FALSE,
  ci = 0.95,
  ties = c("efron", "breslow", "exact"),
  diagnosis = FALSE,
  show = TRUE,
  console = FALSE
)

Arguments

time

Follow-up or stop-time variable, supplied without quotes.

event

Event/status variable, supplied without quotes.

vars

Optional predictor specification created by vars().

data

Optional data frame. When omitted, active R4VN data are used.

failure

Value of event representing the event of interest. For a binary event it defaults to the second factor level or larger numeric value.

id

Optional subject identifier for counting-process/recurrent data.

start

Optional start/entry time. When supplied, time is treated as stop time.

strata

Optional stratification variable for Cox regression.

cluster

Optional clustering variable for robust Cox variance.

frailty

Optional shared-frailty variable. Do not combine with cluster.

ph

Logical; test the proportional-hazards assumption. Default FALSE in cox(). Setting diagnosis = TRUE also requests this diagnostic.

ci

Confidence level, default 0.95.

ties

Cox tie method: "efron", "breslow", or "exact".

diagnosis

Logical; if TRUE, append Cox-model diagnostics including concordance, proportional-hazards testing, and residual summaries. Default FALSE.

show

Logical; open the formatted result in the Viewer. Default TRUE.

console

Logical; also print the traditional result in the Console. Default FALSE.

Value

An object of class r4vn_surv.

Examples

if (requireNamespace("survival", quietly = TRUE)) {
  d <- data.frame(
    time = c(5, 8, 10, 12, 15, 18, 20, 22, 25, 30),
    event = c(1, 0, 1, 1, 0, 1, 0, 1, 1, 0),
    age = c(40, 45, 50, 55, 60, 48, 52, 63, 58, 67),
    sex = factor(rep(c("Female", "Male"), 5))
  )
  cox(time, event, vars = vars(c.age, i.sex), data = d, show = FALSE)
  cox(time, event, vars = vars(c.age, i.sex), data = d,
      diagnosis = TRUE, show = FALSE)
  cox(time, event, vars = vars(c.age), data = d, ph = TRUE, show = FALSE)
}

R4VN documentation built on Sept. 30, 2026, 5:13 p.m.