Skip to content
Open
Show file tree
Hide file tree
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
12 changes: 10 additions & 2 deletions R/llcont.R
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,20 @@ llcont.glm <- function(x, ...){
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 preallocation and vectorized subsetting for performance
res_y <- y[, 1] * 0
cond <- n != 0
res_y[cond] <- y[cond, 1]/n[cond]
y <- res_y
} 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 preallocation and vectorized subsetting for performance
res_wt <- wt * 0
cond <- m > 0
res_wt[cond] <- wt[cond]/m[cond]
wt <- res_wt
dbinom(round(m * y), round(m), mpreds, log = TRUE) * wt
},
quasibinomial = {
Expand Down
48 changes: 0 additions & 48 deletions benchmark_hurdle_ifelse.R

This file was deleted.

Loading