test_that("generate_missingness", {
n <- 1000
mu.X <- c(1, 2, 3, 4)
A <- matrix(runif(n^2) * 2 - 1, ncol = length(mu.X))
Sigma.X <- t(A) %*% A
X.complete.cont <- MASS::mvrnorm(n, mu.X, Sigma.X)
rs <- generate_miss(X.complete.cont, 0.5, mechanism = "MNAR1")
expect_equal(length(rs), 3)
expect_equal(nrow(rs$X.incomp), n)
expect_equal(ncol(rs$X.incomp), 4)
rs <- generate_miss(X.complete.cont, 0.5, mechanism = "MNAR2")
expect_equal(length(rs), 3)
expect_equal(nrow(rs$X.incomp), n)
expect_equal(ncol(rs$X.incomp), 4)
rs <- generate_miss(X.complete.cont, 0.5, mechanism = "MCAR")
expect_equal(length(rs), 3)
expect_equal(nrow(rs$X.incomp), n)
expect_equal(ncol(rs$X.incomp), 4)
rs <- generate_miss(X.complete.cont, 0.5, mechanism = "MAR1")
expect_equal(length(rs), 3)
expect_equal(nrow(rs$X.incomp), n)
expect_equal(ncol(rs$X.incomp), 4)
rs <- generate_miss(X.complete.cont, 0.5, mechanism = "MAR2")
expect_equal(length(rs), 3)
expect_equal(nrow(rs$X.incomp), n)
expect_equal(ncol(rs$X.incomp), 4)
rs <- generate_miss(X.complete.cont, 0.5, mechanism = "MAR3")
expect_equal(length(rs), 3)
expect_equal(nrow(rs$X.incomp), n)
expect_equal(ncol(rs$X.incomp), 4)
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.