tests/testthat/test.imp_simulation.R

context("Missing data imputation - simulation")
library(missCompare)

data("clindata_miss")
small <- clindata_miss[1:40, 1:4]
small$age[1:10] <- NA
cleaned <- clean(small)
y <- get_data(cleaned, matrixplot_sort = T)
simulated <- simulate(rownum = y$Rows, colnum =y$Columns, cormat=y$Corr_matrix)
res <- all_patterns(X_hat = simulated$Simulated_matrix,
                    MD_pattern = y$MD_Pattern,
                    NA_fraction = y$Fraction_missingness,
                    min_PDM = 2)

# simulation runs OK
test_that("simulation runs without errors", {
  suppressWarnings(expect_error(impute_simulated(rownum = y$Rows,
                           colnum = y$Columns,
                           cormat = y$Corr_matrix,
                           MD_pattern = y$MD_Pattern,
                           NA_fraction = y$Fraction_missingness,
                           min_PDM = 2,
                           n.iter = 1), NA))
})

rm(list=ls())

Try the missCompare package in your browser

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

missCompare documentation built on Dec. 1, 2020, 9:09 a.m.