Page 1 of 1

density function for inverse Wishart distribution

Posted: Sun Jun 30, 2024 2:46 pm
by tclark
RATS has functions covering the pdfs of many common distributions, but this does not seem to cover the Inverse Wishart (the pdf is given in sources such as https://en.wikipedia.org/wiki/Inverse-W ... stribution). Has anyone in the RATS community by chance already coded this up? The calculations look to be straightforward, with the trickiest piece being careful with the multivariate gamma piece.

Re: density function for inverse Wishart distribution

Posted: Mon Jul 01, 2024 7:49 am
by TomDoan
For what did you need the full density? The kernel is enough for most purposes.

Re: density function for inverse Wishart distribution

Posted: Mon Jul 01, 2024 9:01 am
by tclark
Thanks, Tom -- fair point, I will need to work through what exactly suffices in this case. What I am trying to do is make use of a Metropolis step (within a Gibbs sampler) to make the prior governing time variation in some parameters something to be estimated, as in a JBES paper by Amir-Ahmadi, Matthes, and Wang (paper at https://cm1518.github.io/files/HP.pdf). The basics appear on p.2 of the appendix (https://cm1518.github.io/files/OnlineAppHP.pdf), where the acceptance probability taken literally requires the pdf of the inverse Wishart, although it may be that things cancel and just the kernel is needed (I can check that later today).

Re: density function for inverse Wishart distribution

Posted: Mon Jul 01, 2024 10:24 am
by tclark
Ok, Tom, you are right: the multivariate gamma piece is irrelevant (cancels out), and everything else is straightforward matrix computation with existing commands and functions. Sorry, I should have realized this before posting.

Re: density function for inverse Wishart distribution

Posted: Mon Jul 01, 2024 2:33 pm
by TomDoan
Remember that %RANWISHARTI saves the log kernel so it can be obtained with %RANLOGKERNEL(). So you generally don't even have to compute that yourself.

Re: density function for inverse Wishart distribution

Posted: Mon Jul 01, 2024 2:45 pm
by tclark
Great -- thanks very much. I actually did not know/remember that, and it will be very handy for the problem at hand.