-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for missing NAs in estimate_infection() model (#528)
* add a lookup to estimate_infections * add R side support * don't internally impute missing as zero * update news * fix data preprocessing order * correction data ingestion * clean up filtering of leading zeros * error check create_clean_reported_cases and add unit tests to cover function * correct handling of missing data in data preprocessing: * refine data preprocessing * update news and tests * update global variables * Update NEWS.md Co-authored-by: Sebastian Funk <[email protected]> * Update R/create.R Co-authored-by: Sebastian Funk <[email protected]> * Update R/create.R Co-authored-by: Sebastian Funk <[email protected]> * Update R/create.R Co-authored-by: Sebastian Funk <[email protected]> * fix line length linting * Document --------- Co-authored-by: Sebastian Funk <[email protected]> Co-authored-by: GitHub Actions <[email protected]>
- Loading branch information
1 parent
cb5289d
commit 380a979
Showing
13 changed files
with
126 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
int t; // unobserved time | ||
int lt; // timepoints in the likelihood | ||
int seeding_time; // time period used for seeding and not observed | ||
int horizon; // forecast horizon | ||
int future_time; // time in future for Rt | ||
array[t - horizon - seeding_time] int<lower = 0> cases; // observed cases | ||
array[lt] int<lower = 0> cases; // observed cases | ||
array[lt] int cases_time; // time of observed cases | ||
vector<lower = 0>[t] shifted_cases; // prior infections (for backcalculation) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
|
||
test_that("create_clean_reported_cases runs without errors", { | ||
expect_no_error(create_clean_reported_cases(example_confirmed, 7)) | ||
}) | ||
|
||
test_that("create_clean_reported_cases returns a data table", { | ||
result <- create_clean_reported_cases(example_confirmed, 7) | ||
expect_s3_class(result, "data.table") | ||
}) | ||
|
||
test_that("create_clean_reported_cases filters leading zeros correctly", { | ||
# Modify example_confirmed to have leading zeros | ||
modified_data <- example_confirmed | ||
modified_data[1:3, "confirm"] <- 0 | ||
|
||
result <- create_clean_reported_cases(modified_data, 7) | ||
# Check if the first row with non-zero cases is retained | ||
expect_equal( | ||
result$date[1], min(modified_data$date[modified_data$confirm > 0]) | ||
) | ||
}) | ||
|
||
test_that("create_clean_reported_cases replaces zero cases correctly", { | ||
# Modify example_confirmed to have zero cases that should be replaced | ||
modified_data <- example_confirmed | ||
modified_data$confirm[10:16] <- 0 | ||
threshold <- 10 | ||
|
||
result <- create_clean_reported_cases( | ||
modified_data, 0, zero_threshold = threshold | ||
) | ||
# Check if zero cases within the threshold are replaced | ||
expect_equal(sum(result$confirm == 0, na.rm = TRUE), 0) | ||
}) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters