DelayedHazFit: Hazard functions with single-crossing constraints

Description Usage Arguments Value Author(s) Examples

View source: R/DelayedHazFit.R

Description

This computes nonparametric estimates of discrete hazards from survival data in two treatment arms under the constraint that the two hazard functions can cross at most one time.

Usage

1
2
DelayedHazFit(times, events, trt, gamma = NULL, theta.fixed = NULL, 
max.times = 100, inner.iter = 50, final.iter = 1000, verbose = TRUE)

Arguments

times

vector of follow-up times

events

vector of event indicators

trt

vector of treatment arm assignment

gamma

value of the gamma parameter

theta.fixed

optional fixed value of theta. Estimated if not provided.

max.times

tbf

inner.iter

tbf

final.iter

tbf

verbose

tbf

Value

an object of class "surv.delay"

Author(s)

Nicholas Henderson

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
set.seed(5172)

### Generate simulated survival data
n <- 400
cens.time <- 8
X1 <- rweibull(n, shape=2.3, scale=7)
X2 <- rweibull(n, shape=.8, scale=10)
Y1 <- pmin(X1, cens.time)
Y2 <- pmin(X2, cens.time)
e1 <- as.numeric(X1 < cens.time)
e2 <- as.numeric(X2 < cens.time)

times <- c(Y1, Y2)  ## follow-up times
events <- c(e1, e2) ## event indicators
trt <- rep(c(0,1), each=n)  ## treatment arm assignment

dhz.obj <- DelayedHazFit(times, events, trt, max.times=50) 

plot(dhz.obj$times, dhz.obj$haz0, type="n")
ntimes <- length(dhz.obj$times)
for(k in 1:ntimes) {
  if(dhz.obj$haz0[k] > dhz.obj$haz1[k]) {
     lines(c(dhz.obj$times[k], dhz.obj$times[k]), c(0, dhz.obj$haz0[k]), lwd=2)
     lines(c(dhz.obj$times[k], dhz.obj$times[k]), c(0, dhz.obj$haz1[k]), col="red", lwd=2)
  } else {
     lines(c(dhz.obj$times[k], dhz.obj$times[k]), c(0, dhz.obj$haz1[k]), col="red", lwd=2)
     lines(c(dhz.obj$times[k], dhz.obj$times[k]), c(0, dhz.obj$haz0[k]), lwd=2)
  }
}
abline(v=dhz.obj$theta, lwd=2, lty=2)

nchenderson/DelayedSurvFit documentation built on Jan. 21, 2021, 9:15 a.m.