Hello Everyone,
I have just started to use Turing. I want to implement a DINA Model ( DINA Model and Parameter Estimation: A Didactic (jstor.org)) which contains both discrete and continuous random variables. Hence, I was looking into Compositional sampling using Turing. But I keep getting exactly same samples of my continuous random variables, resulting in 0 standard deviation. Please help me understand what I may be doing wrong. Below is a version of my code that I used to replicate the issue so that I can post it here.
Thanks for the help!
Code
using Turing
using MCMCChains
@model function fn(I,X)
#I represents number of students
#discrete random variable - which dummy class a student may below to
α ~ Bernoulli(0.5)
# continuous random variable - probability of getting the answer correct based on the class student belongs to
p ~ filldist(Beta(1,1), I, 2)
#X represents that answers these students gave for a question
X ~ arraydist(Bernoulli.(p[:, α+1])) # selecting p
end
# Sampling (Prior) from the model
X_sample = fn(50,missing)()
# Sampling (posterior) based on the prior sampled X. The idea here is just to see whether the code works
chain = sample(fn(50,X_sample), Gibbs(MH(:α), NUTS(100,0.85, :p)), 100)
Output (Summary):
Summary Statistics
parameters mean std naive_se mcse ess rhat es â‹Ż
Symbol Float64 Float64 Float64 Float64 Float64 Float64 â‹Ż
α 1.0000 0.0000 0.0000 0.0000 NaN NaN ⋯
p[1,1] 0.0811 0.0000 0.0000 0.0000 2.0408 0.9899 â‹Ż
p[2,1] 0.6207 0.0000 0.0000 0.0000 NaN NaN â‹Ż
p[3,1] 0.9574 0.0000 0.0000 0.0000 NaN NaN â‹Ż
p[4,1] 0.4273 0.0000 0.0000 0.0000 NaN NaN â‹Ż
p[5,1] 0.0832 0.0000 0.0000 0.0000 NaN NaN â‹Ż
p[6,1] 0.7725 0.0000 0.0000 0.0000 2.0408 0.9899 â‹Ż
p[7,1] 0.8586 0.0000 0.0000 0.0000 NaN NaN â‹Ż
p[8,1] 0.2287 0.0000 0.0000 0.0000 2.0408 0.9899 â‹Ż
p[9,1] 0.3254 0.0000 0.0000 0.0000 NaN NaN â‹Ż
p[10,1] 0.6004 0.0000 0.0000 0.0000 2.0408 0.9899 â‹Ż
Output (actual samples):