Skip to content

Commit

Permalink
linReg: improve singularity error message
Browse files Browse the repository at this point in the history
With this commit, an warning notice is added, if one of the models
in the analysis has a singularity issue. Also fixes an indexing problem
that appears when a model contains aliased coefficients.
  • Loading branch information
raviselker committed Dec 10, 2024
1 parent 6d1c1d4 commit 1667f98
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions R/linreg.b.R
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,9 @@ linRegClass <- R6::R6Class(
if (is.null(self$options$dep) || self$nModels < 1 || length(self$options$blocks[[1]]) == 0)
return()

if (any(private$.getIsAliased()))
setSingularityWarning(self)

private$.populateModelFitTable()
private$.populateModelCompTable()
private$.populateAnovaTables()
Expand Down Expand Up @@ -316,10 +319,11 @@ linRegClass <- R6::R6Class(

VIF <- list()
for (i in seq_along(self$models)) {
if ( ! private$.getIsAliased()[[i]] && length(modelTerms[[i]]) > 1 )
if ( ! private$.getIsAliased()[[i]] && length(modelTerms[[i]]) > 1 ) {
VIF[[i]] <- car::vif(self$models[[i]])
else
VIF[[i]] <- NULL
} else {
VIF[[i]] <- c(VIF, list(NULL))
}
}

return(VIF)
Expand Down

0 comments on commit 1667f98

Please sign in to comment.