View source: R/DelayedHazFit.R
DelayedHazFit | R Documentation |
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.
DelayedHazFit(times, events, trt, gamma.fixed = NULL, theta.fixed = NULL,
weights=NULL, max.times = 100, inner.iter = 50, final.iter = 1000,
verbose = TRUE)
times |
vector of follow-up times |
events |
vector of event indicators: 1 for observed events, 0 for censored observations |
trt |
vector of treatment arm assignment: 1 for active treatment arm, 0 for control arm |
gamma.fixed |
optional fixed value of the superior long-term survival parameter: gamma.fixed = 1 means the active treatment arm has better long-term survival while gamma.fixed = -1 means the control arm has better long-term survival. This is estimated if not provided by the user. |
theta.fixed |
optional fixed value of theta. This is estimated if not provided by the user. |
weights |
optional vector of individual-level weights. This should be a vector with the same length as |
max.times |
The maximum number of bins to use for discretization of the follow-up times. |
inner.iter |
The number of iterations used to find the crossing time parameters. |
final.iter |
Given estimated crossing time parameter estimates, number of iterations used to find survival probabilities. |
verbose |
If |
an object of class surv.delay
This is a list withthe following components
times |
Vector of length m which has the unique, sorted follow-times after discretization. |
surv0 |
Vector of length m which contains estimated control arm survival probabilities at each of the time points in the vector |
surv1 |
Vector of length m which contains estimated active treatment arm survival probabilities at each of the time points in the vector |
haz0 |
Vector of length m which contains estimated control arm hazards at each of the time points in the vector |
haz1 |
Vector of length m which contains estimated active treatment arm hazards at each of the time points in the vector |
nevents0 |
Vector of length m which contains estimated control arm survival probabilities at each of the time points in the vector |
nrisk0 |
Vector of the number at risk in control arm |
nevents1 |
Vector of number of events in active treatment arm |
nrisk1 |
Vector of the number at risk in active treatment arm |
theta |
Estimated value of the survival curve crossing time |
gamma |
Estimated value of which arm has superior long-term survival |
discretized.times |
Vector of discretized follow-up times used in the computation |
negloglik.val |
Value of the negative log-likelihood at convergence |
Nicholas Henderson
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.