| 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 controlled trials. This package is trimmed to reduce the dependencies and validated to be used across industry. See "FDA's final guidance on covariate adjustment"<https://www.regulations.gov/docket/FDA-2019-D-0934>, Tsiatis (2008) <doi:10.1002/sim.3113>, Bugni et al. (2018) <doi:10.1080/01621459.2017.1375934>, Ye, Shao, Yi, and Zhao (2023)<doi:10.1080/01621459.2022.2049278>, Ye, Shao, and Yi (2022)<doi:10.1093/biomet/asab015>, Rosenblum and van der Laan (2010)<doi:10.2202/1557-4679.1138>, Wang et al. (2021)<doi:10.1080/01621459.2021.1981338>, Ye, Bannick, Yi, and Shao (2023)<doi:10.1080/24754269.2023.2205802>, and Bannick, Shao, Liu, Du, Yi, and Ye (2024)<doi:10.48550/arXiv.2306.10213>. |
| Authors: | Liming Li [aut, cre] (ORCID: <https://orcid.org/0009-0008-6870-0878>), Marlena Bannick [aut] (ORCID: <https://orcid.org/0000-0001-6279-5978>), Daniel Sabanes Bove [aut] (ORCID: <https://orcid.org/0000-0002-0176-9239>), Dong Xi [aut], Ting Ye [aut], Yanyao Yi [aut], Gregory Chen [ctb], Gilead Sciences, Inc. [cph, fnd], F. Hoffmann-La Roche AG [cph, fnd], Merck Sharp & Dohme, Inc. [cph, fnd], AstraZeneca plc [cph, fnd], Eli Lilly and Company [cph, fnd], Novartis Pharma AG [cph, fnd], The University of Washington [cph, fnd] |
| Maintainer: | Liming Li <[email protected]> |
| License: | Apache License 2.0 |
| Version: | 0.2.2.9000 |
| Built: | 2026-06-06 06:20:41 UTC |
| Source: | https://github.com/openpharma/robincar2 |
RobinCar2 PackageRobinCar2 implements unbiased prediction and robust inference of variance of a fit in R.
Maintainer: Liming Li [email protected] (ORCID)
Authors:
Marlena Bannick [email protected] (ORCID)
Daniel Sabanes Bove [email protected] (ORCID)
Dong Xi [email protected]
Ting Ye [email protected]
Yanyao Yi [email protected]
Other contributors:
Gregory Chen [email protected] [contributor]
Gilead Sciences, Inc. [copyright holder, funder]
F. Hoffmann-La Roche AG [copyright holder, funder]
Merck Sharp & Dohme, Inc. [copyright holder, funder]
AstraZeneca plc [copyright holder, funder]
Eli Lilly and Company [copyright holder, funder]
Novartis Pharma AG [copyright holder, funder]
The University of Washington [copyright holder, funder]
Useful links:
Report bugs at https://github.com/openpharma/RobinCar2/issues
Obtain the confidence interval for the marginal mean or the contrast.
## S3 method for class 'prediction_cf' confint(object, parm, level = 0.95, include_se = FALSE, ...) ## S3 method for class 'surv_effect' confint(object, parm, level = 0.95, transform, ...) ## S3 method for class 'treatment_effect' confint(object, parm, level = 0.95, transform, ...)## S3 method for class 'prediction_cf' confint(object, parm, level = 0.95, include_se = FALSE, ...) ## S3 method for class 'surv_effect' confint(object, parm, level = 0.95, transform, ...) ## S3 method for class 'treatment_effect' confint(object, parm, level = 0.95, transform, ...)
object |
Object to construct confidence interval. |
parm |
( |
level |
( |
include_se |
( |
... |
Not used. |
transform |
( |
A matrix of the confidence interval.
robin_res <- robin_glm( y_b ~ treatment * s1, data = glm_data, treatment = treatment ~ s1, contrast = "log_risk_ratio" ) confint(robin_res$marginal_mean, level = 0.7) confint(robin_res$contrast, parm = 1:3, level = 0.9)robin_res <- robin_glm( y_b ~ treatment * s1, data = glm_data, treatment = treatment ~ s1, contrast = "log_risk_ratio" ) confint(robin_res$marginal_mean, level = 0.7) confint(robin_res$contrast, parm = 1:3, level = 0.9)
Find Data in a Fit
find_data(fit, ...)find_data(fit, ...)
fit |
A fit object. |
... |
Additional arguments. |
A data frame used in the fit.
This dataset contains the trial example data for GLMs with permute block randomization.
glm_dataglm_data
A data frame with 600 rows and 7 columns:
The ID of the patients.
The treatment assignment, "pbo", "trt1" and "trt2"
The first stratification variable, "a" and "b".
The second stratification variable, "c" and "d".
The covariate following normal distribution.
The continuous response.
The binary response.
The data is generated by the create_glm_data.R script.
Contrast Functions and Jacobians
Create Contrast of Pairs
h_diff(x, y) h_jac_diff(x, y) h_risk_ratio(x, y) h_jac_risk_ratio(x, y) h_odds_ratio(x, y) h_jac_odds_ratio(x, y) h_log_risk_ratio(x, y) h_jac_log_risk_ratio(x, y) h_log_odds_ratio(x, y) h_jac_log_odds_ratio(x, y) eff_jacob(f) pairwise(levels, x = levels) against_ref(levels, ref = levels[1], x = tail(levels, -1)) custom_contrast(levels, x, y)h_diff(x, y) h_jac_diff(x, y) h_risk_ratio(x, y) h_jac_risk_ratio(x, y) h_odds_ratio(x, y) h_jac_odds_ratio(x, y) h_log_risk_ratio(x, y) h_jac_log_risk_ratio(x, y) h_log_odds_ratio(x, y) h_jac_log_odds_ratio(x, y) eff_jacob(f) pairwise(levels, x = levels) against_ref(levels, ref = levels[1], x = tail(levels, -1)) custom_contrast(levels, x, y)
x |
( |
y |
( |
f |
( |
levels |
( |
ref |
( |
Vector of contrasts, or matrix of jacobians.
A list of contrast object with following elements:
Index of the treatment group.
Index of the reference group.
Additional attributes include levels and max_levels indicating the
names of the treatment levels and the maximum number of levels.
h_diff(1:3, 4:6) h_jac_risk_ratio(1:3, 4:6)h_diff(1:3, 4:6) h_jac_risk_ratio(1:3, 4:6)
Obtain counterfactual prediction of a fit.
predict_counterfactual(fit, treatment, data, vcov, vcov_args, ...)predict_counterfactual(fit, treatment, data, vcov, vcov_args, ...)
fit |
fitted object. |
treatment |
( |
data |
( |
vcov |
( |
vcov_args |
( |
... |
Additional arguments for methods. |
List of class prediction_cf containing following elements:
estimate: predicted marginal mean.
residual: residual of the bias-corrected prediction.
predictions: all predicted values.
predictions_liner: linear predictions.
schema: randomization schema.
response: response value.
fit: fitted model.
model_matrix: model matrix.
treatment_formula: treatment assignment and randomization formula.
treatment: treatment value.
group_idx: group index based on the stratification.
variance: estimated variance of the marginal mean.
variance_name: name of the variance.
Covariate adjusted glm model
robin_glm( formula, data, treatment, contrast = c("difference", "risk_ratio", "odds_ratio", "log_risk_ratio", "log_odds_ratio"), contrast_jac = NULL, vcov = "vcovG", family = gaussian(), vcov_args = list(), pair, ... )robin_glm( formula, data, treatment, contrast = c("difference", "risk_ratio", "odds_ratio", "log_risk_ratio", "log_odds_ratio"), contrast_jac = NULL, vcov = "vcovG", family = gaussian(), vcov_args = list(), pair, ... )
formula |
( |
data |
( |
treatment |
( |
contrast |
( |
contrast_jac |
( |
vcov |
( |
family |
( |
vcov_args |
( |
pair |
Pairwise treatment comparison. |
... |
Additional arguments passed to |
If family is MASS::negative.binomial(NA), the function will use MASS::glm.nb instead of glm.
A robin_output object, with marginal_mean and contrast components.
robin_glm( y ~ treatment * s1, data = glm_data, treatment = treatment ~ s1, contrast = "difference" )robin_glm( y ~ treatment * s1, data = glm_data, treatment = treatment ~ s1, contrast = "difference" )
Covariate adjusted lm model
robin_lm( formula, data, treatment, vcov = "vcovG", vcov_args = list(), pair, ... )robin_lm( formula, data, treatment, vcov = "vcovG", vcov_args = list(), pair, ... )
formula |
( |
data |
( |
treatment |
( |
vcov |
( |
vcov_args |
( |
pair |
Pairwise treatment comparison. |
... |
Additional arguments passed to |
A robin_output object, with marginal_mean and contrast components.
robin_lm( y ~ treatment * s1, data = glm_data, treatment = treatment ~ s1 )robin_lm( y ~ treatment * s1, data = glm_data, treatment = treatment ~ s1 )
Calculate log-rank test as well as hazard ratio estimates for survival data, optionally adjusted for covariates and a stratification factor.
robin_surv( formula, data, treatment, comparisons, contrast = c("hazardratio", "none"), test = "logrank", ... )robin_surv( formula, data, treatment, comparisons, contrast = c("hazardratio", "none"), test = "logrank", ... )
formula |
( |
data |
( |
treatment |
( |
comparisons |
( |
contrast |
( |
test |
( |
... |
Additional arguments passed to the survival analysis functions, in particular |
The user can optionally specify a list of comparisons between treatment levels to be performed. The list must have two elements:
Treatment level indices of the treatment group.
Treatment level indices of the control group.
So for example if you would like to compare level 3 with level 1, and also level 3 with level 2
(but not level 2 with level 1) then you can specify:
comparisons = list(c(3, 3), c(1, 2))
A surv_effect object containing the results of the survival analysis.
surv_effect_methods for S3 methods.
# Adjusted for covariates meal.cal and age and adjusted for stratification by strata: robin_surv( formula = Surv(time, status) ~ meal.cal + age + strata(strata), data = surv_data, treatment = sex ~ pb(strata) ) # Adjusted for stratification by strata and ecog but not for covariates: robin_surv( formula = Surv(time, status) ~ 1 + strata(strata, ecog), data = surv_data, treatment = sex ~ sr(1) ) # Unadjusted for covariates and stratification: robin_surv( formula = Surv(time, status) ~ 1, data = surv_data, treatment = sex ~ sr(1) )# Adjusted for covariates meal.cal and age and adjusted for stratification by strata: robin_surv( formula = Surv(time, status) ~ meal.cal + age + strata(strata), data = surv_data, treatment = sex ~ pb(strata) ) # Adjusted for stratification by strata and ecog but not for covariates: robin_surv( formula = Surv(time, status) ~ 1 + strata(strata, ecog), data = surv_data, treatment = sex ~ sr(1) ) # Unadjusted for covariates and stratification: robin_surv( formula = Surv(time, status) ~ 1, data = surv_data, treatment = sex ~ sr(1) )
This dataset contains survival data from the survival
package's survival::lung dataset, modified to include factors for
sex and strata, as well as a binary status variable which is 1
for death and 0 for censored.
surv_datasurv_data
An object of class data.frame with 228 rows and 12 columns.
The data is generated by the create_surv_data.R script.
surv_effect
S3 Methods for surv_effect
## S3 method for class 'surv_effect' print(x, ...) table(x, ...) ## Default S3 method: table(x, ...) ## S3 method for class 'surv_effect' table(x, ...)## S3 method for class 'surv_effect' print(x, ...) table(x, ...) ## Default S3 method: table(x, ...) ## S3 method for class 'surv_effect' table(x, ...)
x |
( |
... |
ignored additional arguments (for compatibility). |
print(surv_effect): prints the surv_effect object.
table(surv_effect): prints and returns invisibly the events table of the surv_effect object.
x <- robin_surv( formula = Surv(time, status) ~ meal.cal + age + strata(strata), data = surv_data, treatment = sex ~ pb(strata) ) print(x) table(x)x <- robin_surv( formula = Surv(time, status) ~ meal.cal + age + strata(strata), data = surv_data, treatment = sex ~ pb(strata) ) print(x) table(x)
Obtain treatment effect and variance from counter-factual prediction
treatment_effect( object, pair = pairwise(names(object$estimate)), eff_measure, eff_jacobian = eff_jacob(eff_measure), contrast_name, ... ) difference(object, ...) risk_ratio(object, ...) odds_ratio(object, ...) log_risk_ratio(object, ...) log_odds_ratio(object, ...)treatment_effect( object, pair = pairwise(names(object$estimate)), eff_measure, eff_jacobian = eff_jacob(eff_measure), contrast_name, ... ) difference(object, ...) risk_ratio(object, ...) odds_ratio(object, ...) log_risk_ratio(object, ...) log_odds_ratio(object, ...)
object |
Object from which to obtain treatment effect. |
pair |
( |
eff_measure |
( |
eff_jacobian |
( |
contrast_name |
( |
... |
Additional arguments for variance. |
A list of treatment_effect object with following elements:
estimate: estimate of the treatment effect.
pair: contrast object indicating the pairwise treatment effect.
contrast: name of the contrast function.
euqal_val: the value for no treatment effect given the contrast.
variance: the variance of the treatment effect.
jacobian: the Jacobian matrix.
contrast_mat: contrast summary matrix.
Generalized Covariance (ANHECOVA)
vcovG(x, decompose = TRUE, ...)vcovG(x, decompose = TRUE, ...)
x |
( |
decompose |
( |
... |
Not used. |
Named covariance matrix.
The heteroskedasticity-consistent covariance matrix for predictions
is obtained with sandwich::vocvHC using sandwich method.
vcovHC(x, type = "HC3", ...)vcovHC(x, type = "HC3", ...)
x |
( |
type |
( |
... |
Additional arguments for |
Matrix of the heteroskedasticity-consistent covariance for the predictions.