test_that("eummd, univariate, no pval, positive beta", { X <- c(7.1, 1.2, 4.3, 0.4) Y <- c(5.5, 2.6, 8.7) beta <- 0.1 seednum <- 1 numperm <- 200 ansList <- eummd(x=X, y=Y, beta=beta, pval=FALSE, seednum=seednum, numperm=numperm) ans_stat <- ansList$stat ans_pval <- ansList$pval ans_beta <- ansList$beta soln_stat <- -0.0594780368951533 # pval will be different, because uses different permutations #soln_pval <- 0.6169154228855721 soln_beta <- 0.1 expect_equal(ans_stat, soln_stat) expect_true(is.na(ans_pval)) expect_equal(ans_beta, soln_beta) }) test_that("eummd, univariate, no pval", { X <- c(7.1, 1.2, 4.3, 0.4) Y <- c(5.5, 2.6, 8.7) beta <- -0.1 seednum <- 1 numperm <- 200 ansList <- eummd(x=X, y=Y, beta=beta, pval=FALSE, seednum=seednum, numperm=numperm) ans_stat <- ansList$stat ans_pval <- ansList$pval ans_beta <- ansList$beta soln_stat <- -0.129327129453085 # pval will be different, because uses different permutations #soln_pval <- 0.6169154228855721 soln_beta <- 1.0/3.2 expect_equal(ans_stat, soln_stat) expect_true(is.na(ans_pval)) expect_equal(ans_beta, soln_beta) }) test_that("eummd, univariate, pval", { set.seed(1) X <- rnorm(50) Y <- rnorm(50) + 2 beta <- -0.1 seednum <- 1 numperm <- 199 ansList <- eummd(x=X, y=Y, beta=beta, pval=TRUE, seednum=seednum, numperm=numperm) ans_stat <- ansList$stat ans_pval <- ansList$pval ans_beta <- ansList$beta soln_stat <- 0.46161798 # pval will be different, because uses different permutations soln_pval <- 0.0025 soln_beta <- 0.76264072 # print(ans_stat) # print(ans_beta) # print(ans_pval) expect_equal(ans_stat, soln_stat) expect_equal(ans_pval, soln_pval) expect_equal(ans_beta, soln_beta) }) test_that("eummd, univariate, pval alternative is two.sided", { set.seed(1) X <- rnorm(50) Y <- rnorm(50) beta <- -0.1 seednum <- 1 numperm <- 199 ansList <- eummd(x=X, y=Y, beta=beta, pval=TRUE, seednum=seednum, numperm=numperm, alternative="two.sided") ans_stat <- ansList$stat ans_pval <- ansList$pval ans_beta <- ansList$beta soln_stat <- (-0.0001853314730196279204281484265237622821587137877941131591796875) # pval will be different, because uses different permutations soln_beta <- 1.17059974 soln_pval <- 0.73 # print(ans_stat) # #print(sprintf("%.100f", ans_stat)) # print(ans_beta) # print(ans_pval) expect_equal(ans_stat, soln_stat) expect_equal(ans_pval, soln_pval) expect_equal(ans_beta, soln_beta) }) test_that("eummd, univariate, pval, two.sided 2", { set.seed(1) X <- rnorm(50) Y <- rnorm(50) + 2 beta <- -0.1 seednum <- 1 numperm <- 199 ansList <- eummd(x=X, y=Y, beta=beta, pval=TRUE, seednum=seednum, numperm=numperm, alternative="two.sided") ans_stat <- ansList$stat ans_pval <- ansList$pval ans_beta <- ansList$beta soln_stat <- 0.46161798 # pval will be different, because uses different permutations soln_pval <- 0.0025 soln_beta <- 0.76264072 # print(ans_stat) # print(ans_beta) # print(ans_pval) expect_equal(ans_stat, soln_stat) expect_equal(ans_pval, soln_pval) expect_equal(ans_beta, soln_beta) }) test_that("eummd, univariate, pval, greater 2, allowzeropval", { set.seed(1) X <- rnorm(50) Y <- rnorm(50) + 2 beta <- -0.1 seednum <- 1 numperm <- 199 ansList <- eummd(x=X, y=Y, beta=beta, pval=TRUE, seednum=seednum, numperm=numperm, alternative="greater", allowzeropval=TRUE) ans_stat <- ansList$stat ans_pval <- ansList$pval ans_beta <- ansList$beta soln_stat <- 0.46161798 # pval will be different, because uses different permutations soln_pval <- 0 soln_beta <- 0.76264072 expect_equal(ans_stat, soln_stat) expect_equal(ans_pval, soln_pval) expect_equal(ans_beta, soln_beta) })