-
-
Notifications
You must be signed in to change notification settings - Fork 40
include_reference
doesn't work for pscl
models
#1134
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
Draft
strengejacke
wants to merge
6
commits into
main
Choose a base branch
from
strengejacke/issue1130
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
617e6e5
`include_reference` doesn't work for `pscl` models
strengejacke fb93525
Merge branch 'main' into strengejacke/issue1130
strengejacke ef4b1db
Merge branch 'main' into strengejacke/issue1130
strengejacke 69601ec
Merge branch 'main' into strengejacke/issue1130
strengejacke d501e3b
Merge branch 'main' into strengejacke/issue1130
strengejacke 948a010
Merge branch 'main' into strengejacke/issue1130
strengejacke File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
---|---|---|
|
@@ -255,13 +255,19 @@ | |
# iterate all factors in the data and check if any factor was used in the model | ||
for (fn in names(factors)) { | ||
f <- factors[[fn]] | ||
# for models from pscl, we have "count_" and "zero_" prefixes, which | ||
# we need to add to "f" names, so that we can match them with the parameters | ||
if (inherits(model, c("zeroinfl", "hurdle"))) { | ||
f <- c(paste0("count_", f), paste0("zero_", f)) | ||
} | ||
# "f" contains all combinations of factor name and levels from the data, | ||
# which we can match with the names of the pretty_names vector | ||
found <- which(names(pretty_names) %in% f) | ||
# if we have a match, we add the reference level to the pretty_names vector | ||
if (length(found)) { | ||
# the reference level is *not* in the pretty names yet | ||
reference_level <- f[!f %in% names(pretty_names)] | ||
reference_level <- gsub("^(count_|zero_)", "", reference_level, fixed = TRUE) | ||
Comment on lines
269
to
+270
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
# for on-the-fly conversion of factors, the names of the factors can | ||
# can also contain "factor()" or "as.factor()" - we need to remove these | ||
|
@@ -279,11 +285,11 @@ | |
if (all(grepl(pattern_cut_right, pretty_level))) { | ||
lower_bounds <- gsub(pattern_cut_right, "\\2", pretty_level) | ||
upper_bounds <- gsub(pattern_cut_right, "\\3", pretty_level) | ||
pretty_level <- gsub(pattern_cut_right, paste0("\\1>", as.numeric(lower_bounds), "-", upper_bounds, "]"), pretty_level) | ||
} else if (all(grepl(pattern_cut_left, pretty_level))) { | ||
lower_bounds <- gsub(pattern_cut_left, "\\2", pretty_level) | ||
upper_bounds <- gsub(pattern_cut_left, "\\3", pretty_level) | ||
pretty_level <- gsub(pattern_cut_left, paste0("\\1", as.numeric(lower_bounds), "-<", upper_bounds, "]"), pretty_level) | ||
} | ||
# insert new pretty level at the correct position in "pretty_names" | ||
pretty_names <- .insert_element_at( | ||
|
@@ -407,7 +413,7 @@ | |
|
||
# helper to format the header / subheader of different model components -------------- | ||
|
||
.format_model_component_header <- function(x, | ||
type, | ||
split_column, | ||
is_zero_inflated, | ||
|
@@ -697,7 +703,7 @@ | |
# or edge cases... | ||
|
||
#' @keywords internal | ||
.format_columns_multiple_components <- function(x, | ||
pretty_names, | ||
split_column = "Component", | ||
digits = 2, | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be beneficial to add a comment explaining why these prefixes are necessary for
pscl
models. This enhances code understanding and maintainability.