Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# fireSense_SpreadPredict (development version)

- A fit made with fireSense_SpreadFit's `link = "logistic3pUpper"` stores `upperTail1`; prediction uses the upper-tail link for it, chosen by the parameter's name (`fireSenseUtils::logisticAll()`). Needs fireSenseUtils >= 0.2.3.9038.

# fireSense_SpreadPredict 1.0.0

First release from `development` since `master` was last updated (2021-01-27). Full history: https://github.com/PredictiveEcology/fireSense_SpreadPredict/compare/a5b41f9...v1.0.0
Expand Down
4 changes: 2 additions & 2 deletions fireSense_SpreadPredict.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ defineModule(sim, list(
person("Alex M.", "Chubaty", email = "achubaty@for-cast.ca", role = "ctb")
),
childModules = character(),
version = list(fireSense_SpreadPredict = "1.0.0.9001", SpaDES.core = "0.1.0"),
version = list(fireSense_SpreadPredict = "1.0.0.9002", SpaDES.core = "0.1.0"),
timeframe = as.POSIXlt(c(NA, NA)),
timeunit = "year",
citation = list("citation.bib"),
documentation = list("README.txt", "fireSense_SpreadPredict.Rmd"),
reqdPkgs = list("magrittr", "Matrix", "methods", "terra", "SpaDES.core (>=3.0.4)", "stats",
"ggplot2", "viridis",
"PredictiveEcology/fireSenseUtils@development (>= 0.2.3.9029)"),
"PredictiveEcology/fireSenseUtils@development (>= 0.2.3.9038)"),
parameters = bindrows(
defineParameter(name = "lowerSpreadProb", class = "numeric", default = 0.13,
desc = "Lower asymptote of the 2- and 3-parameter logistic."),
Expand Down
20 changes: 20 additions & 0 deletions tests/testthat/test-spreadProb-values.R
Original file line number Diff line number Diff line change
Expand Up @@ -195,3 +195,23 @@ test_that("a fit made on the log scale is predicted on the log scale, as before"
## (x = 1.25 -> 0.2409) but (8.517 - 3.605) / 6.395 = 0.768 on the log scale (x = 1.518 -> 0.2445)
expect_gt(abs(v[3] - handLogistic3(1.25)), 0.003)
})

test_that("a fit with upperTail1 is predicted with the upper-tail link, from the parameter's name", {
## fireSense_SpreadFit's link "logistic3pUpper" stores one more logistic parameter, upperTail1
## (fireSenseUtils::logistic3pUpper(), Stukel 1988). It changes the curve only where
## hillSlope1 * x > 0: there u = hillSlope1 * x becomes -log(1 - a * u) / a for a < 0.
v <- predVals(toyRun(toyInputs(params = toyParams(upperTail1 = -0.5))))
handUpper <- function(x, a = -0.5) {
u <- 2 * x
u[u > 0] <- -log(1 - a * u[u > 0]) / a
0.13 + 0.12 / (1 + exp(-u))
}
## cell 4: x = 2.5, u = 5 -> 2 * log(3.5) = 2.505526 -> 0.13 + 0.12 * 0.9245283 = 0.2409434
expect_equal(v[4], 0.2409434, tolerance = 1e-6)
expect_equal(v[c(1, 3, 4, 6, 7, 8)], handUpper(c(0, 1.25, 2.5, 1, 1.125, 1.25)), tolerance = 1e-7)
## below the inflection nothing changes: cell 2 (x = -0.125) is the logistic3p value
expect_equal(v[2], 0.1825388, tolerance = 1e-6)
## and upperTail1 = 0 is logistic3p everywhere
v0 <- predVals(toyRun(toyInputs(params = toyParams(upperTail1 = 0))))
expect_equal(v0, predVals(toyRun()), tolerance = 1e-12)
})
Loading