R/log_lik.R
changed.
Showing 1 of 1 files from the diff.
@@ -899,7 +899,7 @@
Loading
899 | 899 | eta <- disc * (mu - thres) |
|
900 | 900 | y <- prep$data$Y[i] |
|
901 | 901 | # TODO: check if computation can be made more numerically stable |
|
902 | - | if (prep$family$link == "logit") { |
|
902 | + | if (prep$family$link == "logit") { |
|
903 | 903 | # more efficient computation for logit link |
|
904 | 904 | q <- sapply(1:nthres, function(k) eta[, k]) |
|
905 | 905 | p <- cbind(rep(0, nrow(eta)), q[, 1], |
@@ -980,14 +980,23 @@
Loading
980 | 980 | # @param prep a brmsprep object |
|
981 | 981 | # @return vector of log_lik values |
|
982 | 982 | log_lik_truncate <- function(x, cdf, args, i, prep) { |
|
983 | - | lb <- prep$data$lb[i] |
|
984 | - | ub <- prep$data$ub[i] |
|
985 | - | if (!(is.null(lb) && is.null(ub))) { |
|
986 | - | if (is.null(lb)) lb <- -Inf |
|
987 | - | if (is.null(ub)) ub <- Inf |
|
988 | - | x - log(do_call(cdf, c(ub, args)) - do_call(cdf, c(lb, args))) |
|
983 | + | lb <- prep$data[["lb"]][i] |
|
984 | + | ub <- prep$data[["ub"]][i] |
|
985 | + | if (is.null(lb) && is.null(ub)) { |
|
986 | + | return(x) |
|
989 | 987 | } |
|
990 | - | x |
|
988 | + | args$log.p <- TRUE |
|
989 | + | if (!is.null(lb)) { |
|
990 | + | log_cdf_lb <- do_call(cdf, c(lb, args)) |
|
991 | + | } else { |
|
992 | + | log_cdf_lb <- rep(-Inf, length(x)) |
|
993 | + | } |
|
994 | + | if (!is.null(ub)) { |
|
995 | + | log_cdf_ub <- do_call(cdf, c(ub, args)) |
|
996 | + | } else { |
|
997 | + | log_cdf_ub <- rep(0, length(x)) |
|
998 | + | } |
|
999 | + | x - log_diff_exp(log_cdf_ub, log_cdf_lb) |
|
991 | 1000 | } |
|
992 | 1001 | ||
993 | 1002 | # weight log_lik values according to defined weights |
Files | Coverage |
---|---|
R | 82.25% |
Project Totals (70 files) | 82.25% |
3138395320
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file.
The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files.
The size and color of each slice is representing the number of statements and the coverage, respectively.