Skip to content

Commit aaf6700

Browse files
committed
Rel 1.1.0 - Remove pk_plot (moved to SRPlots)
1 parent 9944a96 commit aaf6700

File tree

2 files changed

+20
-14
lines changed

2 files changed

+20
-14
lines changed

src/pk_utilities.jl

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,9 @@
1-
using StatsPlots
2-
31
function pk_qualify(pk::Vector{Float64})
42
pk_good = sum(pk .<= 0.5)
53
pk_ok = length(pk[pk .<= 0.7]) - pk_good
64
pk_bad = length(pk[pk .<= 1]) - pk_good - pk_ok
75
(good=pk_good, ok=pk_ok, bad=pk_bad, very_bad=sum(pk .> 1))
86
end
97

10-
function pk_plot(pk::Vector{Float64}; title="PSIS diagnostic plot.",
11-
leg=:topleft, kwargs...)
12-
scatter(pk, xlab="Datapoint", ylab="Pareto shape k",
13-
marker=2.5, lab="Pk points", leg=leg)
14-
hline!([0.5], lab="pk = 0.5");hline!([0.7], lab="pk = 0.7")
15-
hline!([1], lab="pk = 1.0")
16-
title!(title)
17-
end
18-
198
export
20-
pk_qualify,
21-
pk_plot
9+
pk_qualify

src/waic.jl

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,22 @@
1+
"""
2+
waic(ll::AbstractArray{<:Real}; pointwise=false, log_lik="log_lik, kwargs...)
13
2-
var2(x) = mean(x.^2) .- mean(x)^2
4+
Compute the Widely Applicable Information Criterion (WAIC).
35
6+
# Arguments
7+
* `loglik::AbstractArray` : A vector of posterior log likelihoods
8+
* `pointwise::Bool` : Compute WAIC pointwise, return a vector
9+
10+
11+
# Returns
12+
* `res::NamedTuple`: (WAIC=waics, lppd=lpd, penalty=pD, std_err=se) where
13+
14+
WAIC : Sum of pointwise waic values (or pointwise vector)
15+
lppd : Log pointwise predictive density
16+
penalty : Penalty term ("overfitting penalty")
17+
std_err : Standard error of pointwise waic values
18+
19+
"""
420
function waic( ll::AbstractArray; pointwise=false , log_lik="log_lik" , kwargs... )
521

622
n_samples, n_obs = size(ll)
@@ -31,6 +47,8 @@ function waic( ll::AbstractArray; pointwise=false , log_lik="log_lik" , kwargs..
3147
(WAIC=waics, lppd=lpd, penalty=pD, std_err=se)
3248
end
3349

50+
var2(x) = var(x; corrected=false)
51+
3452
export
3553
var2,
3654
waic

0 commit comments

Comments
 (0)