@@ -46,52 +46,52 @@ ipd <- data.frame(
4646)
4747
4848# # General Tests ----
49- test_that(" IPD_stats () works for MAIC" , {
50- res <- IPD_stats (strategy_maic , ipd , ald , scale = " log_odds" )
49+ test_that(" calc_IPD_stats () works for MAIC" , {
50+ res <- calc_IPD_stats (strategy_maic , ipd , ald , scale = " log_odds" )
5151 expect_type(res $ mean , " double" )
5252 expect_type(res $ var , " double" )
5353})
5454
55- test_that(" IPD_stats () works for STC" , {
56- res <- IPD_stats (strategy_stc , ipd , ald , scale = " log_odds" )
55+ test_that(" calc_IPD_stats () works for STC" , {
56+ res <- calc_IPD_stats (strategy_stc , ipd , ald , scale = " log_odds" )
5757 expect_type(res $ mean , " double" )
5858 expect_type(res $ var , " double" )
5959})
6060
61- test_that(" IPD_stats () works for G-computation (ML)" , {
62- res <- IPD_stats (strategy_gcomp_ml , ipd , ald , scale = " log_odds" )
61+ test_that(" calc_IPD_stats () works for G-computation (ML)" , {
62+ res <- calc_IPD_stats (strategy_gcomp_ml , ipd , ald , scale = " log_odds" )
6363 expect_type(res $ mean , " double" )
6464 expect_type(res $ var , " double" )
6565})
6666
67- test_that(" IPD_stats () works for G-computation (Stan)" , {
68- res <- IPD_stats (strategy_gcomp_stan , ipd , ald , scale = " log_odds" )
67+ test_that(" calc_IPD_stats () works for G-computation (Stan)" , {
68+ res <- calc_IPD_stats (strategy_gcomp_stan , ipd , ald , scale = " log_odds" )
6969 expect_type(res $ mean , " double" )
7070 expect_type(res $ var , " double" )
7171})
7272
73- test_that(" IPD_stats () works for Multiple Imputation Marginalisation" , {
74- res <- IPD_stats (strategy_mim , ipd , ald , scale = " log_odds" )
73+ test_that(" calc_IPD_stats () works for Multiple Imputation Marginalisation" , {
74+ res <- calc_IPD_stats (strategy_mim , ipd , ald , scale = " log_odds" )
7575 expect_type(res $ mean , " double" )
7676 expect_type(res $ var , " double" )
7777})
7878
7979# # Edge Cases ----
80- test_that(" IPD_stats () handles NULL or empty inputs" , {
81- expect_error(IPD_stats (strategy_maic , NULL , ald , scale = " log_odds" ))
82- expect_error(IPD_stats (strategy_maic , ipd , NULL , scale = " log_odds" ))
83- expect_error(IPD_stats (strategy_maic , list (), ald , scale = " log_odds" ))
80+ test_that(" calc_IPD_stats () handles NULL or empty inputs" , {
81+ expect_error(calc_IPD_stats (strategy_maic , NULL , ald , scale = " log_odds" ))
82+ expect_error(calc_IPD_stats (strategy_maic , ipd , NULL , scale = " log_odds" ))
83+ expect_error(calc_IPD_stats (strategy_maic , list (), ald , scale = " log_odds" ))
8484})
8585
86- test_that(" IPD_stats () handles unexpected input types" , {
86+ test_that(" calc_IPD_stats () handles unexpected input types" , {
8787 ipd_wrong <- list (y = " 1" , trt = " A" )
8888 ald_wrong <- list (y.A.sum = " thirty" , N.A = " one hundred" )
8989
90- expect_error(IPD_stats (strategy_maic , ipd_wrong , ald , scale = " log_odds" ))
91- expect_error(IPD_stats (strategy_maic , ipd , ald_wrong , scale = " log_odds" ))
90+ expect_error(calc_IPD_stats (strategy_maic , ipd_wrong , ald , scale = " log_odds" ))
91+ expect_error(calc_IPD_stats (strategy_maic , ipd , ald_wrong , scale = " log_odds" ))
9292})
9393
94- test_that(" IPD_stats () handles extreme values" , {
94+ test_that(" calc_IPD_stats () handles extreme values" , {
9595 ipd_extreme <- data.frame (
9696 y = c(1 , 1 , 1 , 1 , 0 , 0 , 0 , 0 ),
9797 trt = c(" A" , " A" , " A" , " A" , " C" , " C" , " C" , " C" )
@@ -102,46 +102,46 @@ test_that("IPD_stats() handles extreme values", {
102102 y.C.sum = 100 , # All events
103103 N.C = 100
104104 )
105- res <- IPD_stats (strategy_maic , ipd_extreme , ald_extreme , scale = " log_odds" )
105+ res <- calc_IPD_stats (strategy_maic , ipd_extreme , ald_extreme , scale = " log_odds" )
106106 expect_type(res $ mean , " double" )
107107 expect_type(res $ var , " double" )
108108})
109109
110- test_that(" IPD_stats () handles unsupported strategies" , {
110+ test_that(" calc_IPD_stats () handles unsupported strategies" , {
111111 strategy_invalid <- list (class = " unsupported" )
112- expect_error(IPD_stats (strategy_invalid , ipd , ald , scale = " log_odds" ))
112+ expect_error(calc_IPD_stats (strategy_invalid , ipd , ald , scale = " log_odds" ))
113113})
114114
115- test_that(" IPD_stats () handles missing columns" , {
115+ test_that(" calc_IPD_stats () handles missing columns" , {
116116 ipd_missing <- data.frame (
117117 y = c(1 , 0 , 1 , 0 ),
118118 # trt column missing
119119 z = c(" A" , " A" , " C" , " C" )
120120 )
121- expect_error(IPD_stats (strategy_maic , ipd_missing , ald ))
121+ expect_error(calc_IPD_stats (strategy_maic , ipd_missing , ald ))
122122})
123123
124- test_that(" IPD_stats () handles different link functions" , {
124+ test_that(" calc_IPD_stats () handles different link functions" , {
125125 strategy_log <- list (class = " stc" , formula = y ~ trt , family = binomial(link = " log" ))
126126 strategy_identity <- list (class = " stc" , formula = y ~ trt , family = binomial(link = " identity" ))
127127
128- res_log <- IPD_stats (strategy_log , ipd , ald , scale = " log_odds" )
129- res_identity <- IPD_stats (strategy_identity , ipd , ald , scale = " log_odds" )
128+ res_log <- calc_IPD_stats (strategy_log , ipd , ald , scale = " log_odds" )
129+ res_identity <- calc_IPD_stats (strategy_identity , ipd , ald , scale = " log_odds" )
130130
131131 expect_type(res_log $ mean , " double" )
132132 expect_type(res_log $ var , " double" )
133133 expect_type(res_identity $ mean , " double" )
134134 expect_type(res_identity $ var , " double" )
135135})
136136
137- test_that(" IPD_stats () handles unsupported link functions" , {
137+ test_that(" calc_IPD_stats () handles unsupported link functions" , {
138138 strategy_unknown <- list (class = " stc" ,
139139 formula = y ~ trt ,
140140 family = list (link = " unknown" ))
141- expect_error(IPD_stats (strategy_unknown , ipd , ald , scale = " log_odds" ))
141+ expect_error(calc_IPD_stats (strategy_unknown , ipd , ald , scale = " log_odds" ))
142142})
143143
144- test_that(" IPD_stats () handles negative or NA values" , {
144+ test_that(" calc_IPD_stats () handles negative or NA values" , {
145145 ipd_negative <- data.frame (
146146 y = c(- 1 , 0 , 1 , 0 ),
147147 trt = c(" A" , " A" , " C" , " C" )
@@ -152,6 +152,6 @@ test_that("IPD_stats() handles negative or NA values", {
152152 y.C.sum = 20 ,
153153 N.C = 100
154154 )
155- expect_error(IPD_stats (strategy_maic , ipd_negative , ald , scale = " log_odds" ))
156- expect_error(IPD_stats (strategy_maic , ipd , ald_na , scale = " log_odds" ))
155+ expect_error(calc_IPD_stats (strategy_maic , ipd_negative , ald , scale = " log_odds" ))
156+ expect_error(calc_IPD_stats (strategy_maic , ipd , ald_na , scale = " log_odds" ))
157157})
0 commit comments