| Title: | Robust Inference in Complex Innovative Trial Design | 
| Version: | 1.0.0 | 
| 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>. | 
| License: | MIT + file LICENSE | 
| Encoding: | UTF-8 | 
| RoxygenNote: | 7.3.2 | 
| URL: | https://github.com/Eureeca/RobinCID | 
| BugReports: | https://github.com/Eureeca/RobinCID/issues | 
| Suggests: | testthat (≥ 3.0.0) | 
| Config/testthat/edition: | 3 | 
| Imports: | checkmate, numDeriv, stats, MASS | 
| Depends: | R (≥ 3.5) | 
| LazyData: | true | 
| NeedsCompilation: | no | 
| Packaged: | 2025-05-27 06:40:54 UTC; eureka | 
| Author: | Yuhan Qian [aut, cre, cph], Ting Ye [aut], Yanyao Yi [aut], Marlena Bannick [aut] | 
| Maintainer: | Yuhan Qian <yhqian@uw.edu> | 
| Repository: | CRAN | 
| Date/Publication: | 2025-05-29 08:50:13 UTC | 
RobinCID Package
Description
RobinCID implements unbiased prediction and robust inference in R.
Author(s)
Maintainer: Yuhan Qian yhqian@uw.edu [copyright holder]
Authors:
- Ting Ye 
- Yanyao Yi 
- Marlena Bannick 
See Also
Useful links:
Assign Probability according to Design
Description
Assign Probability according to Design
Usage
assign_prob_and_strata(
  data,
  estimand,
  design = list(randomization_var_colnames = NULL, randomization_table = NULL),
  method,
  estimated_propensity = TRUE,
  stratify_by = NULL
)
Arguments
| data | ( | 
| estimand | ( | 
| design | ( | 
| method | estimation method. | 
| estimated_propensity | Whether to use estimated propensity score. | 
| stratify_by | The column name of stratification variable in  | 
Details
design has two elements: randomization_var_colnames (vector) and randomization_table (data.frame)
Value
A new data with columns of the treatment assignment probability.
Compute Estimates and Covariance Matrix
Description
Compute Estimates and Covariance Matrix
Usage
estimate_effect(
  ret,
  y,
  treatment,
  treatments_for_compare,
  data,
  prob_mat,
  post_strata,
  stabilize
)
Arguments
| ret | counterfactual prediction | 
| y | Observed outcome | 
| treatment | name of treatment | 
| treatments_for_compare | description | 
| data | ( | 
| prob_mat | ( | 
| post_strata | ( | 
| stabilize | ( | 
Value
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.
Trial Data
Description
This dataset is generated based on the first three enrollment windows outlined in Figure 1(a) in our paper.
Usage
example
Format
A data frame with 500 rows and 17 columns:
- xc, xb, subtype
- The covariates. 
- t, substudy
- The enrollment window and substudy assignment 
- treatment
- The treatment assignment, "1", "2", "3" and "4" 
- y
- The continuous response. 
- y_b
- The binary response, I(y>3). 
- s12, s12.2, s12.error, s13, s14
- The stratification variables. 
- trt.1, trt.2, trt.3, trt.4
- The assgiment probabilities of trt 1, 2, 3, and 4. 
Source
The data is generated by Yuhan.
Find Data in a Fit
Description
Find Data in a Fit
Usage
find_data(fit, ...)
Arguments
| fit | A fit object. | 
| ... | Additional arguments. | 
Value
A data frame used in the fit.
Contrast Functions and Jacobians
Description
Contrast Functions and Jacobians
Usage
h_diff(x)
h_jac_diff(x)
h_ratio(x)
h_jac_ratio(x)
h_odds_ratio(x)
h_jac_odds_ratio(x)
Arguments
| x | ( | 
Value
Vector of contrasts, or matrix of jacobians.
Examples
h_diff(1:3)
h_jac_ratio(1:3)
Lower Triangular Index
Description
Lower Triangular Index
Usage
h_lower_tri_idx(n)
Arguments
| n | ( | 
Value
Matrix of lower triangular indices.
Counterfactual Prediction
Description
Obtain counterfactual prediction of a fit.
Usage
predict_counterfactual(
  fit.j,
  fit.k,
  treatment,
  treatments_for_compare,
  prob_mat,
  post_strata,
  data,
  stabilize,
  settings
)
Arguments
| 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 | 
Value
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.
S3 Methods for prediction_cf
Description
S3 Methods for prediction_cf
Usage
## S3 method for class 'prediction_cf'
print(x, ...)
Arguments
| x | ( | 
Value
No return value, called for side effects
Functions
-  print(prediction_cf): prints the prediction_cf object.
Post-Stratification Based Inference
Description
Provides robust inference via post stratification.
Usage
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,
  ...
)
Arguments
| data | ( | 
| estimand | ( 
 | 
| design | ( 
 | 
| stratify_by | ( | 
| outcome_model | ( 
 | 
| contrast_specs | ( 
 | 
| alpha | ( | 
| ... | Additional arguments passed to  | 
Details
If family is MASS::negative.binomial(NA), the function will use MASS::glm.nb instead of glm.
Value
A treatment_effect object.
Examples
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())
)
Inverse Probability Weighting Based Inference
Description
Provides robust inference via inverse probability weighting.
Usage
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,
  ...
)
Arguments
| data | ( | 
| estimand | ( 
 | 
| design | ( 
 | 
| estimated_propensity | ( | 
| outcome_model | ( 
 | 
| contrast_specs | ( 
 | 
| alpha | ( | 
| ... | Additional arguments passed to  | 
Details
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.
Value
A treatment_effect object.
Examples
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())
)
Treatment Effect
Description
Obtain treatment effect and variance from counter-factual prediction
Usage
treatment_effect(object, pair, eff_measure, eff_jacobian, alpha, ...)
difference(object, ...)
risk_ratio(object, ...)
odds_ratio(object, ...)
Arguments
| object | Object from which to obtain treatment effect. Must be obtained from  | 
| pair | ( | 
| eff_measure | ( | 
| eff_jacobian | ( | 
| alpha | Nominal level | 
| ... | Additional arguments passed to  | 
Value
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.