From 621866e7526abf6d1099fec26210e70619d4def8 Mon Sep 17 00:00:00 2001 From: Jack Leary Date: Wed, 23 Oct 2024 14:33:02 -0400 Subject: [PATCH] fixed bug in marge2() related to duplicate basis fns -- closes #260 --- R/marge2.R | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/R/marge2.R b/R/marge2.R index 9cd95a9..f2ff978 100644 --- a/R/marge2.R +++ b/R/marge2.R @@ -809,6 +809,12 @@ marge2 <- function(X_pred = NULL, # Some final model output, WIC, GCV etc. B_final <- as.matrix(B[, colnames(B) %in% cnames_2[[which.min(WIC_vec_2)]]]) model_df <- as.data.frame(B_final) + # remove duplicate hinge functions if present + if (length(unique(colnames(model_df))) != ncol(model_df)) { + unique_cols <- which(!duplicated(as.list(model_df))) + B_final <- B_final[, unique_cols] + model_df <- model_df[, unique_cols] + } if (ncol(model_df) == 1) { colnames(model_df) <- c("Intercept") model_formula <- "Y ~ -1 + Intercept" @@ -823,7 +829,7 @@ marge2 <- function(X_pred = NULL, } if (!is.glmm) { if (!is.null(Y.offset)) { - model_df <- dplyr::mutate(model_df, ßcell_offset = Y.offset) + model_df <- dplyr::mutate(model_df, cell_offset = Y.offset) model_formula <- paste0(model_formula, " + ", "offset(log(1 / cell_offset))") # this is correct i promise } model_formula <- stats::as.formula(model_formula)