Skip to content

Commit

Permalink
update tests and snapshots (#49)
Browse files Browse the repository at this point in the history
* update tests and snapshots

* update word list

* fix typo

* update fda guidance link
  • Loading branch information
clarkliming authored Oct 23, 2024
1 parent 8db3037 commit aa7cf6e
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 27 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Authors@R:
)
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 depdendencies and validated to be used across industry.
This package is trimmed to reduce the dependencies and validated to be used across industry.
License: Apache License 2.0
URL: https://github.com/openpharma/RobinCar2/
BugReports: https://github.com/openpharma/RobinCar2/issues
Expand Down
6 changes: 3 additions & 3 deletions R/robin_glm.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ robin_glm <- function(
)
}
if (identical(contrast, "difference")) {
difference(pc)
difference(pc, variance = vcov, vcov_args = vcov_args)
} else if (identical(contrast, "risk_ratio")) {
risk_ratio(pc)
risk_ratio(pc, variance = vcov, vcov_args = vcov_args)
} else if (identical(contrast, "odds_ratio")) {
odds_ratio(pc)
odds_ratio(pc, variance = vcov, vcov_args = vcov_args)
} else {
assert_function(contrast)
assert_function(contrast_jac, null.ok = TRUE)
Expand Down
6 changes: 3 additions & 3 deletions R/treatment_effect.R
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,15 @@ treatment_effect.prediction_cf <- function(
#' @export
#' @inheritParams predict_counterfactual
treatment_effect.lm <- function(
object, pair, variance = gvcov, eff_measure, eff_jacobian,
object, pair, variance = "gvcov", eff_measure, eff_jacobian,
vcov_args = list(), treatment, data = find_data(object), ...) {
pc <- predict_counterfactual(object, data = data, treatment)
treatment_effect(pc, pair = pair, variance = variance, eff_measure = eff_measure, eff_jacobian = eff_jacobian, ...)
}

#' @export
treatment_effect.glm <- function(
object, pair, variance = gvcov, eff_measure, eff_jacobian,
object, pair, variance = "gvcov", eff_measure, eff_jacobian,
vcov_args = list(), treatment, data = find_data(object), ...) {
pc <- predict_counterfactual(object, treatment, data)
treatment_effect(pc, pair = pair, variance = variance, eff_measure = eff_measure, eff_jacobian = eff_jacobian, ...)
Expand Down Expand Up @@ -201,7 +201,7 @@ print.treatment_effect <- function(x, ...) {
),
nrow = length(x)
)
colnames(coef_mat) <- c("Estimate", "Std.Err", "Z Value", "Pr(>z)")
colnames(coef_mat) <- c("Estimate", "Std.Err", "Z Value", "Pr(>|z|)")
row.names(coef_mat) <- attr(x, "name")
stats::printCoefmat(
coef_mat,
Expand Down
2 changes: 1 addition & 1 deletion README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ knitr::opts_chunk$set(
\

RobinCar2 is a package to provide robust inference of covariate adjusted analysis under stratified randomization.
The methods implemented are recommended by [FDA guidance on covariate adjustment]().
The methods implemented are recommended by [FDA guidance on covariate adjustment](https://www.fda.gov/regulatory-information/search-fda-guidance-documents/adjusting-covariates-randomized-clinical-trials-drugs-and-biological-products).
The methods are based on the work of [Ye, Shao, Yi and Zhao (2023)](doi:10.1080/01621459.2022.2049278),
[Ye, Bannick, Yi and Shao (2023)](doi:10.1080/24754269.2023.2205802),
[Ye, Shao, Yi (2023)](doi:10.1093/biomet/asad045>) and
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ Coverage](https://raw.githubusercontent.com/openpharma/RobinCar2/_xml_coverage_r

RobinCar2 is a package to provide robust inference of covariate adjusted
analysis under stratified randomization. The methods implemented are
recommended by [FDA guidance on covariate adjustment](). The methods are
based on the work of [Ye, Shao, Yi and Zhao
recommended by [FDA guidance on covariate
adjustment](https://www.fda.gov/regulatory-information/search-fda-guidance-documents/adjusting-covariates-randomized-clinical-trials-drugs-and-biological-products).
The methods are based on the work of [Ye, Shao, Yi and Zhao
(2023)](doi:10.1080/01621459.2022.2049278), [Ye, Bannick, Yi and Shao
(2023)](doi:10.1080/24754269.2023.2205802), [Ye, Shao, Yi
(2023)](doi:10.1093/biomet/asad045%3E) and [Bannick, Shao, Liu, Du, Yi,
Expand Down
8 changes: 8 additions & 0 deletions inst/WORDLIST
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
ANHECOVA
INference
Liu
ORCID
Pocock
ROBust
RobinCar
Shao
Yi
Zhao
glm
jacobian
jacobians
Expand Down
34 changes: 17 additions & 17 deletions tests/testthat/_snaps/treatment_effect.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
pbo trt1 trt2
0.3560965 0.5806957 0.6213865
Variance Type: function
Estimate Std.Err Z Value Pr(>z)
trt1 - pbo 0.2246 0.0477 4.71 2.5e-06 ***
trt2 - pbo 0.2653 0.0475 5.58 2.4e-08 ***
trt2 - trt1 0.0407 0.0479 0.85 0.4
Variance Type: gvcov
Estimate Std.Err Z Value Pr(>|z|)
trt1 - pbo 0.2246 0.0477 4.71 2.5e-06 ***
trt2 - pbo 0.2653 0.0475 5.58 2.4e-08 ***
trt2 - trt1 0.0407 0.0479 0.85 0.4
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Expand All @@ -36,11 +36,11 @@
pbo trt1 trt2
0.2003208 0.7639709 0.9712499
Variance Type: function
Estimate Std.Err Z Value Pr(>z)
trt1 - pbo 0.564 0.101 5.60 2.2e-08 ***
trt2 - pbo 0.771 0.101 7.61 2.8e-14 ***
trt2 - trt1 0.207 0.107 1.94 0.052 .
Variance Type: gvcov
Estimate Std.Err Z Value Pr(>|z|)
trt1 - pbo 0.564 0.101 5.60 2.2e-08 ***
trt2 - pbo 0.771 0.101 7.61 2.8e-14 ***
trt2 - trt1 0.207 0.107 1.94 0.052 .
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Expand All @@ -61,10 +61,10 @@
0.3560965 0.5806957 0.6213865
Variance Type: none
Estimate Std.Err Z Value Pr(>z)
trt1 - pbo 0.2246 NA NA NA
trt2 - pbo 0.2653 NA NA NA
trt2 - trt1 0.0407 NA NA NA
Estimate Std.Err Z Value Pr(>|z|)
trt1 - pbo 0.2246 NA NA NA
trt2 - pbo 0.2653 NA NA NA
trt2 - trt1 0.0407 NA NA NA

# treatment_effect works if pair is integer

Expand All @@ -82,9 +82,9 @@
pbo trt1 trt2
0.3560965 0.5806957 0.6213865
Variance Type: function
Estimate Std.Err Z Value Pr(>z)
trt1 - pbo 0.2246 0.0477 4.71 2.5e-06 ***
Variance Type: gvcov
Estimate Std.Err Z Value Pr(>|z|)
trt1 - pbo 0.2246 0.0477 4.71 2.5e-06 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

0 comments on commit aa7cf6e

Please sign in to comment.