From bffab8cd46270cba8e7dd1d09c12b880dc8dda2c Mon Sep 17 00:00:00 2001 From: Aki Vehtari Date: Mon, 20 Sep 2021 16:46:20 +0300 Subject: [PATCH 1/2] simplify the normalization in gpdfit, thanks to Seth Axen --- R/gpdfit.R | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/R/gpdfit.R b/R/gpdfit.R index 09025565..7cd46ea3 100644 --- a/R/gpdfit.R +++ b/R/gpdfit.R @@ -40,9 +40,7 @@ gpdfit <- function(x, wip = TRUE, min_grid_pts = 30, sort_x = TRUE) { xstar <- x[floor(N / 4 + 0.5)] # first quartile of sample theta <- 1 / x[N] + (1 - sqrt(M / (jj - 0.5))) / prior / xstar l_theta <- N * lx(theta, x) # profile log-lik - w_theta <- 1 / vapply(jj, FUN.VALUE = numeric(1), FUN = function(j) { - sum(exp(l_theta - l_theta[j])) - }) + w_theta <- exp(l_theta - matrixStats::logSumExp(l_theta)) # normalize theta_hat <- sum(theta * w_theta) k <- mean.default(log1p(-theta_hat * x)) sigma <- -k / theta_hat From 6b87ccb80b7ff7a93415ccecd763cbba5a5f1a95 Mon Sep 17 00:00:00 2001 From: jgabry Date: Tue, 21 Sep 2021 15:33:14 -0400 Subject: [PATCH 2/2] Update NEWS.md --- NEWS.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/NEWS.md b/NEWS.md index 0b0d8b13..5500b86e 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,11 @@ # Items for next release go here +* Speed improvement from simplifying the normalization when fitting the +generalized Pareto distribution. (#187, @sethaxen) + +* Fixed bug where attribute storing normalizing constant of PSIS weights wasn't +updated when using moment matching. (#167, @fweber144) + * Switch unit tests from Travis to GitHub Actions. (#164) ### Bug fixes