diff --git a/R/binary-helper.R b/R/binary-helper.R
index 4f5d729d..21eac20e 100644
--- a/R/binary-helper.R
+++ b/R/binary-helper.R
@@ -115,7 +115,7 @@ glm_makeup <- function(binobj, legend = "before matching", weighted = FALSE) {
n <- tapply(binobj$data$USUBJID, binobj$data$ARM, length)
n_event <- tapply(binobj$data$RESPONSE, binobj$data$ARM, sum)
} else {
- n <- tapply(binobj$data$weights, binobj$data$ARM, length)
+ n <- tapply(binobj$data$weights, binobj$data$ARM, sum)
n_event <- tapply(binobj$data$weights * binobj$data$RESPONSE, binobj$data$ARM, sum)
}
data.frame(
diff --git a/R/maic_anchored.R b/R/maic_anchored.R
index a7f48b1a..8919e5b5 100644
--- a/R/maic_anchored.R
+++ b/R/maic_anchored.R
@@ -485,8 +485,8 @@ maic_anchored_binary <- function(res,
# ~~~ Analysis table
# : set up proper link
glm_link <- switch(eff_measure,
- "RD" = poisson(link = "identity"),
- "RR" = poisson(link = "log"),
+ "RD" = binomial(link = "identity"),
+ "RR" = binomial(link = "log"),
"OR" = binomial(link = "logit")
)
res_template <- list(
diff --git a/R/maic_unanchored.R b/R/maic_unanchored.R
index 741b1b90..854521f8 100644
--- a/R/maic_unanchored.R
+++ b/R/maic_unanchored.R
@@ -355,8 +355,8 @@ maic_unanchored_binary <- function(res,
# ~~~ Analysis table
# : set up proper link
glm_link <- switch(eff_measure,
- "RD" = poisson(link = "identity"),
- "RR" = poisson(link = "log"),
+ "RD" = binomial(link = "identity"),
+ "RR" = binomial(link = "log"),
"OR" = binomial(link = "logit")
)
transform_estimate <- switch(eff_measure,
diff --git a/tests/testthat/_snaps/maic_anchored.md b/tests/testthat/_snaps/maic_anchored.md
index 5831d292..009fed7f 100644
--- a/tests/testthat/_snaps/maic_anchored.md
+++ b/tests/testthat/_snaps/maic_anchored.md
@@ -385,20 +385,20 @@
# maic_anchored for binary case gives the expected result
Code
- testout$descriptive$summary
+ testout_OR$descriptive$summary
Output
- trt_ind treatment type n events events_pct
- 1 C C IPD, before matching 500 338.0000 67.60000
- 2 A A IPD, before matching 500 390.0000 78.00000
- 3 C C IPD, after matching 500 131.2892 26.25784
- 4 A A IPD, after matching 500 142.8968 28.57935
- 5 C C AgD, external 320 120.0000 37.50000
- 6 B B AgD, external 480 280.0000 58.33333
+ trt_ind treatment type n events events_pct
+ 1 C C IPD, before matching 500.0000 338.0000 67.60000
+ 2 A A IPD, before matching 500.0000 390.0000 78.00000
+ 3 C C IPD, after matching 199.4265 131.2892 65.83339
+ 4 A A IPD, after matching 199.4265 142.8968 71.65386
+ 5 C C AgD, external 320.0000 120.0000 37.50000
+ 6 B B AgD, external 480.0000 280.0000 58.33333
---
Code
- testout$inferential$summary
+ testout_OR$inferential$summary
Output
case OR LCL UCL pval
1 AC 1.6993007 1.2809976 2.2541985 2.354448e-04
@@ -410,7 +410,7 @@
---
Code
- testout$inferential$fit
+ testout_OR$inferential$fit
Output
$model_before_ipd
@@ -524,20 +524,298 @@
---
Code
- testout2$descriptive$summary
+ testout_RR$descriptive$summary
Output
- trt_ind treatment type n events events_pct
- 1 C C IPD, before matching 500 338.0000 67.60000
- 2 A A IPD, before matching 500 390.0000 78.00000
- 3 C C IPD, after matching 500 131.2892 26.25784
- 4 A A IPD, after matching 500 142.8968 28.57935
- 5 C C AgD, external 320 120.0000 37.50000
- 6 B B AgD, external 480 280.0000 58.33333
+ trt_ind treatment type n events events_pct
+ 1 C C IPD, before matching 500.0000 338.0000 67.60000
+ 2 A A IPD, before matching 500.0000 390.0000 78.00000
+ 3 C C IPD, after matching 199.4265 131.2892 65.83339
+ 4 A A IPD, after matching 199.4265 142.8968 71.65386
+ 5 C C AgD, external 320.0000 120.0000 37.50000
+ 6 B B AgD, external 480.0000 280.0000 58.33333
---
Code
- testout2$inferential$summary
+ testout_RR$inferential$summary
+ Output
+ case RR LCL UCL pval
+ 1 AC 1.1538462 1.0688892 1.2455556 2.451956e-04
+ 2 adjusted_AC 1.0884122 0.9398949 1.2603975 2.577047e-01
+ 3 BC 1.5555555 1.3250564 1.8261510 6.678781e-08
+ 4 AB 0.7417582 0.6210074 0.8859883 9.832938e-04
+ 5 adjusted_AB 0.6996936 0.5630034 0.8695704 1.281101e-03
+
+---
+
+ Code
+ testout_RR$inferential$fit
+ Output
+ $model_before_ipd
+
+ Call: glm(formula = RESPONSE ~ ARM, family = glm_link, data = ipd)
+
+ Coefficients:
+ (Intercept) ARMA
+ -0.3916 0.1431
+
+ Degrees of Freedom: 999 Total (i.e. Null); 998 Residual
+ Null Deviance: 1170
+ Residual Deviance: 1157 AIC: 1161
+
+ $model_after_ipd
+
+ Call: glm(formula = RESPONSE ~ ARM, family = glm_link, data = ipd,
+ weights = weights)
+
+ Coefficients:
+ (Intercept) ARMA
+ -0.41804 0.08472
+
+ Degrees of Freedom: 999 Total (i.e. Null); 998 Residual
+ Null Deviance: 495.5
+ Residual Deviance: 493.9 AIC: 454.5
+
+ $model_agd
+
+ Call: glm(formula = RESPONSE ~ ARM, family = glm_link, data = pseudo_ipd)
+
+ Coefficients:
+ (Intercept) ARMB
+ -0.9808 0.4418
+
+ Degrees of Freedom: 799 Total (i.e. Null); 798 Residual
+ Null Deviance: 1109
+ Residual Deviance: 1075 AIC: 1079
+
+ $res_AC
+ $res_AC$est
+ [1] 1.088412
+
+ $res_AC$se
+ [1] 0.08181292
+
+ $res_AC$ci_l
+ [1] 0.9398949
+
+ $res_AC$ci_u
+ [1] 1.260397
+
+ $res_AC$pval
+ [1] 0.2577047
+
+
+ $res_AC_unadj
+ $res_AC_unadj$est
+ [1] 1.153846
+
+ $res_AC_unadj$se
+ [1] 0.04507631
+
+ $res_AC_unadj$ci_l
+ [1] 1.068889
+
+ $res_AC_unadj$ci_u
+ [1] 1.245556
+
+ $res_AC_unadj$pval
+ [1] 0.0002451956
+
+
+ $res_BC
+ $res_BC$est
+ [1] 1.555556
+
+ $res_BC$se
+ [1] 0.1279272
+
+ $res_BC$ci_l
+ [1] 1.325056
+
+ $res_BC$ci_u
+ [1] 1.826151
+
+ $res_BC$pval
+ [1] 6.678781e-08
+
+
+ $res_AB
+ result pvalue
+ "0.70[0.56; 0.87]" "0.001"
+
+ $res_AB_unadj
+ result pvalue
+ "0.74[0.62; 0.89]" "0.001"
+
+ $boot_res
+ NULL
+
+ $boot_res_AC
+ NULL
+
+ $boot_res_AB_mc
+ NULL
+
+ $boot_res_AB
+ NULL
+
+
+---
+
+ Code
+ testout_RD$descriptive$summary
+ Output
+ trt_ind treatment type n events events_pct
+ 1 C C IPD, before matching 500.0000 338.0000 67.60000
+ 2 A A IPD, before matching 500.0000 390.0000 78.00000
+ 3 C C IPD, after matching 199.4265 131.2892 65.83339
+ 4 A A IPD, after matching 199.4265 142.8968 71.65386
+ 5 C C AgD, external 320.0000 120.0000 37.50000
+ 6 B B AgD, external 480.0000 280.0000 58.33333
+
+---
+
+ Code
+ testout_RD$inferential$summary
+ Output
+ case RD LCL UCL pval
+ 1 AC 10.400000 4.921741 15.878259 1.985755e-04
+ 2 adjusted_AC 5.820475 -4.207825 15.848775 2.552989e-01
+ 3 BC 20.833333 13.934963 27.731704 3.235832e-09
+ 4 AB -10.433333 -19.242354 -1.624313 2.026711e-02
+ 5 adjusted_AB -15.012859 -27.184724 -2.840993 1.563044e-02
+
+---
+
+ Code
+ testout_RD$inferential$fit
+ Output
+ $model_before_ipd
+
+ Call: glm(formula = RESPONSE ~ ARM, family = glm_link, data = ipd)
+
+ Coefficients:
+ (Intercept) ARMA
+ 0.676 0.104
+
+ Degrees of Freedom: 999 Total (i.e. Null); 998 Residual
+ Null Deviance: 1170
+ Residual Deviance: 1157 AIC: 1161
+
+ $model_after_ipd
+
+ Call: glm(formula = RESPONSE ~ ARM, family = glm_link, data = ipd,
+ weights = weights)
+
+ Coefficients:
+ (Intercept) ARMA
+ 0.6583 0.0582
+
+ Degrees of Freedom: 999 Total (i.e. Null); 998 Residual
+ Null Deviance: 495.5
+ Residual Deviance: 493.9 AIC: 454.5
+
+ $model_agd
+
+ Call: glm(formula = RESPONSE ~ ARM, family = glm_link, data = pseudo_ipd)
+
+ Coefficients:
+ (Intercept) ARMB
+ 0.3750 0.2083
+
+ Degrees of Freedom: 799 Total (i.e. Null); 798 Residual
+ Null Deviance: 1109
+ Residual Deviance: 1075 AIC: 1079
+
+ $res_AC
+ $res_AC$est
+ [1] 5.820475
+
+ $res_AC$se
+ [1] 5.116574
+
+ $res_AC$ci_l
+ [1] -4.207825
+
+ $res_AC$ci_u
+ [1] 15.84877
+
+ $res_AC$pval
+ [1] 0.2552989
+
+
+ $res_AC_unadj
+ $res_AC_unadj$est
+ [1] 10.4
+
+ $res_AC_unadj$se
+ [1] 2.795081
+
+ $res_AC_unadj$ci_l
+ [1] 4.921741
+
+ $res_AC_unadj$ci_u
+ [1] 15.87826
+
+ $res_AC_unadj$pval
+ [1] 0.0001985755
+
+
+ $res_BC
+ $res_BC$est
+ [1] 20.83333
+
+ $res_BC$se
+ [1] 3.519641
+
+ $res_BC$ci_l
+ [1] 13.93496
+
+ $res_BC$ci_u
+ [1] 27.7317
+
+ $res_BC$pval
+ [1] 3.235832e-09
+
+
+ $res_AB
+ result pvalue
+ "-15.01[-27.18; -2.84]" "0.016"
+
+ $res_AB_unadj
+ result pvalue
+ "-10.43[-19.24; -1.62]" "0.020"
+
+ $boot_res
+ NULL
+
+ $boot_res_AC
+ NULL
+
+ $boot_res_AB_mc
+ NULL
+
+ $boot_res_AB
+ NULL
+
+
+---
+
+ Code
+ testout_boot_OR$descriptive$summary
+ Output
+ trt_ind treatment type n events events_pct
+ 1 C C IPD, before matching 500.0000 338.0000 67.60000
+ 2 A A IPD, before matching 500.0000 390.0000 78.00000
+ 3 C C IPD, after matching 199.4265 131.2892 65.83339
+ 4 A A IPD, after matching 199.4265 142.8968 71.65386
+ 5 C C AgD, external 320.0000 120.0000 37.50000
+ 6 B B AgD, external 480.0000 280.0000 58.33333
+
+---
+
+ Code
+ testout_boot_OR$inferential$summary
Output
case OR LCL UCL pval
1 AC 1.6993007 1.2809976 2.2541985 2.354448e-04
@@ -549,7 +827,7 @@
---
Code
- testout2$inferential$fit
+ testout_boot_OR$inferential$fit
Output
$model_before_ipd
diff --git a/tests/testthat/_snaps/maic_unanchored.md b/tests/testthat/_snaps/maic_unanchored.md
index 2dcbc7b5..490a4819 100644
--- a/tests/testthat/_snaps/maic_unanchored.md
+++ b/tests/testthat/_snaps/maic_unanchored.md
@@ -1,27 +1,27 @@
# test binary case
Code
- testout$descriptive$summary
+ testout_RR$descriptive$summary
Output
- trt_ind treatment type n events events_pct
- 1 B B Before matching 400 280.0000 70.00000
- 2 A A Before matching 500 390.0000 78.00000
- 3 B B After matching 400 280.0000 70.00000
- 4 A A After matching 500 142.8968 28.57935
+ trt_ind treatment type n events events_pct
+ 1 B B Before matching 400.0000 280.0000 70.00000
+ 2 A A Before matching 500.0000 390.0000 78.00000
+ 3 B B After matching 400.0000 280.0000 70.00000
+ 4 A A After matching 199.4265 142.8968 71.65386
---
Code
- testout$inferential$summary
+ testout_RR$inferential$summary
Output
- case RR LCL UCL pval
- 1 AB 1.114286 0.9557015 1.299185 0.1671206
- 2 adjusted_AB 1.023627 0.9123647 1.148457 0.6908096
+ case RR LCL UCL pval
+ 1 AB 1.114286 1.0293724 1.206204 0.007455267
+ 2 adjusted_AB 1.023627 0.9123647 1.148457 0.690809607
---
Code
- testout$inferential$fit
+ testout_RR$inferential$fit
Output
$model_before
@@ -32,8 +32,8 @@
-0.3567 0.1082
Degrees of Freedom: 899 Total (i.e. Null); 898 Residual
- Null Deviance: 395.5
- Residual Deviance: 393.5 AIC: 1738
+ Null Deviance: 1023
+ Residual Deviance: 1016 AIC: 1020
$model_after
@@ -45,8 +45,8 @@
-0.35667 0.02335
Degrees of Freedom: 899 Total (i.e. Null); 898 Residual
- Null Deviance: 295.1
- Residual Deviance: 295 AIC: 1145
+ Null Deviance: 726.7
+ Residual Deviance: 726.5 AIC: 712.5
$res_AB
$res_AB$est
@@ -70,16 +70,198 @@
[1] 1.114286
$res_AB_unadj$se
- [1] 0.08768422
+ [1] 0.04511891
+
+ $res_AB_unadj$ci_l
+ [1] 1.029372
+
+ $res_AB_unadj$ci_u
+ [1] 1.206204
+
+ $res_AB_unadj$pval
+ [1] 0.007455267
+
+
+ $boot_res
+ NULL
+
+ $boot_res_AB
+ NULL
+
+
+---
+
+ Code
+ testout_RD$descriptive$summary
+ Output
+ trt_ind treatment type n events events_pct
+ 1 B B Before matching 400.0000 280.0000 70.00000
+ 2 A A Before matching 500.0000 390.0000 78.00000
+ 3 B B After matching 400.0000 280.0000 70.00000
+ 4 A A After matching 199.4265 142.8968 71.65386
+
+---
+
+ Code
+ testout_RD$inferential$summary
+ Output
+ case RD LCL UCL pval
+ 1 AB 8.000000 2.224920 13.775080 0.006626293
+ 2 adjusted_AB 1.653865 -6.532173 9.839902 0.692119096
+
+---
+
+ Code
+ testout_RD$inferential$fit
+ Output
+ $model_before
+
+ Call: glm(formula = RESPONSE ~ ARM, family = glm_link, data = dat)
+
+ Coefficients:
+ (Intercept) ARMA
+ 0.70 0.08
+
+ Degrees of Freedom: 899 Total (i.e. Null); 898 Residual
+ Null Deviance: 1023
+ Residual Deviance: 1016 AIC: 1020
+
+ $model_after
+
+ Call: glm(formula = RESPONSE ~ ARM, family = glm_link, data = dat,
+ weights = weights)
+
+ Coefficients:
+ (Intercept) ARMA
+ 0.70000 0.01654
+
+ Degrees of Freedom: 899 Total (i.e. Null); 898 Residual
+ Null Deviance: 726.7
+ Residual Deviance: 726.5 AIC: 712.5
+
+ $res_AB
+ $res_AB$est
+ [1] 1.653865
+
+ $res_AB$se
+ [1] 4.176627
+
+ $res_AB$ci_l
+ [1] -6.532173
+
+ $res_AB$ci_u
+ [1] 9.839902
+
+ $res_AB$pval
+ [1] 0.6921191
+
+
+ $res_AB_unadj
+ $res_AB_unadj$est
+ [1] 8
+
+ $res_AB_unadj$se
+ [1] 2.946523
+
+ $res_AB_unadj$ci_l
+ [1] 2.22492
+
+ $res_AB_unadj$ci_u
+ [1] 13.77508
+
+ $res_AB_unadj$pval
+ [1] 0.006626293
+
+
+ $boot_res
+ NULL
+
+ $boot_res_AB
+ NULL
+
+
+---
+
+ Code
+ testout_OR$descriptive$summary
+ Output
+ trt_ind treatment type n events events_pct
+ 1 B B Before matching 400.0000 280.0000 70.00000
+ 2 A A Before matching 500.0000 390.0000 78.00000
+ 3 B B After matching 400.0000 280.0000 70.00000
+ 4 A A After matching 199.4265 142.8968 71.65386
+
+---
+
+ Code
+ testout_OR$inferential$summary
+ Output
+ case OR LCL UCL pval
+ 1 AB 1.519481 1.1247154 2.052805 0.006417064
+ 2 adjusted_AB 1.083350 0.7268601 1.614683 0.694183560
+
+---
+
+ Code
+ testout_OR$inferential$fit
+ Output
+ $model_before
+
+ Call: glm(formula = RESPONSE ~ ARM, family = glm_link, data = dat)
+
+ Coefficients:
+ (Intercept) ARMA
+ 0.8473 0.4184
+
+ Degrees of Freedom: 899 Total (i.e. Null); 898 Residual
+ Null Deviance: 1023
+ Residual Deviance: 1016 AIC: 1020
+
+ $model_after
+
+ Call: glm(formula = RESPONSE ~ ARM, family = glm_link, data = dat,
+ weights = weights)
+
+ Coefficients:
+ (Intercept) ARMA
+ 0.84730 0.08006
+
+ Degrees of Freedom: 899 Total (i.e. Null); 898 Residual
+ Null Deviance: 726.7
+ Residual Deviance: 726.5 AIC: 712.5
+
+ $res_AB
+ $res_AB$est
+ [1] 1.08335
+
+ $res_AB$se
+ [1] 0.2275624
+
+ $res_AB$ci_l
+ [1] 0.7268601
+
+ $res_AB$ci_u
+ [1] 1.614683
+
+ $res_AB$pval
+ [1] 0.6941836
+
+
+ $res_AB_unadj
+ $res_AB_unadj$est
+ [1] 1.519481
+
+ $res_AB_unadj$se
+ [1] 0.2373883
$res_AB_unadj$ci_l
- [1] 0.9557015
+ [1] 1.124715
$res_AB_unadj$ci_u
- [1] 1.299185
+ [1] 2.052805
$res_AB_unadj$pval
- [1] 0.1671206
+ [1] 0.006417064
$boot_res
@@ -92,20 +274,20 @@
---
Code
- testout2$descriptive
+ testout_boot_RR$descriptive
Output
$summary
- trt_ind treatment type n events events_pct
- 1 B B Before matching 400 280.0000 70.00000
- 2 A A Before matching 500 390.0000 78.00000
- 3 B B After matching 400 280.0000 70.00000
- 4 A A After matching 500 142.8968 28.57935
+ trt_ind treatment type n events events_pct
+ 1 B B Before matching 400.0000 280.0000 70.00000
+ 2 A A Before matching 500.0000 390.0000 78.00000
+ 3 B B After matching 400.0000 280.0000 70.00000
+ 4 A A After matching 199.4265 142.8968 71.65386
---
Code
- testout2$inferential$fit
+ print(testout_boot_RR$inferential$fit, digits = 5)
Output
$model_before
@@ -113,11 +295,11 @@
Coefficients:
(Intercept) ARMA
- -0.3567 0.1082
+ -0.35667 0.10821
Degrees of Freedom: 899 Total (i.e. Null); 898 Residual
- Null Deviance: 395.5
- Residual Deviance: 393.5 AIC: 1738
+ Null Deviance: 1023
+ Residual Deviance: 1015.6 AIC: 1019.6
$model_after
@@ -126,44 +308,44 @@
Coefficients:
(Intercept) ARMA
- -0.35667 0.02335
+ -0.356675 0.023352
Degrees of Freedom: 899 Total (i.e. Null); 898 Residual
- Null Deviance: 295.1
- Residual Deviance: 295 AIC: 1145
+ Null Deviance: 726.66
+ Residual Deviance: 726.48 AIC: 712.47
$res_AB
$res_AB$est
- [1] 1.023627
+ [1] 1.0236
$res_AB$se
- [1] 0.06025155
+ [1] 0.060252
$res_AB$ci_l
- [1] 0.9123647
+ [1] 0.91236
$res_AB$ci_u
- [1] 1.148457
+ [1] 1.1485
$res_AB$pval
- [1] 0.6908096
+ [1] 0.69081
$res_AB_unadj
$res_AB_unadj$est
- [1] 1.114286
+ [1] 1.1143
$res_AB_unadj$se
- [1] 0.08768422
+ [1] 0.045119
$res_AB_unadj$ci_l
- [1] 0.9557015
+ [1] 1.0294
$res_AB_unadj$ci_u
- [1] 1.299185
+ [1] 1.2062
$res_AB_unadj$pval
- [1] 0.1671206
+ [1] 0.0074553
$boot_res
@@ -177,22 +359,22 @@
Bootstrap Statistics :
- original bias std. error
- t1* 0.02335185 1.366708e-02 0.0538052765
- t2* 0.01056949 8.109601e-05 0.0005263733
+ original bias std. error
+ t1* 0.0233518 0.01366708 0.05380528
+ t2* 0.0030551 -0.00004315 0.00038235
$boot_res_AB
$boot_res_AB$est
- [1] 1.023627
+ [1] 1.0236
$boot_res_AB$se
[1] NA
$boot_res_AB$ci_l
- [1] 0.9086715
+ [1] 0.90867
$boot_res_AB$ci_u
- [1] 1.122032
+ [1] 1.122
$boot_res_AB$pval
[1] NA
@@ -202,11 +384,11 @@
---
Code
- testout2$inferential$summary
+ print(testout_boot_RR$inferential$summary, digits = 5)
Output
- case RR LCL UCL pval
- 1 AB 1.114286 0.9557015 1.299185 0.1671206
- 2 adjusted_AB 1.023627 0.9123647 1.148457 0.6908096
+ case RR LCL UCL pval
+ 1 AB 1.1143 1.02937 1.2062 0.0074553
+ 2 adjusted_AB 1.0236 0.91236 1.1485 0.6908096
# test time to event case
diff --git a/tests/testthat/_snaps/plot_km2/kmplot2-all.svg b/tests/testthat/_snaps/plot_km2/kmplot2-all.svg
index e291ea1b..0c60323a 100644
--- a/tests/testthat/_snaps/plot_km2/kmplot2-all.svg
+++ b/tests/testthat/_snaps/plot_km2/kmplot2-all.svg
@@ -25,7 +25,7 @@
-
+
@@ -678,16 +678,14 @@
Overall Survival
Treatment
-
-
++
+
-
+
-
++
C
A
A (weighted)
@@ -1476,13 +1474,10 @@
Overall Survival
Treatment
-
+
-
+
-
+
B
@@ -1498,7 +1493,7 @@
-
+
@@ -1673,9 +1668,8 @@
Overall Survival
Treatment
-
-
++
+
C
@@ -1744,11 +1738,8 @@
Overall Survival
Treatment
-
-
-
C (AgD)
C (IPD)
diff --git a/tests/testthat/_snaps/plot_km2/kmplot2-by-am.svg b/tests/testthat/_snaps/plot_km2/kmplot2-by-am.svg
index 8bfbb189..716dced2 100644
--- a/tests/testthat/_snaps/plot_km2/kmplot2-by-am.svg
+++ b/tests/testthat/_snaps/plot_km2/kmplot2-by-am.svg
@@ -25,791 +25,788 @@
-
+
-
-
+
+
-
-
-
-
-
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
+
+
+
+
+
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
+
-+
-+
-+
-+
-+
-+
-+
-+
++
++
++
++
++
++
++
++
+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
-
-0.00
-0.25
-0.50
-0.75
-1.00
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-0
-2
-4
-6
-8
-10
-12
-14
-16
-Time
+
+0.00
+0.25
+0.50
+0.75
+1.00
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+0
+2
+4
+6
+8
+10
+12
+14
+16
+Time
Overall Survival
-
-Treatment
-
-
-+
-
-
-+
-
-
-+
-B
-A
-A (weighted)
-Kaplan-Meier Curves
-(A vs B)
-Endpoint: Overall Survival
+
+Treatment
+
++
+
++
+
++
+B
+A
+A (weighted)
+Kaplan-Meier Curves
+(A vs B)
+Endpoint: Overall Survival
@@ -817,7 +814,7 @@
-
+
@@ -873,61 +870,58 @@
-
-
+
+
-
-
-
-
-
+
+
+
+
+
-
-0.00
-0.25
-0.50
-0.75
-1.00
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-0
-2
-4
-6
-8
-10
-12
-14
-Time
+
+0.00
+0.25
+0.50
+0.75
+1.00
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+0
+2
+4
+6
+8
+10
+12
+14
+Time
Overall Survival
-
-Treatment
-
-
-
-
-
-
-C (AgD)
-C (IPD)
-C (IPD,weighted)
-Kaplan-Meier Curves of Common Comparator
-C(IPD vs AgD Trial)
-Endpoint: Overall Survival
+
+Treatment
+
+
+
+C (AgD)
+C (IPD)
+C (IPD,weighted)
+Kaplan-Meier Curves of Common Comparator
+C(IPD vs AgD Trial)
+Endpoint: Overall Survival
diff --git a/tests/testthat/_snaps/plot_km2/kmplot2-by-trial.svg b/tests/testthat/_snaps/plot_km2/kmplot2-by-trial.svg
index 56183f1e..4588e30e 100644
--- a/tests/testthat/_snaps/plot_km2/kmplot2-by-trial.svg
+++ b/tests/testthat/_snaps/plot_km2/kmplot2-by-trial.svg
@@ -25,672 +25,670 @@
-
+
-
-
+
+
-
-
-
-
-
-
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
+
+
+
+
+
+
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
+
-+
-+
-+
-+
-+
-+
-+
-+
++
++
++
++
++
++
++
++
+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
-
-0.00
-0.25
-0.50
-0.75
-1.00
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-0
-2
-4
-6
-8
-10
-12
-14
-16
-Time
+
+0.00
+0.25
+0.50
+0.75
+1.00
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+0
+2
+4
+6
+8
+10
+12
+14
+16
+Time
Overall Survival
-
-Treatment
-
-
-
-
-+
-
-
-+
-
-
-C
-A
-A (weighted)
-C (weighted)
-Kaplan-Meier Curves
-(A vs C) in the IPD trial
-Endpoint: Overall Survival
+
+Treatment
+
++
+
++
+
++
+
++
+C
+A
+A (weighted)
+C (weighted)
+Kaplan-Meier Curves
+(A vs C) in the IPD trial
+Endpoint: Overall Survival
@@ -698,7 +696,7 @@
-
+
@@ -764,182 +762,181 @@
-
-
+
+
-
-
-
-
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
+
+
+
+
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
-
-0.00
-0.25
-0.50
-0.75
-1.00
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-0
-2
-4
-6
-8
-10
-12
-14
-16
-Time
+
+0.00
+0.25
+0.50
+0.75
+1.00
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+0
+2
+4
+6
+8
+10
+12
+14
+16
+Time
Overall Survival
-
-Treatment
-
-
-
-
-+
-C
-B
-Kaplan-Meier Curves
-(B vs C) in the AgD trial
-Endpoint: Overall Survival
+
+Treatment
+
++
+
++
+C
+B
+Kaplan-Meier Curves
+(B vs C) in the AgD trial
+Endpoint: Overall Survival
diff --git a/tests/testthat/_snaps/plot_km2/kmplot2-normalize-by-trial.svg b/tests/testthat/_snaps/plot_km2/kmplot2-normalize-by-trial.svg
index 2a350b6a..c0db2437 100644
--- a/tests/testthat/_snaps/plot_km2/kmplot2-normalize-by-trial.svg
+++ b/tests/testthat/_snaps/plot_km2/kmplot2-normalize-by-trial.svg
@@ -25,672 +25,670 @@
-
+
-
-
+
+
-
-
-
-
-
-
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
+
+
+
+
+
+
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
+
-+
-+
-+
-+
-+
-+
-+
-+
++
++
++
++
++
++
++
++
+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
-
-0.00
-0.25
-0.50
-0.75
-1.00
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-0
-2
-4
-6
-8
-10
-12
-14
-16
-Time
+
+0.00
+0.25
+0.50
+0.75
+1.00
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+0
+2
+4
+6
+8
+10
+12
+14
+16
+Time
Overall Survival
-
-Treatment
-
-
-
-
-+
-
-
-+
-
-
-C
-A
-A (weighted)
-C (weighted)
-Kaplan-Meier Curves
-(A vs C) in the IPD trial
-Endpoint: Overall Survival
+
+Treatment
+
++
+
++
+
++
+
++
+C
+A
+A (weighted)
+C (weighted)
+Kaplan-Meier Curves
+(A vs C) in the IPD trial
+Endpoint: Overall Survival
@@ -698,7 +696,7 @@
-
+
@@ -764,182 +762,181 @@
-
-
+
+
-
-
-
-
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
+
+
+
+
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
-
-0.00
-0.25
-0.50
-0.75
-1.00
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-0
-2
-4
-6
-8
-10
-12
-14
-16
-Time
+
+0.00
+0.25
+0.50
+0.75
+1.00
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+0
+2
+4
+6
+8
+10
+12
+14
+16
+Time
Overall Survival
-
-Treatment
-
-
-
-
-+
-C
-B
-Kaplan-Meier Curves
-(B vs C) in the AgD trial
-Endpoint: Overall Survival
+
+Treatment
+
++
+
++
+C
+B
+Kaplan-Meier Curves
+(B vs C) in the AgD trial
+Endpoint: Overall Survival
diff --git a/tests/testthat/test-maic_anchored.R b/tests/testthat/test-maic_anchored.R
index 42e3f0d7..9f35fdad 100644
--- a/tests/testthat/test-maic_anchored.R
+++ b/tests/testthat/test-maic_anchored.R
@@ -65,6 +65,7 @@ test_that("maic_anchored works for TTE", {
expect_snapshot(testout2$inferential$fit)
})
+
test_that("maic_anchored for binary case gives the expected result", {
data(centered_ipd_twt)
data(agd)
@@ -95,7 +96,7 @@ test_that("maic_anchored for binary case gives the expected result", {
)
# inferential result
- testout <- maic_anchored(
+ testout_OR <- maic_anchored(
weights_object = weighted_data,
ipd = adrs_twt,
pseudo_ipd = pseudo_adrs,
@@ -109,7 +110,36 @@ test_that("maic_anchored for binary case gives the expected result", {
eff_measure = "OR"
)
- testout2 <- maic_anchored(
+ testout_RR <- maic_anchored(
+ weights_object = weighted_data,
+ ipd = adrs_twt,
+ pseudo_ipd = pseudo_adrs,
+ trt_var_ipd = "ARM",
+ trt_var_agd = "ARM",
+ trt_ipd = "A",
+ trt_agd = "B",
+ trt_common = "C",
+ endpoint_name = "Binary Event",
+ endpoint_type = "binary",
+ eff_measure = "RR"
+ )
+
+ testout_RD <- maic_anchored(
+ weights_object = weighted_data,
+ ipd = adrs_twt,
+ pseudo_ipd = pseudo_adrs,
+ trt_var_ipd = "ARM",
+ trt_var_agd = "ARM",
+ trt_ipd = "A",
+ trt_agd = "B",
+ trt_common = "C",
+ endpoint_name = "Binary Event",
+ endpoint_type = "binary",
+ eff_measure = "RD"
+ )
+
+ # bootstrap
+ testout_boot_OR <- maic_anchored(
weights_object = weighted_data2,
ipd = adrs_twt,
pseudo_ipd = pseudo_adrs,
@@ -124,12 +154,20 @@ test_that("maic_anchored for binary case gives the expected result", {
)
# Compare robust outputs
- expect_snapshot(testout$descriptive$summary)
- expect_snapshot(testout$inferential$summary)
- expect_snapshot(testout$inferential$fit)
+ expect_snapshot(testout_OR$descriptive$summary)
+ expect_snapshot(testout_OR$inferential$summary)
+ expect_snapshot(testout_OR$inferential$fit)
+
+ expect_snapshot(testout_RR$descriptive$summary)
+ expect_snapshot(testout_RR$inferential$summary)
+ expect_snapshot(testout_RR$inferential$fit)
+
+ expect_snapshot(testout_RD$descriptive$summary)
+ expect_snapshot(testout_RD$inferential$summary)
+ expect_snapshot(testout_RD$inferential$fit)
# Compare bootstrap outputs
- expect_snapshot(testout2$descriptive$summary)
- expect_snapshot(testout2$inferential$summary)
- expect_snapshot(testout2$inferential$fit)
+ expect_snapshot(testout_boot_OR$descriptive$summary)
+ expect_snapshot(testout_boot_OR$inferential$summary)
+ expect_snapshot(testout_boot_OR$inferential$fit)
})
diff --git a/tests/testthat/test-maic_unanchored.R b/tests/testthat/test-maic_unanchored.R
index 0035c811..cc206fb8 100644
--- a/tests/testthat/test-maic_unanchored.R
+++ b/tests/testthat/test-maic_unanchored.R
@@ -27,7 +27,7 @@ test_that("test binary case", {
)
# unanchored binary MAIC, with CI based on sandwich estimator
- testout <-
+ testout_RR <-
maic_unanchored(
weights_object = weighted_data,
ipd = adrs_sat,
@@ -43,8 +43,42 @@ test_that("test binary case", {
binary_robust_cov_type = "HC3"
)
+ testout_RD <-
+ maic_unanchored(
+ weights_object = weighted_data,
+ ipd = adrs_sat,
+ pseudo_ipd = pseudo_adrs,
+ trt_ipd = "A",
+ trt_agd = "B",
+ trt_var_ipd = "ARM",
+ trt_var_agd = "ARM",
+ endpoint_type = "binary",
+ endpoint_name = "Binary Endpoint",
+ eff_measure = "RD",
+ # binary specific args
+ binary_robust_cov_type = "HC3"
+ )
+
+
+ testout_OR <-
+ maic_unanchored(
+ weights_object = weighted_data,
+ ipd = adrs_sat,
+ pseudo_ipd = pseudo_adrs,
+ trt_ipd = "A",
+ trt_agd = "B",
+ trt_var_ipd = "ARM",
+ trt_var_agd = "ARM",
+ endpoint_type = "binary",
+ endpoint_name = "Binary Endpoint",
+ eff_measure = "OR",
+ # binary specific args
+ binary_robust_cov_type = "HC3"
+ )
+
+
# unanchored binary MAIC, with bootstrapped CI
- testout2 <-
+ testout_boot_RR <-
maic_unanchored(
weights_object = weighted_data2,
ipd = adrs_sat,
@@ -62,14 +96,22 @@ test_that("test binary case", {
# Compare robust outputs
- expect_snapshot(testout$descriptive$summary)
- expect_snapshot(testout$inferential$summary)
- expect_snapshot(testout$inferential$fit)
+ expect_snapshot(testout_RR$descriptive$summary)
+ expect_snapshot(testout_RR$inferential$summary)
+ expect_snapshot(testout_RR$inferential$fit)
+
+ expect_snapshot(testout_RD$descriptive$summary)
+ expect_snapshot(testout_RD$inferential$summary)
+ expect_snapshot(testout_RD$inferential$fit)
+
+ expect_snapshot(testout_OR$descriptive$summary)
+ expect_snapshot(testout_OR$inferential$summary)
+ expect_snapshot(testout_OR$inferential$fit)
# Compare bootstrap outputs
- expect_snapshot(testout2$descriptive)
- expect_snapshot(testout2$inferential$fit)
- expect_snapshot(testout2$inferential$summary)
+ expect_snapshot(testout_boot_RR$descriptive)
+ expect_snapshot(testout_boot_RR$inferential$fit)
+ expect_snapshot(testout_boot_RR$inferential$summary)
})