diff --git a/src/MCMCChains.jl b/src/MCMCChains.jl index 3422620f..f6e6f742 100644 --- a/src/MCMCChains.jl +++ b/src/MCMCChains.jl @@ -48,6 +48,7 @@ export rafterydiag export rstar export hpd +export p_direction """ Chains @@ -85,5 +86,6 @@ include("modelstats.jl") include("plot.jl") include("tables.jl") include("rstar.jl") +include("significance.jl") end # module diff --git a/src/significance.jl b/src/significance.jl new file mode 100644 index 00000000..8040ca9f --- /dev/null +++ b/src/significance.jl @@ -0,0 +1,19 @@ +function p_direction(x::Vector{Float64}) + return maximum([sum(x .> 0) ./ length(x), sum(x .< 0) ./ length(x)]) +end + +function p_direction(chains::Chains; kwargs...) + # Store everything. + funs = [p_direction] + func_names = [:p_direction] + + # Summarize. + summary_df = summarize( + chains, funs...; + func_names=func_names, + name="Probability of Direction (pd)", + kwargs... + ) + + return summary_df +end