Hi Andrei,
When you switch from using scalar x[1], x[2], ... variables to the
vector x[1:K], the sampler(s) assigned by NIMBLE change from slice
samplers on each x[i] to a random walk block sampler. Our slice
sampler recognizes that x[i] are discrete and proposes new values
appropriately. Our random walk block sampler is not designed for
discrete multivariate random variables and so proposes non-integer
values and you get the warnings you do. A simple fix is to configure
the MCMC so that each x[i] is sampled using a slice sampler. But that
presumably defeats the purpose of creating the vectorized binomial
density since each scalar sampler will recompute the likelihood for
the full vector x[1:K].
We don't have a sampler in our provided samplers that would handle
this discrete multivariate case, so if you wanted to continue on this
path, you would probably need to write your own multivariate sampler
for x[1:K]. This could be a version of our RW_block sampler (you can
copy and then modify the sampler_RW_block code from the file
MCMC_samplers.R in
https://github.com/nimble-devnimble) that proposes
integer-valued proposals perhaps via some sort of rounding. There is
discussion of user-defined samplers in Section 5 of chapter 15 of the
NIMBLE manual.
All that being said, there is a bigger issue here. In the form you
write your model, NIMBLE is not constraining y[1:K,1:K] such that the
rowSums are equal to the values of observed. To impose such a
constraint, you need to use the dconstraint() syntax discussed in
Section 5.2.7.3 of the NIMBLE manual. And once you do impose the
constraint, MCMC sampling won't work very well (actually it probably
won't accept any proposals at all) because it will be very hard for a
sampler to propose values of 'y' that are consistent with the fixed
values of 'observed'. I think you would have to come up with your own
user-defined sampler that proposed new 'y' values that are consistent
with 'observed'. E.g., within a row of 'y', you could propose to
increase one element by one and decrease another element by one so the
sum stays fixed.
Chris
> To view this discussion on the web visit
https://groups.google.com/d/msgid/nimble-users/7b471014-d6ba-4e83-9b73-f4e1248dc242%40googlegroups.com.