Skip to content

Commit edf33ef

Browse files
committed
Rel 0.0.1 - Initial working version
1 parent 5f876a2 commit edf33ef

4 files changed

Lines changed: 374 additions & 61 deletions

File tree

Example/compare.png

22.5 KB
Loading

Example/demo_wells.jl

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ using StatisticalRethinking
22
using JSON
33
using StanSample
44
using PSIS
5-
using Statistics
5+
#using Statistics
66
using Printf
7-
using StatsPlots
7+
#using StatsPlots
88

99
ProjDir = @__DIR__
1010

@@ -26,7 +26,7 @@ data1 = (p = m, N = n, y = Int.(y), x = x)
2626
# Fit the model in Stan
2727
rc1 = stan_sample(sm1; data=data1)
2828
if success(rc1)
29-
nt1 = read_samples(sm)
29+
nt1 = read_samples(sm1)
3030

3131
# Compute LOO and standard error
3232
log_lik = nt1.log_lik'
@@ -56,7 +56,7 @@ data2 = (p = m, N = n, y = Int.(y), x = x2)
5656
rc2 = stan_sample(sm1; data=data2)
5757

5858
if success(rc2)
59-
nt2 = read_samples(sm)
59+
nt2 = read_samples(sm1)
6060
# Compute LOO and standard error
6161
log_lik = nt2.log_lik'
6262
loo2, loos2, pk2 = psisloo(log_lik)
@@ -104,12 +104,10 @@ for cvi in 1:10
104104
nt3 = read_samples(sm3)
105105
# Compute LOO and standard error
106106
log_likt = nt3.log_likt'
107-
kfcvs[cvitst[cvi]] = PSIS.logsumexp(log_likt) .- log(size(log_likt, 1))
107+
kfcvs[cvitst[cvi]] = PSIS.logsumexp(log_likt) .- log(size(log_likt, 2))
108108
end
109109
end
110110

111111
# compare PSIS-LOO and k-fold-CV
112-
plot(x = loos, y = kfcvs, xlab = "PSIS-LOO", ylab = "10-fold-CV")
113-
114-
#savefig(PDF(joinpath(ProjDir, "Compare.pdf"), 210mm, 210mm),p)
115-
112+
scatter(loos[1,:], kfcvs[1,:], xlab = "PSIS-LOO", ylab = "10-fold-CV", leg=false)
113+
savefig(joinpath(ProjDir, "compare.png"))

0 commit comments

Comments
 (0)