func.sum: Aggregate 'survfit' object strata

View source: R/package_functions.R

func.sumR Documentation

Aggregate survfit object strata

Description

func.sum calculates the sum and aggregate time points of two cumulative-hazard functions or their variances, designed for use with a survfit object having two strata.

Usage

func.sum(f1, f2, f1time, f2time)

Arguments

f1

vector of cumulative-hazard estimates.

f2

vector of cumulative-hazard estimates.

f1time

vector of survival times for f1.

f2time

vector of survival times for f2.

Value

A list of two numeric vectors.

Examples

library(survival)
res <- summary(survfit(Surv(stop, event) ~ rx, data=bladder))
cols <- lapply(c(2:11) , function(x) res[x])
tbl <- do.call(data.frame, cols)
category = unique(tbl$strata)
temptbl1 = tbl[tbl$strata == category[1],]; temptbl1$n = res$n[1]
temptbl2 = tbl[tbl$strata == category[2],]; temptbl2$n = res$n[2]
sigma1_2 = cumhaz.var(temptbl1)
sigma2_2 = cumhaz.var(temptbl2)
func.sum(c(0, sigma1_2)/temptbl1$n[1], c(0, sigma2_2)/temptbl2$n[2],
  c(0, temptbl1$time), c(0, temptbl2$time))


seasamgo/optband documentation built on April 23, 2023, 1:08 p.m.