## ---- test-multiNorm-rmvn_chol_of_vechsrhocap
tol_i <- 0.05
k_i <- sample(x = 2:10, size = 1)
vechs_i <- toeplitz((k_i:1) / k_i)
vechs_i <- vechs_i[lower.tri(vechs_i, diag = FALSE)]
data_i <- rmvn_chol_of_vechsrhocap(
n = 10000,
x = vechs_i
)
testthat::test_that("test-multiNorm-rmvn_chol_of_vechsrhocap means", {
testthat::expect_true(
all(
abs(
round(
colMeans(data_i),
digits = 0
) - 0
) <= tol_i
)
)
})
testthat::test_that("test-multiNorm-rmvn_chol_of_vechsrhocap covariances", {
testthat::expect_true(
all(
abs(
round(
as.vector(
cov(data_i)
),
digits = 2
) - round(
as.vector(
toeplitz((k_i:1) / k_i)
),
digits = 2
)
) <= tol_i
)
)
})
# coverage
data_i <- rmvn_chol_of_vechsrhocap(
n = 10,
x = vechs_i,
varnames = paste0("x", seq_len(k_i)),
data_frame = TRUE
)
# clean environment
rm(
tol_i,
k_i,
data_i,
vechs_i
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.