I have just released version 0.9.4 of CholWishart. If you want to simulate from the inverse Wishart, compute densities for the Wishart or inverse Wishart, or use the multivariate gamma or digamma function, this is the R package for you. It has a few other functions (notably, its namesake which generates random samples from the Wishart distribution and returns their Cholesky decomposition).
New in this release: the pseudo Wishart and its pseudo-inverse, the generalized inverse Wishart.
As you might recall, the Wishart distribution is the distribution of the scatter matrices of random draws from the multivariate normal distribution. Its degrees of freedom parameter corresponds to the number of observations (though it is readily generalized to take non-integer inputs if the degrees of freedom parameter is larger than the number of dimensions). The pseudo-Wishart is the distribution when the sample size is smaller than the number of dimensions. The generalized inverse Wishart is the distribution of the Moore-Penrose pseudo-inverse of the pseudo-Wishart. The orphaned package rWishart has this function and a couple
other variants of the Wishart integrated into a wrapper function for rWishart()
.
I am already working on version 1.0.0 of the package, which has improved on this by implementing the pseudo-Wishart function in C. The timings below are comparisons of the development version of the package’s functions to versions of those functions in some other packages.
set.seed(20190108)
A <- (1/8) * rWishart(1, 8, diag(5))[,,1]
library(CholWishart)
res <- microbenchmark::microbenchmark(
rInvWishart(1, 10, A),
LaplacesDemon::rinvwishart(10, A),
rPseudoWishart(1, 3, A),
rWishart::rPsuedoWishart(1, 3, A)
)
ggplot2::autoplot(res)
Other news
This package has, as of the latest CRAN update, its first reverse dependency. Huzzah!