diff options
Diffstat (limited to 'tests/testthat/test_distsampOpen.R')
-rw-r--r-- | tests/testthat/test_distsampOpen.R | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/testthat/test_distsampOpen.R b/tests/testthat/test_distsampOpen.R index 2797b80..fe915f4 100644 --- a/tests/testthat/test_distsampOpen.R +++ b/tests/testthat/test_distsampOpen.R @@ -132,6 +132,20 @@ test_that("dso halfnorm key function works",{ # Check K that is too small expect_error(distsampOpen(~1, ~1, ~1, ~x1, data = umf, K=5,keyfun="halfnorm")) + # Check auto-K + fm <- expect_warning(distsampOpen(~1, ~1, ~1, ~x1, data = umf, keyfun="halfnorm")) + expect_false(fm@K == max(umf@y)+20) # the wrong way + + # Check that automatic K value is correct + ya <- array(umf@y, c(50, 4, 7)) + ya <- aperm(ya, c(1,3,2)) + yt <- apply(ya, 1:2, function(x) { + if(all(is.na(x))) + return(NA) + else return(sum(x, na.rm=TRUE)) + }) + expect_equal(max(yt)+20, fm@K) # the correct way + fm <- distsampOpen(~1, ~1, ~1, ~x1, data = umf, K=10,keyfun="halfnorm") expect_equivalent(coef(fm), c(1.4185,1.0471,-0.8275,3.1969,-0.0790), |