if you use summary function in jags. You get the posterior mean and posterior sd of the sample automatically. However, I am confused how to write your own r function to calc