gcecox: Generalized competing event model via cause-specific Cox...

View source: R/gcecox.R

gcecoxR Documentation

Generalized competing event model via cause-specific Cox regression

Description

Fits a generalized competing event (GCE) model on the cause-specific hazard scale and estimates covariate effects on \omega^{+} (event of interest vs. competing event) using the Lunn-McNeil stacked model (see lunnmcneil), with confidence intervals, Wald tests, and an omnibus test. A GCE risk score is formed from the model linear predictor.

Usage

gcecox(formula, ...)

## S3 method for class 'formula'
gcecox(
  formula,
  data,
  subset,
  na.action,
  t = NULL,
  event = NULL,
  competing = NULL,
  conf.level = 0.95,
  cluster.se = TRUE,
  standardize = FALSE,
  contrasts = NULL,
  model = TRUE,
  ...
)

## Default S3 method:
gcecox(
  formula,
  Ind,
  Cov,
  M = NULL,
  t = NULL,
  conf.level = 0.95,
  cluster.se = TRUE,
  standardize = FALSE,
  ...
)

Arguments

formula

a formula with a Surv(time, status) response (formula method), or the numeric vector of follow-up times (default method, where it may also be named Time).

...

passed to coxph for the stacked model.

data

a data frame in which the formula is evaluated.

subset, na.action

as in model.frame.

t

default readout time for time-dependent quantities. If NULL (default), the largest observed event time is used.

event, competing

code (or factor level) marking the event of interest and the competing event; see lunnmcneil.

conf.level

confidence level (default 0.95).

cluster.se

logical; cluster-robust SEs in the Lunn-McNeil model (default TRUE).

standardize

logical; controls only the reported omega+ ratio scale (default FALSE = per natural covariate unit; TRUE = per 1 SD). The risk score is always the normalized (mean-centered) linear predictor regardless of this setting, so cutpoints, plots, and calibration are unaffected. Covariate means/SDs are returned by gce_scaling.

contrasts

optional contrasts specification passed to model.matrix.

model

logical; keep the model frame in the fitted object (default TRUE).

Ind

(default method) a data frame of event indicators. Column 1 = event of interest, column 2 = competing event (0/1).

Cov

(default method) a data frame of covariates.

M

deprecated and ignored. The number of bins is now an argument of the displays (plot(fit, which = "riskscore", bins = ), gce_calibration).

Details

The model is specified with a formula whose response is Surv(time, status); see the Interfaces section of lunnmcneil for the accepted status codings. The fitted object stores the model terms, factor levels, and contrasts, so that predict() can evaluate the risk score and the predicted \omega^{+} for new data.

Fitting does not depend on a time point. The argument t only sets the default readout time for quantities that are functions of time: the predicted absolute \omega^{+}(t) and \omega(t) (predict(type = "ratio"), type = "share"), calibration (gce_calibration), and the time axis of the displays. It can be overridden in each of those functions.

The default method is the matrix interface of earlier versions, gcecox(Time, Ind, Cov, t = ), retained for backward compatibility.

Value

An object of class c("gcecox", "gcemod"). The components most often needed are available through methods rather than by name; see gcemod-methods (print, summary, coef, vcov, confint, logLik, nobs, formula, terms, model.frame, model.matrix, predict, fitted, update, plot). The list also contains coef and var (log omega+ ratios and their covariance matrix on the reported scale), riskscore (mean-centered linear predictor), omegaplus and omega (per-subject predictions at t), omnibus, lunnmcneil (the stacked-model fit), scaling, and the model terms, xlevels, contrasts, and model frame.

See Also

gcefg, gcecif, lunnmcneil, gcemod-methods, gce_cutpoints

Examples

data(hn)
fit <- gcecox(Surv(time, status) ~ age + smoker + t_cat + n_cat + p16,
              data = hn)
fit
summary(fit)
confint(fit)

# risk score and predicted omega+ at 5 years for new subjects
predict(fit, newdata = hn[1:3, ], type = "lp")
predict(fit, newdata = hn[1:3, ], type = "ratio", times = 5)

# matrix interface
Ind <- data.frame(event = as.integer(hn$status == 1),
                  competing = as.integer(hn$status == 2))
gcecox(hn$time, Ind, hn[, c("age", "smoker", "p16")], t = 5)

gcemod documentation built on Dec. 1, 2026, 1:06 a.m.