@@ -68,40 +68,42 @@ test_that("comparison with other packages", {
68
68
69
69
70
70
# Bayesian
71
- out <- correlation(iris , include_factors = FALSE , bayesian = TRUE )
72
- rez <- as.data.frame(as.table(out ))
71
+ if (requireNamespace(" BayesFactor" )) {
72
+ out <- correlation(iris , include_factors = FALSE , bayesian = TRUE )
73
+ rez <- as.data.frame(as.table(out ))
73
74
74
- r <- as.matrix(rez [2 : 5 ])
75
- testthat :: expect_equal(mean(r - cor(iris [1 : 4 ])), 0 , tol = 0.01 )
75
+ r <- as.matrix(rez [2 : 5 ])
76
+ testthat :: expect_equal(mean(r - cor(iris [1 : 4 ])), 0 , tol = 0.01 )
76
77
77
- hmisc <- Hmisc :: rcorr(as.matrix(iris [1 : 4 ]), type = c(" pearson" ))
78
- testthat :: expect_equal(mean(r - hmisc $ r ), 0 , tol = 0.01 )
78
+ hmisc <- Hmisc :: rcorr(as.matrix(iris [1 : 4 ]), type = c(" pearson" ))
79
+ testthat :: expect_equal(mean(r - hmisc $ r ), 0 , tol = 0.01 )
79
80
80
- pd <- as.matrix(attributes(rez )$ pd [2 : 5 ])
81
- p <- bayestestR :: pd_to_p(pd )
82
- testthat :: expect_equal(mean(p - hmisc $ P , na.rm = TRUE ), 0 , tol = 0.01 )
81
+ pd <- as.matrix(attributes(rez )$ pd [2 : 5 ])
82
+ p <- bayestestR :: pd_to_p(pd )
83
+ testthat :: expect_equal(mean(p - hmisc $ P , na.rm = TRUE ), 0 , tol = 0.01 )
83
84
84
85
85
- # Bayesian - Partial
86
- out <- correlation(iris , include_factors = FALSE , bayesian = TRUE , partial = TRUE )
87
- rez <- as.data.frame(as.table(out ))
86
+ # Bayesian - Partial
87
+ out <- correlation(iris , include_factors = FALSE , bayesian = TRUE , partial = TRUE )
88
+ rez <- as.data.frame(as.table(out ))
88
89
89
- r <- as.matrix(rez [2 : 5 ])
90
- ppcor <- ppcor :: pcor(iris [1 : 4 ])
91
- testthat :: expect_equal(max(r - as.matrix(ppcor $ estimate )), 0 , tol = 0.02 )
90
+ r <- as.matrix(rez [2 : 5 ])
91
+ ppcor <- ppcor :: pcor(iris [1 : 4 ])
92
+ testthat :: expect_equal(max(r - as.matrix(ppcor $ estimate )), 0 , tol = 0.02 )
92
93
93
- pd <- as.matrix(attributes(rez )$ pd [2 : ncol(rez )])
94
- p <- bayestestR :: pd_to_p(pd )
95
- testthat :: expect_equal(mean(abs(p - as.matrix(ppcor $ p.value ))), 0 , tol = 0.001 )
94
+ pd <- as.matrix(attributes(rez )$ pd [2 : ncol(rez )])
95
+ p <- bayestestR :: pd_to_p(pd )
96
+ testthat :: expect_equal(mean(abs(p - as.matrix(ppcor $ p.value ))), 0 , tol = 0.001 )
96
97
97
98
98
- # Bayesian (Full) - Partial
99
- out <- correlation(iris , include_factors = FALSE , bayesian = TRUE , partial = TRUE , partial_bayesian = TRUE )
100
- rez <- as.data.frame(as.table(out ))
99
+ # Bayesian (Full) - Partial
100
+ out <- correlation(iris , include_factors = FALSE , bayesian = TRUE , partial = TRUE , partial_bayesian = TRUE )
101
+ rez <- as.data.frame(as.table(out ))
101
102
102
- r <- as.matrix(rez [2 : 5 ])
103
- ppcor <- ppcor :: pcor(iris [1 : 4 ])
104
- testthat :: expect_equal(max(r - as.matrix(ppcor $ estimate )), 0 , tol = 0.02 )
103
+ r <- as.matrix(rez [2 : 5 ])
104
+ ppcor <- ppcor :: pcor(iris [1 : 4 ])
105
+ testthat :: expect_equal(max(r - as.matrix(ppcor $ estimate )), 0 , tol = 0.02 )
106
+ }
105
107
}
106
108
})
107
109
@@ -140,10 +142,12 @@ test_that("format checks", {
140
142
}
141
143
142
144
# Bayesian full partial
143
- out <- correlation(iris , include_factors = TRUE , multilevel = TRUE , bayesian = TRUE , partial = TRUE , partial_bayesian = TRUE )
144
- testthat :: expect_equal(c(nrow(out ), ncol(out )), c(6 , 13 ))
145
- testthat :: expect_equal(c(nrow(as.table(out )), ncol(as.table(out ))), c(4 , 5 ))
146
- testthat :: expect_equal(c(nrow(summary(out )), ncol(summary(out ))), c(3 , 4 ))
145
+ if (requireNamespace(" BayesFactor" )) {
146
+ out <- correlation(iris , include_factors = TRUE , multilevel = TRUE , bayesian = TRUE , partial = TRUE , partial_bayesian = TRUE )
147
+ testthat :: expect_equal(c(nrow(out ), ncol(out )), c(6 , 13 ))
148
+ testthat :: expect_equal(c(nrow(as.table(out )), ncol(as.table(out ))), c(4 , 5 ))
149
+ testthat :: expect_equal(c(nrow(summary(out )), ncol(summary(out ))), c(3 , 4 ))
150
+ }
147
151
})
148
152
149
153
0 commit comments