Skip to content

Commit

Permalink
Fix rafterydiag
Browse files Browse the repository at this point in the history
  • Loading branch information
rikhuijzer committed Sep 1, 2021
1 parent 568d87e commit 7daf2c6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ MIT License
Copyright (c) 2021 Brian J Smith, the Turing team and contributors:

https://github.com/brian-j-smith/Mamba.jl/contributors
https://github.com/TuringLang/MCMCChains.jl/contributors

https://turing.ml/dev/team/

Expand Down
10 changes: 5 additions & 5 deletions src/rafterydiag.jl
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
"""
@doc raw"""
rafterydiag(x::AbstractVector{<:Real}; q=0.025, r=0.005, s=0.95, eps=0.001, range=1:length(x))
Compute the Raftery and Lewis diagnostic [^Raftery1992].
Compute the Raftery and Lewis diagnostic [^rafterydiag].
This diagnostic is used to determine the number of iterations required to estimate a specified quantile `q` within a desired degree of accuracy.
The diagnostic is designed to determine the number of autocorrelated samples required to estimate a specified quantile \$\theta_q\$, such that \$\\Pr(\\theta \\le \\theta_q) = q\$, within a desired degree of accuracy.
In particular, if \$\\hat{\\theta}_q\$ is the estimand and \$\\Pr(\\theta \\le \\hat{\\theta}_q) = \\hat{P}_q\$ the estimated cumulative probability, then accuracy is specified in terms of `r` and `s`, where \$\\Pr(q - r < \\hat{P}_q < q + r) = s\$.
The diagnostic is designed to determine the number of autocorrelated samples required to estimate a specified quantile $\theta_q$, such that $\Pr(\theta \le \theta_q) = q$, within a desired degree of accuracy.
In particular, if $\hat{\theta}_q$ is the estimand and $\Pr(\theta \le \hat{\theta}_q) = \hat{P}_q$ the estimated cumulative probability, then accuracy is specified in terms of `r` and `s`, where $\Pr(q - r < \hat{P}_q < q + r) = s$.
Thinning may be employed in the calculation of the diagnostic to satisfy its underlying assumptions.
However, users may not want to apply the same (or any) thinning when estimating posterior summary statistics because doing so results in a loss of information.
Accordingly, sample sizes estimated by the diagnostic tend to be conservative (too large).
Expand All @@ -13,7 +13,7 @@ Furthermore, the argument `r` specifies the margin of error for estimated cumula
`eps` specifies the tolerance within which the probabilities of transitioning from initial to retained iterations are within the equilibrium probabilities for the chain.
This argument determines the number of samples to discard as a burn-in sequence and is typically left at its default value.
[^Raftery1992]: A L Raftery and S Lewis. Bayesian Statistics, chapter How Many Iterations in the Gibbs Sampler? Volume 4. Oxford University Press, New York, 1992.
[^rafterydiag]: A L Raftery and S Lewis. Bayesian Statistics, chapter How Many Iterations in the Gibbs Sampler? Volume 4. Oxford University Press, New York, 1992.
"""
function rafterydiag(
x::AbstractVector{<:Real}; q=0.025, r=0.005, s=0.95, eps=0.001, range=1:length(x)
Expand Down

0 comments on commit 7daf2c6

Please sign in to comment.