Skip to content

Commit

Permalink
Rel 1.1.0 - Remove pk_plot (moved to SRPlots)
Browse files Browse the repository at this point in the history
  • Loading branch information
goedman committed Oct 5, 2021
1 parent 9944a96 commit aaf6700
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
14 changes: 1 addition & 13 deletions src/pk_utilities.jl
Original file line number Diff line number Diff line change
@@ -1,21 +1,9 @@
using StatsPlots

function pk_qualify(pk::Vector{Float64})
pk_good = sum(pk .<= 0.5)
pk_ok = length(pk[pk .<= 0.7]) - pk_good
pk_bad = length(pk[pk .<= 1]) - pk_good - pk_ok
(good=pk_good, ok=pk_ok, bad=pk_bad, very_bad=sum(pk .> 1))
end

function pk_plot(pk::Vector{Float64}; title="PSIS diagnostic plot.",
leg=:topleft, kwargs...)
scatter(pk, xlab="Datapoint", ylab="Pareto shape k",
marker=2.5, lab="Pk points", leg=leg)
hline!([0.5], lab="pk = 0.5");hline!([0.7], lab="pk = 0.7")
hline!([1], lab="pk = 1.0")
title!(title)
end

export
pk_qualify,
pk_plot
pk_qualify
20 changes: 19 additions & 1 deletion src/waic.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
"""
waic(ll::AbstractArray{<:Real}; pointwise=false, log_lik="log_lik, kwargs...)
var2(x) = mean(x.^2) .- mean(x)^2
Compute the Widely Applicable Information Criterion (WAIC).
# Arguments
* `loglik::AbstractArray` : A vector of posterior log likelihoods
* `pointwise::Bool` : Compute WAIC pointwise, return a vector
# Returns
* `res::NamedTuple`: (WAIC=waics, lppd=lpd, penalty=pD, std_err=se) where
WAIC : Sum of pointwise waic values (or pointwise vector)
lppd : Log pointwise predictive density
penalty : Penalty term ("overfitting penalty")
std_err : Standard error of pointwise waic values
"""
function waic( ll::AbstractArray; pointwise=false , log_lik="log_lik" , kwargs... )

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

var2(x) = var(x; corrected=false)

export
var2,
waic

0 comments on commit aaf6700

Please sign in to comment.