Description Usage Arguments Details Value Author(s) See Also Examples
Function to compute the number of individuals at risk at certain time points, as used in the Kaplan-Meier estimator for instance, depending on stratification.
1 | no.at.risk(formula.s, data.s, sub.s = "all", t.step, t.end)
|
formula.s |
formula composed of a |
data.s |
data frame composed of the variables used in the formula. |
sub.s |
vector of booleans specifying if only a subset of the data should be considered. |
t.step |
time step at which the number of individuals at risk is computed. |
t.end |
maximum time to be considered. |
The original version of this function was kindly provided by Dr Christos Hatzis (January, 17th 2006).
number of individuals at risk at each time step specified in t.step
up to t.end
.
Christos Hatzis, Benjamin Haibe-Kains
1 2 3 4 5 6 7 8 9 | set.seed(12345)
stime <- rexp(100)
cens <- runif(100,.5,2)
sevent <- as.numeric(stime <= cens)
stime <- pmin(stime, cens)
strat <- sample(1:3, 100, replace=TRUE)
dd <- data.frame("surv.time"=stime, "surv.event"=sevent, "strat"=strat)
no.at.risk(formula.s=Surv(surv.time,surv.event) ~ strat, data.s=dd,
sub.s="all", t.step=0.05, t.end=1)
|
Loading required package: survival
Loading required package: prodlim
risk.factor 0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 0.45 0.5 0.55 0.6
strat=1 strat=1 29 27 26 25 24 22 21 20 19 18 16 16 14
strat=2 strat=2 32 32 32 30 30 30 28 27 23 19 19 18 18
strat=3 strat=3 39 34 34 32 32 28 28 27 24 22 20 17 15
0.65 0.7 0.75 0.8 0.85 0.9 0.95 1
strat=1 13 11 11 8 8 8 8 6
strat=2 15 15 14 14 13 13 13 10
strat=3 13 13 12 11 11 9 9 9
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.