Skip to content

Commit

Permalink
Skip tests if suggested packages aren't installed
Browse files Browse the repository at this point in the history
  • Loading branch information
nehill197 committed Aug 19, 2024
1 parent 5d62691 commit 6f680e8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
1 change: 1 addition & 0 deletions tests/testthat/test-dev.R
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ test_that("gamma_pois log_lik", {
})

test_that("gamma_pois deviance", {
skip_if_not_installed("MASS")
samples <- ran_gamma_pois(10000, 3, 0.5)
mod <- MASS::glm.nb(samples ~ 1)
deviance <- sum(dev_gamma_pois(samples, exp(coef(mod)[1]), theta = 1 / mod$theta))
Expand Down
22 changes: 16 additions & 6 deletions tests/testthat/test-log-lik.R
Original file line number Diff line number Diff line change
Expand Up @@ -178,21 +178,31 @@ test_that("beta_binom vectorized", {
})

test_that("beta_binom log_lik", {
skip_if_not_installed("aods3")
samples2 <- ran_beta_binom(100, size = 50, prob = 0.1, theta = 1)
data <- data.frame(
samples2 = samples2,
mod_prob2 = 50 - samples2
)
mod2 <- aods3::aodml(cbind(samples2, mod_prob2) ~ 1,
mod2 <- aods3::aodml(
cbind(samples2, mod_prob2) ~ 1,
data = data,
family = "bb", method = "Nelder-Mead"
family = "bb",
method = "Nelder-Mead"
)
est_prob <- ilogit(mod2$b)
est_theta <- 2 / (1 / mod2$phi - 1)
expect_equal(mod2$logL, sum(log_lik_beta_binom(samples2,
size = 50,
prob = est_prob, theta = est_theta
)))
expect_equal(
mod2$logL,
sum(
log_lik_beta_binom(
samples2,
size = 50,
prob = est_prob,
theta = est_theta
)
)
)
})

test_that("skewnorm missing values", {
Expand Down

0 comments on commit 6f680e8

Please sign in to comment.