-
-
Notifications
You must be signed in to change notification settings - Fork 26
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
Fix subfit
issues (mainly due to the lack of xlev
)
#403
Merged
Conversation
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
… model matrix, not just the number of its columns.
level of a `factor`-coerced `character` variable. Also fix a bug causing a re-ordering of the levels of a `factor` in `newdata` (compared to that `factor` in the original dataset) not to get recognized by `predict.subfit()`, which in turn causes `x %*% rbind(alpha, beta)` to be incorrect in such cases. Also fix an error thrown by `fit_glm_ridge_callback()` in case of unused levels of a `factor`, namely: ``` warning: solve(): system is singular; attempting approx solution Error: solve(): solution not found ```
…glm_ridge_callback()`).
is not necessary (as `collapse_contrasts_solution_path()` would also work correctly without this change), but done for consistency.
…earch_L1()`. This is not necessary (as `search_L1()` would also work correctly without this change, thanks to its `match()` call and the following `indices <- indices[!is.na(indices)]` line), but done for consistency.
(which is the default only for `datafit`s, not for the reference model objects of class `refmodel` that are usually employed in practice) to lead to incorrect predictions from the L1-searched submodels (which are L1-penalized GLMs) if the solution path had a main effect ranked after an interaction term. This bug existed at least from version 2.0.2 on (perhaps even in earlier versions). The mentioned submodel predictions did not only affect the performance evaluation, but also the projected dispersion parameter and the returned Kullback-Leibler divergence (and the corresponding cross-entropy). This bug came up in the unit tests (with `run_more = TRUE`), file `test_datafit.R`, when creating `cvvss_datafit`, element `args_cvvs_i <- args_cvvs_datafit$rstanarm.glm.gauss.spclformul.with_wobs.with_offs.trad.default_meth.kfold.default_search_trms`.
…of the model matrix (for safety reasons).
with `refit_prj = FALSE` to lead to incorrect predictions from the L1-searched submodels if the solution path had a main effect ranked after an interaction term.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This resolves several bugs related to submodel fits of class
subfit
, see the message of commits fcf1408 and d08920a. The main problem was that inpredict.subfit()
, argumentxlev
ofmodel.matrix()
was not used. Unfortunately, deriving thesexlevels
at fitting time is not really straightforward, which is the reason why this PR adds a bunch of code for deriving these at the beginning offit_glm_ridge_callback()
andsearch_L1()
.All of the issues resolved by commit fcf1408 can be reproduced using the following code:
(All of the calls following a commented
debug()
call failed before this PR and succeed afterwards.)For the issue resolved by commit d08920a, see the corresponding commit message for reproducibility instructions.