Skip to content

Commit 00225ef

Browse files
committed
Add eight_schools examples
1 parent fcb6f61 commit 00225ef

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

models.jl

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,4 +173,32 @@ add_model!(MODELS, n500())
173173
end
174174
add_model!(MODELS, multithreaded([1.5, 2.0, 2.5, 1.5, 2.0, 2.5]))
175175

176+
# PosteriorDB
177+
178+
es_J = 8
179+
es_y = [28, 8, -3, 7, -1, 1, 18, 12]
180+
es_sigma = [15, 10, 16, 11, 9, 11, 10, 18]
181+
@model function pdb_eight_schools_centered(J, y, sigma)
182+
mu ~ Normal(0, 5)
183+
tau ~ truncated(Cauchy(0, 5); lower=0)
184+
theta = Vector{Float64}(undef, J)
185+
for i in 1:J
186+
theta[i] ~ Normal(mu, tau)
187+
y[i] ~ Normal(theta[i], sigma[i])
188+
end
189+
end
190+
add_model!(MODELS, pdb_eight_schools_centered(es_J, es_y, es_sigma))
191+
192+
@model function pdb_eight_schools_noncentered(J, y, sigma)
193+
mu ~ Normal(0, 5)
194+
tau ~ truncated(Cauchy(0, 5); lower=0)
195+
theta_trans = Vector{Float64}(undef, J)
196+
for i in 1:J
197+
theta_trans[i] ~ Normal(0, 1)
198+
theta = theta_trans[i] * tau + mu;
199+
y[i] ~ Normal(theta, sigma[i])
200+
end
201+
end
202+
add_model!(MODELS, pdb_eight_schools_noncentered(es_J, es_y, es_sigma))
203+
176204
end # module Models

0 commit comments

Comments
 (0)