Skip to content

Commit

Permalink
Fix occuCOP and IDS
Browse files Browse the repository at this point in the history
  • Loading branch information
kenkellner committed Jan 30, 2024
1 parent 717c6c7 commit 20a7cae
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 2 additions & 0 deletions R/IDS.R
Original file line number Diff line number Diff line change
Expand Up @@ -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")))
Expand Down
4 changes: 2 additions & 2 deletions R/occuCOP.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions tests/testthat/test_IDS.R
Original file line number Diff line number Diff line change
Expand Up @@ -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", {
Expand Down

0 comments on commit 20a7cae

Please sign in to comment.