Skip to content

Commit

Permalink
Merge pull request #257 from stan-dev/fix_loo_moment_matching_p_loo
Browse files Browse the repository at this point in the history
fix loo_moment_match p_loo computation
  • Loading branch information
jgabry authored Mar 5, 2024
2 parents 7db551f + 2f3ca2c commit bb3abb2
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion R/loo_moment_matching.R
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ loo_moment_match_i <- function(i,
dim(log_liki) <- c(S_per_chain, N_chains, 1)
r_eff_i <- loo::relative_eff(exp(log_liki), cores = 1)
dim(log_liki) <- NULL
lpd <- matrixStats::logSumExp(log_liki) - log(length(log_liki))

is_obj <- suppressWarnings(importance_sampling.default(-log_liki,
method = is_method,
Expand Down Expand Up @@ -388,7 +389,6 @@ loo_moment_match_i <- function(i,

# pointwise estimates
elpd_loo_i <- matrixStats::logSumExp(log_liki + lwi)
lpd <- matrixStats::logSumExp(log_liki) - log(length(log_liki))
mcse_elpd_loo <- mcse_elpd(
ll = as.matrix(log_liki), lw = as.matrix(lwi),
E_elpd = exp(elpd_loo_i), r_eff = r_eff_i
Expand Down
Binary file modified tests/testthat/reference-results/moment_match_loo_1.rds
Binary file not shown.
Binary file modified tests/testthat/reference-results/moment_match_loo_2.rds
Binary file not shown.
Binary file modified tests/testthat/reference-results/moment_match_loo_3.rds
Binary file not shown.
Binary file modified tests/testthat/reference-results/moment_match_var_and_cov.rds
Binary file not shown.

0 comments on commit bb3abb2

Please sign in to comment.