Title: | Random Wishart Matrix Generation |
Version: | 0.1.2 |
Maintainer: | Ben Barnard <benbarnard87@gmail.com> |
Description: | An expansion of R's 'stats' random wishart matrix generation. This package allows the user to generate singular, Uhlig and Harald (1994) <doi:10.1214/aos/1176325375>, and pseudo wishart, Diaz-Garcia, et al.(1997) <doi:10.1006/jmva.1997.1689>, matrices. In addition the user can generate wishart matrices with fractional degrees of freedom, Adhikari (2008) <doi:10.1061/(ASCE)0733-9399(2008)134:12(1029)>, commonly used in volatility modeling. Users can also use this package to create random covariance matrices. |
Depends: | R (≥ 3.3) |
Imports: | Matrix, MASS, stats, lazyeval |
License: | GPL-2 |
Encoding: | UTF-8 |
LazyData: | true |
RoxygenNote: | 6.1.1 |
Suggests: | covr, knitr, rmarkdown, testthat |
URL: | https://rwishart.bearstatistics.com |
NeedsCompilation: | no |
Packaged: | 2019-11-19 19:46:52 UTC; ben_b |
Author: | Ben Barnard [aut, cre], Dean Young [aut] |
Repository: | CRAN |
Date/Publication: | 2019-11-19 23:10:02 UTC |
Random Wishart Matrix Generation
Description
An expansion of R's 'stats' random wishart matrix generation. This package allows the user to generate singular, Uhlig and Harald (1994) <doi:10.1214/aos/1176325375>, and pseudo wishart, Diaz-Garcia, et al.(1997) <doi:10.1006/jmva.1997.1689>, matrices. In addition the user can generate wishart matrices with fractional degrees of freedom, Adhikari (2008) <doi:10.1061/(ASCE)0733-9399(2008)134:12(1029)>, commonly used in volatility modeling. Users can also use this package to create random covariance matrices.
Generate n
random matrices, distributed according to the Wishart distribution with parameters Sigma
and df
, W_p(Sigma, df).
Usage
rWishart(n, df, Sigma, covariance = FALSE, simplify = "array")
Arguments
n |
integer: the number of replications. |
df |
numeric parameter, “degrees of freedom”. |
Sigma |
positive definite ( |
covariance |
logical on whether a covariance matrix should be generated |
simplify |
logical or character string; should the result be
simplified to a vector, matrix or higher dimensional array if
possible? For |
Details
If X_1, ..., X_m is a sample of m independent multivariate Gaussians with mean vector 0, and covariance matrix Sigma, the distribution of M = X'X is W_p(Sigma, m).
Value
A numeric array of dimension p * p * n
, where each array is a positive semidefinite matrix, a realization of the Wishart distribution W_p(Sigma, df)
Examples
rWishart(2, 5, diag(1, 20))
Fractional Wishart Helper Function
Description
An expansion of R's 'stats' random wishart matrix generation. This package allows the user to generate singular, Uhlig and Harald (1994) <doi:10.1214/aos/1176325375>, and pseudo wishart, Diaz-Garcia, et al.(1997) <doi:10.1006/jmva.1997.1689>, matrices. In addition the user can generate wishart matrices with fractional degrees of freedom, Adhikari (2008) <doi:10.1061/(ASCE)0733-9399(2008)134:12(1029)>, commonly used in volatility modeling. Users can also use this package to create random covariance matrices.
Generate n
random matrices, distributed according to the Wishart distribution with parameters Sigma
and df
, W_p(Sigma, df).
Usage
FractionalWishart(df, Sigma, covariance = FALSE)
Arguments
df |
numeric parameter, “degrees of freedom”. |
Sigma |
positive definite ( |
covariance |
logical on whether a covariance matrix should be generated |
Details
If X_1, ..., X_m is a sample of m independent multivariate Gaussians with mean vector 0, and covariance matrix Sigma, the distribution of M = X'X is W_p(Sigma, m).
Value
A numeric array of dimension p * p * n
, where each array is a positive semidefinite matrix, a realization of the Wishart distribution W_p(Sigma, df)
Examples
FractionalWishart(22.5, diag(1, 20))
Nonsingular Wishart Helper Function
Description
An expansion of R's 'stats' random wishart matrix generation. This package allows the user to generate singular, Uhlig and Harald (1994) <doi:10.1214/aos/1176325375>, and pseudo wishart, Diaz-Garcia, et al.(1997) <doi:10.1006/jmva.1997.1689>, matrices. In addition the user can generate wishart matrices with fractional degrees of freedom, Adhikari (2008) <doi:10.1061/(ASCE)0733-9399(2008)134:12(1029)>, commonly used in volatility modeling. Users can also use this package to create random covariance matrices.
Generate n
random matrices, distributed according to the Wishart distribution with parameters Sigma
and df
, W_p(Sigma, df).
Usage
NonsingularWishart(df, Sigma, covariance = FALSE)
Arguments
df |
numeric parameter, “degrees of freedom”. |
Sigma |
positive definite ( |
covariance |
logical on whether a covariance matrix should be generated |
Details
If X_1, ..., X_m is a sample of m independent multivariate Gaussians with mean vector 0, and covariance matrix Sigma, the distribution of M = X'X is W_p(Sigma, m).
Value
A numeric array of dimension p * p * n
, where each array is a positive semidefinite matrix, a realization of the Wishart distribution W_p(Sigma, df)
Examples
NonsingularWishart(20, diag(1,5))
Psuedo Wishart Helper Function
Description
An expansion of R's 'stats' random wishart matrix generation. This package allows the user to generate singular, Uhlig and Harald (1994) <doi:10.1214/aos/1176325375>, and pseudo wishart, Diaz-Garcia, et al.(1997) <doi:10.1006/jmva.1997.1689>, matrices. In addition the user can generate wishart matrices with fractional degrees of freedom, Adhikari (2008) <doi:10.1061/(ASCE)0733-9399(2008)134:12(1029)>, commonly used in volatility modeling. Users can also use this package to create random covariance matrices.
Generate n
random matrices, distributed according to the Wishart distribution with parameters Sigma
and df
, W_p(Sigma, df).
Usage
PsuedoWishart(df, Sigma, covariance = FALSE)
Arguments
df |
numeric parameter, “degrees of freedom”. |
Sigma |
positive definite ( |
covariance |
logical on whether a covariance matrix should be generated |
Details
If X_1, ..., X_m is a sample of m independent multivariate Gaussians with mean vector 0, and covariance matrix Sigma, the distribution of M = X'X is W_p(Sigma, m).
Value
A numeric array of dimension p * p * n
, where each array is a positive semidefinite matrix, a realization of the Wishart distribution W_p(Sigma, df)
Examples
PsuedoWishart(5, diag(1, 20))
Singular Wishart Helper Function
Description
An expansion of R's 'stats' random wishart matrix generation. This package allows the user to generate singular, Uhlig and Harald (1994) <doi:10.1214/aos/1176325375>, and pseudo wishart, Diaz-Garcia, et al.(1997) <doi:10.1006/jmva.1997.1689>, matrices. In addition the user can generate wishart matrices with fractional degrees of freedom, Adhikari (2008) <doi:10.1061/(ASCE)0733-9399(2008)134:12(1029)>, commonly used in volatility modeling. Users can also use this package to create random covariance matrices.
Generate n
random matrices, distributed according to the Wishart distribution with parameters Sigma
and df
, W_p(Sigma, df).
Usage
SingularWishart(df, Sigma, covariance = FALSE)
Arguments
df |
numeric parameter, “degrees of freedom”. |
Sigma |
positive definite ( |
covariance |
logical on whether a covariance matrix should be generated |
Details
If X_1, ..., X_m is a sample of m independent multivariate Gaussians with mean vector 0, and covariance matrix Sigma, the distribution of M = X'X is W_p(Sigma, m).
Value
A numeric array of dimension p * p * n
, where each array is a positive semidefinite matrix, a realization of the Wishart distribution W_p(Sigma, df)
Examples
SingularWishart(5, diag(1, 20))
Random Fractional Wishart Matrix
Description
Generate n
random matrices, distributed according to the Wishart distribution with parameters Sigma
and df
, W_p(Sigma, df).
Usage
rFractionalWishart(n, df, Sigma, covariance = FALSE,
simplify = "array")
Arguments
n |
integer: the number of replications. |
df |
numeric parameter, “degrees of freedom”. |
Sigma |
positive definite ( |
covariance |
logical on whether a covariance matrix should be generated |
simplify |
logical or character string; should the result be
simplified to a vector, matrix or higher dimensional array if
possible? For |
Details
If X_1, ..., X_m is a sample of m independent multivariate Gaussians with mean vector 0, and covariance matrix Sigma, the distribution of M = X'X is W_p(Sigma, m).
Value
A numeric array of dimension p * p * n
, where each array is a positive semidefinite matrix, a realization of the Wishart distribution W_p(Sigma, df)
References
Adhikari, S. (2008). Wishart random matrices in probabilistic structural mechanics. Journal of engineering mechanics, 134(12), doi: 10.1061/(ASCE)0733-9399(2008)134:12(1029).
Examples
rFractionalWishart(2, 22.5, diag(1, 20))
Random Nonsingular Wishart Matrix
Description
Generate n
random matrices, distributed according to the Wishart distribution with parameters Sigma
and df
, W_p(Sigma, df).
Usage
rNonsingularWishart(n, df, Sigma, covariance = FALSE,
simplify = "array")
Arguments
n |
integer: the number of replications. |
df |
numeric parameter, “degrees of freedom”. |
Sigma |
positive definite ( |
covariance |
logical on whether a covariance matrix should be generated |
simplify |
logical or character string; should the result be
simplified to a vector, matrix or higher dimensional array if
possible? For |
Details
If X_1, ..., X_m is a sample of m independent multivariate Gaussians with mean vector 0, and covariance matrix Sigma, the distribution of M = X'X is W_p(Sigma, m).
Value
A numeric array of dimension p * p * n
, where each array is a positive semidefinite matrix, a realization of the Wishart distribution W_p(Sigma, df)
Examples
rNonsingularWishart(2, 20, diag(1, 5))
Random Psuedo Wishart Matrix
Description
Generate n
random matrices, distributed according to the Wishart distribution with parameters Sigma
and df
, W_p(Sigma, df).
Usage
rPsuedoWishart(n, df, Sigma, covariance = FALSE, simplify = "array")
Arguments
n |
integer: the number of replications. |
df |
numeric parameter, “degrees of freedom”. |
Sigma |
positive definite ( |
covariance |
logical on whether a covariance matrix should be generated |
simplify |
logical or character string; should the result be
simplified to a vector, matrix or higher dimensional array if
possible? For |
Details
If X_1, ..., X_m is a sample of m independent multivariate Gaussians with mean vector 0, and covariance matrix Sigma, the distribution of M = X'X is W_p(Sigma, m).
Value
A numeric array of dimension p * p * n
, where each array is a positive semidefinite matrix, a realization of the Wishart distribution W_p(Sigma, df)
References
Diaz-Garcia, Jose A, Ramon Gutierrez Jaimez, and Kanti V Mardia. 1997. “Wishart and Pseudo-Wishart Distributions and Some Applications to Shape Theory.” Journal of Multivariate Analysis 63 (1): 73–87. doi:10.1006/jmva.1997.1689.
Examples
rPsuedoWishart(2, 5, diag(1, 20))
Random Singular Wishart Matrix
Description
Generate n
random matrices, distributed according to the Wishart distribution with parameters Sigma
and df
, W_p(Sigma, df).
Usage
rSingularWishart(n, df, Sigma, covariance = FALSE, simplify = "array")
Arguments
n |
integer: the number of replications. |
df |
numeric parameter, “degrees of freedom”. |
Sigma |
positive definite ( |
covariance |
logical on whether a covariance matrix should be generated |
simplify |
logical or character string; should the result be
simplified to a vector, matrix or higher dimensional array if
possible? For |
Details
If X_1, ..., X_m is a sample of m independent multivariate Gaussians with mean vector 0, and covariance matrix Sigma, the distribution of M = X'X is W_p(Sigma, m).
Value
A numeric array of dimension p * p * n
, where each array is a positive semidefinite matrix, a realization of the Wishart distribution W_p(Sigma, df)
References
Uhlig, Harald. 1994. “On Singular Wishart and Singular Multivariate Beta Distributions.” The Annals of Statistics 22 (1): 395–405. doi:10.1214/aos/1176325375.
Examples
rSingularWishart(2, 5, diag(1, 20))
Test if Matrix is a Wishart Matrix
Description
Given a random Wishart matrix, B, from W_p(Sigma, df) and independent random vector a
, then (a' B a) / (a' Sigma a)
is chi-squared with df degrees of freedom.
Usage
wishartTest(WishMat, Sigma, vec = NULL)
Arguments
WishMat |
random Wishart Matrix from W_p(Sigma, df) |
Sigma |
Covariance matrix for W_p(Sigma, df) |
vec |
independent random vector |
Value
A chi-squared random variable with df degrees of freedom.
Examples
wishartTest(rWishart(1, 5, diag(1, 20), simplify = FALSE)[[1]], diag(1, 20))