| Type: | Package |
| Title: | ROBust INference for Covariate Adjustment in Randomized Clinical Trials |
| Version: | 0.1.1 |
| Date: | 2025-03-30 |
| 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>. |
| License: | Apache License 2.0 |
| URL: | https://github.com/openpharma/RobinCar2/ |
| BugReports: | https://github.com/openpharma/RobinCar2/issues |
| Depends: | R (≥ 3.6) |
| Imports: | checkmate, numDeriv, MASS, sandwich, stats, utils |
| Suggests: | knitr, rmarkdown, testthat (≥ 3.0) |
| VignetteBuilder: | knitr |
| Config/testthat/edition: | 3 |
| Encoding: | UTF-8 |
| Language: | en-US |
| LazyData: | true |
| RoxygenNote: | 7.3.2 |
| NeedsCompilation: | no |
| Packaged: | 2025-04-03 09:08:19 UTC; root |
| Author: | Liming Li |
| Maintainer: | Liming Li <liming.li1@astrazeneca.com> |
| Repository: | CRAN |
| Date/Publication: | 2025-04-03 16:10:02 UTC |
RobinCar2 Package
Description
RobinCar2 implements unbiased prediction and robust inference of variance of a fit in R.
Author(s)
Maintainer: Liming Li liming.li1@astrazeneca.com (ORCID)
Authors:
Marlena Bannick mnorwood@uw.edu (ORCID)
Dong Xi Dong.Xi1@gilead.com
Ting Ye tingye1@uw.edu
Yanyao Yi yi_yanyao@lilly.com
Other contributors:
Gregory Chen xiangyi.gregory.chen@msd.com [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]
The University of Washington [copyright holder, funder]
See Also
Useful links:
Report bugs at https://github.com/openpharma/RobinCar2/issues
Prediction Bias
Description
Obtain prediction bias within each stratum.
Usage
bias(residual, treatment, group_idx)
Arguments
residual |
( |
treatment |
( |
group_idx |
( |
Value
Numeric matrix of bias in each stratum.
Block Sum of a matrix
Description
Block Sum of a matrix
Usage
block_sum(x, n)
Dummy Trial Data with Permute-Block Randomization
Description
This dataset contains the dummy trial data with permute block randomization.
Usage
dummy_data
Format
A data frame with 600 rows and 7 columns:
- id
The ID of the patients.
- treatment
The treatment assignment, "pbo", "trt1" and "trt2"
- s1
The first stratification variable, "a" and "b".
- s2
The second stratification variable, "c" and "d".
- covar
The covariate following normal distribution.
- y
The continuous response.
- y_b
The binary response.
Source
The data is generated by the create_dummy.R script.
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.
Obtain Adjustment for Proportion of Treatment Assignment
Description
Obtain Adjustment for Proportion of Treatment Assignment
Usage
h_adjust_pi(pi)
Arguments
pi |
( |
Value
Numeric matrix.
Contrast Functions and Jacobians
Description
Contrast Functions and Jacobians
Create Contrast of Pairs
Usage
h_diff(x, y)
h_jac_diff(x, y)
h_ratio(x, y)
h_jac_ratio(x, y)
h_odds_ratio(x, y)
h_jac_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)
Arguments
x |
( |
y |
( |
f |
( |
levels |
( |
ref |
( |
Value
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
levelsandmax_levelsindicating the names of the treatment levels and the maximum number of levels.
Examples
h_diff(1:3, 4:6)
h_jac_ratio(1:3, 4:6)
Obtain Adjustment for Covariance Matrix
Description
Obtain Adjustment for Covariance Matrix
Usage
h_get_erb(resi, group_idx, trt, pi, randomization)
Arguments
resi |
( |
group_idx |
( |
trt |
( |
pi |
( |
randomization |
( |
Extract Variable Names
Description
Extract Variable Names
Usage
h_get_vars(treatment)
Arguments
treatment |
( |
Details
Extract the formula elements, including treatment, schema and strata.
Value
A list of three elements, treatment, schema and strata.
Obtain the Jacobian matrix
Description
Obtain the Jacobian matrix
Usage
jac_mat(jac, pair)
Counterfactual Prediction
Description
Obtain counterfactual prediction of a fit.
Usage
predict_counterfactual(fit, treatment, data, vcov, vcov_args, ...)
Arguments
fit |
fitted object. |
treatment |
( |
data |
( |
vcov |
( |
vcov_args |
( |
... |
Additional arguments for methods. |
Value
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.
S3 Methods for prediction_cf
Description
S3 Methods for prediction_cf
Usage
## S3 method for class 'prediction_cf'
print(x, level = 0.95, ...)
Arguments
x |
( |
level |
( |
Value
No return value.
Functions
-
print(prediction_cf): prints the prediction_cf object.
Randomization schema
Description
Randomization schema
Usage
randomization_schema
Format
An object of class data.frame with 3 rows and 2 columns.
Covariate adjusted glm model
Description
Covariate adjusted glm model
Usage
robin_glm(
formula,
data,
treatment,
contrast = "difference",
contrast_jac = NULL,
vcov = "vcovG",
family = gaussian(),
vcov_args = list(),
pair,
...
)
Arguments
formula |
( |
data |
( |
treatment |
( |
contrast |
( |
contrast_jac |
( |
vcov |
( |
family |
( |
vcov_args |
( |
pair |
Pairwise treatment comparison. |
... |
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
robin_glm(
y ~ treatment * s1,
data = dummy_data,
treatment = treatment ~ s1, contrast = "difference"
)
Covariate adjusted lm model
Description
Covariate adjusted lm model
Usage
robin_lm(
formula,
data,
treatment,
vcov = "vcovG",
vcov_args = list(),
pair,
...
)
Arguments
formula |
( |
data |
( |
treatment |
( |
vcov |
( |
vcov_args |
( |
pair |
Pairwise treatment comparison. |
... |
Additional arguments passed to |
Value
A treatment_effect object.
Examples
robin_lm(
y ~ treatment * s1,
data = dummy_data,
treatment = treatment ~ s1
)
Treatment Effect
Description
Obtain treatment effect and variance from counter-factual prediction
Usage
treatment_effect(
object,
pair = pairwise(names(object$estimate)),
eff_measure,
eff_jacobian = eff_jacob(eff_measure),
...
)
difference(object, ...)
risk_ratio(object, ...)
odds_ratio(object, ...)
Arguments
object |
Object from which to obtain treatment effect. |
pair |
( |
eff_measure |
( |
eff_jacobian |
( |
... |
Additional arguments for variance. |
Value
A list of treatment_effect object with following elements:
-
estimate: estimate of the treatment effect. -
pair:contrastobject indicating the pairwise treatment effect. -
contrast: name of the contrast function. -
euqal_val: the value for no treatment effect given the contrast. -
marginal_mean: theprediction_cfobject. -
fit: the fitted model. -
treatment: the treatment assignment. -
variance: the variance of the treatment effect. -
jacobian: the Jacobian matrix.
Update levels in a contrast pair
Description
Update levels in a contrast pair
Usage
update_levels(pair, levels)
ANHECOVA Covariance
Description
ANHECOVA Covariance
Usage
vcovG(x, decompose = TRUE, ...)
Arguments
x |
( |
decompose |
( |
... |
Not used. |
Value
Named covariance matrix.
Heteroskedasticity-consistent covariance matrix for predictions
Description
The heteroskedasticity-consistent covariance matrix for predictions
is obtained with sandwich::vocvHC using sandwich method.
Usage
vcovHC(x, type = "HC3", ...)
Arguments
x |
( |
type |
( |
... |
Additional arguments for |
Value
Matrix of the heteroskedasticity-consistent covariance for the predictions.