@@ -27,19 +27,21 @@ test_that("populationHR works as expected for default parameters", {
2727 )
2828
2929 # Summary calculations are match expectations
30- summary_stats <- apply(result [[2 ]], 1 , function (x ) c(mean(x ), quantile(x , c(0.5 , 0.025 , 0.975 ))))
30+ summary_stats <- apply(result [[2 ]], 1 , function (x ) c(mean(x ), quantile(x , c(0.5 , 0.025 , 0.975 )))) | >
31+ t() | >
32+ as.data.frame()
3133 expect_equal(
32- unname(t( summary_stats ) ),
34+ unname(summary_stats ),
3335 unname(result [[1 ]])
3436 )
3537})
3638
3739test_that(" populationHR fails for bad input" , {
3840 mp <- test_data_1 $ jsamples
3941 expect_error(populationHR(object = mp @ data ), " inherit from class" )
40- expect_error(populationHR(object = mp , HR_formula = " arm" ), " formula" )
42+ expect_error(populationHR(object = mp , hr_formula = " arm" ), " formula" )
4143 expect_error(populationHR(object = mp , baseline = ~ arm ), " time term" )
42- expect_error(populationHR(object = mp , HR_formula = ~ XX ), " All variables" )
44+ expect_error(populationHR(object = mp , hr_formula = ~ XX ), " All variables" )
4345 expect_error(populationHR(object = mp , quantiles = c(- 0.3 , NA , 2 )), " quantiles" )
4446})
4547
@@ -51,7 +53,7 @@ test_that("populationHR works as expected for alternative specfications", {
5153 result_arm_cont <- populationHR(
5254 object = mp ,
5355 baseline = ~ splines :: ns(time , df = 5 ),
54- HR_formula = ~ arm + cov_cont ,
56+ hr_formula = ~ arm + cov_cont ,
5557 quantiles = c(0.05 , 0.95 )
5658 )
5759
@@ -64,9 +66,12 @@ test_that("populationHR works as expected for alternative specfications", {
6466
6567
6668 # ## Summary calculations match expectations
67- summary_stats <- apply(result_arm_cont [[2 ]], 1 , function (x ) c(mean(x ), quantile(x , c(0.5 , 0.05 , 0.95 ))))
69+ summary_stats <- apply(result_arm_cont [[2 ]], 1 , function (x ) c(mean(x ), quantile(x , c(0.5 , 0.05 , 0.95 )))) | >
70+ t() | >
71+ as.data.frame()
72+
6873 expect_equal(
69- unname(t( summary_stats ) ),
74+ unname(summary_stats ),
7075 unname(result_arm_cont [[1 ]])
7176 )
7277
@@ -76,7 +81,7 @@ test_that("populationHR works as expected for alternative specfications", {
7681 result_arm <- populationHR(
7782 object = mp ,
7883 baseline = ~ splines :: ns(time , df = 10 ),
79- HR_formula = ~ arm ,
84+ hr_formula = ~ arm ,
8085 quantiles = c(0.05 , 0.95 )
8186 )
8287
@@ -88,9 +93,11 @@ test_that("populationHR works as expected for alternative specfications", {
8893 )
8994
9095 # Summary calculations match expectations
91- summary_stats <- apply(result_arm [[2 ]], 1 , function (x ) c(mean(x ), quantile(x , c(0.5 , 0.05 , 0.95 ))))
96+ summary_stats <- apply(result_arm [[2 ]], 1 , function (x ) c(mean(x ), quantile(x , c(0.5 , 0.05 , 0.95 )))) | >
97+ t() | >
98+ as.data.frame()
9299 expect_equal(
93- unname(t( summary_stats ) ),
94- unname(result_arm [[1 ]])
100+ unname(summary_stats ),
101+ unname(result [[1 ]])
95102 )
96103})
0 commit comments