I am reading the following in the book "Bayesian Data Analysis"
In the book, the matrix S is defined as follows:
For the sake of the question, let's assume that I have S calculated. I would like to be able to sample from the distribution of Sigma|y, i.e., the inverse wishart distribution. I am using the MCMCpack package in R to do so and what I can't quite understand is whether the function expects me to pass it S or the inverse of S, i.e.,
library(MCMCpack)
S <- matrix(c(1,.3,.3,1),2,2)
## Use S?
riwish(4, S)
## or use S^{-1}
riwish(4, solve(S))
It is not clear to me from the documentation which one is expected.


I think the way to figure this out is to think carefully about whether each object/variable is on the variance scale or the precision (inverse-variance) scale.
?riwishsays:We want the final answer (the posterior distribution of the covariance matrix) to be on the variance scale. If the mean of the random variable is is proportional to
S, that must mean thatSas input toriwishshould also be on the covariance scale.We can also confirm by brute force that using
Sgives us a sensible value (since the Jeffreys prior is weakly informative we should get a mean approximately equal toS):