survfit_phregr: Survival Curve for Proportional Hazards Regression Models

View source: R/wrappers.R

survfit_phregrR Documentation

Survival Curve for Proportional Hazards Regression Models

Description

Obtains the predicted survivor function for a proportional hazards regression model.

Usage

survfit_phregr(
  fit_phregr,
  newdata,
  sefit = TRUE,
  conftype = "log-log",
  conflev = 0.95
)

Arguments

fit_phregr

The output from the phregr call.

newdata

A data frame with the same variable names as those that appear in the phregr call. For right-censored data, one curve is produced per row to represent a cohort whose covariates correspond to the values in newdata. For counting-process data, one curve is produced per id in newdata to present the survival curve along the path of time-dependent covariates at the observed event times in the data used to fit phregr.

sefit

Whether to compute the standard error of the survival estimates.

conftype

The type of the confidence interval. One of "none", "plain", "log", "log-log" (the default), or "arcsin". The arcsin option bases the intervals on asin(sqrt(surv)).

conflev

The level of the two-sided confidence interval for the survival probabilities. Defaults to 0.95.

Details

If newdata is not provided and there is no covariate, survival curves based on the basehaz data frame will be produced.

Value

A data frame with the following variables:

  • id: The id of the subject for counting-process data with time-dependent covariates.

  • time: The observed times in the data used to fit phregr.

  • nrisk: The number of patients at risk at the time point in the data used to fit phregr.

  • nevent: The number of patients having event at the time point in the data used to fit phregr.

  • cumhaz: The cumulative hazard at the time point.

  • surv: The estimated survival probability at the time point.

  • sesurv: The standard error of the estimated survival probability.

  • lower: The lower confidence limit for survival probability.

  • upper: The upper confidence limit for survival probability.

  • conflev: The level of the two-sided confidence interval.

  • conftype: The type of the confidence interval.

  • covariates: The values of covariates based on newdata.

  • stratum: The stratum of the subject.

Author(s)

Kaifeng Lu, kaifenglu@gmail.com

References

Terry M. Therneau and Patricia M. Grambsch. Modeling Survival Data: Extending the Cox Model. Springer-Verlag, 2000.

Examples


library(dplyr)

# Example 1 with right-censored data
fit1 <- phregr(data = rawdata %>% filter(iterationNumber == 1) %>%
                 mutate(treat = 1*(treatmentGroup == 1)),
               stratum = "stratum",
               time = "timeUnderObservation", event = "event",
               covariates = "treat")

surv1 <- survfit_phregr(fit1,
                        newdata = data.frame(
                          stratum = as.integer(c(1,1,2,2)),
                          treat = c(1,0,1,0)))

# Example 2 with counting process data and robust variance estimate
fit2 <- phregr(data = heart %>% mutate(rx = as.numeric(transplant) - 1),
               time = "start", time2 = "stop", event = "event",
               covariates = c("rx", "age"), id = "id", robust = TRUE)

surv2 <- survfit_phregr(fit2,
                        newdata = data.frame(
                          id = c(4,4,11,11),
                          age = c(-7.737,-7.737,-0.019,-0.019),
                          start = c(0,36,0,26),
                          stop = c(36,39,26,153),
                          rx = c(0,1,0,1)))


lrstat documentation built on Oct. 18, 2024, 9:06 a.m.