diff --git a/DESCRIPTION b/DESCRIPTION index a543bc9..7caa28e 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: unmarked -Version: 1.4.3.9002 -Date: 2024-09-16 +Version: 1.4.3.9003 +Date: 2024-09-18 Type: Package Title: Models for Data from Unmarked Animals Authors@R: c( diff --git a/R/ranef.R b/R/ranef.R index 51858e7..1f43496 100644 --- a/R/ranef.R +++ b/R/ranef.R @@ -680,10 +680,15 @@ setMethod("ranef_internal", "unmarkedFitOccuMulti", function(object, ...){ setMethod("ranef_internal", "unmarkedFitOccuRN", function(object, ...){ - K <- list(...)$K - if(is.null(K)) { + + if(methods::.hasSlot(object, "K")){ + K <- object@K + } else { + K <- list(...)$K + if(is.null(K)) { warning("You did not specify K, the maximum value of N, so it was set to 50") K <- 50 + } } lam <- predict(object, type="state", level=NULL, na.rm=FALSE)$Predicted # Too slow R <- length(lam) diff --git a/tests/testthat/test_occuRN.R b/tests/testthat/test_occuRN.R index 90bb95e..6b871c6 100644 --- a/tests/testthat/test_occuRN.R +++ b/tests/testthat/test_occuRN.R @@ -45,7 +45,7 @@ test_that("occuRN can fit models",{ expect_equal(dim(res), dim(woodthrushUMF@y)) expect_equal(res[1,1], 0.73757, tol=1e-4) - r <- ranef(fm_C, K=10) + r <- ranef(fm_C) expect_equal(dim(r@post), c(50,11,1)) expect_equal(bup(r)[1:4], c(5.1059,5.6125,3.2689,5.6125), tol=1e-4) @@ -126,7 +126,7 @@ test_that("occuRN can handle NAs",{ expect_true(is.na(ft[1,1])) # missing obs cov expect_true(all(!is.na(ft[2,]))) # missing site cov - r <- ranef(fm_na, K=30) + r <- ranef(fm_na) expect_equal(nrow(r@post), numSites(fm_na@data)) expect_true(all(is.na(r@post[1:2,,1]))) })