@@ -4,8 +4,6 @@ options(mc.cores = 1)
44context(" loo_subsampling" )
55
66test_that(" overall loo_subampling works as expected (compared with loo) for diff_est" , {
7- skip_if_not_installed(" checkmate" )
8-
97 set.seed(123 )
108 N <- 1000 ; K <- 10 ; S <- 1000 ; a0 <- 3 ; b0 <- 2
119 p <- 0.7
@@ -91,8 +89,6 @@ test_that("overall loo_subampling works as expected (compared with loo) for diff
9189})
9290
9391test_that(" loo with subsampling of all observations works as ordinary loo." , {
94- skip_if_not_installed(" checkmate" )
95-
9692 set.seed(123 )
9793 N <- 1000 ; K <- 10 ; S <- 1000 ; a0 <- 3 ; b0 <- 2
9894 p <- 0.7
@@ -122,8 +118,6 @@ test_that("loo with subsampling of all observations works as ordinary loo.", {
122118})
123119
124120test_that(" overall loo_subsample works with diff_srs as expected (compared with loo)" , {
125- skip_if_not_installed(" checkmate" )
126-
127121 set.seed(123 )
128122 N <- 1000 ; K <- 10 ; S <- 1000 ; a0 <- 3 ; b0 <- 2
129123 p <- 0.7
@@ -143,8 +137,6 @@ test_that("overall loo_subsample works with diff_srs as expected (compared with
143137})
144138
145139test_that(" Test the srs estimator with 'none' approximation" , {
146- skip_if_not_installed(" checkmate" )
147-
148140 set.seed(123 )
149141 N <- 1000 ; K <- 10 ; S <- 1000 ; a0 <- 3 ; b0 <- 2
150142 p <- 0.7
@@ -186,8 +178,6 @@ test_that("Test the srs estimator with 'none' approximation", {
186178})
187179
188180test_that(" Test the Hansen-Hurwitz estimator" , {
189- skip_if_not_installed(" checkmate" )
190-
191181 set.seed(123 )
192182 N <- 1000 ; K <- 10 ; S <- 1000 ; a0 <- 3 ; b0 <- 2
193183 p <- 0.7
@@ -245,7 +235,7 @@ test_that("Test the Hansen-Hurwitz estimator", {
245235
246236
247237test_that(" update.psis_loo_ss works as expected (compared with loo)" , {
248- skip_if_not_installed( " checkmate " )
238+
249239
250240 set.seed(123 )
251241 N <- 1000 ; K <- 10 ; S <- 1000 ; a0 <- 3 ; b0 <- 2
@@ -344,7 +334,7 @@ test_that("update.psis_loo_ss works as expected (compared with loo)", {
344334context(" loo_subsampling_approximations" )
345335
346336test_that(" elpd_loo_approximation works as expected" , {
347- skip_if_not_installed( " checkmate " )
337+
348338
349339 set.seed(123 )
350340 N <- 10 ; K <- 10 ; S <- 1000 ; a0 <- 3 ; b0 <- 2
@@ -396,7 +386,7 @@ test_that("elpd_loo_approximation works as expected", {
396386
397387
398388test_that(" Test loo_approximation_draws" , {
399- skip_if_not_installed( " checkmate " )
389+
400390
401391 set.seed(123 )
402392 N <- 1000 ; K <- 10 ; S <- 1000 ; a0 <- 3 ; b0 <- 2
@@ -432,7 +422,7 @@ test_that("Test loo_approximation_draws", {
432422
433423
434424test_that(" waic using delta method and gradient" , {
435- skip_if_not_installed( " checkmate " )
425+
436426
437427 if (FALSE ){
438428 # Code to generate testdata - saved and loaded to avoid dependency of mvtnorm
@@ -488,7 +478,7 @@ test_that("waic using delta method and gradient", {
488478})
489479
490480test_that(" waic using delta 2nd order method" , {
491- skip_if_not_installed( " checkmate " )
481+
492482
493483 if (FALSE ){
494484 # Code to generate testdata - saved and loaded to avoid dependency of MCMCPack
@@ -575,7 +565,7 @@ test_that("waic using delta 2nd order method", {
575565context(" loo_subsampling_estimation" )
576566
577567test_that(" whhest works as expected" , {
578- skip_if_not_installed( " checkmate " )
568+
579569
580570 N <- 100
581571 m <- 10
@@ -636,7 +626,7 @@ test_that("whhest works as expected", {
636626
637627
638628test_that(" srs_diff_est works as expected" , {
639- skip_if_not_installed( " checkmate " )
629+
640630
641631 set.seed(1234 )
642632 N <- 1000
@@ -672,7 +662,7 @@ test_that("srs_diff_est works as expected", {
672662})
673663
674664test_that(" srs_est works as expected" , {
675- skip_if_not_installed( " checkmate " )
665+
676666
677667 set.seed(1234 )
678668 # Cochran 1976 example Table 2.2
@@ -725,7 +715,8 @@ test_that("srs_est works as expected", {
725715context(" loo_subsampling cases" )
726716
727717test_that(" Test loo_subsampling and loo_approx with radon data" , {
728- skip_if_not_installed(" checkmate" )
718+ skip_on_cran() # avoid going over time limit for tests
719+
729720 load(test_path(" test_radon_laplace_loo.rda" ))
730721 # Rename to spot variable leaking errors
731722 llfun_test <- llfun
@@ -833,13 +824,14 @@ test_that("Test loo_subsampling and loo_approx with radon data", {
833824
834825
835826test_that(" Test the vignette" , {
836- skip_if_not_installed(" checkmate" )
827+ skip_on_cran()
828+
837829
838830 # NOTE
839831 # If any of these test fails, the vignette probably needs to be updated
840832
841- if (FALSE ){
842- # Generate vignett test case
833+ if (FALSE ) {
834+ # Generate vignette test case
843835 library(" rstan" )
844836 stan_code <- "
845837 data {
@@ -986,7 +978,7 @@ test_that("Test the vignette", {
986978context(" loo_compare_subsample" )
987979
988980test_that(" loo_compare_subsample" , {
989- skip_if_not_installed( " checkmate " )
981+ skip_on_cran() # to get under cran check time limit
990982
991983 set.seed(123 )
992984 N <- 1000
@@ -1067,9 +1059,10 @@ test_that("loo_compare_subsample", {
10671059
10681060})
10691061
1062+ context(" subsample with tis, sis" )
10701063
10711064test_that(" Test 'tis' and 'sis'" , {
1072- skip_if_not_installed( " checkmate " )
1065+ skip_on_cran( )
10731066
10741067 set.seed(123 )
10751068 N <- 1000 ; K <- 10 ; S <- 1000 ; a0 <- 3 ; b0 <- 2
@@ -1160,6 +1153,3 @@ test_that("Test 'tis' and 'sis'", {
11601153 expect_gt(loo_ss_sis_S10 $ estimates [" elpd_loo" , " Estimate" ] + SEs * loo_ss_sis_S10 $ estimates [" elpd_loo" , " subsampling SE" ], loo_ss_full $ estimates [" elpd_loo" , " Estimate" ])
11611154 expect_lt(loo_ss_sis_S10 $ estimates [" elpd_loo" , " Estimate" ] - SEs * loo_ss_sis_S10 $ estimates [" elpd_loo" , " subsampling SE" ], loo_ss_full $ estimates [" elpd_loo" , " Estimate" ])
11621155})
1163-
1164-
1165-
0 commit comments