Description Usage Arguments Value Note Author(s) References Examples
View source: R/rmf.matrix.gibbs.R
Simulate a random orthonormal matrix from the matrix von Mises-Fisher distribution using Gibbs sampling.
1 | rmf.matrix.gibbs(M, X, rscol = NULL)
|
M |
a matrix. |
X |
the current value of the random orthonormal matrix. |
rscol |
the number of columns to update simultaneously. |
a new value of the matrix X
obtained by Gibbs sampling.
This provides one Gibbs scan. The function should be used iteratively.
Peter Hoff
Hoff(2009)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | Z<-matrix(rnorm(10*5),10,5)
U<-rmf.matrix(Z)
U<-rmf.matrix.gibbs(Z,U)
## The function is currently defined as
function (M, X, rscol = NULL)
{
if (is.null(rscol)) {
rscol <- max(2, min(round(log(dim(M)[1])), dim(M)[2]))
}
sM <- svd(M)
H <- sM$u %*% diag(sM$d)
Y <- X %*% sM$v
m <- dim(H)[1]
R <- dim(H)[2]
for (iter in 1:round(R/rscol)) {
r <- sample(seq(1, R, length = R), rscol)
N <- NullC(Y[, -r])
y <- rmf.matrix(t(N) %*% H[, r])
Y[, r] <- N %*% y
}
Y %*% t(sM$v)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.