| Type: | Package | 
| Title: | 'surv' Object Confidence Bands Optimized by Area | 
| Version: | 0.2.2 | 
| Date: | 2023-03-29 | 
| Description: | Given a certain coverage level, obtains simultaneous confidence bands for the survival and cumulative hazard functions such that the area between is minimized. Produces an approximate solution based on local time arguments. | 
| Depends: | R (≥ 3.1.0) | 
| Imports: | utils, LambertW | 
| License: | GPL-2 | GPL-3 | 
| URL: | https://github.com/seasamgo/optband | 
| BugReports: | https://github.com/seasamgo/optband/issues | 
| RoxygenNote: | 7.1.1 | 
| Encoding: | UTF-8 | 
| Suggests: | stats, survival, km.ci, knitr, rmarkdown | 
| VignetteBuilder: | knitr, rmarkdown | 
| NeedsCompilation: | no | 
| Packaged: | 2023-03-30 16:29:32 UTC; tracys2 | 
| Author: | Sam Tracy [aut, cre], Tom Chen [aut] | 
| Maintainer: | Sam Tracy <seasamgo@gmail.com> | 
| Repository: | CRAN | 
| Date/Publication: | 2023-03-31 08:20:04 UTC | 
Variance of the cumulative-hazard function
Description
cumhaz.var estimates the cumulative-hazard function variance using Greenwood's
formula for a survfit object containing estimated survival curves.
Usage
cumhaz.var(survi)
Arguments
| survi | a  | 
Value
A numeric vector.
Examples
library(survival)
fit <- survfit(Surv(stop, event) ~ 1, data=bladder)
cumhaz.var(fit)
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))
Truncate survfit object
Description
modify.surv.fun truncates survfit by upper and lower bounds.
Usage
modify.surv.fun(survi, tl, tu)
Arguments
| survi | a  | 
| tl | the lower bound. | 
| tu | the upper bound. | 
Value
A truncated survfit object.
Examples
library(survival)
fit <- survfit(Surv(stop, event) ~ 1, data=bladder)
fit2 <- modify.surv.fun(fit, .1, .9)
Confidence bands optimized by area
Description
opt.ci obtains simultaneous confidence bands for the survival or
cumulative-hazard functions such that the area between is minimized.
Usage
opt.ci(survi, conf.level = 0.95, fun = "surv", tl = NA, tu = NA, samples = 1)
Arguments
| survi | a  | 
| conf.level | desired coverage level. | 
| fun | "surv" for survival function and "cumhaz" for the cumulative-hazard. function, with "surv" as the default. | 
| tl | a lower bound for truncation. | 
| tu | an upper bound for truncation. | 
| samples | the number of groups (1 or 2). | 
Details
Produces an approximate solution based on local time arguments.
Value
A survfit object with optimized confidence bands.
Examples
library(survival)
# fit and plot a Kaplan-Meier curve
fit <- survfit(Surv(stop, event) ~ 1, data=bladder)
plot(fit)
fit2 <- opt.ci(fit)
plot(fit2)
The psi function
Description
psi returns 
\psi(x)=\sqrt{-W_{-1}(-x^2)}
using the Lambert W function (see package LambertW).
Usage
psi(x)
Arguments
| x | a numeric value, possibly vectorized. | 
Value
A numeric value, possibly vectorized.
Examples
psi(.1)
Modified vector dot product
Description
riemsum returns a modified dot product described by two vectors.
Usage
riemsum(x, y)
Arguments
| x | a numeric 'width' vector. | 
| y | a numeric 'height' vector. | 
Value
A numeric value.
Examples
x <- 1:10
riemsum(x,x)
Evaluate whether times are in an interval
Description
surv.range evaluates survfit object survival times by upper and lower bounds.
Usage
surv.range(survi, tl, tu)
Arguments
| survi | a  | 
| tl | the lower bound. | 
| tu | the upper bound. | 
Value
A boolean vector.
Examples
library(survival)
fit <- survfit(Surv(stop, event) ~ 1, data=bladder)
summary(fit)
surv.range(fit, .1, .9)