I think the problem is that you are supposed to add your distribution and data to the code. For example,
lpfun = function f(chain::Chains) # function to compute the logpdf values
niter, nparams, nchains = size(chain)
lp = zeros(niter + nchains) # resulting logpdf values
for i = 1:nparams
lp += map(p -> logpdf(BinomialLogit(p...), your_data), Array(chain[:,i,:]))
end
return lp
end
DIC, pD = dic(chn, lpfun)
However, I think this API might be difficult for users. It might be better to do something like this:
DIC, pD = dic(chn, distribution_object, the_data)
Under my proposal, the function dic would create the lpfun
function and perform the calculations as normal. This way the user does not need to modify functions.
@cpfiffer, would this be a better way to compute DIC or did I misunderstand the documentation?