From 300c98cd2e26ed3347993131799b29761521daaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kirill=20M=C3=BCller?= Date: Fri, 29 Sep 2023 16:47:52 -0700 Subject: [PATCH 1/2] Use model(code = ) --- tests/testthat/test-model.R | 2 +- tests/testthat/test-zzz-analyse.R | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/testthat/test-model.R b/tests/testthat/test-model.R index 4a8257e..df507d7 100644 --- a/tests/testthat/test-model.R +++ b/tests/testthat/test-model.R @@ -32,7 +32,7 @@ test_that("analyse", { prediction[i] <- exp(bIntercept + bYear * Year[i] + bHabitatQuality[HabitatQuality[i]] + bSiteYear[Site[i], YearFactor[i]]) } " - model <- model(template, + model <- model(code = template, select_data = list("Year+" = numeric(), YearFactor = factor(), Site = factor(), Density = numeric(), HabitatQuality = factor()), diff --git a/tests/testthat/test-zzz-analyse.R b/tests/testthat/test-zzz-analyse.R index 086ef05..3fd3c74 100644 --- a/tests/testthat/test-zzz-analyse.R +++ b/tests/testthat/test-zzz-analyse.R @@ -39,7 +39,7 @@ test_that("analyse character vector", { residual[i] <- res_lnorm(Density[i], fit[i], exp(log_sDensity)) }" - model <- model(jags_template, + model <- model(code = jags_template, select_data = list("Year+" = numeric(), YearFactor = factor(), Site = factor(), Density = numeric(), HabitatQuality = factor()), @@ -171,7 +171,7 @@ test_that("analyse vectorized stand alone character", { residual[i] <- res_lnorm(Density[i], fit[i], exp(log_sDensity)) }" - model <- model(jags_template, + model <- model(code = jags_template, select_data = list("Year+" = numeric(), YearFactor = factor(), Site = factor(), Density = numeric(), HabitatQuality = factor()), @@ -268,7 +268,7 @@ test_that("analyse vectorized embedded expression", { data <- embr::density99 data$YearFactor <- factor(data$Year) - model <- model("model{ + model <- model(code = "model{ bIntercept ~ dnorm(0, 5^-2) bYear ~ dnorm(0, .5^-2) # bYear2 ~ dnorm(0, .5^-2) From 4b2ccdfca562de214bb2467ec5d2f7f896b36143 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kirill=20M=C3=BCller?= Date: Fri, 29 Sep 2023 17:24:40 -0700 Subject: [PATCH 2/2] Relax test --- tests/testthat/test-zzz-analyse.R | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/testthat/test-zzz-analyse.R b/tests/testthat/test-zzz-analyse.R index 3fd3c74..9a0002a 100644 --- a/tests/testthat/test-zzz-analyse.R +++ b/tests/testthat/test-zzz-analyse.R @@ -55,8 +55,8 @@ test_that("analyse character vector", { expect_true(all(as.integer(data2$YearFactor) == 1L)) # need random seed so repeatable R2c <- R2(analysis, "Density") - expect_gt(R2c, 0.6) - expect_lt(R2c, 0.8) + expect_gt(R2c, 0.5) + expect_lt(R2c, 0.9) R2m <- R2(analysis, "Density", marginal = TRUE) expect_gt(R2m, 0.0) @@ -187,8 +187,8 @@ test_that("analyse vectorized stand alone character", { expect_true(all(as.integer(data2$YearFactor) == 1L)) # need random seed so repeatable R2c <- R2(analysis, "Density") - expect_gt(R2c, 0.6) - expect_lt(R2c, 0.8) + expect_gt(R2c, 0.5) + expect_lt(R2c, 0.9) R2m <- R2(analysis, "Density", marginal = TRUE) expect_gt(R2m, 0.0) @@ -314,8 +314,8 @@ random_effects = list(bSiteYear = c("Site", "YearFactor"))) expect_true(all(as.integer(data2$YearFactor) == 1L)) # need random seed so repeatable R2c <- R2(analysis, "Density") - expect_gt(R2c, 0.6) - expect_lt(R2c, 0.8) + expect_gt(R2c, 0.5) + expect_lt(R2c, 0.9) R2m <- R2(analysis, "Density", marginal = TRUE) expect_gt(R2m, 0.0)