From 20a7cae2d08dc9390f7110eed20288751d4266cf Mon Sep 17 00:00:00 2001 From: Ken Kellner Date: Tue, 30 Jan 2024 15:48:24 -0500 Subject: Fix occuCOP and IDS --- R/IDS.R | 2 ++ R/occuCOP.R | 4 ++-- tests/testthat/test_IDS.R | 3 +++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/R/IDS.R b/R/IDS.R index 38338b1..c0b1534 100644 --- a/R/IDS.R +++ b/R/IDS.R @@ -73,6 +73,8 @@ IDS <- function(lambdaformula = ~1, formlist <- list(lam=lambdaformula, ds=form_hds, pc=form_pc, oc=form_oc, phi=availformula) + check_no_support(formlist) + stopifnot(inherits(dataDS, "unmarkedFrameDS")) stopifnot(inherits(dataPC, c("unmarkedFramePCount", "NULL"))) stopifnot(inherits(dataOC, c("unmarkedFrameOccu", "NULL"))) diff --git a/R/occuCOP.R b/R/occuCOP.R index f22c235..07875e3 100644 --- a/R/occuCOP.R +++ b/R/occuCOP.R @@ -79,7 +79,7 @@ setMethod( # Occupancy submodel ------------------------------------------------------- # Retrieve the fixed-effects part of the formula - psiformula <- lme4::nobars(as.formula(formlist$psiformula)) + psiformula <- remove_bars(as.formula(formlist$psiformula)) psiVars <- all.vars(psiformula) # Retrieve the site covariates @@ -109,7 +109,7 @@ setMethod( # Detection submodel ------------------------------------------------------- # Retrieve the fixed-effects part of the formula - lambdaformula <- lme4::nobars(as.formula(formlist$lambdaformula)) + lambdaformula <- remove_bars(as.formula(formlist$lambdaformula)) lambdaVars <- all.vars(lambdaformula) # Retrieve the observation covariates diff --git a/tests/testthat/test_IDS.R b/tests/testthat/test_IDS.R index 61d348d..7565b25 100644 --- a/tests/testthat/test_IDS.R +++ b/tests/testthat/test_IDS.R @@ -72,6 +72,9 @@ test_that("IDS can fit models with covariates", { unitsOut="kmsq") expect_equal(length(coef(mod_sim)), 4) expect_equal(length(coef(mod_sep)), 5) + + # Doesn't support random effects + expect_error(update(mod_sep, lambdaformula = ~elev + (1|group))) }) test_that("IDS can fit models with occupancy data", { -- cgit v1.2.3