Skip to content

Commit 540e84b

Browse files
committed
add DIC
1 parent dd21171 commit 540e84b

5 files changed

Lines changed: 22 additions & 16 deletions

File tree

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[deps]
2+
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"

examples/arsenic/compare.png

471 Bytes
Loading

src/ParetoSmoothedImportanceSampling.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,17 @@ arXiv preprint arXiv:1507.02646.
3232

3333
module ParetoSmoothedImportanceSampling
3434

35-
using StatsFuns
35+
using StatsFuns, Statistics
3636

3737
psis_path = @__DIR__
3838

3939
include("psisloo.jl")
4040
include("psislw.jl")
4141
include("gpdfitnew.jl")
4242
include("gpinv.jl")
43-
#include("logsumexp.jl")
4443
include("waic.jl")
4544
include("pk_utilities.jl")
45+
include("dic.jl")
4646

4747
export
4848
psis_path

src/dic.jl

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
2+
"""
3+
dic(loglike::AbstractVector{<:Real})
4+
5+
Computes Deviance Information Criterion (DIC).
6+
7+
# Arguments
8+
* `log_lik::AbstractArray`: Array of size n x m containing n posterior samples of the log likelihood terms p(y_i|\theta^s).
9+
10+
# Returns
11+
* `dic::Real`: DIC value
12+
"""
13+
function dic(loglike::AbstractVector{<:Real})
14+
D = deviance.(loglike)
15+
return mean(D) + 0.5 * var(D)
16+
end
17+
18+
deviance(loglikelihood::Real) = -2 * loglikelihood

src/logsumexp.jl

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)