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

Pass extra arguments mice.impute.rf() to ranger::ranger() #563

Merged
merged 2 commits into from Jul 19, 2023

Conversation

edbonneville
Copy link
Contributor

Hi! This PR allows to pass ... arguments to ranger::ranger() when using mice.impute.rf().

  • ... was only being passed along when rfPackage = "randomForest"; should want the same behaviour with the now default rfPackage = "ranger".
  • I initially just changed fit to ranger::ranger(x = xobs, y = yobs, num.trees = ntree, ...), but this triggers unused arguments warning for "type" (which I think is passed along to all mice.impute.method functions?). Hence, I use list(...), set extra_ranger_args[["type"]] <- NULL, and proceed with do.call() to avoid this warning.
  • Motivated in part because some of the extra ranger() arguments (e.g. mtry) can affect the quality of the imputations quite a bit.

@stefvanbuuren
Copy link
Member

Is a useful extension, but please implement in a slightly different way:

  • The ranger() function produces a warning for any argument name that is not in its argument list. It does not have a silent option, so also other names produce warnings.
  • Use fit <- suppressWarnings(ranger::ranger(x = xobs, y = yobs, num.trees = ntree, ...)) instead. This style is also used in various places in mice.impute.xxx() functions (though it has some downsides).
  • We cannot easily get rid off the global type model as this it used in various 2l functions.
  • A neater alternative for passing down argument is the blots facility (from "block-dots"), which allows you to specify dots argument for each block (this doesn't however solve the type warning).

Looking forward to your tweak.

@edbonneville
Copy link
Contributor Author

It has now been edited.. thank you also for mentioning the blots facility, which I was not yet aware of (and is indeed neater!).

@stefvanbuuren stefvanbuuren merged commit 87073f8 into amices:master Jul 19, 2023
6 checks passed
@edbonneville edbonneville deleted the passing_args_ranger branch July 19, 2023 13:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants