Repository navigation
Fix term matching in check_collinearity() for clm scale and nominal effects, more vglm families, and backticked multinomial names - #992
Merged
Conversation
…, more vglm families, backticked multinomial names, and a rank-deficient flag without NA columns
… and name the scale and nominal effects left out
…lm()` in `check_collinearity()`
…covariance matrix has no NA columns
…k deficient, document the new vglm families, and test more cases in `check_collinearity()`
Contributor
There was a problem hiding this comment.
🔵 Needs a closer look
Split the optional mclogit test dependency and document its backticked-name fix in NEWS.
No open issues 🎉
1 file not reviewed
man/check_collinearity.Rd: Generated file
What changed in this PR
Fixes term-to-coefficient matching in check_collinearity() across CLM, VGAM, and multinomial models.
Changes:
- Corrects CLM, VGAM, and backticked-name matching.
- Improves rank-deficiency handling.
- Adds regression tests and updates documentation, NEWS, and version metadata.
| File | Summary |
|---|---|
tests/testthat/test-check_collinearity.R |
Adds regression coverage for affected model types. |
R/check_collinearity.R |
Updates term matching and rank-deficiency logic. |
NEWS.md |
Documents user-visible fixes. |
man/check_collinearity.Rd |
Updates function documentation. |
DESCRIPTION |
Increments the development version. |
Review effort: Lite
Contributor
Author
|
Copilot summary points addressed in bf3b7cd: the |
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
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.
check_collinearity()matched coefficients to the wrong terms, or to no terms, for three kinds of models.What changes
ordinal::clm()with scale effects. The variance-covariance matrix has the thresholds first, then the location slopes, then the scale effects. A scale effect can have the same name as a location slope. An example isx1inclm(y ~ x1 + x2 + x3, scale = ~ x1). The slopes were kept by name, so the VIF ofx1also used the scale column. clm slopes are now kept by position. For clm fits with scale or nominal effects, a message names the effects that the VIFs leave out. A location term that is also a nominal effect, which clm drops, is no longer reported as rank deficient.VGAM::vglm()with thesratio(),cratio(),acat(), andpoissonff()families. These fits took the default branch with theassignlist of the model matrix. When a term had more than one column, they failed with "'list' object cannot be coerced to type 'integer'". Otherwise they gave VIFs for the wrong terms. They now use the branch that the multinomial and cumulative families use. The Details section of?check_collinearitynames the new families.y ~ `my x` + x2.insight::get_varcov()drops the backticks from the column names, whilecoef()and the model matrix keep them. These fits returnedNULLwith "Could not extract model terms". Backticks are now removed on all sides before matching.rank_deficientattribute, nona_columns_index, and noNA. For that matrix, it usedna_colsbefore it was set.na_colsnow starts asNULL.Tests
scale = ~ x1and withnominal = ~ x3, against the generalized VIF of the location slope columns ofvcov().sratio(parallel = TRUE)), against the generalized VIF over the columns that theassignlist gives each term. The poissonff fit also matchesglm(family = poisson).my_x.insight::get_varcov()with therank_deficientattribute and noNAcolumns.These tests fail on main and pass with this change. The one failing test in
devtools::test(),test_performance - lavaanin test-test_performance.R, fails the same way on main.#990 and #991 also change
R/check_collinearity.RandNEWS.md.