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 𝔼[Wrpλ(W)]
and 𝔼[W−rpλ(W−1)],
respectively. The last two are used to generate an analytical expression
of 𝔼[Wrpλ(W)]
and 𝔼[W−rpλ(W−1)],
respectively.
Moments of β-Wishart:
wishmom()
The function wishmom()
computes $\mathbb{E}\left[\prod_{j=1}^r
\mbox{tr}(W^j)^{f_j}W^{iw}\right]$ numerically, where W ∼ Wmβ(n, Σ).
When iw = 0, it
computes $\mathbb{E}[\prod_{j=1}^r
\mbox{tr}(W^j)^{f_j}]$.
Arguments
n
: degrees of freedom of the β-Wishart distributionS
: covariance matrix of the β-Wishart distributionf
: a vector of nonnegative integers fj that represents the power for tr(Wj), j = 1, …, riw
: Power of Walpha
: The type of Wishart distribution (α = 2/β):1/2
: Quaternion Wishart1
: Complex Wishart2
: Real Wishart (default)
Output
When iw = 0, it returns $\mathbb{E}[\prod_{j=1}^r \mbox{tr}(W^j)^{f_j}]$. When iw ≠ 0, it returns $\mathbb{E}[\prod_{j=1}^r \mbox{tr}(W^j)^{f_j}W^{iw}]$.
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 $\mathbb{E}\left[\prod_{j=1}^r
\mbox{tr}(W^j)^{f_j}W^{iw}\right]$, where W ∼ Wmβ(n, Σ).
When iw = 0, it
generates an analytical expression of $\mathbb{E}[\prod_{j=1}^r
\mbox{tr}(W^j)^{f_j}]$.
Arguments
f
: a vector of nonnegative integers fj that represents the power for tr(Wj), j = 1, …, riw
: Power of Walpha
: The type of Wishart distribution (α = 2/β):1/2
: Quaternion Wishart1
: Complex Wishart2
: Real Wishart (default)
latex
: The type of outputTRUE
: LaTeX expressionFALSE
: Dataframe (default)
Output
When iw = 0, the
output is an analytical expression of $\mathbb{E}[\prod_{j=1}^r
\mbox{tr}(W^j)^{f_j}]$. When iw ≠ 0, the output is an
analytical expression of $\mathbb{E}[\prod_{j=1}^r
\mbox{tr}(W^j)^{f_j}W^{iw}]$. 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 $\mathbb{E}\left[\prod_{j=1}^r
\mbox{tr}(W^{-j})^{f_j}W^{-iw}\right]$ numerically, where W ∼ Wmβ(n, Σ).
When iw = 0, it
computes $\mathbb{E}[\prod_{j=1}^r
\mbox{tr}(W^{-j})^{f_j}]$.
Arguments
n
: degrees of freedom of the β-Wishart distributionS
: covariance matrix of the β-Wishart distributionf
: a vector of nonnegative integers fj that represents the power for tr(W−j), j = 1, …, riw
: Power of W−1alpha
: The type of Wishart distribution (α = 2/β):1/2
: Quaternion Wishart1
: Complex Wishart2
: Real Wishart (default)
Output
When iw = 0, it returns $\mathbb{E}[\prod_{j=1}^r \mbox{tr}(W^{-j})^{f_j}]$. When iw ≠ 0, it returns $\mathbb{E}[\prod_{j=1}^r \mbox{tr}(W^{-j})^{f_j}W^{-iw}]$.
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 $\mathbb{E}\left[\prod_{j=1}^r
\mbox{tr}(W^{-j})^{f_j}W^{-iw}\right]$, where W ∼ Wmβ(n, Σ).
When iw = 0, it
generates an analytical expression of $\mathbb{E}[\prod_{j=1}^r
\mbox{tr}(W^{-j})^{f_j}]$.
Arguments
f
: a vector of nonnegative integers fj that represents the power for tr(W−j), j = 1, …, riw
: Power of W−1alpha
: The type of Wishart distribution (α = 2/β):1/2
: Quaternion Wishart1
: Complex Wishart2
: Real Wishart (default)
latex
: The type of outputTRUE
: LaTeX expressionFALSE
: Dataframe (default)
Output
When iw = 0, the
output is an analytical expression of $\mathbb{E}[\prod_{j=1}^r
\mbox{tr}(W^{-j})^{f_j}]$. When iw ≠ 0, the output is an
analytical expression of $\mathbb{E}[\prod_{j=1}^r
\mbox{tr}(W^{-j})^{f_j}W^{-iw}]$. 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 ñ and Σ, where ñ = n − m + 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)