From 67409a9fc404abc114720e8afb1a552c973a0d4e Mon Sep 17 00:00:00 2001 From: Sarah Teichman Date: Wed, 31 Jul 2024 16:06:57 -0700 Subject: [PATCH] use grant's more general way to check for an intercept column --- R/multinom_test.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/multinom_test.R b/R/multinom_test.R index 4de5ca1..d00d704 100644 --- a/R/multinom_test.R +++ b/R/multinom_test.R @@ -30,8 +30,8 @@ covariates in formula must be provided.") X <- model.matrix(formula, data) } - # if X has intercept column, remove it - if (sum(X[, 1] == 1) == nrow(X)) { + # if X has intercept column (or a column of repeating values), remove it + if (all(round((X %*% solve(t(X) %*% X) %*% t(X)) %*% rep(1, nrow(X)), 1e-20) == 1)) { X <- X[, -1, drop = FALSE] }