Learn R Programming

mets (version 1.3.11)

survivalG: G-Estimator for Cox and Fine-Gray Models

Description

Computes the G-estimator (G-formula) for standardized survival or cumulative incidence estimates: $$ \hat S(t, A=a) = n^{-1} \sum_i \hat S(t, A=a, Z_i) $$

Usage

survivalG(
  x,
  data,
  time = NULL,
  Avalues = NULL,
  varname = NULL,
  same.data = TRUE,
  First = FALSE
)

Value

An object of class "survivalG" containing:

risk

Standardized risk estimates.

risk.iid

Influence functions for the risk estimates.

difference

Pairwise differences in risks.

ratio

Risk ratios.

survival.ratio

Survival ratios (for phreg).

survival.difference

Survival differences (for phreg).

Arguments

x

Object of class "phreg" or "cifreg".

data

Data frame for risk averaging. Must be part of the data used for fitting unless same.data=FALSE.

time

Time point for estimation.

Avalues

Values to compare for the first covariate \(A\).

varname

Name of the variable to be treated as the treatment/exposure variable (default is the first variable).

same.data

Logical; assumes the same data is used for fitting and averaging.

First

Logical; if TRUE, uses only the first record for G-averaging (useful for start-stop structures).

Author

Thomas Scheike

Details

Based on a phreg or cifreg object. Provides influence functions for these risk estimates, allowing for standard error computation.

If the first covariate is a factor, contrasts between all levels are computed automatically. If it is continuous, specific values must be provided via Avalues.

Examples

Run this code
data(bmt)
bmt$time <- bmt$time + runif(408) * 0.001
bmt$event <- (bmt$cause != 0) * 1
bmt$id <- 1:408
dfactor(bmt) <- tcell.f ~ tcell

# Fine-Gray model
fg1 <- cifreg(Event(time, cause) ~ tcell.f + platelet + age, bmt,
              cause = 1, cox.prep = TRUE, propodds = NULL)
summary(survivalG(fg1, bmt, 50))

 ## Reduce Ex.Timings
# Cox model
ss <- phreg(Surv(time, event) ~ tcell.f + platelet + age, bmt)
summary(survivalG(ss, bmt, 50))

# Stratified Cox model
ss <- phreg(Surv(time, event) ~ strata(tcell.f) + platelet + age, bmt)
summary(survivalG(ss, bmt, 50))

# Time-varying G-estimates
sst <- survivalGtime(ss, bmt, n = 50)
plot(sst)

# Among treated (specify id to link influence functions)
ss <- phreg(Surv(time, event) ~ tcell.f + platelet + age + cluster(id), bmt)
summary(survivalG(ss, subset(bmt, tcell == 1), 50))

Run the code above in your browser using DataLab