Nothing
test_that("gof_power can return Monte Carlo confidence intervals", {
set.seed(314)
range01 <- matrix(c(0, 1, 0, 1), 2, 2)
mean_shift_TS <- function(dta, pnull, param) {
out <- sum((colMeans(dta) - 0.5)^2)
names(out) <- "MeanShift"
out
}
z <- gof_power(
pnull_u2, rnull_u2, ralt_u2, c(1, 1.4),
TS = mean_shift_TS,
Ranges = range01,
B = 20, maxProcessor = 1,
CI = TRUE, conf.level = 0.95,
SuppressMessages = TRUE,
seed = 314
)
expect_s3_class(z, "MDgof_power")
expect_true(all(c("power", "mc.se", "lower", "upper", "B",
"conf.level", "interval", "alpha", "param_alt",
"seed") %in% names(z)))
expect_equal(dim(z$power), c(2L, 1L))
expect_equal(dim(z$mc.se), dim(z$power))
expect_equal(dim(z$lower), dim(z$power))
expect_equal(dim(z$upper), dim(z$power))
expect_true(all(z$lower <= z$power, na.rm = TRUE))
expect_true(all(z$power <= z$upper, na.rm = TRUE))
expect_true(all(z$lower >= 0 & z$upper <= 1, na.rm = TRUE))
expect_equal(z$interval, "Wilson")
expect_equal(z$conf.level, 0.95)
d <- as.data.frame(z)
expect_s3_class(d, "data.frame")
expect_true(all(c("param_alt", "method", "power", "mc.se",
"lower", "upper") %in% names(d)))
expect_equal(nrow(d), 2L)
expect_invisible(print(z))
})
test_that("gof_power preserves its historical return type when CI is FALSE", {
set.seed(315)
range01 <- matrix(c(0, 1, 0, 1), 2, 2)
mean_shift_TS <- function(dta, pnull, param) {
out <- sum((colMeans(dta) - 0.5)^2)
names(out) <- "MeanShift"
out
}
z <- gof_power(
pnull_u2, rnull_u2, ralt_u2, c(1, 1.4),
TS = mean_shift_TS,
Ranges = range01,
B = 10, maxProcessor = 1,
CI = FALSE,
SuppressMessages = TRUE,
seed = 315
)
expect_true(is.matrix(z))
expect_false(inherits(z, "MDgof_power"))
})
test_that("gof_power validates CI arguments", {
expect_error(
gof_power(pnull_u2, rnull_u2, ralt_u2, 1, B = 10,
maxProcessor = 1, CI = NA),
"CI must be TRUE or FALSE"
)
expect_error(
gof_power(pnull_u2, rnull_u2, ralt_u2, 1, B = 10,
maxProcessor = 1, CI = TRUE, conf.level = 1),
"conf.level"
)
})
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.