EVOLUTION-MANAGER
Edit File: rWishart.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Random Wishart Distributed Matrices</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for rWishart {stats}"><tr><td>rWishart {stats}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Random Wishart Distributed Matrices</h2> <h3>Description</h3> <p>Generate <code>n</code> random matrices, distributed according to the Wishart distribution with parameters <code>Sigma</code> and <code>df</code>, <i>W_p(Sigma, df)</i>. </p> <h3>Usage</h3> <pre> rWishart(n, df, Sigma) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>n</code></td> <td> <p>integer sample size.</p> </td></tr> <tr valign="top"><td><code>df</code></td> <td> <p>numeric parameter, “degrees of freedom”.</p> </td></tr> <tr valign="top"><td><code>Sigma</code></td> <td> <p>positive definite (<i>p * p</i>) “scale” matrix, the matrix parameter of the distribution.</p> </td></tr> </table> <h3>Details</h3> <p>If <i>X1,...,Xm, Xi in R^p</i> is a sample of <i>m</i> independent multivariate Gaussians with mean (vector) 0, and covariance matrix <i>Σ</i>, the distribution of <i>M = X'X</i> is <i>W_p(Σ, m)</i>. </p> <p>Consequently, the expectation of <i>M</i> is </p> <p style="text-align: center;"><i>E[M] = m * Sigma.</i></p> <p>Further, if <code>Sigma</code> is scalar (<i>p = 1</i>), the Wishart distribution is a scaled chi-squared (<i>chi^2</i>) distribution with <code>df</code> degrees of freedom, <i>W_1(sigma^2, m) = sigma^2 chi[m]^2</i>. </p> <p>The component wise variance is </p> <p style="text-align: center;"><i> Var(M[i,j]) = m*(S[i,j]^2 + S[i,i] * S[j,j]), where S=Sigma.</i></p> <h3>Value</h3> <p>a numeric <code><a href="../../base/html/array.html">array</a></code>, say <code>R</code>, of dimension <i>p * p * n</i>, where each <code>R[,,i]</code> is a positive definite matrix, a realization of the Wishart distribution <i>W_p(Sigma, df)</i>. </p> <h3>Author(s)</h3> <p>Douglas Bates</p> <h3>References</h3> <p>Mardia, K. V., J. T. Kent, and J. M. Bibby (1979) <em>Multivariate Analysis</em>, London: Academic Press. </p> <h3>See Also</h3> <p><code><a href="cor.html">cov</a></code>, <code><a href="Normal.html">rnorm</a></code>, <code><a href="Chisquare.html">rchisq</a></code>. </p> <h3>Examples</h3> <pre> ## Artificial S <- toeplitz((10:1)/10) set.seed(11) R <- rWishart(1000, 20, S) dim(R) # 10 10 1000 mR <- apply(R, 1:2, mean) # ~= E[ Wish(S, 20) ] = 20 * S stopifnot(all.equal(mR, 20*S, tolerance = .009)) ## See Details, the variance is Va <- 20*(S^2 + tcrossprod(diag(S))) vR <- apply(R, 1:2, var) stopifnot(all.equal(vR, Va, tolerance = 1/16)) </pre> <hr /><div style="text-align: center;">[Package <em>stats</em> version 3.6.0 <a href="00Index.html">Index</a>]</div> </body></html>