Skip to content

Commit b20faaa

Browse files
committed
Added review suggestions
1 parent 4ff827f commit b20faaa

File tree

4 files changed

+21
-20
lines changed

4 files changed

+21
-20
lines changed

R/aedseo.R

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,14 @@
1313
#' @param level The confidence level for parameter estimates, a numeric value
1414
#' between 0 and 1.
1515
#' @param disease_threshold An integer specifying the threshold for considering
16-
#' a disease outbreak. It defines the one time step disease threshold that has
17-
#' to be surpassed to trigger a seasonal onset alarm. If the sum of cases in a
18-
#' k window exceeds this threshold * k, a seasonal onset alarm is triggered.
16+
#' a disease outbreak. It defines the per time-step disease threshold that has
17+
#' to be surpassed to possibly trigger a seasonal onset alarm. If the total
18+
#' number of cases in a window of size k exceeds `disease_threshold * k`,
19+
#' a seasonal onset alarm can be triggered.
1920
#' @param family A character string specifying the family for modeling.
2021
#' Choose between "poisson," or "quasipoisson".
21-
#' @param na_percentage_allowed Numeric value specifying how many percentage of
22-
#' the observables in the k window that are allowed to be NA.
22+
#' @param na_fraction_allowed Numeric value specifying the fraction of
23+
#' observables in the window of size k that are allowed to be NA.
2324
#'
2425
#' @return A `aedseo` object containing:
2526
#' - 'reference_time': The time point for which the growth rate is estimated.
@@ -36,7 +37,7 @@
3637
#' disease threshold?
3738
#' - 'seasonal_onset_alarm': Logical. Is there a seasonal onset alarm?
3839
#' - 'converged': Logical. Was the IWLS judged to have converged?
39-
#' - 'skipped_window': Logical. Was the window skipped?
40+
#' - 'skipped_window': Logical. Was the window skipped due to missing?
4041
#'
4142
#' @export
4243
#'
@@ -62,7 +63,7 @@
6263
#' level = 0.95,
6364
#' disease_threshold = 200,
6465
#' family = "poisson",
65-
#' na_percentage_allowed = 0.4,
66+
#' na_fraction_allowed = 0.4,
6667
#' )
6768
#'
6869
#' # Print the AEDSEO results
@@ -77,7 +78,7 @@ aedseo <- function(
7778
"quasipoisson"
7879
# TODO: #10 Include negative.binomial regressions. @telkamp7
7980
),
80-
na_percentage_allowed = 0.4) {
81+
na_fraction_allowed = 0.4) {
8182
# Throw an error if any of the inputs are not supported
8283
family <- rlang::arg_match(family)
8384

@@ -93,7 +94,7 @@ aedseo <- function(
9394
obs_iter <- tsd[(i - k + 1):i, ]
9495

9596
# Evaluate NA values in windows
96-
if (sum(is.na(obs_iter)) >= k * na_percentage_allowed) {
97+
if (sum(is.na(obs_iter)) >= k * na_fraction_allowed) {
9798
skipped_window[i] <- TRUE
9899
# Set fields to NA since the window is skipped
99100
growth_rates <- list(estimate = c(NA, NA, NA),

man/aedseo.Rd

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/test-aedseo.R

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ test_that("The growth rate models converge", {
2727
level = 0.95,
2828
family = "poisson",
2929
disease_threshold = 20,
30-
na_percentage_allowed = 0.2
30+
na_fraction_allowed = 0.2
3131
)
3232
aedseo_quasipoisson <- aedseo(
3333
tsd = tsd_data_nbinom,
3434
k = 3,
3535
level = 0.95,
3636
family = "quasipoisson",
3737
disease_threshold = 20,
38-
na_percentage_allowed = 0.2
38+
na_fraction_allowed = 0.2
3939
)
4040

4141
# Check if they all converge
@@ -79,18 +79,18 @@ test_that("Test if it works with weeks with NA values", {
7979
level = 0.95,
8080
family = "poisson",
8181
disease_threshold = 20,
82-
na_percentage_allowed = 0.4
82+
na_fraction_allowed = 0.4
8383
)
8484

8585
# Test if correct amount of windows with NA are skipped
8686
k <- 3
87-
na_percentage_allowed <- 0.4
87+
na_fraction_allowed <- 0.4
8888
n <- base::nrow(tsd_data_poisson_na)
8989
skipped_window_count <- 0
9090

9191
for (i in k:n) {
9292
obs_iter <- tsd_data_poisson_na[(i - k + 1):i, ]
93-
if (sum(is.na(obs_iter)) >= k * na_percentage_allowed) {
93+
if (sum(is.na(obs_iter)) >= k * na_fraction_allowed) {
9494
skipped_window_count <- skipped_window_count + 1
9595
}
9696
}

vignettes/aedseo_introduction.Rmd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ In the following figure, the simulated data (solid circles) is visualized alongs
174174
plot(tsd_data)
175175
```
176176

177-
Next, the time series data object is passed to the `aedseo()` function. Here, a window width of $k=5$ is specified, meaning that a total of 5 weeks is used in the local estimate of the exponential growth rate. $na_percentage_allowed = 0.4$ defines how many percentage of the observables in the k window that are allowed to be NA, here 0.4*5 = 20%. Additionally, a 95\% confidence interval is specified. Finally, the exponential growth rate is estimated using quasi-Poisson regression to account for overdispersion in the data.
177+
Next, the time series data object is passed to the `aedseo()` function. Here, a window size of $k=5$ is specified, meaning that a total of 5 weeks is used in the local estimate of the exponential growth rate. $na_fraction_allowed = 0.4$ defines how large a fraction of observables in the k window that are allowed to be NA, here 0.4*5 = 2 observables. Additionally, a 95\% confidence interval is specified. Finally, the exponential growth rate is estimated using quasi-Poisson regression to account for overdispersion in the data.
178178

179179
```{r}
180180
# Apply the 'aedseo' algorithm
@@ -184,7 +184,7 @@ aedseo_results <- aedseo(
184184
level = 0.95,
185185
disease_threshold = 2000,
186186
family = "quasipoisson",
187-
na_percentage_allowed = 0.4
187+
na_fraction_allowed = 0.4
188188
)
189189
```
190190

0 commit comments

Comments
 (0)