Skip to content

Commit

Permalink
define logit and inv.logit for annual interannualVar and test interan…
Browse files Browse the repository at this point in the history
…naulVar
  • Loading branch information
Sarah Endicott committed Oct 17, 2024
1 parent 5c81550 commit 5ebe3c8
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
9 changes: 9 additions & 0 deletions R/betaSample.R
Original file line number Diff line number Diff line change
Expand Up @@ -152,3 +152,12 @@ rtrunc <- function (n, spec, a = -Inf, b = Inf, ...){
x <- qtrunc(u, spec, a = a, b = b, ...)
return(x)
}

# used for annual interannual variation
inv.logit <-function(x){
exp(x)/(1+exp(x))
}

logit <-function(x){
log(x/(1-x))
}
13 changes: 13 additions & 0 deletions tests/testthat/test-caribouPopGrowth.R
Original file line number Diff line number Diff line change
Expand Up @@ -214,3 +214,16 @@ test_that("pop Growth matches Johnson figures", {
expect_equal(testCheck$lambda, theor_lam, tolerance = 0.003)
expect_equal(testCheck$lambda, mean(check$lambda), tolerance = 0.003)
})

test_that("interannualVar works as expected", {
def_IV <- caribouPopGrowth(rep(1000, 10), 200, R_bar = 0.7, S_bar = 0.99, progress = FALSE)
expect_s3_class(def_IV, "data.frame")

phi_IV <- caribouPopGrowth(rep(1000, 10), 200, R_bar = 0.7, S_bar = 0.99, progress = FALSE,
interannualVar = list(R_phi = 0.5, S_phi = 0.5))
expect_s3_class(phi_IV, "data.frame")

annual_IV <- caribouPopGrowth(rep(1000, 10), 200, R_bar = 0.7, S_bar = 0.99, progress = FALSE,
interannualVar = list(R_annual = 0.5, S_annual = 0.5))
expect_s3_class(annual_IV, "data.frame")
})

0 comments on commit 5ebe3c8

Please sign in to comment.