tests/testthat/test-impute_methods_by_simulation.R

test_that("imputation methods works via simulation", {
  skip("Too long run time to check every time or on CRAN")
  set.seed(123)
  expect_equal(
    rowMeans(
      replicate(
        1000,
        colMeans(
          suppressWarnings(
            impute_EM(
              delete_MCAR(
                mvtnorm::rmvnorm(100, rep(0, 7)),
                p = 0.2
              ),
              stochastic = TRUE
            )
          )
        )
      )
    ),
    rep(0, 7),
    tolerance = 0.01
  )
})

Try the missMethods package in your browser

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

missMethods documentation built on Sept. 16, 2022, 5:08 p.m.