stan-dev / posterior

The posterior R package
https://mc-stan.org/posterior/
Other
167 stars 24 forks source link

posterior_khat gives wrong result if S<225 and S/5 not an integer #382

Closed avehtari closed 2 weeks ago

avehtari commented 2 weeks ago

Example

set.seed(1); 
x=rnorm(224);
> pareto_khat(c(x[1:198],1000),tail="right",r_eff=1)
[1] -0.2347783
> pareto_khat(c(x[1:199],1000),tail="right",r_eff=1)
[1] 0.7224969
> pareto_khat(c(x[1:198],1000),tail="right",r_eff=1,ndraws_tail=40)
[1] 0.7224969

The issue comes from a missing ceiling() and odd behavior with non-integer ndraws_tail. PR on the way, but recording the issue here first.