View source: R/sim-pc-hazard.R
rchaz | R Documentation |
Simulates data from piecwise constant baseline hazard that can also be of Cox type. Censor data at highest value of the break points.
rchaz( cumhazard, rr, n = NULL, entry = NULL, cum.hazard = TRUE, cause = 1, extend = FALSE )
cumhazard |
cumulative hazard, or piece-constant rates for periods defined by first column of input. |
rr |
relative risk for simulations, alternatively when rr=1 specify n |
n |
number of simulation if rr not given |
entry |
delayed entry time for simuations. |
cum.hazard |
specifies wheter input is cumulative hazard or rates. |
cause |
name of cause |
extend |
to extend piecewise constant with constant rate. Default is average rate over time from cumulative (when TRUE), if numeric then uses given rate. |
For a piecewise linear cumulative hazard the inverse is easy to compute with and delayed entry x we compute
Λ^{-1}(Λ(x) + E/RR)
, where RR are the relative risks and E is exponential with mean 1. This quantity has survival function
P(T > t | T>x) = exp(-RR (Λ(t) - Λ(x)))
.
Thomas Scheike
chaz <- c(0,1,1.5,2,2.1) breaks <- c(0,10, 20, 30, 40) cumhaz <- cbind(breaks,chaz) n <- 100 X <- rbinom(n,1,0.5) beta <- 0.2 rrcox <- exp(X * beta) pctime <- rchaz(cumhaz,n=1000,cum.hazard=FALSE) pctimecox <- rchaz(cumhaz,rrcox,cum.hazard=FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.