@@ -2,9 +2,9 @@ using StatisticalRethinking
22using JSON
33using StanSample
44using PSIS
5- using Statistics
5+ # using Statistics
66using Printf
7- using StatsPlots
7+ # using StatsPlots
88
99ProjDir = @__DIR__
1010
@@ -26,7 +26,7 @@ data1 = (p = m, N = n, y = Int.(y), x = x)
2626# Fit the model in Stan
2727rc1 = stan_sample (sm1; data= data1)
2828if 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)
5656rc2 = stan_sample (sm1; data= data2)
5757
5858if 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
109109end
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