rmatrixbeta {matrixsampling} | R Documentation |
Matrix Beta sampler
Description
Samples a matrix Beta (type I) distribution.
Usage
rmatrixbeta(n, p, a, b, Theta1 = NULL, Theta2 = NULL, def = 1,
checkSymmetry = TRUE)
Arguments
n |
sample size, a positive integer |
p |
dimension, a positive integer |
a , b |
parameters of the distribution, positive numbers with constraints given in Details |
Theta1 |
numerator noncentrality parameter, a positive semidefinite real
matrix of order |
Theta2 |
denominator noncentrality parameter, a positive semidefinite real
matrix of order |
def |
|
checkSymmetry |
logical, whether to check the symmetry of |
Details
A Beta random matrix U
is defined as follows.
Take two independent Wishart random matrices
S1 ~ Wp(2a,Ip,Θ1)
and
S2 ~ Wp(2b,Ip,Θ2).
-
definition 1: U = (S1+S2)-½S1(S1+S2)-½
-
definition 2: U = S1½(S1+S2)-1S1½
In the central case, the two definitions yield the same distribution. Under definition 2, the Beta distribution is related to the Beta type II distribution by U ~ V(I+V)-1.
Parameters a
and b
are positive numbers that satisfy the
following constraints:
if both
Theta1
andTheta2
are the null matrix,a+b > (p-1)/2
; ifa < (p-1)/2
, it must be half an integer; ifb < (p-1)/2
, it must be half an integerif
Theta1
is not the null matrix,a >= (p-1)/2
; ifb < (p-1)/2
, it must be half an integerif
Theta2
is not the null matrix,b >= (p-1)/2
; ifa < (p-1)/2
, it must be half an integer
Value
A numeric three-dimensional array; simulations are stacked along the third dimension (see example).
Warning
Definition 2 requires the calculation of the square root of
S1 ~ Wp(2a,Ip,Θ1)
(see Details). While S1 is always
positive semidefinite in theory, it could happen that the simulation of
S1 is not positive semidefinite,
especially when a
is small. In this case the calculation of the square root
will return NaN
.
Note
The matrix variate Beta distribution is usually defined only for
a > (p-1)/2
and b > (p-1)/2
. In this case, a random matrix U
generated from this distribution satisfies 0 < U < I
.
For an half integer a \le (p-1)/2
, it satisfies 0 \le U < I
and rank(U)=2a
.
For an half integer b \le (p-1)/2
, it satisfies 0 < U \le I
and rank(I-U)=2b
.
Examples
Bsims <- rmatrixbeta(10000, 3, 1, 1)
dim(Bsims) # 3 3 10000