I have several models and applied waic/loo on model comparison.
I noticed that sometimes elpd_waic > 0 and then waic < 0.
If my understanding is correct, waic and looic should be > 0 ?
So I traced back and found that the log-likelihood matrix is kind of weird.
Here’s some info on model:
Model Info:
function: stan_mvmer
formula (y1): Y ~ month + I(month^2) + (month | id)
family (y1): gaussian [identity]
algorithm: sampling
priors: see help('prior_summary')
sample: 1000 (posterior sample size)
num obs: 77 (y1)
groups: id (25)
runtime: <0.1 mins
Estimates:
mean sd 2.5% 25% 50% 75% 97.5%
y1|(Intercept) 0.067 0.030 0.009 0.049 0.067 0.086 0.125
y1|month 0.035 0.052 -0.070 0.001 0.036 0.071 0.139
y1|I(month^2) 0.022 0.017 -0.012 0.011 0.022 0.034 0.056
y1|sigma 0.145 0.014 0.121 0.136 0.145 0.153 0.176
y1|mean_PPD 0.180 0.024 0.128 0.165 0.179 0.196 0.224
Sigma[id:y1|(Intercept),y1|(Intercept)] 0.003 0.004 0.000 0.000 0.002 0.005 0.015
Sigma[id:y1|month,y1|(Intercept)] 0.001 0.002 -0.004 0.000 0.000 0.002 0.005
Sigma[id:y1|month,y1|month] 0.009 0.005 0.003 0.006 0.008 0.011 0.021
log-posterior -50.256 7.200 -65.446 -54.853 -50.005 -45.344 -37.229
Diagnostics:
mcse Rhat n_eff
y1|(Intercept) 0.001 1.000 1079
y1|month 0.002 1.001 639
y1|I(month^2) 0.001 1.001 782
y1|sigma 0.000 0.999 838
y1|mean_PPD 0.001 1.000 889
Sigma[id:y1|(Intercept),y1|(Intercept)] 0.000 1.001 454
Sigma[id:y1|month,y1|(Intercept)] 0.000 1.007 114
Sigma[id:y1|month,y1|month] 0.000 1.007 311
log-posterior 0.533 1.004 183
I run 2 chains with 1,000 iterations for each chain.
Here’s the histogram of log likelihood of fitted model:
I know it is possible that log likelihood might be > 0, but this is weird…
I don’t know the exact reason, but I multiply Y
by 10.
Before, the range of Y is [0.05, 1.14], now it is [0.5, 11.4].
The model info:
Model Info:
function: stan_mvmer
formula (y1): Y ~ month + I(month^2) + (month | id)
family (y1): gaussian [identity]
algorithm: sampling
priors: see help('prior_summary')
sample: 1000 (posterior sample size)
num obs: 77 (y1)
groups: id (25)
runtime: <0.1 mins
Estimates:
mean sd 2.5% 25% 50% 75% 97.5%
y1|(Intercept) 0.663 0.304 0.071 0.471 0.661 0.862 1.271
y1|month 0.369 0.541 -0.670 0.014 0.381 0.750 1.394
y1|I(month^2) 0.218 0.190 -0.149 0.091 0.212 0.347 0.597
y1|sigma 1.456 0.145 1.219 1.346 1.444 1.551 1.775
y1|mean_PPD 1.794 0.231 1.368 1.641 1.805 1.936 2.273
Sigma[id:y1|(Intercept),y1|(Intercept)] 0.303 0.380 0.000 0.036 0.152 0.424 1.331
Sigma[id:y1|month,y1|(Intercept)] 0.072 0.240 -0.477 -0.033 0.067 0.199 0.551
Sigma[id:y1|month,y1|month] 0.895 0.463 0.259 0.576 0.810 1.106 2.086
log-posterior -230.414 7.409 -245.770 -235.059 -230.053 -225.311 -216.799
Diagnostics:
mcse Rhat n_eff
y1|(Intercept) 0.010 1.001 900
y1|month 0.022 1.002 594
y1|I(month^2) 0.007 1.001 691
y1|sigma 0.006 1.007 499
y1|mean_PPD 0.007 0.999 1180
Sigma[id:y1|(Intercept),y1|(Intercept)] 0.019 1.009 384
Sigma[id:y1|month,y1|(Intercept)] 0.023 1.019 107
Sigma[id:y1|month,y1|month] 0.029 1.010 250
log-posterior 0.651 1.024 130
And log likelihood:
now it seems common, I guess…
Is this multiplication, Y * 10
, the right way to fix this problem?
And the weird value of elpd_waic and waic is caused by this problem?
Any help would be appreciated!