Learn R Programming

riskRegression (version 1.4.3)

ate: Compute the average treatment effect using CSC.

Description

Use the g-formula to estimate the average treatment effect

Usage

ate(object, data, treatment, contrasts = NULL, times, cause,
  conf.level = 0.95, se = TRUE, band = FALSE, B = 0, nSim.band = 1000,
  seed, handler = c("mclapply", "foreach"), mc.cores = 1, verbose = TRUE,
  logTransform = FALSE, store.iid = "full", ...)

Arguments

object

outcome model which describes how event risk depends on treatment and covariates. The object carry its own call and have a predictRisk method. See examples.

data

data set in which to evaluate risk predictions based on the outcome model

treatment

name of the treatment variable

contrasts

the levels of treatment variable to be compared

times

time points at which to evaluate risks

cause

the cause of interest

conf.level

Numeric. Confidence level of the confidence intervals.

se

Logical. If TRUE add the standard errors and confidence intervals to the output.

band

Logical. If TRUE add the confidence bands to the output.

B

the number of bootstrap replications used to compute the confidence intervals. If it equals 0, then Wald-type confidence intervals are computed. They rely on the standard error estimated using the influence function of the estimator.

nSim.band

the number of simulations used to compute the quantiles for the confidence bands.

seed

An integer used to generate seeds for bootstrap and to achieve reproducibility of the bootstrap confidence intervals.

handler

parallel handler for bootstrap. Either "mclapply" or "foreach". If "foreach" use doParallel to create a cluster.

mc.cores

Passed to parallel::mclapply or doParallel::registerDoParallel. The number of cores to use, i.e. at most how many child processes will be run simultaneously. The option is initialized from environment variable MC_CORES if set.

verbose

Logical. If TRUE inform about estimated run time.

logTransform

Should the confidence interval for the ratio be computed using a log-tranformation. Only active if Wald-type confidence intervals are computed.

store.iid

Implementation used to estimate the standard error. Can be "full" or "minimal". "minimal" requires less memory but can only estimate the standard for the difference between treatment effects (and not for the ratio).

...

passed to predictRisk

Value

A list with: point estimates, bootstrap quantile confidence intervals model: the CSC model (optional)

Details

WARNING: the p.value and the confidence intervals for the ratio using Wald-type approximations are still experimental.

Examples

Run this code
# NOT RUN {
library(survival)
library(rms)

set.seed(10)
n <- 100

## Cox model
dtS <- sampleData(n,outcome="survival")
dtS$time <- round(dtS$time,1)
dtS$X1 <- factor(rbinom(n, prob = c(0.3,0.4) , size = 2), labels = paste0("T",0:2))

fit=cph(formula = Surv(time,event)~ X1+X2,data=dtS,y=TRUE,x=TRUE)

# }
# NOT RUN {
ateFit1 <- ate(fit, data = dtS, treatment = "X1", contrasts = NULL,
        times = 5:8, B = 1e3, y = TRUE,  mc.cores=1)

ateFit1 <- ate(fit, data = dtS, treatment = "X1", contrasts = NULL,
        times = 5:8, B = 1e1, y = TRUE,  mc.cores=1)
ateFit2 <- ate(fit, data = dtS, treatment = "X1", contrasts = NULL,
        times = 5:8, B = 0, y = TRUE, band = TRUE, mc.cores=1)

ateFit3 <- ate(fit, data = dtS, treatment = "X1", contrasts = NULL,
           times = 5:8, B = 0, y = TRUE, band = TRUE, mc.cores=1,
           store.iid = "minimal")
# }
# NOT RUN {
## Competing risks: Cause specific Cox regression
# }
# NOT RUN {
set.seed(17)
n=100
dt <- sampleData(n,outcome="competing.risks")
dt$time <- round(dt$time,1)
dt$X1 <- factor(rbinom(n, prob = c(0.2,0.3,0.2) , size = 3), labels = paste0("T",0:3))
fitCR= CSC(Hist(time,event)~ X1+X8,data=dt,cause=1)
ate(fitCR, data = dt, treatment = "X1", contrasts = NULL,
        times = 7, cause = 1, B = 2, mc.cores=1)

atefit=ate(fitCR, data = dt, treatment = "X1", contrasts = NULL,
        times = 1:7, cause = 1, mc.cores=1, se = FALSE, band = FALSE)


 ate(fitCR, data = dt, treatment = "X1", contrasts = NULL,
        times = 5:7, cause = 1, B = 0, se = TRUE, band = TRUE, mc.cores=1)
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab