| Title: | Robust Inference in Complex Innovative Trial Design |
|---|---|
| Description: | Perform robust estimation and inference in platform trials and other master protocol trials. Yuhan Qian, Yifan Yi, Jun Shao, Yanyao Yi, Gregory Levin, Nicole Mayer-Hamblett, Patrick J. Heagerty, Ting Ye (2025) <doi:10.48550/arXiv.2411.12944>. |
| Authors: | Yuhan Qian [aut, cre, cph], Ting Ye [aut], Yanyao Yi [aut], Marlena Bannick [aut] |
| Maintainer: | Yuhan Qian <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 1.0.0.9000 |
| Built: | 2026-06-02 09:19:13 UTC |
| Source: | https://github.com/eureeca/robincid |
RobinCID PackageRobinCID implements unbiased prediction and robust inference in R.
Maintainer: Yuhan Qian [email protected] [copyright holder]
Authors:
Ting Ye
Yanyao Yi
Marlena Bannick
Useful links:
Assign Probability according to Design
assign_prob_and_strata( data, estimand, design = list(randomization_var_colnames = NULL, randomization_table = NULL), method, estimated_propensity = TRUE, stratify_by = NULL )assign_prob_and_strata( data, estimand, design = list(randomization_var_colnames = NULL, randomization_table = NULL), method, estimated_propensity = TRUE, stratify_by = NULL )
data |
( |
estimand |
( |
design |
( |
method |
estimation method. |
estimated_propensity |
Whether to use estimated propensity score. |
stratify_by |
The column name of stratification variable in |
design has two elements: randomization_var_colnames (vector) and randomization_table (data.frame)
A new data with columns of the treatment assignment probability.
Compute Estimates and Covariance Matrix
estimate_effect( ret, y, treatment, treatments_for_compare, data, prob_mat, post_strata, stabilize )estimate_effect( ret, y, treatment, treatments_for_compare, data, prob_mat, post_strata, stabilize )
ret |
counterfactual prediction |
y |
Observed outcome |
treatment |
name of treatment |
treatments_for_compare |
description |
data |
( |
prob_mat |
( |
post_strata |
( |
stabilize |
( |
A list of "estimate_effect" object with following elements:
estimate: estimate of the treatment effect.
inner_variance: estimate of the covariance matrix.
method: estimation method.
This dataset is generated based on the first three enrollment windows outlined in Figure 1(a) in our paper.
exampleexample
A data frame with 500 rows and 17 columns:
The covariates.
The enrollment window and substudy assignment
The treatment assignment, "1", "2", "3" and "4"
The continuous response.
The binary response, I(y>3).
The stratification variables.
The assgiment probabilities of trt 1, 2, 3, and 4.
The data is generated by Yuhan.
Find Data in a Fit
find_data(fit, ...)find_data(fit, ...)
fit |
A fit object. |
... |
Additional arguments. |
A data frame used in the fit.
Contrast Functions and Jacobians
h_diff(x) h_jac_diff(x) h_ratio(x) h_jac_ratio(x) h_odds_ratio(x) h_jac_odds_ratio(x)h_diff(x) h_jac_diff(x) h_ratio(x) h_jac_ratio(x) h_odds_ratio(x) h_jac_odds_ratio(x)
x |
( |
Vector of contrasts, or matrix of jacobians.
h_diff(1:3) h_jac_ratio(1:3)h_diff(1:3) h_jac_ratio(1:3)
Obtain counterfactual prediction of a fit.
predict_counterfactual( fit.j, fit.k, treatment, treatments_for_compare, prob_mat, post_strata, data, stabilize, settings )predict_counterfactual( fit.j, fit.k, treatment, treatments_for_compare, prob_mat, post_strata, data, stabilize, settings )
fit.j |
fitted object for trt j. |
fit.k |
fitted object for trt k. |
treatment |
name of treatment column |
treatments_for_compare |
( |
prob_mat |
( |
post_strata |
( |
data |
( |
stabilize |
stabilize |
settings |
estimation setting |
A list of prediction_cf object with following elements:
estimation: = estimation,
sample_size: sample size of ECE population.
fit.j: fitted model for the treatment specified in tx_to_compare.
fit.k: fitted model for the treatment specified in tx_to_compare.
Provides robust inference via post stratification.
robin_ps( data, estimand = list(tx_colname = NULL, tx_to_compare = NULL), design = list(randomization_var_colnames = NULL, randomization_table = NULL), stratify_by = NULL, outcome_model = list(formula = NULL, family = gaussian()), contrast_specs = list(contrast = "difference", contrast_jac = NULL), alpha = 0.05, ... )robin_ps( data, estimand = list(tx_colname = NULL, tx_to_compare = NULL), design = list(randomization_var_colnames = NULL, randomization_table = NULL), stratify_by = NULL, outcome_model = list(formula = NULL, family = gaussian()), contrast_specs = list(contrast = "difference", contrast_jac = NULL), alpha = 0.05, ... )
data |
( |
estimand |
(
|
design |
(
|
stratify_by |
( |
outcome_model |
(
|
contrast_specs |
(
|
alpha |
( |
... |
Additional arguments passed to |
If family is MASS::negative.binomial(NA), the function will use MASS::glm.nb instead of glm.
A treatment_effect object.
data_sim <- RobinCID::example tx_colname <- "treatment" treatment_levels <- unique(data_sim[[tx_colname]]) tx_to_compare <- c("trt.1", "trt.3") randomization_var_colnames <- c("t", "subtype") df <- data_sim[c("xb", "xc", tx_colname, randomization_var_colnames, "y")] randomization_table <- unique(data_sim[c(randomization_var_colnames, treatment_levels)]) robin_ps( data = df, estimand = list(tx_colname = tx_colname, tx_to_compare = tx_to_compare), design = list(randomization_var_colnames = randomization_var_colnames, randomization_table = randomization_table), stratify_by = NULL, outcome_model = list(formula = y ~ 1, family = gaussian()) )data_sim <- RobinCID::example tx_colname <- "treatment" treatment_levels <- unique(data_sim[[tx_colname]]) tx_to_compare <- c("trt.1", "trt.3") randomization_var_colnames <- c("t", "subtype") df <- data_sim[c("xb", "xc", tx_colname, randomization_var_colnames, "y")] randomization_table <- unique(data_sim[c(randomization_var_colnames, treatment_levels)]) robin_ps( data = df, estimand = list(tx_colname = tx_colname, tx_to_compare = tx_to_compare), design = list(randomization_var_colnames = randomization_var_colnames, randomization_table = randomization_table), stratify_by = NULL, outcome_model = list(formula = y ~ 1, family = gaussian()) )
Provides robust inference via inverse probability weighting.
robin_wt( data, estimand = list(tx_colname = NULL, tx_to_compare = NULL), design = list(randomization_var_colnames = NULL, randomization_table = NULL), estimated_propensity = TRUE, outcome_model = list(formula = NULL, family = gaussian()), contrast_specs = list(contrast = "difference", contrast_jac = NULL), alpha = 0.05, ... )robin_wt( data, estimand = list(tx_colname = NULL, tx_to_compare = NULL), design = list(randomization_var_colnames = NULL, randomization_table = NULL), estimated_propensity = TRUE, outcome_model = list(formula = NULL, family = gaussian()), contrast_specs = list(contrast = "difference", contrast_jac = NULL), alpha = 0.05, ... )
data |
( |
estimand |
(
|
design |
(
|
estimated_propensity |
( |
outcome_model |
(
|
contrast_specs |
(
|
alpha |
( |
... |
Additional arguments passed to |
If randomization_table is provided, it must include columns corresponding to randomization_var_colnames,
as well as treatment assignment probability columns named after the treatment levels in tx_colname from data.
If family is MASS::negative.binomial(NA), the function will use MASS::glm.nb instead of glm.
A treatment_effect object.
data_sim <- RobinCID::example tx_colname <- "treatment" treatment_levels <- unique(data_sim[[tx_colname]]) tx_to_compare <- c("trt.1", "trt.3") randomization_var_colnames <- c("t", "subtype") df <- data_sim[c("xb", "xc", tx_colname, randomization_var_colnames, "y")] randomization_table <- unique(data_sim[c(randomization_var_colnames, treatment_levels)]) robin_wt( data = df, estimand = list(tx_colname = tx_colname, tx_to_compare = tx_to_compare), design = list(randomization_var_colnames = randomization_var_colnames, randomization_table = randomization_table), estimated_propensity = FALSE, outcome_model = list(formula = y ~ 1, family = gaussian()) )data_sim <- RobinCID::example tx_colname <- "treatment" treatment_levels <- unique(data_sim[[tx_colname]]) tx_to_compare <- c("trt.1", "trt.3") randomization_var_colnames <- c("t", "subtype") df <- data_sim[c("xb", "xc", tx_colname, randomization_var_colnames, "y")] randomization_table <- unique(data_sim[c(randomization_var_colnames, treatment_levels)]) robin_wt( data = df, estimand = list(tx_colname = tx_colname, tx_to_compare = tx_to_compare), design = list(randomization_var_colnames = randomization_var_colnames, randomization_table = randomization_table), estimated_propensity = FALSE, outcome_model = list(formula = y ~ 1, family = gaussian()) )
Obtain treatment effect and variance from counter-factual prediction
treatment_effect(object, pair, eff_measure, eff_jacobian, alpha, ...) difference(object, ...) risk_ratio(object, ...) odds_ratio(object, ...)treatment_effect(object, pair, eff_measure, eff_jacobian, alpha, ...) difference(object, ...) risk_ratio(object, ...) odds_ratio(object, ...)
object |
Object from which to obtain treatment effect. Must be obtained from |
pair |
( |
eff_measure |
( |
eff_jacobian |
( |
alpha |
Nominal level |
... |
Additional arguments passed to |
A list of treatment_effect object with following elements:
mm_name: name of the treatments to compare.
marginal_mean: estimate of the treatment effect.
mmvariance: estimate of the covariance matrix.
trt_effect: estimate of the contrast.
variance: estimate of the variance of contrast.
contrast: name of the contrast function.
settings: estimation settings.