test_that("compute.alpha works correctly", { # alpha for identity matrix R <- diag(10) expect_equal(compute.alpha(R), 0) # more interesting case R <- matrix(c(1, .3, .3, .3, 1, .2, .3, .2, 1), 3, 3) alpha <- compute.alpha(R) expect_true(is.numeric(alpha)) expect_true(alpha >= 0) }) test_that("compute.beta works correctly", { R <- matrix(c(1, .4, .2, .4, 1, .3, .2, .3, 1), 3, 3) rownames(R) <- colnames(R) <- as.character(1:3) # split sets beta <- compute.beta(R, "1", "3") expect_true(beta >= 0 && beta <= 1) # larger groups beta <- compute.beta(R, c("1","3"), "2") expect_true(beta >= 0 && beta <= 1) }) test_that("hc.beta fails on invalid inputs", { R <- matrix(rnorm(9), 3, 3) expect_error(hc.beta(1:3)) expect_error(hc.beta(R, is.corr = TRUE)) expect_error(hc.beta(R, is.corr = FALSE, n.splits = - 2)) expect_error(hc.beta(R, is.corr = FALSE, splits = "HCSVD")) })