Skip to content

Commit

Permalink
fixed bug in marge2() related to duplicate basis fns -- closes #260
Browse files Browse the repository at this point in the history
  • Loading branch information
jr-leary7 committed Oct 23, 2024
1 parent 40c2ade commit 621866e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion R/marge2.R
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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)
Expand Down

0 comments on commit 621866e

Please sign in to comment.