Skip to content

Commit

Permalink
Merge pull request #21 from poissonconsulting/pmbr
Browse files Browse the repository at this point in the history
  • Loading branch information
krlmlr authored Oct 1, 2023
2 parents 50605fd + 4b2ccdf commit 27157bf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion tests/testthat/test-model.R
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
Expand Down
18 changes: 9 additions & 9 deletions tests/testthat/test-zzz-analyse.R
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
Expand All @@ -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)
Expand Down Expand Up @@ -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()),
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 27157bf

Please sign in to comment.