From c9c995bbecd10a0b3de809f9d1b1b1ae4997a0b4 Mon Sep 17 00:00:00 2001 From: seonghobae <8172694+seonghobae@users.noreply.github.com> Date: Mon, 31 Aug 2026 04:20:39 +0000 Subject: [PATCH 1/3] =?UTF-8?q?=E2=9A=A1=20Bolt:=20Optimize=20ifelse=20ove?= =?UTF-8?q?rhead=20in=20glm=20binomial=20likelihood=20calculations?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- R/llcont.R | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/R/llcont.R b/R/llcont.R index d8e496a..40d2fcf 100644 --- a/R/llcont.R +++ b/R/llcont.R @@ -51,14 +51,23 @@ llcont.glm <- function(x, ...){ switch(fam, binomial = { if(is.matrix(y)) { - ## Bolt: replaced apply(..., 1, sum) with optimized rowSums() for performance n <- rowSums(y) - y <- ifelse(n == 0, 0, y[, 1]/n) + ## Bolt: replaced ifelse with mathematical operations and logical subsetting for performance + y_opt <- y[, 1]/n + cond_n <- n == 0 + cond_n[is.na(cond_n)] <- FALSE + y_opt[cond_n] <- 0 + y <- y_opt } else { n <- rep.int(1, length(y)) } m <- if (any(n > 1)) n else wt - wt <- ifelse(m > 0, (wt/m), 0) + ## Bolt: replaced ifelse with mathematical operations and logical subsetting for performance + wt_opt <- wt/m + cond_m <- m <= 0 + cond_m[is.na(cond_m)] <- FALSE + wt_opt[cond_m] <- 0 + wt <- wt_opt dbinom(round(m * y), round(m), mpreds, log = TRUE) * wt }, quasibinomial = { From b9cfec37d011e0fabb21a3ad43fd6e3a83eeace1 Mon Sep 17 00:00:00 2001 From: seonghobae <8172694+seonghobae@users.noreply.github.com> Date: Mon, 31 Aug 2026 04:30:05 +0000 Subject: [PATCH 2/3] =?UTF-8?q?=E2=9A=A1=20Bolt:=20Optimize=20ifelse=20ove?= =?UTF-8?q?rhead=20in=20glm=20binomial=20likelihood=20calculations?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From a69bc8aa1a0190970f5746c0dcd9be289d63b152 Mon Sep 17 00:00:00 2001 From: seonghobae <8172694+seonghobae@users.noreply.github.com> Date: Mon, 31 Aug 2026 04:34:49 +0000 Subject: [PATCH 3/3] =?UTF-8?q?=E2=9A=A1=20Bolt:=20Optimize=20ifelse=20ove?= =?UTF-8?q?rhead=20in=20glm=20binomial=20likelihood=20calculations?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit