Skip to content

Commit

Permalink
bug fix loglik_high_lambda
Browse files Browse the repository at this point in the history
  • Loading branch information
rsetienne committed Jul 16, 2024
1 parent 24920f7 commit 9077b3e
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions R/DAISIE_loglik_high_lambda.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,26 @@ DAISIE_loglik_high_lambda <- function(pars1, brts, stac) {
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]
return(out)
}
if (stac == 2 | stac == 6) {
out <- -gam * brtsdiff[1] +
log(gam) * (stac == 2) +
log(1 - exp(-gam * brtsdiff[2])) * (stac == 6) +
#log(-expm1(-gam * brtsdiff[2])) * (stac == 6) +
#log1p(-exp(-gam * brtsdiff[2])) * (stac == 6) +
log(N) +
(N - 1) * log(mu) +
lgamma(N) +
- (N - 1) * log(N - 1) +
- mu / (N - 1) * sum((1:N) * (0:(N - 1)) * brtsdiff[(2 + (stac == 6)):(N + 1 + (stac == 6))])
return(out)
N <- lbrts - 1 - (stac == 6)
mu <- pars1[2]
gam <- pars1[4]
brtsdiff <- brts - c(brts[2:lbrts], 0)
out <- -gam * brtsdiff[1] +
log(gam) * (stac == 2) +
log(1 - exp(-gam * brtsdiff[2])) * (stac == 6) +
#log(-expm1(-gam * brtsdiff[2])) * (stac == 6) +
#log1p(-exp(-gam * brtsdiff[2])) * (stac == 6) +
log(N) +
(N - 1) * log(mu) +
lgamma(N) +
- (N - 1) * log(N - 1) +
- mu / (N - 1) * sum((1:N) * (0:(N - 1)) * brtsdiff[(2 + (stac == 6)):(N + 1 + (stac == 6))])
return(out)
} else return(-Inf) # stac == 1, 3, 4, 5, 7, 8, 9
#Stac 6 to be checked
return(out)
Expand Down

0 comments on commit 9077b3e

Please sign in to comment.