Export srs_diff_est()#340
Conversation
synced with upstream/master
as proposed by @avehtari in issue stan-dev#333
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #340 +/- ##
==========================================
- Coverage 92.78% 92.72% -0.06%
==========================================
Files 31 31
Lines 2992 2984 -8
==========================================
- Hits 2776 2767 -9
- Misses 216 217 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
The example should be based on flexible enough model so that After we have useful loglik matrix, the example code would be something like This matches what someone was asking |
Either is fine by me. Also if we're only using it for this example, we could also just generate an example loglik matrix in the example code instead of storing it. |
|
I think the interesting examples can be slow to run. I'll test subsampling with few interesting real models this week |
|
Thus would be a good example with data from https://archive.ics.uci.edu/ml/datasets/wine+quality library(dplyr)
library(brms)
options(brms.backend = "cmdstanr")
options(mc.cores = 4)
library(loo)
wine <- read.delim(root("winequality-red", "winequality-red.csv"), sep = ";") |>
distinct()
wine_scaled <- as.data.frame(scale(wine))
fitos <- brm(ordered(quality) ~ .,
family = cumulative("logit"),
prior = prior(R2D2(mean_R2 = 1/3, prec_R2 = 3)),
data = wine_scaled,
seed = 1,
silent = 2,
refresh = 0)
log_lik_matrix <- log_lik(fitos)
N <- nrow(wine_scaled)
Nsub <- 100
# posterior log-score
lpd <- elpd(log_lik_matrix)
sum(lpd$pointwise[,"elpd"])
# Use PSIS-LOO for subsample of Nsub randomly selected observations
set.seed(1)
idx <- sample(1:N, Nsub)
elpd_loo_sub <- loo(log_lik_matrix[,idx])
sum(elpd_loo_sub$pointwise[,"elpd_loo"]) / Nsub * N
# Use difference estimator to combine fast result and subsampled accurate result
loo:::srs_diff_est(lpd$pointwise[,"elpd"], elpd_loo_sub$pointwise[,"elpd_loo"], idx)
# Comparison to using PSIS-LOO for all observations
loo(log_lik_matrix)
As compiling and sampling the brms model takes some time, I would store only the |
Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 5 to 6. - [Release notes](https://github.com/codecov/codecov-action/releases) - [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md) - [Commits](codecov/codecov-action@v5...v6) --- updated-dependencies: - dependency-name: codecov/codecov-action dependency-version: '6' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com>
…ns/codecov/codecov-action-6 Bump codecov/codecov-action from 5 to 6
|
Interesting, do I understand it correctly that the |
Further bump up touchstone iterations
Latest R and LTS ubuntu
Bumped touchstone reqs
Update posterior gpdfit branch to get newer touchstone functionality
use posterior::gpdfit and posterior::qgeneralized_pareto()
|
Instead of generating log_lik on the fly, we could use the stored wine log_lik which was added in #352. This would make the example to run much faster. Need to check whether wine log_lik was added only for touchstone and was it too big for CRAN, @jgabry , @VisruthSK |
as proposed by @avehtari in issue stan-dev#333
…into export-srs-diff-est
|
This is how benchmark results would change (along with a 95% confidence interval in relative change) if 1cdb60f is merged into master:
|
|
The tests are failing so I will give a short summary of what I did. Second, I renamed Third, I added the example by @avehtari to Fourth, I did So I hope that I shouldnt be too far from getting the tests to pass. Do you have an idea why they might fail?
Of course also an option! I just wanted give the |
Yes to both. Clocks in at about 40MB, and is currently only in the touchstone directory. |
|
Hi @vinniott! Thanks for working on this.
I think we should figure out how we're storing/using the wine data before we fix the tests. Apologize if you already know this, but if you click on the failed runs, you'll be able to scroll down till you see R CMD check output. Locally, you can run
I think the problem here might be that you ran some code locally before that to make Hope that slightly clears up why the tests are failing, and how to (hopefully) reproduce those failures locally. |

Fixes #333
Note:
@exampleyet because I did not have time yet to get fully familiar with the whole package.