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

rPsuedoWishart(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

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))
#> , , 1 #> #> [,1] [,2] [,3] [,4] [,5] [,6] #> [1,] 1.88049631 -1.24181787 -0.08835364 0.1957302 -1.1759100 0.28826440 #> [2,] -1.24181787 6.50048408 3.35898912 -0.3207295 5.1877660 0.98233714 #> [3,] -0.08835364 3.35898912 3.31530905 -1.2363603 3.2638494 0.14803112 #> [4,] 0.19573019 -0.32072947 -1.23636029 2.5441284 1.6087439 -0.74644629 #> [5,] -1.17591002 5.18776600 3.26384937 1.6087439 8.6426670 -0.71915096 #> [6,] 0.28826440 0.98233714 0.14803112 -0.7464463 -0.7191510 1.67756850 #> [7,] 0.53177838 0.36384020 0.34997611 0.7345091 1.2508437 -0.18892198 #> [8,] -0.12044401 -1.94117580 0.21670320 -1.5530903 -1.3689851 -0.42908005 #> [9,] 0.92129001 -2.81465219 -2.25574920 3.1370089 2.1291862 -0.34237741 #> [10,] -3.29581922 2.57664592 0.09860344 1.1961050 3.0674252 -2.11218656 #> [11,] -1.17667130 -0.84242765 -1.32662898 0.1760402 -1.2974579 -0.58679668 #> [12,] 1.55949999 -0.04324542 1.25754634 0.5465893 2.3735961 -0.01622408 #> [13,] 1.18576699 -1.84513985 -2.84614053 -1.0550716 -7.4575664 2.47211605 #> [14,] -0.80159534 2.91534099 0.03627867 -0.5491989 -0.5589280 1.90432402 #> [15,] -0.37940515 -0.90960750 -0.20713317 0.1889374 -0.8642396 -1.78906049 #> [16,] -1.37180183 1.02217789 -3.11040249 1.7744799 -1.9262158 1.21629959 #> [17,] -1.01091945 -0.85365923 -0.48743250 0.7203520 0.5884735 -1.79176301 #> [18,] 0.89779912 -0.35158541 1.96080261 -1.6246748 0.3145391 -0.23960060 #> [19,] 1.70516296 -4.41075005 -3.32596640 1.2549170 -4.3401586 0.19483565 #> [20,] -1.67187685 4.28715898 0.74479134 2.3854146 5.2643125 -0.56446406 #> [,7] [,8] [,9] [,10] [,11] [,12] #> [1,] 0.5317784 -0.1204440 0.9212900 -3.29581922 -1.1766713 1.55949999 #> [2,] 0.3638402 -1.9411758 -2.8146522 2.57664592 -0.8424277 -0.04324542 #> [3,] 0.3499761 0.2167032 -2.2557492 0.09860344 -1.3266290 1.25754634 #> [4,] 0.7345091 -1.5530903 3.1370089 1.19610499 0.1760402 0.54658933 #> [5,] 1.2508437 -1.3689851 2.1291862 3.06742521 -1.2974579 2.37359613 #> [6,] -0.1889220 -0.4290800 -0.3423774 -2.11218656 -0.5867967 -0.01622408 #> [7,] 0.5236966 -0.5156207 1.0655985 -0.42571585 -0.6049084 1.02955331 #> [8,] -0.5156207 2.3324732 -0.3457974 -1.00782659 0.1065259 0.23325685 #> [9,] 1.0655985 -0.3457974 8.7943872 -2.50041699 -0.8016265 3.02950787 #> [10,] -0.4257158 -1.0078266 -2.5004170 8.88988194 2.6641167 -3.23889770 #> [11,] -0.6049084 0.1065259 -0.8016265 2.66411667 1.6058548 -2.02366825 #> [12,] 1.0295533 0.2332568 3.0295079 -3.23889770 -2.0236682 3.32621082 #> [13,] -1.0019714 -1.1286386 -2.8709390 -3.19876636 0.7797864 -2.83018518 #> [14,] -0.5097833 -1.7375367 -2.5881652 0.74773477 0.3997161 -2.01678958 #> [15,] -0.1465509 0.2980829 -2.2538811 3.05753874 1.1648880 -1.28673762 #> [16,] -0.5911365 -3.0973609 -0.3894705 3.18654826 2.1352687 -3.72515404 #> [17,] -0.1029773 0.4307193 -0.1076739 3.45816489 1.2537956 -0.89520594 #> [18,] 0.1529661 1.8260928 -0.8367658 -2.37679176 -1.2992984 1.82647304 #> [19,] 0.0689369 -0.2209200 2.9841707 -3.11522688 0.2676520 0.10693398 #> [20,] 0.6512410 -2.8131671 0.4961624 5.22055574 0.5518115 -0.66333813 #> [,13] [,14] [,15] [,16] [,17] [,18] #> [1,] 1.1857670 -0.80159534 -0.37940515 -1.3718018 -1.0109195 0.89779912 #> [2,] -1.8451398 2.91534099 -0.90960750 1.0221779 -0.8536592 -0.35158541 #> [3,] -2.8461405 0.03627867 -0.20713317 -3.1104025 -0.4874325 1.96080261 #> [4,] -1.0550716 -0.54919889 0.18893744 1.7744799 0.7203520 -1.62467483 #> [5,] -7.4575664 -0.55892800 -0.86423960 -1.9262158 0.5884735 0.31453905 #> [6,] 2.4721160 1.90432402 -1.78906049 1.2162996 -1.7917630 -0.23960060 #> [7,] -1.0019714 -0.50978334 -0.14655094 -0.5911365 -0.1029773 0.15296614 #> [8,] -1.1286386 -1.73753667 0.29808292 -3.0973609 0.4307193 1.82609279 #> [9,] -2.8709390 -2.58816519 -2.25388108 -0.3894705 -0.1076739 -0.83676577 #> [10,] -3.1987664 0.74773477 3.05753874 3.1865483 3.4581649 -2.37679176 #> [11,] 0.7797864 0.39971607 1.16488795 2.1352687 1.2537956 -1.29929836 #> [12,] -2.8301852 -2.01678958 -1.28673762 -3.7251540 -0.8952059 1.82647304 #> [13,] 10.1375737 3.98638873 -0.73406747 5.7044102 -2.3454912 -2.10731712 #> [14,] 3.9863887 4.11183579 -1.16464555 4.5213242 -1.4727648 -1.94956096 #> [15,] -0.7340675 -1.16464555 2.94990363 -0.3117688 2.0799279 0.01718319 #> [16,] 5.7044102 4.52132417 -0.31176876 9.0478946 -0.2073338 -4.98003708 #> [17,] -2.3454912 -1.47276483 2.07992794 -0.2073338 2.2435528 -0.35494096 #> [18,] -2.1073171 -1.94956096 0.01718319 -4.9800371 -0.3549410 2.99242127 #> [19,] 3.9242436 -0.68318615 -0.23475231 1.8149693 -0.4849327 -1.08774118 #> [20,] -2.7356393 1.66629724 0.34578079 3.4641622 1.0837767 -2.53145575 #> [,19] [,20] #> [1,] 1.7051630 -1.6718769 #> [2,] -4.4107501 4.2871590 #> [3,] -3.3259664 0.7447913 #> [4,] 1.2549170 2.3854146 #> [5,] -4.3401586 5.2643125 #> [6,] 0.1948356 -0.5644641 #> [7,] 0.0689369 0.6512410 #> [8,] -0.2209200 -2.8131671 #> [9,] 2.9841707 0.4961624 #> [10,] -3.1152269 5.2205557 #> [11,] 0.2676520 0.5518115 #> [12,] 0.1069340 -0.6633381 #> [13,] 3.9242436 -2.7356393 #> [14,] -0.6831862 1.6662972 #> [15,] -0.2347523 0.3457808 #> [16,] 1.8149693 3.4641622 #> [17,] -0.4849327 1.0837767 #> [18,] -1.0877412 -2.5314558 #> [19,] 4.7396531 -2.3502863 #> [20,] -2.3502863 6.1863727 #> #> , , 2 #> #> [,1] [,2] [,3] [,4] [,5] [,6] #> [1,] 4.00668140 1.39619040 -1.2031052 -2.8969454 -3.0790659 1.06366702 #> [2,] 1.39619040 2.02463174 -0.5303869 -1.3159829 1.4077501 1.05593124 #> [3,] -1.20310516 -0.53038693 0.7349453 0.4763100 0.7124516 -1.03150032 #> [4,] -2.89694542 -1.31598286 0.4763100 22.6594948 7.2234181 -1.56549168 #> [5,] -3.07906593 1.40775013 0.7124516 7.2234181 8.2928491 1.20296213 #> [6,] 1.06366702 1.05593124 -1.0315003 -1.5654917 1.2029621 5.40322105 #> [7,] -1.82941834 -0.94221918 1.0478925 1.4855653 1.3496615 -0.67240881 #> [8,] 0.88994307 -1.10951371 -0.1986635 -2.5772689 -3.3521367 0.48320219 #> [9,] -0.08466672 0.62226314 0.7800527 -5.5952136 -0.8600820 -2.69483214 #> [10,] -0.14949164 0.47593743 0.3735317 -5.6759716 0.6794684 3.24225454 #> [11,] -1.50296188 -3.00802262 0.5565255 -0.8115165 -4.3547601 -3.56293977 #> [12,] 2.76658685 2.42025320 -1.4881788 -0.9728255 1.1141970 4.18929182 #> [13,] -0.90607548 0.31930243 0.9258957 -4.1797729 0.9547393 0.07778905 #> [14,] 1.52101705 2.23308398 -1.2453065 -3.4684265 0.8612286 2.51444185 #> [15,] 1.20462489 2.97010403 0.1092993 5.7044306 5.7993972 1.24425063 #> [16,] 2.33541474 0.69615297 -0.7754678 -3.4265740 -2.5327763 0.70520795 #> [17,] 1.73327030 0.39549512 0.2032303 -5.5499447 -1.4166964 2.95159827 #> [18,] 0.36042231 -0.99926614 -0.8867332 -1.7227036 -1.7376607 4.17882331 #> [19,] 3.94481297 1.26620104 -1.3551706 -4.1898037 -4.0741176 0.13342843 #> [20,] -0.82735458 -0.09741393 -0.5601624 2.4888181 1.0717510 0.60295079 #> [,7] [,8] [,9] [,10] [,11] [,12] #> [1,] -1.82941834 0.88994307 -0.08466672 -0.1494916 -1.5029619 2.7665869 #> [2,] -0.94221918 -1.10951371 0.62226314 0.4759374 -3.0080226 2.4202532 #> [3,] 1.04789253 -0.19866350 0.78005270 0.3735317 0.5565255 -1.4881788 #> [4,] 1.48556527 -2.57726886 -5.59521365 -5.6759716 -0.8115165 -0.9728255 #> [5,] 1.34966149 -3.35213669 -0.86008202 0.6794684 -4.3547601 1.1141970 #> [6,] -0.67240881 0.48320219 -2.69483214 3.2422545 -3.5629398 4.1892918 #> [7,] 1.74685361 -0.08115338 0.35802890 1.0878001 0.4243304 -1.7966753 #> [8,] -0.08115338 1.88847438 -0.51928150 0.6636351 1.8015421 -0.4084005 #> [9,] 0.35802890 -0.51928150 4.05758825 0.4993003 0.6227474 -1.7792765 #> [10,] 1.08780011 0.66363509 0.49930031 5.1107979 -2.4691545 1.4232707 #> [11,] 0.42433039 1.80154211 0.62274735 -2.4691545 6.4911189 -4.6111187 #> [12,] -1.79667533 -0.40840053 -1.77927653 1.4232707 -4.6111187 5.1245965 #> [13,] 1.32476980 -0.21942540 2.18749774 2.9576796 -1.0355945 -0.6740592 #> [14,] -2.00116177 -0.86792254 -0.10138111 0.5440061 -2.8073587 3.5450428 #> [15,] 0.42335563 -2.74243137 -0.10946704 0.8833961 -6.7012490 3.3321615 #> [16,] -1.24538736 0.81711497 0.22168323 0.1409039 -0.3433361 1.4867044 #> [17,] 0.94325321 1.58740460 0.35278463 4.9415481 -2.4570223 1.7165243 #> [18,] -0.45509189 2.03004478 -3.23786312 2.1346575 0.2749298 1.8877442 #> [19,] -2.37959946 0.92533729 0.51763568 -1.1875470 -0.2005181 2.1517370 #> [20,] -0.81681448 -0.51953764 -1.55129742 -1.5691454 0.4611332 0.5125772 #> [,13] [,14] [,15] [,16] [,17] [,18] #> [1,] -0.90607548 1.5210170 1.2046249 2.3354147 1.7332703 0.36042231 #> [2,] 0.31930243 2.2330840 2.9701040 0.6961530 0.3954951 -0.99926614 #> [3,] 0.92589568 -1.2453065 0.1092993 -0.7754678 0.2032303 -0.88673316 #> [4,] -4.17977295 -3.4684265 5.7044306 -3.4265740 -5.5499447 -1.72270357 #> [5,] 0.95473935 0.8612286 5.7993972 -2.5327763 -1.4166964 -1.73766073 #> [6,] 0.07778905 2.5144419 1.2442506 0.7052079 2.9515983 4.17882331 #> [7,] 1.32476980 -2.0011618 0.4233556 -1.2453874 0.9432532 -0.45509189 #> [8,] -0.21942540 -0.8679225 -2.7424314 0.8171150 1.5874046 2.03004478 #> [9,] 2.18749774 -0.1013811 -0.1094670 0.2216832 0.3527846 -3.23786312 #> [10,] 2.95767958 0.5440061 0.8833961 0.1409039 4.9415481 2.13465753 #> [11,] -1.03559447 -2.8073587 -6.7012490 -0.3433361 -2.4570223 0.27492983 #> [12,] -0.67405923 3.5450428 3.3321615 1.4867044 1.7165243 1.88774420 #> [13,] 2.87059905 -0.3849570 0.9518607 -0.4143602 2.6257188 -0.84140503 #> [14,] -0.38495703 4.0626188 0.9775981 1.1669455 -0.4234292 0.78581591 #> [15,] 0.95186069 0.9775981 9.4890908 -0.4285345 1.6379416 -3.10494440 #> [16,] -0.41436016 1.1669455 -0.4285345 1.5666726 1.0458193 0.62177136 #> [17,] 2.62571884 -0.4234292 1.6379416 1.0458193 6.5006701 2.03428722 #> [18,] -0.84140503 0.7858159 -3.1049444 0.6217714 2.0342872 5.52288578 #> [19,] -1.35291155 1.9382919 -0.4888391 2.5456110 0.3132329 0.01256316 #> [20,] -1.63947636 1.2104091 -1.2300612 -0.3863602 -2.7538974 1.00954490 #> [,19] [,20] #> [1,] 3.94481297 -0.82735458 #> [2,] 1.26620104 -0.09741393 #> [3,] -1.35517056 -0.56016236 #> [4,] -4.18980374 2.48881809 #> [5,] -4.07411757 1.07175101 #> [6,] 0.13342843 0.60295079 #> [7,] -2.37959946 -0.81681448 #> [8,] 0.92533729 -0.51953764 #> [9,] 0.51763568 -1.55129742 #> [10,] -1.18754700 -1.56914539 #> [11,] -0.20051813 0.46113320 #> [12,] 2.15173700 0.51257717 #> [13,] -1.35291155 -1.63947636 #> [14,] 1.93829192 1.21040912 #> [15,] -0.48883914 -1.23006120 #> [16,] 2.54561099 -0.38636018 #> [17,] 0.31323285 -2.75389739 #> [18,] 0.01256316 1.00954490 #> [19,] 4.58060857 -0.28704537 #> [20,] -0.28704537 2.08766361 #>