How to predict values using estimates from rjags / JAGS

Viewed 3816

After setting up the model and training it with Gibbs Sampling, I got the result of all the prediction of hidden values with:

jags <- jags.model('example.bug',
               data = data,
               n.chains = 4,
               n.adapt = 100)

update(jags, 1000)

samples <- jags.samples(jags,
         c('r','alpha','alpha_i','alpha_u','u','i'),
         1000)

Where r is a list of rating, and some of them are withheld for a prediction with the model. And suppose I can get them with r[test], where test is a list of integer indicating the index of the rating withheld. But when I tried to get them using this way:

summary(samples$r, mean)[test]

I just got this:

$drop.dims
iteration     chain 
 1000         4 

Could you please tell me how to get the expected value? Thank you in advance!

1 Answers
Related