-
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.
Handle messaging around model treatment of missingness (#774)
* Add message about NA treatment for option "missing" * Add missing tests for obs_opts * Add NEWS item * Improve messages Co-authored-by: Sebastian Funk <[email protected]> * Check if na is explicitly specified by user Co-authored-by: Sebastian Funk <[email protected]> * Change less regular to non-daily * Create function to test for complete data * Add tests for test_data_complete * Document test_data_complete * Add function to crosscheck na as missing setting with data * Move message elsewhere and only check if na is specified for later use * Add new global * Apply na cross checking function in main functions * Rename dirty data * Add test for na cross checking function * Add more tests to obs_opts * Remove global variable * Use alternative syntax to avoid linting issues * copy before modifying data.table * Fix test * Update NEWS.md * Make message/warning verbose and test for message/warning * Simplify comment * Use vapply for type safety * Add lifecycle badge * Add lifecycle badge * Improve docs * Return unmodified obs_opts * Move removal of element of obs_opts() into checker function * Use setequal instead of checking lengths * Remove new unnecessary new lines * Remove trailing white space * Add test to check for expected element introduced * Add new argument to pass column names * Add error for column mismatch * Refactor for readability * Perform missingness check on the raw data * Remove test that no longer applies * Add reviewer and PR number Co-authored-by: Sebastian Funk <[email protected]> --------- Co-authored-by: Sebastian Funk <[email protected]>
- Loading branch information
1 parent
259b150
commit f5927c4
Showing
9 changed files
with
290 additions
and
7 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
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
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,31 @@ | ||
test_that("obs_opts returns expected default values", { | ||
result <- suppressWarnings(obs_opts()) | ||
|
||
expect_s3_class(result, "obs_opts") | ||
expect_equal(result$family, "negbin") | ||
expect_equal(result$weight, 1) | ||
expect_true(result$week_effect) | ||
expect_equal(result$week_length, 7L) | ||
expect_equal(result$scale, list(mean = 1, sd = 0)) | ||
expect_equal(result$accumulate, 0) | ||
expect_true(result$likelihood) | ||
expect_false(result$return_likelihood) | ||
}) | ||
|
||
test_that("obs_opts returns expected messages", { | ||
# The option na = "accumulate" informs the user of what is | ||
# going to be done once every 8 hours, so hard to test regularly. | ||
# NB: We change the local setting here to throw the message on demand, rather | ||
# than every 8 hours, for the sake of multiple runs of the test within | ||
# 8 hours. | ||
rlang::local_options(rlib_message_verbosity = "verbose") | ||
expect_message( | ||
obs_opts(na = "accumulate"), | ||
"modelled values that correspond to NA values" | ||
) | ||
}) | ||
|
||
test_that("obs_opts behaves as expected for user specified na treatment", { | ||
# If user explicitly specifies NA as missing, then don't throw message | ||
expect_false(obs_opts(na = "missing")$na_as_missing_default_used) | ||
}) |