rbmf.O2: Simulate a '2*2' Orthogonal Random Matrix

Description Usage Arguments Value Author(s) References Examples

View source: R/rbmf.O2.R

Description

Simulate a 2*2 random orthogonal matrix from the Bingham-von Mises-Fisher distribution using a rejection sampler.

Usage

1
rbmf.O2(A, B, C, env = FALSE)

Arguments

A

a symmetric matrix.

B

a diagonal matrix with decreasing entries.

C

a 2x2 matrix.

env

which rejection envelope to use, Bingham (bingham) or von Mises-Fisher (mf)?

Value

A random 2x2 orthogonal matrix simulated from the Bingham-von Mises-Fisher distribution.

Author(s)

Peter Hoff

References

Hoff(2009)

Examples

 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
26
## The function is currently defined as
function (A, B, C, env = FALSE) 
{
    sC <- svd(C)
    d1 <- sum(sC$d)
    eA <- eigen(A)
    ab <- sum(eA$val * diag(B))
    if (d1 <= ab | env == "bingham") {
        lrmx <- sum(sC$d)
        lr <- -Inf
        while (lr < log(runif(1))) {
            X <- rbing.O2(A, B, a = (eA$val[1] - eA$val[2]) * 
                (B[1, 1] - B[2, 2]), E = eA$vec)
            lr <- sum(diag(t(X) %*% C)) - lrmx
        }
    }
    if (d1 > ab | env == "mf") {
        lrmx <- sum(eA$val * sort(diag(B), decreasing = TRUE))
        lr <- -Inf
        while (lr < log(runif(1))) {
            X <- rmf.matrix(C)
            lr <- sum(diag(B %*% t(X) %*% A %*% X)) - lrmx
        }
    }
    X
  }

rstiefel documentation built on June 15, 2021, 5:07 p.m.