density function for inverse Wishart distribution

If you are seeking RATS code for implementing a particular technique or replicating results from a paper, post your request here. Be sure to include complete citations for any papers or books.
tclark
Posts: 99
Joined: Wed Nov 08, 2006 3:20 pm

density function for inverse Wishart distribution

Unread post 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.
Todd Clark
Economic Research Dept.
Federal Reserve Bank of Cleveland
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: density function for inverse Wishart distribution

Unread post by TomDoan »

For what did you need the full density? The kernel is enough for most purposes.
tclark
Posts: 99
Joined: Wed Nov 08, 2006 3:20 pm

Re: density function for inverse Wishart distribution

Unread post 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).
Todd Clark
Economic Research Dept.
Federal Reserve Bank of Cleveland
tclark
Posts: 99
Joined: Wed Nov 08, 2006 3:20 pm

Re: density function for inverse Wishart distribution

Unread post 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.
Todd Clark
Economic Research Dept.
Federal Reserve Bank of Cleveland
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: density function for inverse Wishart distribution

Unread post 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.
tclark
Posts: 99
Joined: Wed Nov 08, 2006 3:20 pm

Re: density function for inverse Wishart distribution

Unread post by tclark »

Great -- thanks very much. I actually did not know/remember that, and it will be very handy for the problem at hand.
Todd Clark
Economic Research Dept.
Federal Reserve Bank of Cleveland
Post Reply