tests/testthat/test-test_power_by_es_catch_power4test_error.R

skip_on_cran()

library(testthat)

test_that("Power by es", {

mod <-
"
m ~ x
y ~ m + x
"
mod_es <-
"
y ~ x: s
.ind.x->m->y: .09
"
out <- power4test(nrep = 5,
                  model = mod,
                  pop_es = mod_es,
                  n = 100,
                  R = 1000,
                  ci_type = "mc",
                  test_fun = test_indirect_effect,
                  test_args = list(x = "x",
                                   m = "m",
                                   y = "y",
                                   mc_ci = TRUE),
                  iseed = 1234,
                  progress = FALSE,
                  parallel = FALSE)
tmp <- power4test_by_es(out,
                        pop_es_name = ".ind.x->m->y",
                        pop_es_values = seq(.75, .90, .05),
                        by_nrep = 10,
                        progress = FALSE)
expect_true(length(tmp) == 2)
})

Try the power4mome package in your browser

Any scripts or data that you put into this service are public.

power4mome documentation built on Sept. 9, 2025, 5:35 p.m.