Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bugs in endemic_channel function #145

Merged
merged 9 commits into from
Sep 16, 2024
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
5 changes: 2 additions & 3 deletions R/endemic_channel.R
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,8 @@ endemic_channel <- function(incidence_historic, observations = NULL,
"`observations` must be numeric and positive" =
(is.numeric(observations) &&
all(observations >= 0)),
"`observations` size doesn't correspond to incidence interval" =
((incidence_historic$interval == "1 week" &
length(observations) == 52))
"`observations` size is larger than the epidemiological year" =
(length(observations) <= 52)
)
}

Expand Down
6 changes: 3 additions & 3 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,8 @@ geometric_mean <- function(x, method = c(
w_positive <- length(x_positive) / n_x
x_negative <- x[x < 0]
w_negative <- length(x_negative) / n_x
gm_positive <- exp(sum(log(x_positive)) / n_x)
gm_negative <- -1 * exp(sum(log(abs(x_negative))) / n_x)
gm_positive <- exp(sum(log(x_positive)))
gm_negative <- -1 * exp(sum(log(abs(x_negative))))
gm <- w_positive * gm_positive + w_negative * gm_negative
} else if (method == "optimized") {
# The formula is:
Expand Down Expand Up @@ -309,7 +309,7 @@ geometric_sd <- function(x, method = c(

if (method == "positive") {
stopifnot("`x` includes zero or negative values,
check the geom_mean methods" = any(x <= 0))
check the geom_mean methods" = any(x > 0))
gsd <- stats::sd((log(x)))
} else if (method == "shifted") {
x_shifted <- x + shift
Expand Down
1 change: 1 addition & 0 deletions inst/WORDLIST
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Codecov
ColOpenData
Cordovez
DIVIPOLA
DOI
De
DOI
Epimodelac
Expand Down
Loading