Skip to content

Commit

Permalink
Merge pull request #388 from stan-dev/update_ess_sd
Browse files Browse the repository at this point in the history
use the same equation in ess_sd as in mcse_sd
  • Loading branch information
paul-buerkner authored Dec 21, 2024
2 parents aeb26ba + b962b63 commit 20e3aa1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion R/convergence.R
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,10 @@ ess_sd <- function(x, ...) UseMethod("ess_sd")
#' @rdname ess_sd
#' @export
ess_sd.default <- function(x, ...) {
.ess(.split_chains(abs(x-mean(x))))
# var/sd are not a simple expectation of g(X), e.g. variance
# has (X-E[X])^2. The following ESS is based on a relevant quantity
# in the computation and is empirically a good choice.
.ess(.split_chains((x-mean(x))^2))
}

#' @rdname ess_sd
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-convergence.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ test_that("ess diagnostics return reasonable values", {
expect_true(ess > 250 & ess < 310)

ess <- ess_sd(tau)
expect_true(ess > 250 & ess < 310)
expect_true(ess > 230 & ess < 280)

ess <- ess_bulk(tau)
expect_true(ess > 230 & ess < 280)
Expand Down

0 comments on commit 20e3aa1

Please sign in to comment.