Skip to content

Commit

Permalink
early exit loglik_high_lambda
Browse files Browse the repository at this point in the history
  • Loading branch information
rsetienne committed Jul 15, 2024
1 parent 47c29e0 commit 24920f7
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions R/DAISIE_loglik_high_lambda.R
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
DAISIE_loglik_high_lambda <- function(pars1, brts, stac) {
lbrts <- length(brts)
if (brts[lbrts] == 0) {
brts <- brts[-lbrts]
lbrts <- length(brts)
brts <- brts[-lbrts]
lbrts <- length(brts)
}
N <- lbrts - 1 - (stac == 6)
mu <- pars1[2]
gam <- pars1[4]
brtsdiff <- brts - c(brts[2:(N + 1)], 0)
if (stac == 0) {
out <- -gam * brts[1]
out <- -gam * brts[1]
return(out)
}
if (stac == 2 | stac == 6) {
out <- -gam * brtsdiff[1] +
Expand All @@ -22,10 +23,8 @@ DAISIE_loglik_high_lambda <- function(pars1, brts, stac) {
lgamma(N) +
- (N - 1) * log(N - 1) +
- mu / (N - 1) * sum((1:N) * (0:(N - 1)) * brtsdiff[(2 + (stac == 6)):(N + 1 + (stac == 6))])
}
if (stac == 1 | stac == 3 | stac == 4 | stac == 5 | stac >= 7) {
out <- -Inf
}
return(out)
} else return(-Inf) # stac == 1, 3, 4, 5, 7, 8, 9
#Stac 6 to be checked
return(out)
}

0 comments on commit 24920f7

Please sign in to comment.