- Operating System: Mac OS X El Capitan Version 10.11.6
- brms Version: 2.3.1
Rstan version 2.17.3
Hello,
I’m trying to do some model checking and comparison with loo through brms, and I’m running into difficulties. I’ve been trying to do two things.
The first thing is I’ve been trying to create the Loo-PIT Overlay Plot in the Marginal Posterior Predictive Checks section of the “Using the Loo Package” Vignette (https://cran.r-project.org/web/packages/loo/vignettes/loo2-example.html) for my data and models.
loo_model7_3l <- loo(model7_3l, reloo = TRUE) # Run loo on the model.
loo_model7_3l # Show loo output
Computed from 4000 by 521 log-likelihood matrix
Estimate SE
elpd_loo 463.3 17.5
p_loo 94.7 5.8
looic -926.6 35.0
------
Monte Carlo SE of elpd_loo is NA.
Pareto k diagnostic values:
Count Pct. Min. n_eff
(-Inf, 0.5] (good) 487 93.5% 574
(0.5, 0.7] (ok) 33 6.3% 110
(0.7, 1] (bad) 1 0.2% 578
(1, Inf) (very bad) 0 0.0% <NA>
See help('pareto-k-diagnostic') for details.
plot(loo_model7_3l) # Plotting Pareto k diagnostics
![Loo_Plot|654x360](upload://94H5YGRWVvfJpfkn79F2dh6bOTx.png)
So everything is running fine until I get to the code for the Loo-PIT Overlay Plot
yrep <- posterior_predict(model7_3l)
ppc_loo_pit_overlay(
y = rwbl_filter$log_MeHg,
yrep = yrep,
lw = weights(loo_model7_3l$psis_object)
)
# I get the following error message:
Coordinate system already present. Adding new coordinate system, which will replace the existing one.
![PIT_check|690x363](upload://uvfchmcoEYSMQGvF7tYrH4Yt9Dq.png)
So I don’t understand why I’m getting a blank plot since the only changes I’ve made to the code is to input my own models and objects. In the vignette, the examples are based on using rstanarm. Do I have to tweak the code to make it run with brms?
The second thing is that I’m having issues running loo with my other models. In this example, I run loo on another model, model8_3l.
loo_model8_3l <- loo(model8_3l)
loo_model8_3l
Computed from 4000 by 521 log-likelihood matrix
Estimate SE
elpd_loo 463.4 17.7
p_loo 94.4 6.0
looic -926.7 35.3
------
Monte Carlo SE of elpd_loo is NA.
Pareto k diagnostic values:
Count Pct. Min. n_eff
(-Inf, 0.5] (good) 497 95.4% 416
(0.5, 0.7] (ok) 20 3.8% 192
(0.7, 1] (bad) 4 0.8% 37
(1, Inf) (very bad) 0 0.0% <NA>
See help('pareto-k-diagnostic') for details.
From the above I can see that I have 4 observations with a pareto_k > 0.7, so I try to run it again with reloo = TRUE. This is where I’m running into issues.
loo_model8_3l <- loo(model8_3l, reloo = TRUE)
Error: New factor levels are not allowed.
Levels allowed: '17-RNA-03_K', '17-RNA-09_B', '17-RNA-09_G', '17-RNA-09_K', '17-RNA-09_R', '17-RNA-5_B', '17-RNA-5_G', '17-RNA-5_K', '17-RNA-5_R', '17-TJT-1_K', '17-TJT-1_R', '17-TJT-100_B', '17-TJT-100_K', '17-TJT-100_R', '17-TJT-102_K', '17-TJT-105_B', '17-TJT-105_K', '17-TJT-105_R', '17-TJT-107_B', '17-TJT-107_G', '17-TJT-107_K', '17-TJT-107_R', '17-TJT-108_B', '17-TJT-108_K', '17-TJT-110_B', '17-TJT-110_K', '17-TJT-111_B', '17-TJT-111_K', '17-TJT-111_R', '17-TJT-115_B', '17-TJT-115_K', '17-TJT-115_R', '17-TJT-117_B', '17-TJT-117_R', '17-TJT-121_B', '17-TJT-121_K', '17-TJT-121_R', '17-TJT-127_B', '17-TJT-127_G', '17-TJT-127_K', '17-TJT-127_R', '17-TJT-128_B', '17-TJT-128_K', '17-TJT-128_R', '17-TJT-13_B', '17-TJT-13_K', '17-TJT-131_B', '17-TJT-131_K', '17-TJT-131_R', '17-TJT-134_B', '17-TJT-134_K', '17-TJT-134_R', '17-TJT-135_B', '17-TJT-135_K', '17-TJT-136_B', '17-TJT-136_K', '17-TJT-139_B', '17-TJT-139_G', '17-TJT-139_K', '17-TJT-139_R',
I’m not sure why this model is having issues when the other wasn’t. Does anyone have an idea of what’s going on here?
Thanks.