Using the wishmom Package

Raymond Kan and Preston Liang

2024-08-25

Introduction

The wishmom package provides functions to compute the expectation of matrix-valued functions of β-Wishart and inverse β-Wishart distributions (β=1: Real Wishart, β=2: Complex Wishart, β=4: Quaternion Wishart, β=8: Octonion Wishart). The main functions in this package are wishmom() and iwishmom(), which handle the numerical computation of moments of β-Wishart and inverse β-Wishart distributions, respectively. The corresponding functions for generating analytical expressions of moments of β-Wishart and inverse β-Wishart distributions are wishmom_sym() and iwishmom_sym(). These programs are developed based on the results in Letac and Massam (2004) and Hillier and Kan (2024).

You can install the package and load it using:

install.packages("wishmom")
library("wishmom")


Mathematical Background

β-Wishart Distribution

The β-Wishart distribution is a fundamental distribution in multivariate statistics. When β=1,2,4,8, it is the real Wishart, complex Wishart, quaternion Wishart, and octonion Wishart, respectively. The density function of WWmβ(n,Σ), i,e., a β-Wishart distribution with n degrees of freedom and an m×m covariance matrix Σ, is given by (when n>m1) (see Díaz-García and Gutiérrez-Jáimez (2011, Corollary 1))

f(W)=(β2)mnβ2Γm(β)(nβ2)|Σ|nβ2|W|(nm+1)β21etr(βΣ1W2),

where

Γm(β)(a)=πm(m1)β4i=1mΓ(a(i1)β2).

Note that we do not require n to be an integer but the definition of the density of W requires β=1,2,4 or 8. However, if our interest is only on the functions of eigenvalues of W, we can generalize this to any real β>0. Therefore, for any symmetric functions (say power-sum) of the eigenvalues of W, they can be well defined even when β is not equal to 1,2,4 or 8. For WWmβ(n,Σ), the joint density of its eigenvalues λ1λm is given by (see Dresnky, Edelman, Genoar, Kan, and Koev (2021))

f(λ1,,λm)=|Σ|nβ2Km(β)(nβ2)|Λ|(nm+1)β210F0(β)(β2Λ,Σ1)1i<jm(λiλj)β, where Λ=Diag(λ1,,λm),

Km(β)(a)=(2β)maπm(m1)β2Γm(β)(mβ2)Γm(β)(a)[Γ(β2)]m,

0F0(β)(A,B)=k=0κkCκ(β)(A)Cκ(β)(B)k!Cκ(β)(Im),

and Cκ(β)(X) is the Jack function of the eigenvalues of X.

Instead of using β, we use α=2/β in our programs to describe the type of Wishart distribution. Therefore, α=2 is for real Wishart, α=1 is for complex Wishart, and α=1/2 is for quaternion Wishart.

Moments of Matrix-valued Functions of β-Wishart and Inverse β-Wishart Distributions

Let λ=(λ1,,λk) be an integer partition of a positive integer k, where |λ|=λ1++λk=k, with λ1λ2λk0. The power-sum symmetric function pλ(W) of W corresponding to a partition λ is defined as

pλ(W)=i=1(λ)pλi(W),

where (λ) is the number of non-zero parts of λ, and pi(W)=tr(Wi). We are interested in computing

E[Wrpλ(W)]andE[Wrpλ(W1)],

where WWmβ(n,Σ).

The method that we use is based on a generalization of the recurrence relations given in Hillier and Kan (2024) for which the cases of β=1 and 2 were developed. Specifically, we have the following recurrence relations:

E[Wr+1pλ(W)]=[n+(2β1)r]ΣE[Wrpλ(W)]+j=1rΣE[Wrjpj(W)pλ(W)]+2βi=1(λ)λiΣE[Wr+λipλ(i)(W)],Σ1E[Wrpλ(W1)]=[n~(2β1)r]E[W(r+1)pλ(W1)]j=1rE[Wr1+jpj(W1)pλ(W1)]2βi=1(λ)λiE[Wr1λipλ(i)(W1)], where n~=nm+1(2/β) and λ(i) is λ with its i-th element removed. Together with the boundary conditions E[W]=nΣ and E[W1]=Σ1/n~, we can obtain E[Erpλ(W)] and E[Wrpλ(W1)]. Note that E[Wrpλ(W1)] exists if and only if n~>2(r+|λ|).

Let k=r+|λ|. Hillier and Kan (2024) show that E[Wrpλ(W)]=i=1k[ρkicλ,ρpρ(Σ)]Σi,E[Wrpλ(W1)]=i=1k[ρkic~λ,ρpρ(Σ1)]Σi, where cλ,ρ and c~λ,ρ are constants that depend on n and n~, respectively, but they do not depend on Σ. In addition, we have E[pλ(W)]=κkhκpκ(Σ),E[pλ(W1)]=κkh~κpκ(Σ1), where hκ and h~κ are constants that depend on n and n~, repsectively, but they do not depend on Σ.

Using the recurrence relations, Hillier and Kan (2024) develop efficient algorithms for computing the constants cλ,ρ, c~λ,ρ, hκ and h~κ.


Main Functions in the Package

There are four main functions in this package: wishmom(), iwishmom(), wishmom_sym(), and iwishmom_sym(). The first two are used to numerically compute E[Wrpλ(W)] and E[Wrpλ(W1)], respectively. The last two are used to generate an analytical expression of E[Wrpλ(W)] and E[Wrpλ(W1)], respectively.

Moments of β-Wishart:

wishmom()

The function wishmom() computes E[j=1rtr(Wj)fjWiw] numerically, where WWmβ(n,Σ). When iw=0, it computes E[j=1rtr(Wj)fj].

Arguments

  • n: degrees of freedom of the β-Wishart distribution
  • S: covariance matrix of the β-Wishart distribution
  • f: a vector of nonnegative integers fj that represents the power for tr(Wj), j=1,,r
  • iw: Power of W
  • alpha: The type of Wishart distribution (α=2/β):
    • 1/2: Quaternion Wishart
    • 1: Complex Wishart
    • 2: Real Wishart (default)

Output

When iw=0, it returns E[j=1rtr(Wj)fj]. When iw0, it returns E[j=1rtr(Wj)fjWiw].

Examples

# Example 1: For E[tr(W)^4] with W ~ W_m^1(n,S), where n and S are defined below:
n <- 20
S <- matrix(c(25, 49,
              49, 109), nrow=2, ncol=2)
wishmom(n, S, 4) # iw = 0, for real Wishart distribution
#> [1] 8.705084e+13

# Example 2: For E[tr(W)^2*tr(W^3)*W^2] with W ~ W_m^1(n,S), where n and S, are defined below:
n <- 20
S <- matrix(c(25, 49,
              49, 109), nrow=2, ncol=2)
wishmom(n, S, c(2, 0, 1), 2, 2) # iw = 2, for real Wishart distribution
#>              [,1]         [,2]
#> [1,] 9.039462e+23 1.956948e+24
#> [2,] 1.956948e+24 4.258714e+24

# Example 3: For E[tr(W)^2*tr(W^3)] with W ~ W_m^2(n,S), where n and S are defined below:
n <- 20
S <- matrix(c(25, 49 + 2i,
              49 - 2i, 109), nrow=2, ncol=2)
wishmom(n, S, c(2, 0, 1), 0, 1) # iw = 0, for complex Wishart distribution
#> [1] 2.078126e+17

# Example 4: For E[tr(W)*tr(W^2)^2*tr(W^3)^2*W] with W ~ W_m^2(n,S), where n, S, are defined below:
n <- 20
S <- matrix(c(25, 49 + 2i,
              49 - 2i, 109), nrow=2, ncol=2)
wishmom(n, S, c(1, 2, 2), 1, 1) # iw = 1, for complex Wishart distribution
#>                            [,1]                       [,2]
#> [1,] 3.418999e+41+5.014362e+20i 6.943130e+41-2.833930e+40i
#> [2,] 6.943130e+41+2.833930e+40i 1.532151e+42-2.882805e+22i

wishmom_sym()

The function wishmom_sym() generates an analytical expression of E[j=1rtr(Wj)fjWiw], where WWmβ(n,Σ). When iw=0, it generates an analytical expression of E[j=1rtr(Wj)fj].

Arguments

  • f: a vector of nonnegative integers fj that represents the power for tr(Wj), j=1,,r
  • iw: Power of W
  • alpha: The type of Wishart distribution (α=2/β):
    • 1/2: Quaternion Wishart
    • 1: Complex Wishart
    • 2: Real Wishart (default)
  • latex: The type of output
    • TRUE: LaTeX expression
    • FALSE: Dataframe (default)

Output

When iw=0, the output is an analytical expression of E[j=1rtr(Wj)fj]. When iw0, the output is an analytical expression of E[j=1rtr(Wj)fjWiw]. If latex = FALSE (default), the output is a data frame that stores the coefficients for the analytical expression. If latex = TRUE, the output is a LATEX formatted string of the result in terms of n and Σ.

Examples

# Example 1: For E[tr(W)^4] with W ~ W_m^1(n,Sigma), represented as a dataframe:
wishmom_sym(4) # iw = 0, for real Wishart distribution
#>     kappa h_kappa
#> 1       4      48
#> 2     3,1     32n
#> 3     2,2     12n
#> 4   2,1,1   12n^2
#> 5 1,1,1,1     n^3

# Example 2: For E[tr(W)*tr(W^2)W] with W ~ W_m^1(n,Sigma), represented as a dataframe:
wishmom_sym(c(1,1), 1) # iw = 1, for real Wishart distribution
#>   i   rho          c
#> 1 1     3    4n^2+4n
#> 2 1   2,1 n^3+n^2+4n
#> 3 1 1,1,1        n^2
#> 4 2     2  2n^2+2n+8
#> 5 2   1,1         6n
#> 6 3     1 4n^2+4n+16
#> 7 4  <NA>     24n+24

# Example 3: For E[tr(W)^4] with W ~ W_m^2(n,Sigma), represented as a LaTeX string:
writeLines(wishmom_sym(4, 0, 1, latex=TRUE)) # iw = 0, for complex Wishart distribution
#> (6)p_{(4)}(\Sigma)
#> +(8n)p_{(3,1)}(\Sigma)
#> +(3n)p_{(2,2)}(\Sigma)
#> +(6n^2)p_{(2,1,1)}(\Sigma)
#> +(n^3)p_{(1,1,1,1)}(\Sigma)

# Example 4: For E[tr(W)*tr(W^2)W] with W ~ W_m^2(n,Sigma), represented as a LaTeX string:
writeLines(wishmom_sym(c(1, 1), 1, 1, latex=TRUE)) # iw = 1, for complex Wishart distribution
#> [(2n^2)p_{(3)}(\Sigma)+(n^3+2n)p_{(2, 1)}(\Sigma)+(n^2)p_{(1, 1, 1)}(\Sigma)]\Sigma
#> +[(n^2+2)p_{(2)}(\Sigma)+(3n)p_{(1, 1)}(\Sigma)]\Sigma^2
#> +(2n^2+4)p_{(1)}(\Sigma)\Sigma^3
#> +(6n)\Sigma^4

Moments of Inverse β-Wishart:

iwishmom()

The function iwishmom() computes E[j=1rtr(Wj)fjWiw] numerically, where WWmβ(n,Σ). When iw=0, it computes E[j=1rtr(Wj)fj].

Arguments

  • n: degrees of freedom of the β-Wishart distribution
  • S: covariance matrix of the β-Wishart distribution
  • f: a vector of nonnegative integers fj that represents the power for tr(Wj), j=1,,r
  • iw: Power of W1
  • alpha: The type of Wishart distribution (α=2/β):
    • 1/2: Quaternion Wishart
    • 1: Complex Wishart
    • 2: Real Wishart (default)

Output

When iw=0, it returns E[j=1rtr(Wj)fj]. When iw0, it returns E[j=1rtr(Wj)fjWiw].

Examples

# Example 1: For E[tr(W^{-1})^2] with W ~ W_m^1(n,S), where n and S are defined below:
n <- 20
S <- matrix(c(25, 49,
              49, 109), nrow=2, ncol=2)
iwishmom(n, S, 2) # iw = 0, for real Wishart distribution
#> [1] 0.0006680892

# Example 2: For E[tr(W^{-1})^2*tr(W^{-3})W^{-2}] with W ~ W_m^1(n,S), where n and S are defined below:
n <- 20
S <- matrix(c(25, 49,
              49, 109), nrow=2, ncol=2)
iwishmom(n, S, c(2, 0, 1), 2, 2) # iw = 2, for real Wishart distribution
#>               [,1]          [,2]
#> [1,]  1.328434e-10 -6.101692e-11
#> [2,] -6.101692e-11  2.824292e-11

# Example 3: For E[tr(W^{-1})^2*tr(W^{-3})] with W ~ W_m^2(n,S), where n and S are defined below:
n <- 20
S <- matrix(c(25, 49 + 2i,
              49 - 2i, 109), nrow=2, ncol=2)
iwishmom(n, S, c(2, 0, 1), 0, 1) # iw = 0, for complex Wishart distribution
#> [1] 1.17985e-08

# Example 4: For E[tr(W^{-1})*tr(W^{-2})^2*tr(W^{-3})^2*W^{-1}] with W ~ W_m^2(n,S), where n and S are defined below:
n <- 30
S <- matrix(c(25, 49 + 2i,
              49 -2i, 109), nrow=2, ncol=2)
iwishmom(n, S, c(1, 2, 2), 1, 1) # iw = 1, for complex Wishart distribution
#>                             [,1]                        [,2]
#> [1,]  1.348928e-21+0.000000e+00i -6.116211e-22+2.496413e-23i
#> [2,] -6.116211e-22-2.496413e-23i  3.004350e-22+0.000000e+00i

iwishmom_sym()

The function iwishmom_sym() generates an analytical expression of E[j=1rtr(Wj)fjWiw], where WWmβ(n,Σ). When iw=0, it generates an analytical expression of E[j=1rtr(Wj)fj].

Arguments

  • f: a vector of nonnegative integers fj that represents the power for tr(Wj), j=1,,r
  • iw: Power of W1
  • alpha: The type of Wishart distribution (α=2/β):
    • 1/2: Quaternion Wishart
    • 1: Complex Wishart
    • 2: Real Wishart (default)
  • latex: The type of output
    • TRUE: LaTeX expression
    • FALSE: Dataframe (default)

Output

When iw=0, the output is an analytical expression of E[j=1rtr(Wj)fj]. When iw0, the output is an analytical expression of E[j=1rtr(Wj)fjWiw]. If latex = FALSE (default), the output is a data frame that stores the coefficients for the analytical expression. If latex = TRUE, the output is a LATEX formatted string of the result in terms of n~ and Σ, where n~=nm+1α and m is the dimension of the β-Wishart distribution.

Examples

# Example 1: For E[tr(W^{-1})^4] with W ~ W_m^1(n,Sigma), represented as a dataframe:
iwishmom_sym(4) # iw = 0, for real Wishart distribution
#> $dataframe
#>     kappa      h_kappa_numerator
#> 1       4              240n1-288
#> 2     3,1           64n1^2-256n1
#> 3     2,2        12n1^2-60n1+216
#> 4   2,1,1  12n1^3-72n1^2+36n1+72
#> 5 1,1,1,1 n1^4-7n1^3+n1^2+35n1-6
#> 
#> $denominator
#> [1] "n1^8-7n1^7-11n1^6+107n1^5+34n1^4-388n1^3-24n1^2+288n1"

# Example 2: For E[tr(W^{-1})*tr(W^{-2})W^{-1}] with W ~ W_m^1(n,Sigma), represented as a dataframe:
iwishmom_sym(c(1,1), 1) # iw = 1, for real Wishart distribution
#> $dataframe
#>   i   rho          c_numerator
#> 1 1     3 4n1^3-16n1^2-20n1+24
#> 2 1   2,1 n1^4-6n1^3+3n1^2+6n1
#> 3 1 1,1,1     n1^3-6n1^2+3n1+6
#> 4 2     2    2n1^3-10n1^2+36n1
#> 5 2   1,1       10n1^2-42n1+36
#> 6 3     1 4n1^3-16n1^2+60n1-72
#> 7 4  <NA>          40n1^2-48n1
#> 
#> $denominator
#> [1] "n1^8-7n1^7-11n1^6+107n1^5+34n1^4-388n1^3-24n1^2+288n1"

# Example 3: For E[tr(W^{-1})^4] with W ~ W_m^2(n,Sigma), represented as a LaTeX string:
writeLines(iwishmom_sym(4, 0, 1, latex=TRUE)) # iw = 0, for complex Wishart distribution
#> [(30\tilde{n})p_{(4)}(\Sigma^{-1})
#> +(16\tilde{n}^2-24)p_{(3,1)}(\Sigma^{-1})
#> +(3\tilde{n}^2+18)p_{(2,2)}(\Sigma^{-1})
#> +(6\tilde{n}^3-24\tilde{n})p_{(2,1,1)}(\Sigma^{-1})
#> +(\tilde{n}^4-8\tilde{n}^2+6)p_{(1,1,1,1)}(\Sigma^{-1})]
#> /(\tilde{n}^8-14\tilde{n}^6+49\tilde{n}^4-36\tilde{n}^2)

# Example 4: For E[tr(W^{-1})*tr(W^{-2})W^{-1}] with W ~ W_m^2(n,Sigma), represented as a LaTeX string:
writeLines(iwishmom_sym(c(1, 1), 1, 1, latex=TRUE)) # iw = 1, for complex Wishart distribution
#> [[(2\tilde{n}^3-8\tilde{n})p_{(3)}(\Sigma^{-1})+(\tilde{n}^4-4\tilde{n}^2)p_{(2,1)}(\Sigma^{-1})+(\tilde{n}^3-4\tilde{n})p_{(1,1,1)}(\Sigma^{-1})]\Sigma^{-1}
#> +[(\tilde{n}^3+6\tilde{n})p_{(2)}(\Sigma^{-1})+(5\tilde{n}^2)p_{(1,1)}(\Sigma^{-1})]\Sigma^{-2}
#> +(2\tilde{n}^3+12\tilde{n})p_{(1)}(\Sigma^{-1})\Sigma^{-3}
#> +(10\tilde{n}^2)\Sigma^{-4}]
#> /(\tilde{n}^8-14\tilde{n}^6+49\tilde{n}^4-36\tilde{n}^2)


Auxiliary Functions

Below is a list of auxiliary functions that are called by wishmom, iwishmom, wishmom_sym, and iwishmom_sym.

ip_desc()

The function ip_desc() generates all integer partitions of a given integer k in a reverse lexicographical order.

Arguments

  • k: A positive integer to be partitioned

Output

A matrix where each row represents an integer partition of k, listed in a reverse lexicographical order.

Examples

# Example 1: List of integer partitions of 3
ip_desc(3)
#>      [,1] [,2] [,3]
#> [1,]    3    0    0
#> [2,]    2    1    0
#> [3,]    1    1    1

# Example 2: List of integer partitions of 5
ip_desc(5)
#>      [,1] [,2] [,3] [,4] [,5]
#> [1,]    5    0    0    0    0
#> [2,]    4    1    0    0    0
#> [3,]    3    2    0    0    0
#> [4,]    3    1    1    0    0
#> [5,]    2    2    1    0    0
#> [6,]    2    1    1    1    0
#> [7,]    1    1    1    1    1

dkmap()

The function dkmap() computes the mapping matrix Dk discussed in Appendix B of Hillier and Kan (2024), modified for the general β-Wishart case. The returned matrix is Dk but with n in the diagonal elements removed.

Arguments

  • k: The order of the mapping matrix Dk (a positive integer)
  • alpha: The type of β-Wishart distribution (α=2/β):
    • 1/2: Quaternion Wishart
    • 1: Complex Wishart
    • 2: Real Wishart (default)

Output

The mapping matrix Dk but with n removed from its diagonal.

Examples

# Example 1: Compute the mapping matrix for k = 2, real Wishart
dkmap(2)
#>      [,1] [,2] [,3] [,4]
#> [1,]    2    1    1    0
#> [2,]    2    1    0    1
#> [3,]    4    0    0    0
#> [4,]    0    4    0    0

# Example 2: Compute the mapping matrix for k = 1, complex Wishart
dkmap(1, 1)
#>      [,1] [,2]
#> [1,]    0    1
#> [2,]    1    0

# Example 3: Compute the mapping matrix for k = 2, quaternion Wishart
dkmap(2, 1/2)
#>      [,1] [,2] [,3] [,4]
#> [1,] -1.0  1.0    1    0
#> [2,]  0.5 -0.5    0    1
#> [3,]  1.0  0.0    0    0
#> [4,]  0.0  1.0    0    0

denpoly()

The function denpoly() computes the coefficients of the denominator polynomial for the elements H~k and C~k. The function returns a vector containing the coefficients in descending powers of n~, with the last element being the coefficient of n~.

Arguments

  • k: The order of the polynomial (a positive integer)
  • alpha: The type of β-Wishart distribution (α=2/β):
    • 1/2: Quaternion Wishart
    • 1: Complex Wishart
    • 2: Real Wishart (default)

Output

A vector containing the coefficients of the denominator polynomial in descending powers of n~ for the elements of H~k and C~k.

Examples

# Example 1: Compute the denominator polynomial for k = 3 and alpha = 2
# Output corresponds to the polynomial n1^5-3n1^4-8n1^3+12n1^2+16n1,
# where n1 is \eqn{\tilde{n}}
denpoly(3)
#> [1]  1 -3 -8 12 16

# Example 2: Compute the denominator polynomial for k = 2 and alpha = 1
# Output corresponds to the polynomial n1^3-n1, where n1 is \eqn{\tilde{n}}
denpoly(2, alpha = 1)
#> [1]  1  0 -1

qk_coeff()

The function qk_coeff() computes the coefficient matrix Ck, which is obtained based on Corollary 1 of Hillier and Kan (2024), after a modification for the general β-Wishart case. Ck is represented as a 3-dimensional array where each slice along the third dimension represents a coefficient matrix of the polynomial in descending powers of n.

Arguments

  • k: The order of the Ck matrix
  • alpha: The type of Wishart distribution (α=2/β):
    • 1/2: Quaternion Wishart
    • 1: Complex Wishart
    • 2: Real Wishart (default)

Output

A 3-dimensional array representing Ck, a matrix of constants that allow us to obtain E[pλ(W)Wr], where r+|λ|=k and WWmβ(n,Σ).

Examples

# Example 1:
qk_coeff(2) # For real Wishart distribution with k = 2
#> , , 1
#> 
#>      [,1] [,2]
#> [1,]    1    0
#> [2,]    0    1
#> 
#> , , 2
#> 
#>      [,1] [,2]
#> [1,]    1    1
#> [2,]    2    0

# Example 2:
qk_coeff(3, 1) # For complex Wishart distribution with k = 3
#> , , 1
#> 
#>      [,1] [,2] [,3] [,4]
#> [1,]    1    0    0    0
#> [2,]    0    1    0    0
#> [3,]    0    0    1    0
#> [4,]    0    0    0    1
#> 
#> , , 2
#> 
#>      [,1] [,2] [,3] [,4]
#> [1,]    0    2    1    0
#> [2,]    2    0    0    1
#> [3,]    2    0    0    1
#> [4,]    0    2    1    0
#> 
#> , , 3
#> 
#>      [,1] [,2] [,3] [,4]
#> [1,]    1    0    0    1
#> [2,]    0    1    1    0
#> [3,]    0    2    0    0
#> [4,]    2    0    0    0

# Example 3:
qk_coeff(2, 1/2) # For quaternion Wishart distribution with k = 2
#> , , 1
#> 
#>      [,1] [,2]
#> [1,]    1    0
#> [2,]    0    1
#> 
#> , , 2
#> 
#>      [,1] [,2]
#> [1,] -0.5    1
#> [2,]  0.5    0

wish_ps()

The function wish_ps() computes the coefficient matrix Hk that allows us to compute E[pκ(W)], which is obtained based on Proposition 5 of Hillier and Kan (2024), after a modification for the general β-Wishart case. Hk is represented as a 3-dimensional array where each slice along the third dimension represents a coefficient matrix of the polynomial in descending powers of n.

Arguments

  • k: The order of the Hk matrix
  • alpha: The type of Wishart distribution (α=2/β):
    • 1/2: Quaternion Wishart
    • 1: Complex Wishart
    • 2: Real Wishart (default)

Output

A 3-dimensional array representing Hk, a matrix of constants that allows us to obtain E[pκ(W)], where |κ|=k and WWmβ(n,Σ).

Examples

# Example 1:
wish_ps(3) # For real Wishart distribution with k = 3
#> , , 1
#> 
#>      [,1] [,2] [,3]
#> [1,]    1    0    0
#> [2,]    0    1    0
#> [3,]    0    0    1
#> 
#> , , 2
#> 
#>      [,1] [,2] [,3]
#> [1,]    3    3    0
#> [2,]    4    1    1
#> [3,]    0    6    0
#> 
#> , , 3
#> 
#>      [,1] [,2] [,3]
#> [1,]    4    3    1
#> [2,]    4    4    0
#> [3,]    8    0    0

# Example 2:
wish_ps(4, 1) # For complex Wishart distribution with k = 4
#> , , 1
#> 
#>      [,1] [,2] [,3] [,4] [,5]
#> [1,]    1    0    0    0    0
#> [2,]    0    1    0    0    0
#> [3,]    0    0    1    0    0
#> [4,]    0    0    0    1    0
#> [5,]    0    0    0    0    1
#> 
#> , , 2
#> 
#>      [,1] [,2] [,3] [,4] [,5]
#> [1,]    0    4    2    0    0
#> [2,]    3    0    0    3    0
#> [3,]    4    0    0    2    0
#> [4,]    0    4    1    0    1
#> [5,]    0    0    0    6    0
#> 
#> , , 3
#> 
#>      [,1] [,2] [,3] [,4] [,5]
#> [1,]    5    0    0    6    0
#> [2,]    0    7    3    0    1
#> [3,]    0    8    2    0    1
#> [4,]    6    0    0    5    0
#> [5,]    0    8    3    0    0
#> 
#> , , 4
#> 
#>      [,1] [,2] [,3] [,4] [,5]
#> [1,]    0    4    1    0    1
#> [2,]    3    0    0    3    0
#> [3,]    2    0    0    4    0
#> [4,]    0    4    2    0    0
#> [5,]    6    0    0    0    0

# Example 3:
wish_ps(2, 1/2) # For quaternion Wishart distribution with k = 2
#> , , 1
#> 
#>      [,1] [,2]
#> [1,]    1    0
#> [2,]    0    1
#> 
#> , , 2
#> 
#>      [,1] [,2]
#> [1,] -0.5    1
#> [2,]  0.5    0

qkn_coeff()

The function qkn_coeff() computes the inverse of the coefficient matrix C~k, which is obtained based on Corollary 2 of Hillier and Kan (2024), after a modification for the general β-Wishart case. C~k1 is represented as a 3-dimensional array where each slice along the third dimension represents a coefficient matrix of the polynomial in descending powers of n~.

Arguments

  • k: The order of the C~k matrix
  • alpha: The type of Wishart distribution (α=2/β):
    • 1/2: Quaternion Wishart
    • 1: Complex Wishart
    • 2: Real Wishart (default)

Output

A 3-dimensional array representing C~k1, a matrix of constants that allow us to obtain E[pλ(W1)Wr], where r+|λ|=k and WWmβ(n,Σ).

Examples

# Example 1:
qkn_coeff(2) # For real Wishart distribution with k = 2
#> , , 1
#> 
#>      [,1] [,2]
#> [1,]    1    0
#> [2,]    0    1
#> 
#> , , 2
#> 
#>      [,1] [,2]
#> [1,]   -1   -1
#> [2,]   -2    0

# Example 2:
qkn_coeff(3, 1) # For complex Wishart distribution with k = 3
#> , , 1
#> 
#>      [,1] [,2] [,3] [,4]
#> [1,]    1    0    0    0
#> [2,]    0    1    0    0
#> [3,]    0    0    1    0
#> [4,]    0    0    0    1
#> 
#> , , 2
#> 
#>      [,1] [,2] [,3] [,4]
#> [1,]    0   -2   -1    0
#> [2,]   -2    0    0   -1
#> [3,]   -2    0    0   -1
#> [4,]    0   -2   -1    0
#> 
#> , , 3
#> 
#>      [,1] [,2] [,3] [,4]
#> [1,]    1    0    0    1
#> [2,]    0    1    1    0
#> [3,]    0    2    0    0
#> [4,]    2    0    0    0

# Example 3:
qkn_coeff(2, 1/2) # For quaternion Wishart distribution with k = 2
#> , , 1
#> 
#>      [,1] [,2]
#> [1,]    1    0
#> [2,]    0    1
#> 
#> , , 2
#> 
#>      [,1] [,2]
#> [1,]  0.5   -1
#> [2,] -0.5    0

iwish_ps()

The function iwish_ps() computes the inverse of the coefficient matrix H~k that allows us to compute E[pκ(W1)], which is obtained based on Eq.(82) of Hillier and Kan (2024), after a modification for the general β-Wishart case. H~k1 is represented as a 3-dimensional array where each slice along the third dimension represents a coefficient matrix of the polynomial in descending powers of n~.

Arguments

  • k: The order of the H~k matrix
  • alpha: The type of Wishart distribution (α=2/β):
    • 1/2: Quaternion Wishart
    • 1: Complex Wishart
    • 2: Real Wishart (default)

Output

A 3-dimensional array representing H~k1, a matrix of constants that allows us to obtain E[pκ(W1)], where |κ|=k and WWmβ(n,Σ).

Examples

# Example 1:
iwish_ps(3) # For real Wishart distribution with k = 3
#> , , 1
#> 
#>      [,1] [,2] [,3]
#> [1,]    1    0    0
#> [2,]    0    1    0
#> [3,]    0    0    1
#> 
#> , , 2
#> 
#>      [,1] [,2] [,3]
#> [1,]   -3   -3    0
#> [2,]   -4   -1   -1
#> [3,]    0   -6    0
#> 
#> , , 3
#> 
#>      [,1] [,2] [,3]
#> [1,]    4    3    1
#> [2,]    4    4    0
#> [3,]    8    0    0

# Example 2:
iwish_ps(4, 1) # For complex Wishart distribution with k = 4
#> , , 1
#> 
#>      [,1] [,2] [,3] [,4] [,5]
#> [1,]    1    0    0    0    0
#> [2,]    0    1    0    0    0
#> [3,]    0    0    1    0    0
#> [4,]    0    0    0    1    0
#> [5,]    0    0    0    0    1
#> 
#> , , 2
#> 
#>      [,1] [,2] [,3] [,4] [,5]
#> [1,]    0   -4   -2    0    0
#> [2,]   -3    0    0   -3    0
#> [3,]   -4    0    0   -2    0
#> [4,]    0   -4   -1    0   -1
#> [5,]    0    0    0   -6    0
#> 
#> , , 3
#> 
#>      [,1] [,2] [,3] [,4] [,5]
#> [1,]    5    0    0    6    0
#> [2,]    0    7    3    0    1
#> [3,]    0    8    2    0    1
#> [4,]    6    0    0    5    0
#> [5,]    0    8    3    0    0
#> 
#> , , 4
#> 
#>      [,1] [,2] [,3] [,4] [,5]
#> [1,]    0   -4   -1    0   -1
#> [2,]   -3    0    0   -3    0
#> [3,]   -2    0    0   -4    0
#> [4,]    0   -4   -2    0    0
#> [5,]   -6    0    0    0    0

# Example 3:
iwish_ps(2, 1/2) # For quaternion Wishart distribution with k = 2
#> , , 1
#> 
#>      [,1] [,2]
#> [1,]    1    0
#> [2,]    0    1
#> 
#> , , 2
#> 
#>      [,1] [,2]
#> [1,]  0.5   -1
#> [2,] -0.5    0

qkn_coeffr()

The function qkn_coeffr() computes the coefficient matrix C~k for the general β-Wishart case. Elements of C~k are rational polynomials of n~. The output contains two components: c and den. c is a 3-dimensional array where each slice along the third dimension represents a coefficient matrix of the numerator polynomial in descending powers of n~, and den is a vector that represents the coefficients of the denominator polynomial in descending power of n~.

Arguments

  • k: The order of the C~k matrix
  • alpha: The type of Wishart distribution (α=2/β):
    • 1/2: Quaternion Wishart
    • 1: Complex Wishart
    • 2: Real Wishart (default)

Output

The output has two components: c and den. c is a 3-dimensional array representing the numerator polynomial of C~k, and den is a vector representing the denominator polynomial of C~k, where C~k is a matrix of constants that allow us to obtain E[pλ(W1)Wr], where r+|λ|=k and WWmβ(n,Σ).

Examples

# Example 1:
qkn_coeffr(2) # For real Wishart distribution with k = 2
#> $c
#> , , 1
#> 
#>      [,1] [,2]
#> [1,]    1    0
#> [2,]    0    1
#> 
#> , , 2
#> 
#>      [,1] [,2]
#> [1,]    0    1
#> [2,]    2   -1
#> 
#> 
#> $den
#> [1]  1 -1 -2
 
# Example 2:
qkn_coeffr(3, 1) # For complex Wishart distribution with k = 3
#> $c
#> , , 1
#> 
#>      [,1] [,2] [,3] [,4]
#> [1,]    1    0    0    0
#> [2,]    0    1    0    0
#> [3,]    0    0    1    0
#> [4,]    0    0    0    1
#> 
#> , , 2
#> 
#>      [,1] [,2] [,3] [,4]
#> [1,]    0    2    1    0
#> [2,]    2    0    0    1
#> [3,]    2    0    0    1
#> [4,]    0    2    1    0
#> 
#> , , 3
#> 
#>      [,1] [,2] [,3] [,4]
#> [1,]    0    0    0    2
#> [2,]    0    0    2    0
#> [3,]    0    4   -2    0
#> [4,]    4    0    0   -2
#> 
#> 
#> $den
#> [1]  1  0 -5  0  4

# Example 3:
qkn_coeffr(2, 1/2) # For quaternion Wishart distribution with k = 2
#> $c
#> , , 1
#> 
#>      [,1] [,2]
#> [1,]    1    0
#> [2,]    0    1
#> 
#> , , 2
#> 
#>      [,1] [,2]
#> [1,]  0.0  1.0
#> [2,]  0.5  0.5
#> 
#> 
#> $den
#> [1]  1.0  0.5 -0.5

iwish_psr()

The function iwish_psr() computes the coefficient matrix H~k for the general β-Wishart case. Elements of H~k are rational polynomials of n~. The output contains two components: c and den. c is a 3-dimensional array where each slice along the third dimension represents a coefficient matrix of the numerator polynomial in descending powers of n~, and den is a vector that represents the coefficients of the denominator polynomial in descending power of n~.

Arguments

  • k: The order of the C~k matrix
  • alpha: The type of Wishart distribution (α=2/β):
    • 1/2: Quaternion Wishart
    • 1: Complex Wishart
    • 2: Real Wishart (default)

Output

The output has two components: c and den. c is a 3-dimensional array representing the numerator polynomial of H~k, and den is a vector representing the denominator polynomial of H~k, where H~k is a matrix of constants that allow us to obtain E[pλ(W1)], where |λ|=k and WWmβ(n,Σ).

Examples

# Example 1:
iwsih_psr(2) # For real Wishart distribution with k = 2
#> $c
#> , , 1
#> 
#>      [,1] [,2]
#> [1,]    1    0
#> [2,]    0    1
#> 
#> , , 2
#> 
#>      [,1] [,2]
#> [1,]    0    1
#> [2,]    2   -1
#> 
#> 
#> $den
#> [1]  1 -1 -2
 
# Example 2:
iwish_psr(4, 1) # For complex Wishart distribution with k = 4
#> $c
#> , , 1
#> 
#>      [,1] [,2] [,3] [,4] [,5]
#> [1,]    1    0    0    0    0
#> [2,]    0    1    0    0    0
#> [3,]    0    0    1    0    0
#> [4,]    0    0    0    1    0
#> [5,]    0    0    0    0    1
#> 
#> , , 2
#> 
#>      [,1] [,2] [,3] [,4] [,5]
#> [1,]    0    4    2    0    0
#> [2,]    3    0    0    3    0
#> [3,]    4    0    0    2    0
#> [4,]    0    4    1    0    1
#> [5,]    0    0    0    6    0
#> 
#> , , 3
#> 
#>      [,1] [,2] [,3] [,4] [,5]
#> [1,]    1    0    0   10    0
#> [2,]    0    3    6    0    2
#> [3,]    0   16   -6    0    1
#> [4,]   10    0    0    1    0
#> [5,]    0   16    3    0   -8
#> 
#> , , 4
#> 
#>      [,1] [,2] [,3] [,4] [,5]
#> [1,]    0    4   -3    0    5
#> [2,]    3    0    0    3    0
#> [3,]   -6    0    0   12    0
#> [4,]    0    4    6    0   -4
#> [5,]   30    0    0  -24    0
#> 
#> , , 5
#> 
#>      [,1] [,2] [,3] [,4] [,5]
#> [1,]    0    0    0    0    0
#> [2,]    0   12   -9    0   -3
#> [3,]    0  -24   18    0    6
#> [4,]    0    0    0    0    0
#> [5,]    0  -24   18    0    6
#> 
#> 
#> $den
#> [1]   1   0 -14   0  49   0 -36   0

# Example 3:
iwish_psr(2, 1/2) # For quaternion Wishart distribution with k = 2
#> $c
#> , , 1
#> 
#>      [,1] [,2]
#> [1,]    1    0
#> [2,]    0    1
#> 
#> , , 2
#> 
#>      [,1] [,2]
#> [1,]  0.0  1.0
#> [2,]  0.5  0.5
#> 
#> 
#> $den
#> [1]  1.0  0.5 -0.5


References

Díaz-García, José and Gutiérrez-Jáimez, Ramón (2011). On Wishart distribution: som extension. Linear Algebra and its Applications, 435, 1296-1310.

Drensky, Vesselin, Edelman, Alan, Genoar, Tierney, Kan, Raymond, and Koev, Plamen (2021). The Densities and Distributions of the Largest Eigenvalue and the Trace of a Beta-Wishart Matrix. Random Matrices: Theory and Applications, 10(1).

Letac, Gérard, and Massam, Héelène (2004). All invariant moments of the Wishart distribution. Scandinavian Journal of Statistics, 31, 295-318.

Hillier, Grant, and Kan, Raymond (2024). On the expectations of equivariant matrix-valued functions of Wishart and inverse Wishart Matrices. Scandinavian Journal of Statistics, 51, 697-723.