Closed ShanaScogin closed 2 years ago
Going to expand this to include general clean up for the testthat files. Need to add skip_if_not_installed() such as the following:
test_that("Simple model runs with mcmcTab", {
testthat::skip_if_not_installed("rjags")
data("jags_logit")
object <- mcmcTab(jags_logit,
ci = c(0.025, 0.975),
pars = NULL,
Pr = FALSE,
ROPE = NULL)
value <- object[2, 2]
check_against <- c(0.527)
expect_equal(round(as.numeric(value), 2), round(check_against, 2))
})
Files include
I don't think the tests in test_mcmcRocPrc.R are working due to an error thrown in the line pardraws <- as.matrix(coda::as.mcmc(object))
in the chunk below. Need to sort this before can add the skips:
# pull out a predicted probability matrix and yvec, for simple testing
data("jags_logit")
object <- jags_logit
mdl_data <- object$model$data()
xdata <- as.matrix(cbind(X0 = 1L, as.data.frame(mdl_data[c("X1", "X2")])))
yvec <- mdl_data[["Y"]]
pardraws <- as.matrix(coda::as.mcmc(object))
betadraws <- pardraws[, c(sprintf("b[%s]", 1:ncol(xdata - 1)))]
pred_prob <- plogis(xdata %*% t(betadraws))
R2jags moved to depends to fix the error in #88 since it's needed for some mcmc functions. This means loading the package in the helper file is fine. The rest of the files have been refitted with the skip_if_not_installed()
lines with their various dependencies in commit f8f8e23
Right now R2jags is loaded separately from tests, but it makes it hard to go in and find code that depends on this. Might be easier to go in and call each function that uses R2jags from the namespace, ie R2jags::function().