Skip to content
Merged
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
3 changes: 3 additions & 0 deletions R/psis.R
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,9 @@ psis_smooth_tail <- function(x, cutoff) {
fit <- posterior::gpdfit(exp(x) - exp_cutoff, sort_x = FALSE)
k <- fit$k
sigma <- fit$sigma
if (is.na(k)) {
k <- Inf
}
if (is.finite(k)) {
p <- (seq_len(len) - 0.5) / len
qq <- posterior::qgeneralized_pareto(p, 0, sigma, k) + exp_cutoff
Expand Down
8 changes: 3 additions & 5 deletions tests/testthat/test_psis.R
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,9 @@ test_that("do_psis_i throws warning if all tail values the same", {
})

test_that("psis_smooth_tail returns original tail values if k is infinite", {
# skip on M1 Mac until we figure out why this test fails only on M1 Mac
skip_if(Sys.info()[["sysname"]] == "Darwin" && R.version$arch == "aarch64")

xx <- c(1, 2, 3, 4, 4, 4, 4, 4, 4, 4, 4)
val <- suppressWarnings(psis_smooth_tail(xx, 3))
xx <- log(c(2, 2, 2, 2, 3, 4, 5, 6))
val <- suppressWarnings(psis_smooth_tail(xx, 0))
expect_equal(val$tail, xx)
expect_equal(val$k, Inf)
})

Loading