Description Usage Arguments Details Author(s) Examples
Confidence intervals and confidence Bands for the predicted absolute risk (cumulative incidence function).
1 2 3 4 5 |
object |
A |
parm |
not used. For compatibility with the generic method. |
level |
[numeric, 0-1] Level of confidence. |
nsim.band |
[integer, >0]the number of simulations used to compute the quantiles for the confidence bands. |
meanRisk.transform |
[character] the transformation used to improve coverage
of the confidence intervals for the mean risk in small samples.
Can be |
diffRisk.transform |
[character] the transformation used to improve coverage
of the confidence intervals for the risk difference in small samples.
Can be |
ratioRisk.transform |
[character] the transformation used to improve coverage
of the confidence intervals for the risk ratio in small samples.
Can be |
seed |
[integer, >0] seed number set when performing simulation for the confidence bands. If not given or NA no seed is set. |
bootci.method |
[character] Method for constructing bootstrap confidence intervals. Either "perc" (the default), "norm", "basic", "stud", or "bca". |
... |
not used. |
Confidence bands and confidence intervals computed via the influence function
are automatically restricted to the interval [0;1].
Confidence intervals obtained via bootstrap are computed
using the boot.ci
function of the boot
package.
p-value are obtained using test inversion method
(finding the smallest confidence level such that the interval contain the null hypothesis).
Brice Ozenne
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 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | library(survival)
library(data.table)
## ## generate data ####
set.seed(10)
d <- sampleData(70,outcome="survival")
d[, X1 := paste0("T",rbinom(.N, size = 2, prob = c(0.51)))]
## table(d$X1)
#### stratified Cox model ####
fit <- coxph(Surv(time,event)~X1 + strata(X2) + X6,
data=d, ties="breslow", x = TRUE, y = TRUE)
#### average treatment effect ####
fit.ate <- ate(fit, treatment = "X1", times = 1:3, data = d,
se = TRUE, iid = TRUE, band = TRUE)
print(fit.ate, type = "meanRisk")
## manual calculation of se
dd <- copy(d)
dd$X1 <- rep(factor("T0", levels = paste0("T",0:2)), NROW(dd))
out <- predictCox(fit, newdata = dd, se = TRUE, times = 1:3, average.iid = TRUE)
term1 <- -out$survival.average.iid
term2 <- sweep(1-out$survival, MARGIN = 2, FUN = "-", STATS = colMeans(1-out$survival))
sqrt(colSums((term1 + term2/NROW(d))^2))
## note
out2 <- predictCox(fit, newdata = dd, se = TRUE, times = 1:3, iid = TRUE)
mean(out2$survival.iid[,1,1])
out$survival.average.iid[1,1]
## check confidence intervals (no transformation)
fit.ate$meanRisk[, .(lower = meanRisk + qnorm(0.025) * meanRisk.se,
upper = meanRisk + qnorm(0.975) * meanRisk.se)]
## add confidence intervals computed on the log-log scale
## and backtransformed
outCI <- confint(fit.ate,
meanRisk.transform = "loglog", diffRisk.transform = "atanh",
ratioRisk.transform = "log")
print(outCI, type = "meanRisk")
newse <- fit.ate$meanRisk[, meanRisk.se/(meanRisk*log(meanRisk))]
fit.ate$meanRisk[, .(lower = exp(-exp(log(-log(meanRisk)) - 1.96 * newse)),
upper = exp(-exp(log(-log(meanRisk)) + 1.96 * newse)))]
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.