Title: | Robust Inference for Covariate Adjustment in Randomized Clinical Trials |
---|---|
Description: | Performs robust estimation and inference when using covariate adjustment and/or covariate-adaptive randomization in randomized clinical trials. Ting Ye, Jun Shao, Yanyao Yi, Qinyuan Zhao (2023) <doi:10.1080/01621459.2022.2049278>. Ting Ye, Marlena Bannick, Yanyao Yi, Jun Shao (2023) <doi:10.1080/24754269.2023.2205802>. Ting Ye, Jun Shao, Yanyao Yi (2023) <doi:10.1093/biomet/asad045>. Marlena Bannick, Jun Shao, Jingyi Liu, Yu Du, Yanyao Yi, Ting Ye (2024) <doi:10.48550/arXiv.2306.10213>. |
Authors: | Marlena Bannick [cre, aut] , Ting Ye [aut], Yanyao Yi [aut], Faith Bian [aut] |
Maintainer: | Marlena Bannick <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.3.2 |
Built: | 2024-12-08 07:20:31 UTC |
Source: | CRAN |
Generate permuted block treatment assignments
car_pb(z, trt_label, trt_alc, blocksize = 4L)
car_pb(z, trt_label, trt_alc, blocksize = 4L)
z |
The car_strata design matrix, as a data frame with factor variables |
trt_label |
Treatment label |
trt_alc |
Treatment allocation vector |
blocksize |
Permuted block blocksize |
A vector of treatment assignments with labels from the 'trt_label' argument, based on stratified permuted block randomization.
# Create car_strata variables library(fastDummies) library(dplyr) x <- runif(100) z <- cut(x, breaks=c(0, 0.25, 0.5, 0.75, 1.0)) z <- dummy_cols(z) %>% mutate(across(where(is.numeric), as.factor)) car_pb(z[, 2:5], c(0, 1, 2), trt_alc=c(1/4, 1/2, 1/4), blocksize=4L)
# Create car_strata variables library(fastDummies) library(dplyr) x <- runif(100) z <- cut(x, breaks=c(0, 0.25, 0.5, 0.75, 1.0)) z <- dummy_cols(z) %>% mutate(across(where(is.numeric), as.factor)) car_pb(z[, 2:5], c(0, 1, 2), trt_alc=c(1/4, 1/2, 1/4), blocksize=4L)
Generate Pocock-Simon minimization treatment assignments
car_ps(z, treat, ratio, imb_measure, p_bc = 0.8)
car_ps(z, treat, ratio, imb_measure, p_bc = 0.8)
z |
The car_strata design matrix |
treat |
A vector of length k (the number of treatment arms), which labels the treatment arms being compared. |
ratio |
A vector of length k (the number of treatment arms), which indicates the allocation ratio, e.g., c(1,1,1) for equal allocation with three treatment arms. |
imb_measure |
What measure of imbalance should be minimzed during randomization – either "Range" or "SD" |
p_bc |
The biased probability, i.e., the probability of assigning each patient to the arm that minimizes the imbalance. Default is 0.8 |
treatment assignment vector
A vector of treatment assignments with labels from the ‘treat' argument, based on Pocock-Simon’s minimization.
Ting Ye Yanyao Yi
# Create car_strata variables library(fastDummies) library(dplyr) x <- runif(100) z <- cut(x, breaks=c(0, 0.25, 0.5, 0.75, 1.0)) z <- dummy_cols(z) A <- car_ps( z=z[, 2:5], treat=c(0, 1, 2), ratio=c(1, 1, 1), imb_measure="Range" )
# Create car_strata variables library(fastDummies) library(dplyr) x <- runif(100) z <- cut(x, breaks=c(0, 0.25, 0.5, 0.75, 1.0)) z <- dummy_cols(z) A <- car_ps( z=z[, 2:5], treat=c(0, 1, 2), ratio=c(1, 1, 1), imb_measure="Range" )
Generate simple randomization treatment assignments
car_sr(n, p_trt)
car_sr(n, p_trt)
n |
Number of observations |
p_trt |
Proportion allotted to treatment |
A vector of treatment assignments as 0's and 1's based on simple randomization.
car_sr(10, p_trt=0.4)
car_sr(10, p_trt=0.4)
Data generation function from JRSS-B paper
data_gen( n, theta, randomization, p_trt, case = c("case1", "case2", "case3", "case4", "case5") )
data_gen( n, theta, randomization, p_trt, case = c("case1", "case2", "case3", "case4", "case5") )
n |
total number of subjects to be generated |
theta |
true treatment effect |
randomization |
randomization method in c("SR","CABC","permuted_block","minimization","urn") |
p_trt |
proportion of treatment arm |
case |
simulation case in the paper |
A data frame with the following columns:
t |
event time |
delta |
event indicator |
I1 |
assignment to treatment group 1 |
I0 |
assignment to treatment group 0 |
model_z1 , model_z2
|
covariates |
car_strata1 , ...
|
strata variables |
Data generation function from covariate adjusted log-rank paper
data_gen2( n, theta, randomization, p_trt, case = c("case1", "case2", "case3", "case4"), blocksize = 4 )
data_gen2( n, theta, randomization, p_trt, case = c("case1", "case2", "case3", "case4"), blocksize = 4 )
n |
total number of subjects to be generated |
theta |
true treatment effect |
randomization |
randomization method in c("SR","CABC","permuted_block","minimization","urn") |
p_trt |
proportion of treatment arm |
case |
simulation case in the paper |
blocksize |
block size for permuted block design |
A data frame with the following columns:
t |
event time |
delta |
event indicator |
I1 |
assignment to treatment group 1 |
I0 |
assignment to treatment group 0 |
model_w3 |
covariates |
car_strata1 , ...
|
strata variables |
Print calibration result
## S3 method for class 'CalibrationResult' print(x, ...)
## S3 method for class 'CalibrationResult' print(x, ...)
x |
A GLMModel result. If you'd like to calibrate a linear adjustment, use 'robincar_glm' instead of 'robincar_linear'. |
... |
Additional arguments |
Prints the treatment mean estimates (and variances) based on a calibration on top of a GLM working model, along with the settings used. See RobinCar::robincar_calibrate().
Print contrast result
## S3 method for class 'ContrastResult' print(x, ...)
## S3 method for class 'ContrastResult' print(x, ...)
x |
A ContrastResult object |
... |
Additional arguments |
Prints estimates (and variances) of treatment contrasts based on a linear or GLM working model, along with the settings used. See RobinCar::robincar_contrast()
Print glm model result
## S3 method for class 'GLMModelResult' print(x, ...)
## S3 method for class 'GLMModelResult' print(x, ...)
x |
A GLMModelResult object |
... |
Additional arguments |
Prints the treatment mean estimates (and variances) based on a GLM working model, along with the settings used. See RobinCar::robincar_glm().
Print linear model result
## S3 method for class 'LinModelResult' print(x, ...)
## S3 method for class 'LinModelResult' print(x, ...)
x |
A LinModelResult object |
... |
Additional arguments |
Prints the treatment mean estimates (and variances) based on a linear working model, along with the settings used. See RobinCar::robincar_linear().
Print TTE result
## S3 method for class 'TTEResult' print(x, ...)
## S3 method for class 'TTEResult' print(x, ...)
x |
A TTEResult object |
... |
Additional arguments |
Prints results of time-to-event covariate adjusted analyses including covariate-adjusted (stratified) logrank, robust Cox score, and covariate-adjusted hazard ratio. Prints summary statistics about number of observations and events, possibly by strata, and the test statistics and/or estimates, and p-values. See RobinCar::robincar_tte() and RobinCar::robincar_covhr().
Uses linear or joint calibration to "calibrate" the estimates from a linear or GLM-type adjustment.
Linear calibration fits a linear model with treatment (and treatment-by-covariate interactions) and with the predicted as constructed covariates where
is the number of treatment groups;
joint calibration also includes
the strata variables as covariates.
robincar_calibrate(result, joint = FALSE, add_x = NULL)
robincar_calibrate(result, joint = FALSE, add_x = NULL)
result |
A GLMModelResult |
joint |
If true, then performs joint calibration
with the |
add_x |
Additional x to use in the calibration. Must have been in the original dataset that robincar_glm was called on. |
A result object that has the same structure as RobinCar::robincar_glm(), with the argument 'result' included as "original" in the list.
Estimate a treatment contrast using the result of RobinCar::robincar_linear(), RobinCar::robincar_glm(), or RobinCar::robincar_SL() using the delta method.
robincar_contrast(result, contrast_h, contrast_dh = NULL)
robincar_contrast(result, contrast_h, contrast_dh = NULL)
result |
A LinModelResult or GLMModelResult |
contrast_h |
An optional function to specify a desired contrast |
contrast_dh |
An optional jacobian function for the contrast |
A contrast object which has the following attributes:
result |
A dplyr::tibble() with the label of the treatment contrast (e.g., 1 vs. 0), the estimate of the treatment contrast, estimated SE, and p-value based on a z-test with estimate and SE. |
varcov |
The variance-covariance matrix for the treatment contrast estimates. |
settings |
List of model settings used for the contrast. |
Estimate a covariate-adjusted hazard ratio ('adj_method="CL"'), or a covariate-adjusted stratified hazard ratio ('adj_method="CSL"').
robincar_covhr( df, treat_col, response_col, event_col, car_strata_cols = NULL, covariate_cols = NULL, p_trt = 0.5, ref_arm = NULL, car_scheme = "simple", adj_method = "CL", interval = c(-10, 10) )
robincar_covhr( df, treat_col, response_col, event_col, car_strata_cols = NULL, covariate_cols = NULL, p_trt = 0.5, ref_arm = NULL, car_scheme = "simple", adj_method = "CL", interval = c(-10, 10) )
df |
A data.frame with the required columns |
treat_col |
Name of column in df with treatment variable |
response_col |
Name of the column in df with response variable |
event_col |
Name of column in df with event indicator (0/FALSE=no event, 1/TRUE=event) |
car_strata_cols |
Names of columns in df with car_strata variables |
covariate_cols |
Names of columns in df with covariate variables |
p_trt |
Treatment allocation ratio for the reference arm. |
ref_arm |
Reference arm of the treatment group, defaults to NULL, which results in using the first element of 'unique(data[, treat_col])'. |
car_scheme |
Name of the type of covariate-adaptive randomization scheme. One of: "simple", "pocock-simon", "biased-coin", "permuted-block". |
adj_method |
Adjustment method (one of "CL", "CSL") |
interval |
Interval for uniroot function |
An object with attribute named "result", which lists:
theta_L |
estimate of the hazard ratio |
se_theta_L |
SE estimate of the hazard ratio |
theta_CL |
estimate of the covariate-adjusted hazard ratio |
se_theta_CL |
SE estimate of the covariate-adjusted hazard ratio |
Other attributes are the settings used, data attributes, and the original data frame supplied by the user.
Robust cox score adjustment
robincar_coxscore(...)
robincar_coxscore(...)
... |
Arguments to robincar_tte, other than 'adj_method' |
A result object with the following attributes:
result |
A list: "statistic" is the robust Cox score test statistic which can be used to obtain p-values; "U" and "se" are the numerator and denominator of the test statistic, respectively. |
settings |
The covariate adjustment settings used. |
original_df |
The dataset supplied by the user. |
Estimate treatment-group-specific response means and (optionally) treatment group contrasts using a generalized linear working model.
robincar_glm( df, treat_col, response_col, formula = NULL, car_strata_cols = NULL, car_scheme = "simple", g_family = stats::gaussian, g_accuracy = 7, contrast_h = NULL, contrast_dh = NULL )
robincar_glm( df, treat_col, response_col, formula = NULL, car_strata_cols = NULL, car_scheme = "simple", g_family = stats::gaussian, g_accuracy = 7, contrast_h = NULL, contrast_dh = NULL )
df |
A data.frame with the required columns |
treat_col |
Name of column in df with treatment variable |
response_col |
Name of the column in df with response variable |
formula |
The formula to use for adjustment specified using as.formula("..."). This overrides car_strata_cols and covariate_cols. |
car_strata_cols |
Names of columns in df with car_strata variables |
car_scheme |
Name of the type of covariate-adaptive randomization scheme. One of: "simple", "pocock-simon", "biased-coin", "permuted-block". |
g_family |
Family that would be supplied to glm(...), e.g., binomial. If no link specified, will use default link, like behavior in glm. If you wish to use a negative binomial working model with an unknown dispersion parameter, then use 'g_family="nb"'. |
g_accuracy |
Level of accuracy to check prediction un-biasedness. |
contrast_h |
An optional function to specify a desired contrast |
contrast_dh |
An optional jacobian function for the contrast (otherwise use numerical derivative) |
The output is the AIPW estimator given by (for each treatment group ):
where is the outcome,
is the treatment assignment,
are the covariates,
,
and
is the estimated conditional mean function based on the GLM working model.
This working model has treatment
-specific coefficients if 'adj_method' is "heterogeneous". Otherwise, they are shared across the treatment arms.
Alternatively, if 'formula' is used, the working model can be specified according to the user.
Importantly, the estimated variance accounts for misspecification of the working model, and for covariate-adaptive randomization.
If 'contrast_h' argument is used, outputs a 'main' and a 'contrast' object. The 'main' object has the following structure:
result |
A dplyr::tibble() with the treatment label, treatment mean estimate using AIPW, estimated SE, and p-value based on a z-test with estimate and SE. |
varcov |
The variance-covariance matrix for the treatment mean estimates. |
settings |
List of model settings used in covariate adjustment. |
original_df |
The original dataset provided by the user. |
mod |
The fit from the glm() working model used for covariate adjustment. |
mu_a |
Predicted potential outcomes for each treatment category (columns) and individual (rows). These are the |
.
g.estimate |
The G-computation estimate based only on |
data |
Attributes about the dataset. |
The 'contrast' object has a structure that is documented in RobinCar::robincar_contrast().
Estimate treatment-group-specific response means and (optionally) treatment group contrasts using a linear working model for continuous outcomes.
robincar_linear( df, treat_col, response_col, car_strata_cols = NULL, covariate_cols = NULL, car_scheme = "simple", adj_method = "ANOVA", contrast_h = NULL, contrast_dh = NULL )
robincar_linear( df, treat_col, response_col, car_strata_cols = NULL, covariate_cols = NULL, car_scheme = "simple", adj_method = "ANOVA", contrast_h = NULL, contrast_dh = NULL )
df |
A data.frame with the required columns |
treat_col |
Name of column in df with treatment variable |
response_col |
Name of the column in df with response variable |
car_strata_cols |
Names of columns in df with car_strata variables |
covariate_cols |
Names of columns in df with covariate variables. **If you want to include the strata variables as covariates also, add them here.** |
car_scheme |
Name of the type of covariate-adaptive randomization scheme. One of: "simple", "pocock-simon", "biased-coin", "permuted-block". |
adj_method |
Name of linear adjustment method to use. One of: "ANOVA", "ANCOVA", "ANHECOVA". |
contrast_h |
An optional function to specify a desired contrast |
contrast_dh |
An optional jacobian function for the contrast (otherwise use numerical derivative) |
* Adjustment method "ANOVA" fits a linear model with formula 'Y ~ A' where 'A' is the treatment group indicator and 'Y' is the response. * "ANCOVA" fits a linear model with 'Y ~ A + X' where 'X' are the variables specified in the 'covariate_cols' argument. * "ANHECOVA" fits a linear model with 'Y ~ A*X', the main effects and treatment-by-covariate interactions.
See value of RobinCar::robincar_glm(), this function is a wrapper using a linear link function.
Perform a robust covariate-adjusted logrank test ("CL") that can be stratified ("CSL") if desired.
robincar_logrank(adj_method, ...)
robincar_logrank(adj_method, ...)
adj_method |
Adjustment method, one of "CL", "CSL" |
... |
Additional arguments to 'robincar_tte' |
A result object with the following attributes:
result |
A list: "statistic" is the adjusted logrank test statistic which can be used to obtain p-values; "U" and "se" are the numerator and denominator of the test statistic, respectively. |
settings |
The covariate adjustment settings used. |
original_df |
The dataset supplied by the user. |
library(magrittr) library(dplyr) library(forcats) set.seed(0) n=100 data.simu0=data_gen(n=n, theta=0, randomization="permuted_block", p_trt=0.5, case="case2") %>% mutate(strata1=sample(letters[1:3],n,replace=TRUE), strata2=sample(LETTERS[4:5],n,replace=TRUE)) out <- robincar_logrank(df=data.simu0, treat_col="I1", p_trt=0.5, ref_arm=0, response_col="t", event_col="delta", covariate_cols=c("model_z1", "model_z2"), car_scheme="simple", adj_method=c("CL")) set.seed(0) n=100 data.simu0=data_gen(n=n, theta=0, randomization="permuted_block", p_trt=0.5, case="case1") data.simu <- data.simu0 %>% tidyr::pivot_longer(cols=starts_with("car_strata"), names_prefix="car_strata", names_to="strt") %>% filter(value==1) %>% select(-value) %>% mutate(strt=forcats::as_factor(strt)) %>% select(t,strt) %>% left_join(data.simu0, .) out1 <- robincar_logrank(df=data.simu, treat_col="I1", p_trt=0.5, ref_arm=0, response_col="t", event_col="delta", car_strata_cols="strt", covariate_cols=NULL, car_scheme=c("permuted-block"), adj_method=c("CSL") )
library(magrittr) library(dplyr) library(forcats) set.seed(0) n=100 data.simu0=data_gen(n=n, theta=0, randomization="permuted_block", p_trt=0.5, case="case2") %>% mutate(strata1=sample(letters[1:3],n,replace=TRUE), strata2=sample(LETTERS[4:5],n,replace=TRUE)) out <- robincar_logrank(df=data.simu0, treat_col="I1", p_trt=0.5, ref_arm=0, response_col="t", event_col="delta", covariate_cols=c("model_z1", "model_z2"), car_scheme="simple", adj_method=c("CL")) set.seed(0) n=100 data.simu0=data_gen(n=n, theta=0, randomization="permuted_block", p_trt=0.5, case="case1") data.simu <- data.simu0 %>% tidyr::pivot_longer(cols=starts_with("car_strata"), names_prefix="car_strata", names_to="strt") %>% filter(value==1) %>% select(-value) %>% mutate(strt=forcats::as_factor(strt)) %>% select(t,strt) %>% left_join(data.simu0, .) out1 <- robincar_logrank(df=data.simu, treat_col="I1", p_trt=0.5, ref_arm=0, response_col="t", event_col="delta", car_strata_cols="strt", covariate_cols=NULL, car_scheme=c("permuted-block"), adj_method=c("CSL") )
Estimate treatment-group-specific response means and (optionally) treatment group contrasts using a generalized linear working model.
robincar_SL( df, treat_col, response_col, car_strata_cols = NULL, covariate_cols = NULL, car_scheme = "simple", covariate_to_include_strata = NULL, SL_libraries = c(), SL_learners = c(), k_split = 2, g_accuracy = 7, contrast_h = NULL, contrast_dh = NULL )
robincar_SL( df, treat_col, response_col, car_strata_cols = NULL, covariate_cols = NULL, car_scheme = "simple", covariate_to_include_strata = NULL, SL_libraries = c(), SL_learners = c(), k_split = 2, g_accuracy = 7, contrast_h = NULL, contrast_dh = NULL )
df |
A data.frame with the required columns |
treat_col |
Name of column in df with treatment variable |
response_col |
Name of the column in df with response variable |
car_strata_cols |
Names of columns in df with car_strata variables |
covariate_cols |
Names of columns in df with covariate variables |
car_scheme |
Name of the type of covariate-adaptive randomization scheme. One of: "simple", "pocock-simon", "biased-coin", "permuted-block". |
covariate_to_include_strata |
Whether to include car_strata variables in covariate adjustment. Defaults to F for ANOVA and ANCOVA; defaults to T for ANHECOVA. User may override by passing in this argument. |
SL_libraries |
Vector of super-learner libraries to use for the covariate adjustment (see SuperLearner::listWrappers) |
SL_learners |
Optional list of super-learner "learners" to use for the covariate adjustment (see SuperLearner::create.Learner()) |
k_split |
Number of splits to use in cross-fitting |
g_accuracy |
Level of accuracy to check prediction un-biasedness (in digits). |
contrast_h |
An optional function to specify a desired contrast |
contrast_dh |
An optional jacobian function for the contrast (otherwise use numerical derivative) |
*WARNING: This function is still under development and has not been extensively tested.* This function currently only works for two treatment groups. Before using this function, you must load the SuperLearner library with 'library(SuperLearner)', otherwise the function call will fail.
See value of RobinCar::robincar_glm, but the working model for is based on the AIPW::AIPW package that uses specified SuperLearner libraries and cross-fitting.
Also, 'mod' attribute is an object of class AIPW::AIPW.
library(SuperLearner) library(ranger) n <- 1000 set.seed(10) DATA2 <- data.frame(A=rbinom(n, size=1, prob=0.5), y=rbinom(n, size=1, prob=0.2), x1=rnorm(n), x2=rnorm(n), x3=as.factor(rbinom(n, size=1, prob=0.5)), z1=rbinom(n, size=1, prob=0.5), z2=rbinom(n, size=1, prob=0.5)) DATA2[, "y"] <- NA As <- DATA2$A == 1 DATA2[DATA2$A == 1, "y"] <- rbinom( sum(As), size=1, prob=exp(DATA2[As,]$x1)/(1+exp(DATA2[As,]$x1))) DATA2[DATA2$A == 0, "y"] <- rbinom( n-sum(As), size=1, prob=exp(1 + 5*DATA2[!As,]$x1 + DATA2[!As,]$x2)/ (1+exp(1 + 5*DATA2[!As,]$x1 + DATA2[!As,]$x2))) DATA2$A <- as.factor(DATA2$A) sl.mod <- robincar_SL( df=DATA2, response_col="y", treat_col="A", car_strata_cols=c("z1"), covariate_cols=c("x1"), SL_libraries=c("SL.ranger"), car_scheme="permuted-block", covariate_to_include_strata=TRUE ) sl.mod$result
library(SuperLearner) library(ranger) n <- 1000 set.seed(10) DATA2 <- data.frame(A=rbinom(n, size=1, prob=0.5), y=rbinom(n, size=1, prob=0.2), x1=rnorm(n), x2=rnorm(n), x3=as.factor(rbinom(n, size=1, prob=0.5)), z1=rbinom(n, size=1, prob=0.5), z2=rbinom(n, size=1, prob=0.5)) DATA2[, "y"] <- NA As <- DATA2$A == 1 DATA2[DATA2$A == 1, "y"] <- rbinom( sum(As), size=1, prob=exp(DATA2[As,]$x1)/(1+exp(DATA2[As,]$x1))) DATA2[DATA2$A == 0, "y"] <- rbinom( n-sum(As), size=1, prob=exp(1 + 5*DATA2[!As,]$x1 + DATA2[!As,]$x2)/ (1+exp(1 + 5*DATA2[!As,]$x1 + DATA2[!As,]$x2))) DATA2$A <- as.factor(DATA2$A) sl.mod <- robincar_SL( df=DATA2, response_col="y", treat_col="A", car_strata_cols=c("z1"), covariate_cols=c("x1"), SL_libraries=c("SL.ranger"), car_scheme="permuted-block", covariate_to_include_strata=TRUE ) sl.mod$result
Estimate treatment-group-specific response means and (optionally) treatment group contrasts using a generalized linear working model. Perform median adjustment to limit randomness induced from cross-fitting.
robincar_SL_median( n_times, seed, df, treat_col, response_col, car_strata_cols = NULL, covariate_cols = NULL, car_scheme = "simple", covariate_to_include_strata = NULL, SL_libraries = c(), SL_learners = c(), k_split = 2, g_accuracy = 7, contrast_h = NULL, contrast_dh = NULL )
robincar_SL_median( n_times, seed, df, treat_col, response_col, car_strata_cols = NULL, covariate_cols = NULL, car_scheme = "simple", covariate_to_include_strata = NULL, SL_libraries = c(), SL_learners = c(), k_split = 2, g_accuracy = 7, contrast_h = NULL, contrast_dh = NULL )
n_times |
Number of times to run the robincar_SL function |
seed |
Seed to set before running the set of functions |
df |
A data.frame with the required columns |
treat_col |
Name of column in df with treatment variable |
response_col |
Name of the column in df with response variable |
car_strata_cols |
Names of columns in df with car_strata variables |
covariate_cols |
Names of columns in df with covariate variables |
car_scheme |
Name of the type of covariate-adaptive randomization scheme. One of: "simple", "pocock-simon", "biased-coin", "permuted-block". |
covariate_to_include_strata |
Whether to include car_strata variables in covariate adjustment. Defaults to F for ANOVA and ANCOVA; defaults to T for ANHECOVA. User may override by passing in this argument. |
SL_libraries |
Vector of super-learner libraries to use for the covariate adjustment (see SuperLearner::listWrappers) |
SL_learners |
Optional list of super-learner "learners" to use for the covariate adjustment (see SuperLearner::create.Learner()) |
k_split |
Number of splits to use in cross-fitting |
g_accuracy |
Level of accuracy to check prediction un-biasedness (in digits). |
contrast_h |
An optional function to specify a desired contrast |
contrast_dh |
An optional jacobian function for the contrast (otherwise use numerical derivative) |
*WARNING: This function is still under development and has not been extensively tested.* This function currently only works for two treatment groups. Before using this function, you must load the SuperLearner library with 'library(SuperLearner)', otherwise the function call will fail.
See value of RobinCar::robincar_SL. Attributes 'mods' and 'mu_as' are lists of 'mod' and 'mu_a' attributes, respectively, for each replicate of 'robincar_SL' used in the median.
Perform a covariate-adjusted logrank test ('adj_method="CL"'), covariate-adjusted stratified logrank test ('adj_method="CSL"'), or a covariate-adjusted robust Cox score test ('adj_method="coxscore"').
robincar_tte( df, treat_col, response_col, event_col, adj_method, car_strata_cols = NULL, covariate_cols = NULL, p_trt = 0.5, ref_arm = NULL, sparse_remove = TRUE, car_scheme = "simple" )
robincar_tte( df, treat_col, response_col, event_col, adj_method, car_strata_cols = NULL, covariate_cols = NULL, p_trt = 0.5, ref_arm = NULL, sparse_remove = TRUE, car_scheme = "simple" )
df |
A data.frame with the required columns |
treat_col |
Name of column in df with treatment variable |
response_col |
Name of the column in df with response variable |
event_col |
Name of column in df with event indicator (0/FALSE=no event, 1/TRUE=event) |
adj_method |
Adjustment method (one of "CL", "CSL", or "coxscore") |
car_strata_cols |
Names of columns in df with car_strata variables |
covariate_cols |
Names of columns in df with covariate variables |
p_trt |
Treatment allocation ratio for the reference arm. |
ref_arm |
Reference arm of the treatment group, defaults to NULL, which results in using the first element of 'unique(data[, treat_col])'. |
sparse_remove |
Remove sparse car_strata from calculation |
car_scheme |
Name of the type of covariate-adaptive randomization scheme. One of: "simple", "pocock-simon", "biased-coin", "permuted-block". |
'robincar_coxscore' and 'robincar_logrank' are wrapper functions around 'robincar_tte'.
For adjustment method "CL" or "CSL", see value of RobinCar::robincar_logrank(); for adjustment method "coxscore" see value of RobinCar::robincar_coxscore().