library("SimMultiCorrData")
context("Correlation boundaries by correlation method 2")
skip_on_cran()
options(scipen = 999)
tol <- 1e-5
L <- calc_theory("Logistic", c(0, 1))
Six <- list(seq(1.7, 1.8, 0.01))
marginal <- list(0.3)
lam <- 0.5
pois_eps <- 0.0001
size <- 2
prob <- 0.75
mu <- size * (1 - prob)/prob
nb_eps <- 0.0001
Rey <- matrix(0.4, 4, 4)
diag(Rey) <- 1
test_that("works for 0 continuous, 1 ordinal, 1 Poisson, 1 NB", {
expect_equal(all.equal(valid_corr2(k_cat = 1, k_pois = 1, k_nb = 1,
marginal = marginal, lam = lam, pois_eps = pois_eps, size = size,
prob = prob, nb_eps = nb_eps, rho = Rey[1:3, 1:3])$L_rho[1, 2], -0.7898746,
tolerance = tol, check.attributes = FALSE), TRUE)
expect_equal(all.equal(valid_corr2(k_cat = 1, k_pois = 1, k_nb = 1,
marginal = marginal, lam = lam, pois_eps = pois_eps, size = size,
mu = mu, nb_eps = nb_eps, rho = Rey[1:3, 1:3])$L_rho[1, 2], -0.7898746,
tolerance = tol, check.attributes = FALSE), TRUE)
})
test_that("works for Fleishman method: 1 continuous, 1 ordinal, 1 Poisson,
1 NB", {
expect_equal(all.equal(valid_corr2(k_cont = 1, k_cat = 1, k_pois = 1,
k_nb = 1, method = "Fleishman", means = L[1], vars = L[2]^2, skews = L[3],
skurts = L[4], marginal = marginal,
lam = lam, pois_eps = pois_eps, size = size,
prob = prob, nb_eps = nb_eps, rho = Rey)$constants[1, "c3"],
0.03605955, tolerance = tol, check.attributes = FALSE), TRUE)
expect_equal(all.equal(valid_corr2(k_cont = 1, k_cat = 1, k_pois = 1,
k_nb = 1, method = "Fleishman", means = L[1], vars = L[2]^2, skews = L[3],
skurts = L[4], marginal = marginal,
lam = lam, pois_eps = pois_eps, size = size,
mu = mu, nb_eps = nb_eps, rho = Rey)$constants[1, "c3"], 0.03605955,
tolerance = tol, check.attributes = FALSE), TRUE)
})
test_that("works for Fleishman method: 1 continuous, 0 ordinal, 1 Poisson,
1 NB", {
expect_equal(all.equal(valid_corr2(k_cont = 1, k_cat = 0, k_pois = 1,
k_nb = 1, method = "Fleishman", means = L[1], vars = L[2]^2, skews = L[3],
skurts = L[4], lam = lam, pois_eps = pois_eps, size = size,
prob = prob, nb_eps = nb_eps, rho = Rey[1:3, 1:3])$constants[1, "c3"],
0.03605955, tolerance = tol, check.attributes = FALSE), TRUE)
expect_equal(all.equal(valid_corr2(k_cont = 1, k_cat = 0, k_pois = 1,
k_nb = 1, method = "Fleishman", means = L[1], vars = L[2]^2, skews = L[3],
skurts = L[4], lam = lam, pois_eps = pois_eps, size = size,
mu = mu, nb_eps = nb_eps, rho = Rey[1:3, 1:3])$constants[1, "c3"],
0.03605955, tolerance = tol, check.attributes = FALSE), TRUE)
})
test_that("works for Fleishman method: 1 continuous, 1 ordinal, 0 Poisson,
1 NB", {
expect_equal(all.equal(valid_corr2(k_cont = 1, k_cat = 1, k_pois = 0,
k_nb = 1, method = "Fleishman", means = L[1], vars = L[2]^2, skews = L[3],
skurts = L[4], marginal = marginal, nb_eps = nb_eps,
size = size, prob = prob, rho = Rey[1:3, 1:3])$constants[1, "c3"],
0.03605955, tolerance = tol, check.attributes = FALSE), TRUE)
expect_equal(all.equal(valid_corr2(k_cont = 1, k_cat = 1, k_pois = 0,
k_nb = 1, method = "Fleishman", means = L[1], vars = L[2]^2, skews = L[3],
skurts = L[4], marginal = marginal, nb_eps = nb_eps,
size = size, mu = mu, rho = Rey[1:3, 1:3])$constants[1, "c3"], 0.03605955,
tolerance = tol, check.attributes = FALSE), TRUE)
})
test_that("works for Fleishman method: 1 continuous, 1 ordinal, 1 Poisson,
0 NB", {
expect_equal(all.equal(valid_corr2(k_cont = 1, k_cat = 1, k_pois = 1,
method = "Fleishman", means = L[1], vars = L[2]^2, skews = L[3],
skurts = L[4], marginal = marginal, pois_eps = pois_eps,
lam = lam, rho = Rey[1:3, 1:3])$constants[1, "c3"], 0.03605955,
tolerance = tol, check.attributes = FALSE), TRUE)
})
test_that("works for Polynomial method: 1 continuous, 1 ordinal, 1 Poisson,
1 NB", {
expect_equal(all.equal(valid_corr2(k_cont = 1, k_cat = 1, k_pois = 1,
k_nb = 1, method = "Polynomial", means = L[1], vars = L[2]^2, skews = L[3],
skurts = L[4], fifths = L[5], sixths = L[6], Six = Six,
marginal = marginal, lam = lam, pois_eps = pois_eps, size = size,
prob = prob, nb_eps = nb_eps, rho = Rey)$constants[1, "c5"],
0.0000006124845, tolerance = tol, check.attributes = FALSE), TRUE)
expect_equal(all.equal(valid_corr2(k_cont = 1, k_cat = 1, k_pois = 1,
k_nb = 1, method = "Polynomial", means = L[1], vars = L[2]^2, skews = L[3],
skurts = L[4], fifths = L[5], sixths = L[6], Six = Six,
marginal = marginal, lam = lam, pois_eps = pois_eps, size = size,
mu = mu, nb_eps = nb_eps, rho = Rey)$constants[1, "c5"], 0.0000006124845,
tolerance = tol, check.attributes = FALSE), TRUE)
})
test_that("works for Polynomial method: 1 continuous, 0 ordinal, 1 Poisson,
1 NB", {
expect_equal(all.equal(valid_corr2(k_cont = 1, k_cat = 0, k_pois = 1,
k_nb = 1, method = "Polynomial", means = L[1], vars = L[2]^2, skews = L[3],
skurts = L[4], fifths = L[5], sixths = L[6], Six = Six,
lam = lam, pois_eps = pois_eps, size = size,
prob = prob, nb_eps = nb_eps, rho = Rey[1:3, 1:3])$constants[1, "c5"],
0.0000006124845, tolerance = tol, check.attributes = FALSE), TRUE)
expect_equal(all.equal(valid_corr2(k_cont = 1, k_cat = 0, k_pois = 1,
k_nb = 1, method = "Polynomial", means = L[1], vars = L[2]^2, skews = L[3],
skurts = L[4], fifths = L[5], sixths = L[6], Six = Six,
lam = lam, pois_eps = pois_eps, size = size,
prob = prob, nb_eps = nb_eps, rho = Rey[1:3, 1:3])$constants[1, "c5"],
0.0000006124845, tolerance = tol, check.attributes = FALSE), TRUE)
})
test_that("works for Polynomial method: 1 continuous, 1 ordinal, 0 Poisson,
1 NB", {
expect_equal(all.equal(valid_corr2(k_cont = 1, k_cat = 1, k_pois = 0,
k_nb = 1, method = "Polynomial", means = L[1], vars = L[2]^2, skews = L[3],
skurts = L[4], fifths = L[5], sixths = L[6], Six = Six,
marginal = marginal, size = size, nb_eps = nb_eps,
prob = prob, rho = Rey[1:3, 1:3])$constants[1, "c5"], 0.0000006124845,
tolerance = tol, check.attributes = FALSE), TRUE)
expect_equal(all.equal(valid_corr2(k_cont = 1, k_cat = 1, k_pois = 0,
k_nb = 1, method = "Polynomial", means = L[1], vars = L[2]^2, skews = L[3],
skurts = L[4], fifths = L[5], sixths = L[6], Six = Six, marginal = marginal,
size = size, mu = mu, nb_eps = nb_eps,
rho = Rey[1:3, 1:3])$constants[1, "c5"],
0.0000006124845, tolerance = tol, check.attributes = FALSE), TRUE)
})
test_that("works for Polynomial method: 1 continuous, 1 ordinal, 1 Poisson,
0 NB", {
expect_equal(all.equal(valid_corr2(k_cont = 1, k_cat = 1, k_pois = 1,
method = "Polynomial", means = L[1], vars = L[2]^2, skews = L[3],
skurts = L[4], fifths = L[5], sixths = L[6], Six = Six,
marginal = marginal, lam = lam, pois_eps = pois_eps,
rho = Rey[1:3, 1:3])$constants[1, "c5"], 0.0000006124845,
tolerance = tol, check.attributes = FALSE), TRUE)
})
Rey2 <- matrix(0.4, 5, 5)
diag(Rey2) <- 1
test_that("works for Polynomial method: same continuous distribution", {
expect_equal(all.equal(valid_corr2(k_cont = 2, k_cat = 1, k_pois = 1,
k_nb = 1, method = "Polynomial", means = rep(L[1], 2),
vars = rep(L[2]^2, 2), skews = rep(L[3], 2), skurts = rep(L[4], 2),
fifths = rep(L[5], 2), sixths = rep(L[6], 2), Six = list(1.75, 1.75),
marginal = marginal, lam = lam, pois_eps = pois_eps, size = size,
prob = prob, nb_eps = nb_eps, rho = Rey2)$constants[1, "c5"],
0.0000006124845, tolerance = tol, check.attributes = FALSE), TRUE)
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.