Skip to content
Merged
Changes from 3 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
0ecf6f1
Fix collinearity inflation for ordinal models
jmgirard Apr 23, 2026
c645ff7
Address gemini-code-review feedback
jmgirard Apr 23, 2026
75f16f0
Apply styling
jmgirard Apr 23, 2026
3a84e3e
Revert gemini suggestion and fix slope identification
jmgirard Apr 23, 2026
b7f9fb5
Remove extra whitespace for air
jmgirard Apr 23, 2026
091be38
Move processing before rank deficiency checks
jmgirard Apr 23, 2026
035e33d
Break up condition for linter
jmgirard Apr 23, 2026
b3b266d
Remove dangling spaces for linter
jmgirard Apr 23, 2026
577e59a
Improve name-matching
jmgirard Apr 23, 2026
6f8c986
Fix line width again
jmgirard Apr 23, 2026
adcf453
Fix dangling spaces again
jmgirard Apr 23, 2026
d5d8798
Add news and increment version
jmgirard Apr 26, 2026
37cdbdc
Add clmm test
jmgirard Apr 26, 2026
0f2e0a5
Style for air
jmgirard Apr 26, 2026
1df8633
Style for air
jmgirard Apr 26, 2026
93cde37
Style for air
jmgirard Apr 26, 2026
f51ef91
Style for air
jmgirard Apr 26, 2026
ab7d8af
Style for air
jmgirard Apr 26, 2026
a46a0b3
Style for air
jmgirard Apr 26, 2026
c2a6b5c
Style for air
jmgirard Apr 26, 2026
e52bb08
Style for air
jmgirard Apr 26, 2026
16cbe71
Add clm test and fix bug
jmgirard Apr 26, 2026
fe9f424
Style for air
jmgirard Apr 26, 2026
f34962d
Merge branch 'main' into jmgirard/issue900
strengejacke Apr 27, 2026
3805449
Merge branch 'main' into jmgirard/issue900
strengejacke May 1, 2026
4639d89
Delete .vscode/settings.json
jmgirard May 1, 2026
8e5caa3
add offset test
jmgirard May 2, 2026
4a2acab
remove sanity check comment
jmgirard May 2, 2026
9f622e9
Style for air
jmgirard May 2, 2026
d84bf41
Style for air
jmgirard May 2, 2026
7311745
Style for air
jmgirard May 2, 2026
4a1f33e
Style for air
jmgirard May 2, 2026
56d9556
ignore .vscode
jmgirard May 2, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 23 additions & 6 deletions R/check_collinearity.R
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@
}


.check_collinearity <- function(x, component, ci = 0.95, verbose = TRUE) {

Check warning on line 450 in R/check_collinearity.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/check_collinearity.R,line=450,col=1,[cyclocomp_linter] Reduce the cyclomatic complexity of this expression from 44 to at most 40. Consider replacing high-complexity sections like loops and branches with helper functions.

Check warning on line 450 in R/check_collinearity.R

View workflow job for this annotation

GitHub Actions / lint / lint

file=R/check_collinearity.R,line=450,col=1,[cyclocomp_linter] Reduce the cyclomatic complexity of this expression from 44 to at most 40. Consider replacing high-complexity sections like loops and branches with helper functions.
v <- .safe(insight::get_varcov(x, component = component, verbose = FALSE))

# sanity check
Expand Down Expand Up @@ -491,12 +491,29 @@
}
}

# check for missing intercept
if (insight::has_intercept(x)) {
v <- v[-1, -1]
term_assign <- term_assign[-1]
} else if (isTRUE(verbose)) {
insight::format_alert("Model has no intercept. VIFs may not be sensible.")
# Filter to true slope parameters (handles multiple intercepts in ordinal models)
if (inherits(x, c("clm", "clmm"))) {
slope_names <- insight::find_parameters(x)$conditional
Comment thread
jmgirard marked this conversation as resolved.
Outdated
if (is.null(slope_names)) {
slope_names <- names(x$beta)
}
keep_idx <- which(colnames(v) %in% slope_names)
Comment thread
jmgirard marked this conversation as resolved.
} else if (insight::has_intercept(x)) {
Comment thread
jmgirard marked this conversation as resolved.
# Standard behavior: drop the first column/row (the singular intercept)
keep_idx <- seq_len(ncol(v))[-1]
} else {
keep_idx <- seq_len(ncol(v))
if (isTRUE(verbose)) {
insight::format_alert("Model without intercept. VIFs may not be sensible.")
}
}

# Safely subset the matrix and the assignment vector
if (length(keep_idx) < ncol(v)) {
if (!is.null(term_assign) && length(term_assign) == ncol(v)) {
term_assign <- term_assign[keep_idx]
}
v <- v[keep_idx, keep_idx, drop = FALSE]
}
Comment thread
jmgirard marked this conversation as resolved.

f <- insight::find_formula(x, verbose = FALSE)
Expand Down Expand Up @@ -535,7 +552,7 @@
return(NULL)
}

R <- stats::cov2cor(v)

Check warning on line 555 in R/check_collinearity.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/check_collinearity.R,line=555,col=3,[object_overwrite_linter] 'R' is an exported object from package 'tools'. Avoid re-using such symbols.

Check warning on line 555 in R/check_collinearity.R

View workflow job for this annotation

GitHub Actions / lint / lint

file=R/check_collinearity.R,line=555,col=3,[object_overwrite_linter] 'R' is an exported object from package 'tools'. Avoid re-using such symbols.
detR <- det(R)

result <- vector("numeric")
Expand Down
Loading