diff --git a/tests/testthat/test-condition-pr-matrix.R b/tests/testthat/test-condition-pr-matrix.R index 01cb9d3..69bda84 100644 --- a/tests/testthat/test-condition-pr-matrix.R +++ b/tests/testthat/test-condition-pr-matrix.R @@ -25,6 +25,7 @@ test_that("Complete randomization", { }) test_that("declaration to condition_pr_mat errors", { + skip_if_not_installed("randomizr") expect_error( declaration_to_condition_pr_mat(randomizr::declare_ra(N = n), 1, NULL), @@ -41,6 +42,7 @@ test_that("declaration to condition_pr_mat errors", { }) test_that("condition args work properly", { + skip_if_not_installed("randomizr") # Condition args work properly mat01 <- declaration_to_condition_pr_mat( @@ -61,6 +63,7 @@ test_that("condition args work properly", { }) test_that("Complete randomization with number of treated units not fixed", { + skip_if_not_installed("randomizr") # comp_odd_ra <- randomizr::declare_ra(N = 3, prob = 0.5) @@ -83,6 +86,7 @@ test_that("Complete randomization with number of treated units not fixed", { }) test_that("Complete randomization with non 0.5 as remainder", { + skip_if_not_installed("randomizr") comp_odd_ra <- randomizr::declare_ra(N = 3, prob = 0.4) decl_cond_pr_mat <- declaration_to_condition_pr_mat(comp_odd_ra) @@ -95,6 +99,7 @@ test_that("Complete randomization with non 0.5 as remainder", { ) }) test_that("Simple ra", { + skip_if_not_installed("randomizr") # Simple randomization prs <- rep(0.4, times = n) @@ -113,6 +118,7 @@ test_that("Simple ra", { ) }) test_that("Blocked complete ra", { + skip_if_not_installed("randomizr") # Blocked case dat <- data.frame( @@ -129,6 +135,8 @@ test_that("Blocked complete ra", { ) }) test_that("Blocked complete ra with remainder", { + skip_if_not_installed("randomizr") + dat <- data.frame( bl = c("A", "B", "A", "B", "B", "B"), pr = c(0.5, 0.25, 0.5, 0.25, 0.25, 0.25) @@ -147,6 +155,7 @@ test_that("Blocked complete ra with remainder", { ) }) test_that("Clustered complete ra", { + skip_if_not_installed("randomizr") # Cluster complete case dat <- data.frame( @@ -173,6 +182,7 @@ test_that("Clustered complete ra", { }) test_that("Clustered ra", { + skip_if_not_installed("randomizr") # Cluster simple ? Should this be simple or no? --NJF dat <- data.frame( @@ -204,6 +214,7 @@ test_that("Clustered ra", { }) test_that("Blocked and Clustered ra", { + skip_if_not_installed("randomizr") # Blocked and clustered dat <- data.frame( @@ -221,6 +232,7 @@ test_that("Blocked and Clustered ra", { }) test_that("Blocked and clusted ra with remainder", { + skip_if_not_installed("randomizr") # with remainder dat <- data.frame( @@ -238,6 +250,8 @@ test_that("Blocked and clusted ra with remainder", { }) test_that("Custom ra", { + skip_if_not_installed("randomizr") + cust_perms <- cbind(c(1, 0, 1, 0), c(1, 1, 0, 0)) cust_ra <- randomizr::declare_ra(permutation_matrix = cust_perms) @@ -248,6 +262,7 @@ test_that("Custom ra", { }) test_that("Errors for things that we can't support", { + skip_if_not_installed("randomizr") # # multiple armed experiments @@ -275,6 +290,8 @@ test_that("Errors for things that we can't support", { }) test_that("probability not fixed within blocks", { + skip_if_not_installed("randomizr") + bl_small <- randomizr::declare_ra( blocks = c(1, 1, 2, 2), prob = 0.4 @@ -295,6 +312,7 @@ test_that("probability not fixed within blocks", { }) test_that("N=2, m=1", { + skip_if_not_installed("randomizr") comp <- randomizr::declare_ra(N = 2, m = 1) assign( diff --git a/tests/testthat/test-difference-in-means.R b/tests/testthat/test-difference-in-means.R index a0f4d08..263c515 100644 --- a/tests/testthat/test-difference-in-means.R +++ b/tests/testthat/test-difference-in-means.R @@ -472,6 +472,8 @@ test_that("DIM works with character args", { }) test_that("DIM unbiased", { + skip_if_not_installed("randomizr") + dat <- data.frame( i = 1:10, Y0 = c( diff --git a/tests/testthat/test-horvitz-thompson.R b/tests/testthat/test-horvitz-thompson.R index d89eca2..f9d803e 100644 --- a/tests/testthat/test-horvitz-thompson.R +++ b/tests/testthat/test-horvitz-thompson.R @@ -26,6 +26,8 @@ test_that("Horvitz-Thompson matches d-i-m under certain conditions", { }) test_that("Horvitz-Thompson works in simple case", { + skip_if_not_installed("randomizr") + n <- 40 dat <- data.frame( y = rnorm(n) @@ -167,6 +169,8 @@ test_that("Horvitz-Thompson works in simple case", { }) test_that("Horvitz-Thompson works with clustered data", { + skip_if_not_installed("randomizr") + n <- 8 dat <- data.frame( y = rnorm(n), @@ -339,6 +343,8 @@ test_that("Horvitz-Thompson works with clustered data", { }) test_that("Horvitz-Thompson works with missingness", { + skip_if_not_installed("randomizr") + n <- 40 dat <- data.frame( y = rnorm(n), @@ -386,6 +392,8 @@ test_that("Horvitz-Thompson works with missingness", { # test blocks in the data test_that("Estimating Horvitz-Thompson can be done two ways with blocks", { + skip_if_not_installed("randomizr") + n <- 40 dat <- data.frame( y = rnorm(n), @@ -449,6 +457,8 @@ test_that("Estimating Horvitz-Thompson can be done two ways with blocks", { # errors when arguments are passed that shouldn't be together test_that("Horvitz-Thompson properly checks arguments and data", { + skip_if_not_installed("randomizr") + n <- 8 dat <- data.frame( y = rnorm(n), @@ -618,6 +628,8 @@ test_that("Works without variation in treatment", { }) test_that("multi-valued treatments not allowed in ra_declaration", { + skip_if_not_installed("randomizr") + dat <- data.frame( y = rnorm(20), ps = 0.4 diff --git a/tests/testthat/test-lm-cluster.R b/tests/testthat/test-lm-cluster.R index 2f1a432..5c1ced3 100644 --- a/tests/testthat/test-lm-cluster.R +++ b/tests/testthat/test-lm-cluster.R @@ -63,6 +63,7 @@ test_that("lm cluster se", { lm_interact_simple <- lm(Y ~ Z * X, data = dat) + skip_if_not_installed("sandwich") bm_interact <- BMlmSE( lm_interact_simple, @@ -357,6 +358,8 @@ test_that("lm works with quoted or unquoted vars and withor without factor clust }) test_that("Clustered SEs work with clusters of size 1", { + skip_if_not_installed("sandwich") + dat <- data.frame( Y = rnorm(100), X = rnorm(100), diff --git a/tests/testthat/test-lm-robust.R b/tests/testthat/test-lm-robust.R index 6c774d7..cce4285 100644 --- a/tests/testthat/test-lm-robust.R +++ b/tests/testthat/test-lm-robust.R @@ -569,6 +569,7 @@ test_that("multiple outcomes", { vcov(lmro) ) + skip_if_not_installed("sandwich") for (se_type in setdiff(se_types, "classical")) { expect_equal( sandwich::vcovHC(lmo, type = se_type), diff --git a/tests/testthat/test-replicate-HT-middleton.R b/tests/testthat/test-replicate-HT-middleton.R index 5885e17..046ca91 100644 --- a/tests/testthat/test-replicate-HT-middleton.R +++ b/tests/testthat/test-replicate-HT-middleton.R @@ -1,6 +1,7 @@ context("Verification - HT matches Joel Middleton code") test_that("We match Joel's estimator", { + skip_if_not_installed("randomizr") # Code from Joel Middleton n <- 400 diff --git a/tests/testthat/test-s3-methods.R b/tests/testthat/test-s3-methods.R index 49b2a97..97b5496 100644 --- a/tests/testthat/test-s3-methods.R +++ b/tests/testthat/test-s3-methods.R @@ -183,6 +183,7 @@ test_that("tidy, glance, summary, and print work", { ) ## lh_robust + skip_if_not_installed("car") lho <- lh_robust( mpg ~ cyl + am, data = mtcars, @@ -1078,6 +1079,7 @@ test_that("update works", { }) test_that("setting different alpha in lm_robust call leads to different CIs in tidy", { + skip_if_not_installed("fabricatr") set.seed(15) library(fabricatr) @@ -1103,6 +1105,7 @@ test_that("setting different alpha in lm_robust call leads to different CIs in t }) test_that("conf int for lh_robust works", { + skip_if_not_installed("fabricatr") set.seed(15) library(fabricatr)