Generate n random matrices, distributed according to the Wishart distribution with parameters Sigma and df, W_p(Sigma, df).

rSingularWishart(n, df, Sigma, covariance = FALSE, simplify = "array")

Arguments

n

integer: the number of replications.

df

numeric parameter, “degrees of freedom”.

Sigma

positive definite (\(p\times p\)) “scale” matrix, the matrix parameter of the distribution.

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 sapply it must be named and not abbreviated. The default value, TRUE, returns a vector or matrix if appropriate, whereas if simplify = "array" the result may be an array of “rank” (\(=\)length(dim(.))) one higher than the result of FUN(X[[i]]).

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)

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).

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))
#> , , 1 #> #> [,1] [,2] [,3] [,4] [,5] [,6] #> [1,] 4.496122747 2.47286117 1.04635474 0.004355063 -2.5315425 -0.92925706 #> [2,] 2.472861171 3.44413887 1.26959264 1.237882502 1.0950183 0.76673151 #> [3,] 1.046354737 1.26959264 1.77858542 -0.219811493 0.7659096 0.11335942 #> [4,] 0.004355063 1.23788250 -0.21981149 4.103538677 3.2429428 2.69337670 #> [5,] -2.531542500 1.09501834 0.76590960 3.242942750 8.9728584 2.89299031 #> [6,] -0.929257060 0.76673151 0.11335942 2.693376703 2.8929903 2.19286845 #> [7,] 3.144114142 1.87358683 1.55462979 1.684476746 -0.4047529 0.64901278 #> [8,] 1.831155110 0.79849451 0.23015757 -1.194387216 -3.9316539 -0.97237624 #> [9,] -0.248284314 -1.04228519 1.08281735 -0.880454205 1.2031090 -0.55106578 #> [10,] -0.219195677 -1.18617945 -0.71967980 -0.380840959 -1.1080962 -0.53625095 #> [11,] 0.258481363 -0.41611808 -0.05076391 4.857468708 3.6759255 2.69991251 #> [12,] 0.532383104 -0.59057988 0.61934323 -2.255056011 -2.3371620 -1.49219136 #> [13,] -1.364369600 -0.19811542 -0.50990550 2.435807345 -0.5748421 2.21529820 #> [14,] -3.345898564 -1.66937433 -0.04172636 0.920477293 -1.4043704 2.00517488 #> [15,] 3.446133529 1.15529340 2.52175529 -0.381603256 0.1106376 -0.86786024 #> [16,] 2.214015766 1.40295050 0.11544473 1.940356565 0.6123041 0.58729133 #> [17,] 2.323012017 1.86031402 1.24038189 0.679019787 3.4904505 -0.23026195 #> [18,] 0.339735809 -0.07978953 -2.17926040 1.839844397 -1.9292950 0.65064488 #> [19,] -1.054940520 -1.06096135 1.05970034 -4.200681968 -0.1773063 -2.32179782 #> [20,] -2.071123756 -0.62178843 -0.09315525 -1.488151324 -1.7080956 -0.01356917 #> [,7] [,8] [,9] [,10] [,11] [,12] #> [1,] 3.14411414 1.83115511 -0.2482843 -0.21919568 0.25848136 0.53238310 #> [2,] 1.87358683 0.79849451 -1.0422852 -1.18617945 -0.41611808 -0.59057988 #> [3,] 1.55462979 0.23015757 1.0828173 -0.71967980 -0.05076391 0.61934323 #> [4,] 1.68447675 -1.19438722 -0.8804542 -0.38084096 4.85746871 -2.25505601 #> [5,] -0.40475285 -3.93165394 1.2031090 -1.10809622 3.67592549 -2.33716199 #> [6,] 0.64901278 -0.97237624 -0.5510658 -0.53625095 2.69991251 -1.49219136 #> [7,] 3.99681767 0.72029005 0.6643212 -0.36409009 3.40773920 -0.03014889 #> [8,] 0.72029005 2.33037081 -1.0932861 -0.05091026 -2.39257933 0.97854613 #> [9,] 0.66432124 -1.09328610 2.6252769 0.18420341 1.35806231 0.89147509 #> [10,] -0.36409009 -0.05091026 0.1842034 0.63766708 0.45717851 0.17839517 #> [11,] 3.40773920 -2.39257933 1.3580623 0.45717851 9.40839733 -2.12302461 #> [12,] -0.03014889 0.97854613 0.8914751 0.17839517 -2.12302461 1.56507368 #> [13,] 0.53747710 0.62335164 -1.7263066 -0.16801722 2.00207835 -1.04850987 #> [14,] -0.54909423 0.89755359 -0.9881515 -0.20275907 0.26436812 0.04971903 #> [15,] 3.96893829 0.01263142 3.0692920 -0.18071099 2.71536171 1.26938398 #> [16,] 2.21242869 -0.13253457 -0.1922637 -0.01416424 3.03971927 -0.90560522 #> [17,] 1.84430652 -1.52585035 1.7864532 -0.39613054 2.15540818 -0.39610824 #> [18,] -0.29834889 0.74045099 -2.7048943 0.63311926 1.19079398 -1.41847302 #> [19,] -2.14757587 -0.15109842 2.0981594 -0.11417940 -4.86958674 2.19656123 #> [20,] -2.02519402 1.21456995 -1.1465792 -0.35286530 -3.93909742 0.74335629 #> [,13] [,14] [,15] [,16] [,17] [,18] #> [1,] -1.3643696 -3.34589856 3.44613353 2.21401577 2.3230120 0.33973581 #> [2,] -0.1981154 -1.66937433 1.15529340 1.40295050 1.8603140 -0.07978953 #> [3,] -0.5099055 -0.04172636 2.52175529 0.11544473 1.2403819 -2.17926040 #> [4,] 2.4358073 0.92047729 -0.38160326 1.94035657 0.6790198 1.83984440 #> [5,] -0.5748421 -1.40437035 0.11063761 0.61230413 3.4904505 -1.92929496 #> [6,] 2.2152982 2.00517488 -0.86786024 0.58729133 -0.2302620 0.65064488 #> [7,] 0.5374771 -0.54909423 3.96893829 2.21242869 1.8443065 -0.29834889 #> [8,] 0.6233516 0.89755359 0.01263142 -0.13253457 -1.5258504 0.74045099 #> [9,] -1.7263066 -0.98815150 3.06929203 -0.19226366 1.7864532 -2.70489430 #> [10,] -0.1680172 -0.20275907 -0.18071099 -0.01416424 -0.3961305 0.63311926 #> [11,] 2.0020784 0.26436812 2.71536171 3.03971927 2.1554082 1.19079398 #> [12,] -1.0485099 0.04971903 1.26938398 -0.90560522 -0.3961082 -1.41847302 #> [13,] 5.1068123 6.26449529 -2.69778122 -0.26846824 -3.9654463 2.25359137 #> [14,] 6.2644953 10.06865714 -3.42688940 -2.41198968 -6.4641202 0.69815234 #> [15,] -2.6977812 -3.42688940 6.91829103 1.83446232 4.2390647 -3.17493052 #> [16,] -0.2684682 -2.41198968 1.83446232 2.30274016 2.2057695 1.11181292 #> [17,] -3.9654463 -6.46412016 4.23906468 2.20576953 5.7561596 -1.92088694 #> [18,] 2.2535914 0.69815234 -3.17493052 1.11181292 -1.9208869 4.41260418 #> [19,] -3.6174622 -1.68379623 1.16604201 -2.42331854 0.8308740 -3.95816891 #> [20,] 2.1846744 4.74798088 -3.19917649 -2.55553160 -4.0219732 -0.15256591 #> [,19] [,20] #> [1,] -1.0549405 -2.07112376 #> [2,] -1.0609614 -0.62178843 #> [3,] 1.0597003 -0.09315525 #> [4,] -4.2006820 -1.48815132 #> [5,] -0.1773063 -1.70809559 #> [6,] -2.3217978 -0.01356917 #> [7,] -2.1475759 -2.02519402 #> [8,] -0.1510984 1.21456995 #> [9,] 2.0981594 -1.14657923 #> [10,] -0.1141794 -0.35286530 #> [11,] -4.8695867 -3.93909742 #> [12,] 2.1965612 0.74335629 #> [13,] -3.6174622 2.18467440 #> [14,] -1.6837962 4.74798088 #> [15,] 1.1660420 -3.19917649 #> [16,] -2.4233185 -2.55553160 #> [17,] 0.8308740 -4.02197321 #> [18,] -3.9581689 -0.15256591 #> [19,] 5.9389430 1.29286827 #> [20,] 1.2928683 4.05282600 #> #> , , 2 #> #> [,1] [,2] [,3] [,4] [,5] [,6] #> [1,] 5.4368110 2.99809180 1.479165320 -3.10149298 -1.56908180 3.6768618 #> [2,] 2.9980918 5.00425046 -0.270553781 -1.24762334 0.02946354 4.5189416 #> [3,] 1.4791653 -0.27055378 2.084698987 -0.24885346 0.30496693 0.2142017 #> [4,] -3.1014930 -1.24762334 -0.248853465 2.70664376 1.10053928 -1.9657107 #> [5,] -1.5690818 0.02946354 0.304966933 1.10053928 2.21492131 -0.2876180 #> [6,] 3.6768618 4.51894161 0.214201670 -1.96571071 -0.28761801 4.5546636 #> [7,] 1.1644761 0.90008029 -0.571724039 -0.87324355 -0.86899316 0.6967893 #> [8,] -3.5866357 -2.64341813 -2.101125554 1.70340059 -1.05564696 -2.9441997 #> [9,] 0.4177317 3.98788726 -0.003178642 0.83645614 1.68033441 3.2039849 #> [10,] -2.5875393 0.37685467 -2.378863305 0.66399604 0.49810260 0.0611505 #> [11,] -0.6207906 1.71965888 -1.822539915 -0.08154119 -0.27802710 1.4852704 #> [12,] -1.0021484 1.56138242 -1.099216635 0.90653800 1.28145505 0.3602908 #> [13,] -0.9522321 -2.83634683 -1.558322164 -0.87499173 -2.36380036 -2.1392729 #> [14,] 0.3065371 -1.18442349 2.946137391 0.92728936 1.52452484 -0.7534573 #> [15,] 2.0963446 2.37642831 0.665625507 -0.84651109 0.15714053 2.4087790 #> [16,] 0.6348351 -1.32143683 0.642367247 -0.52825281 -0.74349106 -0.9046342 #> [17,] -1.1405063 -2.00081571 -0.477525572 -0.11658182 0.24742690 -2.0401719 #> [18,] 0.4141434 -3.70082836 0.323483005 -2.98457673 -0.43594353 -1.7386781 #> [19,] 0.1105901 -2.38379602 -0.691796234 -1.93852162 -1.49457524 -1.1544674 #> [20,] -0.7574311 -5.05364861 2.346229340 1.04992124 -0.07920224 -4.8743534 #> [,7] [,8] [,9] [,10] [,11] [,12] #> [1,] 1.164476136 -3.58663570 0.417731722 -2.5875393 -0.62079056 -1.00214843 #> [2,] 0.900080293 -2.64341813 3.987887256 0.3768547 1.71965888 1.56138242 #> [3,] -0.571724039 -2.10112555 -0.003178642 -2.3788633 -1.82253991 -1.09921664 #> [4,] -0.873243548 1.70340059 0.836456143 0.6639960 -0.08154119 0.90653800 #> [5,] -0.868993157 -1.05564696 1.680334415 0.4981026 -0.27802710 1.28145505 #> [6,] 0.696789293 -2.94419965 3.203984931 0.0611505 1.48527041 0.36029079 #> [7,] 1.118316129 -0.17117164 -0.443343243 -0.3846707 0.05825846 0.84199106 #> [8,] -0.171171643 4.96303632 -2.012985658 2.5700598 1.51467057 -0.57366109 #> [9,] -0.443343243 -2.01298566 5.226404581 1.1841707 1.70385382 1.80089970 #> [10,] -0.384670740 2.57005981 1.184170715 4.2141205 3.15093273 0.41798534 #> [11,] 0.058258465 1.51467057 1.703853816 3.1509327 3.01601295 0.10860004 #> [12,] 0.841991055 -0.57366109 1.800899699 0.4179853 0.10860004 3.67695511 #> [13,] 0.432530589 3.85275154 -4.153821830 1.5478717 0.99667925 -2.30460761 #> [14,] -1.492827425 -2.51539514 0.500984188 -2.8623394 -2.71687329 -1.06428745 #> [15,] 0.156132315 -2.15491069 1.971002184 -0.5754599 0.26848149 0.17374492 #> [16,] 0.159897503 0.01224757 -1.928576622 -1.3437015 -1.19780917 -0.96361141 #> [17,] 0.480662081 0.56342233 -2.371529728 -0.3585206 -1.20130973 0.93438687 #> [18,] -0.503440937 0.10987187 -4.941765059 0.4739439 -0.71085395 -3.44769941 #> [19,] 0.002576151 1.81705441 -3.685975323 1.2463115 0.65327258 -2.81273554 #> [20,] 0.112211849 -0.29874747 -4.936679003 -5.1818855 -5.53891152 -0.01693155 #> [,13] [,14] [,15] [,16] [,17] [,18] #> [1,] -0.9522321 0.3065371 2.0963446 0.63483513 -1.1405063 0.4141434 #> [2,] -2.8363468 -1.1844235 2.3764283 -1.32143683 -2.0008157 -3.7008284 #> [3,] -1.5583222 2.9461374 0.6656255 0.64236725 -0.4775256 0.3234830 #> [4,] -0.8749917 0.9272894 -0.8465111 -0.52825281 -0.1165818 -2.9845767 #> [5,] -2.3638004 1.5245248 0.1571405 -0.74349106 0.2474269 -0.4359435 #> [6,] -2.1392729 -0.7534573 2.4087790 -0.90463421 -2.0401719 -1.7386781 #> [7,] 0.4325306 -1.4928274 0.1561323 0.15989750 0.4806621 -0.5034409 #> [8,] 3.8527515 -2.5153951 -2.1549107 0.01224757 0.5634223 0.1098719 #> [9,] -4.1538218 0.5009842 1.9710022 -1.92857662 -2.3715297 -4.9417651 #> [10,] 1.5478717 -2.8623394 -0.5754599 -1.34370147 -0.3585206 0.4739439 #> [11,] 0.9966792 -2.7168733 0.2684815 -1.19780917 -1.2013097 -0.7108539 #> [12,] -2.3046076 -1.0642874 0.1737449 -0.96361141 0.9343869 -3.4476994 #> [13,] 5.6637826 -2.9326926 -1.8961991 1.06179905 1.1215934 4.4454140 #> [14,] -2.9326926 4.9986310 0.5262937 0.57355423 -0.4983960 -0.1179677 #> [15,] -1.8961991 0.5262937 1.4616347 -0.42307366 -1.2163899 -1.2955730 #> [16,] 1.0617990 0.5735542 -0.4230737 0.95006025 0.6596412 1.6481427 #> [17,] 1.1215934 -0.4983960 -1.2163899 0.65964119 2.3974651 2.4083900 #> [18,] 4.4454140 -0.1179677 -1.2955730 1.64814269 2.4083900 11.3292409 #> [19,] 4.6539045 -1.7332902 -1.1874947 1.05569804 1.1074698 6.8536060 #> [20,] 0.1823178 3.7977208 -1.9006823 2.54162888 3.2595687 1.4392538 #> [,19] [,20] #> [1,] 0.110590115 -0.75743108 #> [2,] -2.383796024 -5.05364861 #> [3,] -0.691796234 2.34622934 #> [4,] -1.938521615 1.04992124 #> [5,] -1.494575236 -0.07920224 #> [6,] -1.154467448 -4.87435336 #> [7,] 0.002576151 0.11221185 #> [8,] 1.817054413 -0.29874747 #> [9,] -3.685975323 -4.93667900 #> [10,] 1.246311514 -5.18188550 #> [11,] 0.653272582 -5.53891152 #> [12,] -2.812735543 -0.01693155 #> [13,] 4.653904470 0.18231779 #> [14,] -1.733290196 3.79772080 #> [15,] -1.187494651 -1.90068229 #> [16,] 1.055698037 2.54162888 #> [17,] 1.107469766 3.25956870 #> [18,] 6.853606027 1.43925384 #> [19,] 5.265165752 -0.40981781 #> [20,] -0.409817805 11.78585618 #>