Skip to content
Open
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
15 changes: 12 additions & 3 deletions R/llcont.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Comment on lines +56 to +70

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 Boundary equivalence lacks regression coverage

No test exercises y_opt with zero trials or wt_opt with zero weights. These boundaries drive the new overwrite logic.

Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

dbinom(round(m * y), round(m), mpreds, log = TRUE) * wt
},
quasibinomial = {
Expand Down
Loading