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

Bug: Warning in imputation functions is too restrictive #1810

Closed
bundfussr opened this issue Mar 8, 2023 · 3 comments · Fixed by #1812 or #1813
Closed

Bug: Warning in imputation functions is too restrictive #1810

bundfussr opened this issue Mar 8, 2023 · 3 comments · Fixed by #1812 or #1813
Assignees
Labels
bug Something isn't working hotfix Issue to be released in the next patch release programming

Comments

@bundfussr
Copy link
Collaborator

What happened?

The following call issues a warning.

  derive_vars_dtm(
    dtc = AESTDTC,
    new_vars_prefix = "AST",
    highest_imputation = "Y",
    time_imputation = "last",
    min_dates = exprs(TEMP_TRTSDTM),
    max_dates = exprs(AENDTM),
    preserve = TRUE
  ) 

It is caused by the following check.

  if (highest_imputation == "Y" & !is.null(min_dates) & date_imputation != "first") {
    warning("If `highest_impuation` = \"Y\" and `min_dates` is specified, `date_imputation` should be set to \"first\".") # nolint
  }

It should be updated to

  if (highest_imputation == "Y" & is.null(min_dates) & date_imputation == "first") {
    warning("If `highest_impuation` = \"Y\" and `date_imputation = \"first\"` is specified, `min_dates` should be specified.") # nolint
  }

Session Information

No response

Reproducible Example

No response

@bundfussr bundfussr added bug Something isn't working programming hotfix Issue to be released in the next patch release labels Mar 8, 2023
@bundfussr
Copy link
Collaborator Author

@millerg23 , found this bug. We think we should fix it in a hotfix release.

@bms63 , @thomas-neitmann , @zdz2101 , do you agree?

@zdz2101
Copy link
Collaborator

zdz2101 commented Mar 8, 2023

image

I think when I was trying to implement the fix during the release, I tried following the "guidance" here, is there a particular "hierachy" of the function arguments? So for highest_impuation == "Y" , if I'm interpreting correctly, there should be a check of 1:1 correspondence between:

  • supplying min_dates and date_imputation == "first"
  • supplying max_dates and date_imputation == "last"

image

Wondering if we need to consider them in separate case-conditions?

@bundfussr
Copy link
Collaborator Author

If highest_imputation == "Y", three conditions should be checked:

  • date_imputation %in% c("first", "last")
  • if date_imputation == "first" then min_dates should be specified.
  • if date_imputation == "last" then max_dates should be specified.

In particular, it is permitted to specify both min_dates and max_dates.

@zdz2101 zdz2101 self-assigned this Mar 8, 2023
@zdz2101 zdz2101 linked a pull request Mar 8, 2023 that will close this issue
14 tasks
@bms63 bms63 linked a pull request Mar 10, 2023 that will close this issue
14 tasks
@bms63 bms63 closed this as completed Mar 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment