Skip to content

Commit

Permalink
regenerate doc and reindent lines
Browse files Browse the repository at this point in the history
  • Loading branch information
jgabry committed Feb 21, 2024
1 parent c80d5b2 commit 0a55d59
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 20 deletions.
28 changes: 14 additions & 14 deletions R/E_loo.R
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@
#' calling `E_loo()`, the smoothed log-weights are used to estimate
#' Pareto-k's, which may produce optimistic estimates.
#'
#' For mean, var, and sd the returned Pareto-k is maximum of
#' Pareto-k's for left and right tail of \eqn{hr} and right tail of
#' \eqn{r}, where \eqn{h=x} in case of mean and \eqn{h=x^2} in case
#' of var and sd, and \eqn{r} is the importance ratio. For quantile
#' the returned Pareto-k is the Pareto-k for the right tail of
#' \eqn{r}.
#' For mean, var, and sd the returned Pareto-k is the maximum of the
#' Pareto-k's for the left and right tail of \eqn{hr} and the right tail of
#' \eqn{r}, where \eqn{r} is the importance ratio and \eqn{h=x} for
#' `type="mean"` and \eqn{h=x^2} for `type="var"` and `type="sd"`. For
#' `type="quantile"`, the returned Pareto-k is the Pareto-k for the right tail
#' of \eqn{r}.
#' }
#' }
#'
Expand Down Expand Up @@ -288,13 +288,13 @@ E_loo_khat.matrix <- function(x, psis_object, log_ratios, ...) {
#' @return Scalar h-specific k-hat estimate.
#'
.E_loo_khat_i <- function(x_i, log_ratios_i, tail_len_i) {
h_theta <- x_i
r_theta <- exp(log_ratios_i - max(log_ratios_i))
khat_r <- posterior::pareto_khat(r_theta, tail="right", ndraws_tail = tail_len_i)$khat
if (is.null(x_i)) {
khat_r
} else {
khat_hr <- posterior::pareto_khat(h_theta*r_theta, tail="both", ndraws_tail = tail_len_i)$khat
h_theta <- x_i
r_theta <- exp(log_ratios_i - max(log_ratios_i))
khat_r <- posterior::pareto_khat(r_theta, tail="right", ndraws_tail = tail_len_i)$khat
if (is.null(x_i)) {
khat_r
} else {
khat_hr <- posterior::pareto_khat(h_theta*r_theta, tail="both", ndraws_tail = tail_len_i)$khat
max(khat_hr, khat_r)
}
}
}
20 changes: 14 additions & 6 deletions man/E_loo.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 0a55d59

Please sign in to comment.