rSingularWishart: Random Singular Wishart Matrix

Description Usage Arguments Details Value References Examples

View source: R/rSingularWishart.R

Description

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

Usage

1
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 * 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]]).

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

1
rSingularWishart(2, 5, diag(1, 20))

Example output

Attaching package:rWishartThe following object is masked frompackage:stats:

    rWishart

, , 1

             [,1]        [,2]       [,3]       [,4]       [,5]       [,6]
 [1,]  2.24594595  0.20416114 -2.8088324 -0.9392127  1.2409473 -1.1433585
 [2,]  0.20416114  4.05954463  0.1588047 -2.7967496 -1.0342127  0.5061729
 [3,] -2.80883237  0.15880473  5.7851403  2.4084655 -1.3497167  0.9973122
 [4,] -0.93921269 -2.79674961  2.4084655  7.0021272 -1.5708844  0.1495864
 [5,]  1.24094730 -1.03421268 -1.3497167 -1.5708844  2.2151027 -1.1809569
 [6,] -1.14335846  0.50617291  0.9973122  0.1495864 -1.1809569  0.9462936
 [7,] -0.41019042 -0.06813676 -3.1774679 -4.0462186  0.3587987  0.5909168
 [8,] -0.93391505  1.32345535  1.5480094 -3.6743119  0.9103832  0.2483523
 [9,]  2.25330671  0.24305529 -1.6368967 -1.8441303  2.7150242 -2.1798768
[10,]  1.32549976  0.95888106 -1.0945575 -2.3404514  1.6758697 -1.2272822
[11,] -1.21355092 -0.81506179  0.2843817  2.4783331 -2.2370270  1.5516170
[12,] -1.68866398  1.83660512  4.4683786 -1.4200441  0.2432557  0.1205373
[13,] -1.33041064  4.41154672  2.9238698 -1.9168502 -1.7922529  0.9972818
[14,] -1.97519224  0.65321707  1.2054573 -0.8866949 -1.2793482  1.2400148
[15,] -0.03393561 -2.65687129 -0.4400471  0.9298185  0.8944527 -0.1234071
[16,]  1.81590141 -0.80004867 -3.7933019 -2.0269403  1.6391525 -0.9345286
[17,] -0.14805382  1.41468406 -0.3025584 -4.4069656  1.3315105 -0.2618671
[18,]  0.01070160 -2.94778131  1.4557559  3.8857154  1.1582291 -1.4163182
[19,] -1.93650954 -0.52280108  3.6981571  6.2256232 -3.3645831  1.4917236
[20,]  0.06342989 -2.01372149  0.5799692 -0.7919519  2.1576278 -0.7696287
              [,7]       [,8]        [,9]      [,10]        [,11]      [,12]
 [1,] -0.410190420 -0.9339150  2.25330671  1.3254998 -1.213550915 -1.6886640
 [2,] -0.068136755  1.3234553  0.24305529  0.9588811 -0.815061790  1.8366051
 [3,] -3.177467880  1.5480094 -1.63689672 -1.0945575  0.284381697  4.4683786
 [4,] -4.046218585 -3.6743119 -1.84413026 -2.3404514  2.478333053 -1.4200441
 [5,]  0.358798701  0.9103832  2.71502416  1.6758697 -2.237027020  0.2432557
 [6,]  0.590916763  0.2483523 -2.17987679 -1.2272822  1.551617027  0.1205373
 [7,]  7.469808356  1.3353296 -0.36362844  0.5064454 -0.001367755 -1.5816357
 [8,]  1.335329600  3.7660433  0.78459178  1.2242802 -1.966410217  3.6495855
 [9,] -0.363628442  0.7845918  6.64476449  4.3269542 -5.553426163  2.0559183
[10,]  0.506445442  1.2242802  4.32695416  3.0856963 -3.883482188  1.8842331
[11,] -0.001367755 -1.9664102 -5.55342616 -3.8834822  5.186018440 -3.3476286
[12,] -1.581635714  3.6495855  2.05591834  1.8842331 -3.347628566  6.5146938
[13,] -0.726436225  2.2324497  0.08823838  0.9743422 -1.338950480  4.4972679
[14,]  3.036814125  1.2116054 -1.74122194 -0.6139236  0.729288284  1.1779296
[15,]  0.103124185 -0.3660353 -1.34347176 -1.3336700  1.489514469 -1.8424931
[16,]  2.623605015 -0.3983096  1.86780588  1.2180473 -0.991985646 -2.4439069
[17,]  3.215517677  3.2505357  2.69906695  2.5607319 -3.318243149  2.9941185
[18,] -1.893202505 -1.3260934  3.92055588  1.7351714 -2.951841411  1.5781417
[19,] -4.568734985 -2.9963924 -5.07246269 -3.9951570  4.738283363 -1.0233656
[20,] -0.300844865  1.7072918  1.40301576  0.7107684 -1.505443816  1.2521331
            [,13]       [,14]       [,15]      [,16]      [,17]        [,18]
 [1,] -1.33041064 -1.97519224 -0.03393561  1.8159014 -0.1480538  0.010701597
 [2,]  4.41154672  0.65321707 -2.65687129 -0.8000487  1.4146841 -2.947781306
 [3,]  2.92386975  1.20545729 -0.44004706 -3.7933019 -0.3025584  1.455755945
 [4,] -1.91685025 -0.88669490  0.92981853 -2.0269403 -4.4069656  3.885715355
 [5,] -1.79225287 -1.27934815  0.89445266  1.6391525  1.3315105  1.158229060
 [6,]  0.99728178  1.24001477 -0.12340711 -0.9345286 -0.2618671 -1.416318151
 [7,] -0.72643622  3.03681412  0.10312419  2.6236050  3.2155177 -1.893202505
 [8,]  2.23244974  1.21160545 -0.36603533 -0.3983096  3.2505357 -1.326093441
 [9,]  0.08823838 -1.74122194 -1.34347176  1.8678059  2.6990669  3.920555876
[10,]  0.97434221 -0.61392358 -1.33367003  1.2180473  2.5607319  1.735171359
[11,] -1.33895048  0.72928828  1.48951447 -0.9919856 -3.3182431 -2.951841411
[12,]  4.49726794  1.17792965 -1.84249313 -2.4439069  2.9941185  1.578141737
[13,]  6.46951864  1.89116573 -3.51881953 -2.5493892  2.0198679 -1.606507074
[14,]  1.89116573  2.97462728 -0.75937831 -0.7670735  1.5039478 -0.811714284
[15,] -3.51881953 -0.75937831  2.64170327  0.7328503 -1.1756367 -0.010596947
[16,] -2.54938923 -0.76707346  0.73285029  2.8959122  0.9503066 -0.174824326
[17,]  2.01986788  1.50394784 -1.17563669  0.9503066  4.2878915 -0.149801984
[18,] -1.60650707 -0.81171428 -0.01059695 -0.1748243 -0.1498020  7.342627096
[19,]  0.64319167  0.03415299  0.25510453 -3.6468120 -5.0194956 -0.003528435
[20,] -2.11187886 -0.90905266  1.91286320  0.6254062  1.0707149  1.317837060
             [,19]       [,20]
 [1,] -1.936509540  0.06342989
 [2,] -0.522801083 -2.01372149
 [3,]  3.698157126  0.57996920
 [4,]  6.225623154 -0.79195187
 [5,] -3.364583144  2.15762781
 [6,]  1.491723601 -0.76962869
 [7,] -4.568734985 -0.30084486
 [8,] -2.996392424  1.70729185
 [9,] -5.072462692  1.40301576
[10,] -3.995156986  0.71076836
[11,]  4.738283363 -1.50544382
[12,] -1.023365591  1.25213305
[13,]  0.643191668 -2.11187886
[14,]  0.034152994 -0.90905266
[15,]  0.255104531  1.91286320
[16,] -3.646812038  0.62540624
[17,] -5.019495620  1.07071488
[18,] -0.003528435  1.31783706
[19,]  8.576101846 -2.26791529
[20,] -2.267915286  3.32513598

, , 2

            [,1]       [,2]       [,3]       [,4]       [,5]       [,6]
 [1,]  9.6987359  3.9923727 -0.2315783  0.3026180  5.4801702 -3.0238208
 [2,]  3.9923727  3.7931672 -0.1035219 -0.8575663  4.7836950 -2.0465555
 [3,] -0.2315783 -0.1035219 12.0773996 -2.0507346  2.0552975  6.4100175
 [4,]  0.3026180 -0.8575663 -2.0507346  1.3667227 -0.5179042 -1.5068604
 [5,]  5.4801702  4.7836950  2.0552975 -0.5179042  8.6824122 -1.1159144
 [6,] -3.0238208 -2.0465555  6.4100175 -1.5068604 -1.1159144  7.5917121
 [7,]  0.4840630  1.9167546  5.3757119 -1.6502183  3.4818877  2.2301495
 [8,]  2.7787013  1.1204779 -0.4423874  0.7331256  0.8576445 -3.9670532
 [9,] -3.5560647 -4.7612687 -2.9655476  2.8878459 -3.1863790  2.2027578
[10,]  2.2729954  3.8535592 -1.1898375 -0.4860826  5.2797352 -3.2788718
[11,] -3.2786812 -2.4901536  2.3658634  0.6074890 -2.7307809  0.7107934
[12,] -1.5097028 -0.2336061 -0.3537399  0.8673868  1.5061714 -0.5059144
[13,] -1.3235072 -2.4396155  1.9671003  0.2898915 -2.3819874  3.2166254
[14,] -3.6093028 -1.5030339 -3.2337508  0.5862051 -3.8584915 -2.8385019
[15,]  4.2653104  3.0628211 -1.4144668 -0.1883655  1.7028850 -5.6845936
[16,] -0.5679943 -1.0777570  2.0891299 -0.0990132 -1.0022390  1.8830446
[17,]  5.2962160  1.4359408  3.1313568  0.2245969  4.6205615  2.2403539
[18,]  0.1133549 -0.2749000  0.6935404  0.8440361  1.2937554 -0.1668140
[19,]  8.0788229  4.7941537 -0.5163439 -0.7399572  5.1355214 -3.5660199
[20,]  3.0010035  1.9070081 -6.1641122 -0.1616952 -1.6011026 -5.4085333
            [,7]        [,8]       [,9]       [,10]      [,11]       [,12]
 [1,]  0.4840630  2.77870129 -3.5560647  2.27299543 -3.2786812 -1.50970283
 [2,]  1.9167546  1.12047788 -4.7612687  3.85355925 -2.4901536 -0.23360613
 [3,]  5.3757119 -0.44238742 -2.9655476 -1.18983746  2.3658634 -0.35373987
 [4,] -1.6502183  0.73312557  2.8878459 -0.48608263  0.6074890  0.86738675
 [5,]  3.4818877  0.85764450 -3.1863790  5.27973522 -2.7307809  1.50617144
 [6,]  2.2301495 -3.96705315  2.2027578 -3.27887184  0.7107934 -0.50591436
 [7,]  3.8339585 -0.25306845 -3.8272783  1.96057560 -0.1521613  0.19528856
 [8,] -0.2530684  3.63909579 -2.6550726  1.41202181  0.8307033 -0.05492467
 [9,] -3.8272783 -2.65507262 12.2099112 -4.20696588  1.8463248  2.66368642
[10,]  1.9605756  1.41202181 -4.2069659  5.21989851 -1.8396064  1.23006556
[11,] -0.1521613  0.83070334  1.8463248 -1.83960636  3.4222888  0.91043230
[12,]  0.1952886 -0.05492467  2.6636864  1.23006556  0.9104323  2.39489165
[13,] -0.6407410 -1.47539216  3.5801314 -3.33852810  1.1375667 -0.32298848
[14,] -1.8955274  1.31832970 -0.1855433 -0.27503320  1.9028843  0.26271207
[15,]  0.3359441  4.49355513 -7.0578025  3.18024718 -0.5650648 -1.24590838
[16,]  0.2337000 -0.49849513  0.9766758 -1.60365506  0.8233940 -0.29249083
[17,]  1.3860708 -0.60128848  1.6683949  0.04601831 -1.7731288  0.12403236
[18,]  0.1524857  0.42893303  2.1872606  0.34197429  0.8685511  1.50858409
[19,]  1.3239744  2.74955606 -6.7938989  3.58426393 -3.5003534 -1.91486278
[20,] -2.3408978  2.35619738 -5.1248581  1.32480301 -2.2512005 -2.63821070
           [,13]      [,14]      [,15]      [,16]       [,17]      [,18]
 [1,] -1.3235072 -3.6093028  4.2653104 -0.5679943  5.29621596  0.1133549
 [2,] -2.4396155 -1.5030339  3.0628211 -1.0777570  1.43594083 -0.2749000
 [3,]  1.9671003 -3.2337508 -1.4144668  2.0891299  3.13135677  0.6935404
 [4,]  0.2898915  0.5862051 -0.1883655 -0.0990132  0.22459694  0.8440361
 [5,] -2.3819874 -3.8584915  1.7028850 -1.0022390  4.62056150  1.2937554
 [6,]  3.2166254 -2.8385019 -5.6845936  1.8830446  2.24035386 -0.1668140
 [7,] -0.6407410 -1.8955274  0.3359441  0.2337000  1.38607077  0.1524857
 [8,] -1.4753922  1.3183297  4.4935551 -0.4984951 -0.60128848  0.4289330
 [9,]  3.5801314 -0.1855433 -7.0578025  0.9766758  1.66839495  2.1872606
[10,] -3.3385281 -0.2750332  3.1802472 -1.6036551  0.04601831  0.3419743
[11,]  1.1375667  1.9028843 -0.5650648  0.8233940 -1.77312877  0.8685511
[12,] -0.3229885  0.2627121 -1.2459084 -0.2924908  0.12403236  1.5085841
[13,]  2.5532199 -0.8663158 -3.1623321  1.2562465  1.21830519  0.2340636
[14,] -0.8663158  4.2816901  1.7799790 -0.5314361 -4.96724967 -0.4342409
[15,] -3.1623321  1.7799790  7.3436379 -1.2294407 -1.71582483 -0.7277697
[16,]  1.2562465 -0.5314361 -1.2294407  0.7558475  0.65162565  0.1019345
[17,]  1.2183052 -4.9672497 -1.7158248  0.6516257  6.51518630  1.1748126
[18,]  0.2340636 -0.4342409 -0.7277697  0.1019345  1.17481264  1.3379079
[19,] -2.6185452 -2.2407430  5.6120630 -1.0867325  2.79360537 -0.8364576
[20,] -2.4816194  2.5092530  5.5764570 -1.4506686 -3.07891186 -2.2584859
           [,19]      [,20]
 [1,]  8.0788229  3.0010035
 [2,]  4.7941537  1.9070081
 [3,] -0.5163439 -6.1641122
 [4,] -0.7399572 -0.1616952
 [5,]  5.1355214 -1.6011026
 [6,] -3.5660199 -5.4085333
 [7,]  1.3239744 -2.3408978
 [8,]  2.7495561  2.3561974
 [9,] -6.7938989 -5.1248581
[10,]  3.5842639  1.3248030
[11,] -3.5003534 -2.2512005
[12,] -1.9148628 -2.6382107
[13,] -2.6185452 -2.4816194
[14,] -2.2407430  2.5092530
[15,]  5.6120630  5.5764570
[16,] -1.0867325 -1.4506686
[17,]  2.7936054 -3.0789119
[18,] -0.8364576 -2.2584859
[19,]  8.2929082  4.6214287
[20,]  4.6214287  8.3067717

rWishart documentation built on Nov. 20, 2019, 1:07 a.m.