diff options
author | Ken Kellner <ken@kenkellner.com> | 2022-09-20 16:18:48 -0400 |
---|---|---|
committer | Ken Kellner <ken@kenkellner.com> | 2022-09-20 16:18:48 -0400 |
commit | cfaa7345c60b9063650bd5f3c6b00c4f991d6699 (patch) | |
tree | 7f97d566b645564559b5a3b91860b0231a6d4f91 | |
parent | 0cf7271c084eb5cd6051ffec73ef905a2ea2cb17 (diff) | |
parent | 06f15cef6579b931307fb5bd6fb386d63abfb6b5 (diff) |
Merge branch 'master' into kfold
-rw-r--r-- | DESCRIPTION | 4 | ||||
-rw-r--r-- | R/submodel.R | 2 | ||||
-rw-r--r-- | tests/testthat/test_submodel.R | 9 |
3 files changed, 12 insertions, 3 deletions
diff --git a/DESCRIPTION b/DESCRIPTION index 7cd21b7..f586af0 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,5 +1,5 @@ Package: ubms -Version: 1.1.9005 +Version: 1.1.9006 Date: 2022-09-20 Title: Bayesian Models for Data from Unmarked Animals using 'Stan' Authors@R: person("Ken", "Kellner", email="contact@kenkellner.com", @@ -12,7 +12,7 @@ Imports: gridExtra, lme4, loo, - Matrix, + Matrix (>= 1.5-0), methods, pbapply, Rcpp (>= 0.12.0), diff --git a/R/submodel.R b/R/submodel.R index 79369bb..8090113 100644 --- a/R/submodel.R +++ b/R/submodel.R @@ -164,7 +164,7 @@ check_formula <- function(formula, data){ rand <- lme4::findbars(formula) if(is.null(rand)) return(invisible()) - char <- paste(formula, collapse=" ") + char <- paste(lme4::findbars(formula)[[1]], collapse=" ") if(grepl(":|/", char)){ stop("Nested random effects (using / and :) are not supported", call.=FALSE) diff --git a/tests/testthat/test_submodel.R b/tests/testthat/test_submodel.R index b57f03b..484026d 100644 --- a/tests/testthat/test_submodel.R +++ b/tests/testthat/test_submodel.R @@ -387,6 +387,15 @@ test_that("check_formula identifies unsupported formulas",{ expect_error(check_formula(~(1|x1 : x2), dat)) }) +test_that("check_formula allows : in non-random effects part of formula",{ + dat <- data.frame(y=rnorm(10), x1=rnorm(10), x2=rnorm(10), + x3=sample(letters[1:3], 10, replace=T), + x4=sample(letters[4:6], 10, replace=T)) + expect_error(check_formula(~x1*x2 + (1|x3), dat), NA) + expect_error(check_formula(~x1:x2 + (1|x3), dat), NA) + expect_error(check_formula(~x1:x2 + (1|x3:x2), dat)) +}) + test_that("check_formula handles very long formulas",{ dat <- data.frame(y=rnorm(10), longcovariate1=rnorm(10), longcovariate2=rnorm(10), longcovariate3=rnorm(10), longcovariate4=rnorm(10), |