Skip to content
Merged
Changes from all commits
Commits
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
11 changes: 9 additions & 2 deletions R/get_condition_number_for_fit.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,16 @@ get_condition_number_for_fit <- function(
}
mat <- as.matrix(fit$correlation_matrix)
if(!inherits(mat, "matrix") || diff(dim(mat)) != 0) {
cli::cli_abort("Needs a square matrix to calculate condition number.")
cli::cli_alert_warning("Needs a square matrix to calculate condition number.")
return(NA)
}
calc_condition_number(mat)
tryCatch({
cond <- calc_condition_number(mat)
}, error = function(e) {
cli::cli_alert_warning("Failed to calculate condition number: {e}")
cond <- NA
})
cond
}

#' Calculate the condition number given a matrix
Expand Down
Loading