MCMC: The Wishart Distribution

2017/10/17

Categories: Statistics Tags: statistics Markov Chain

The Wishart Distribution

Description

Density function and random generation from the Wishart distribution.

dwish(W, v, S) rwish(v, S) Arguments

W Positive definite matrix W (p x p). v Wishart degrees of freedom (scalar). S Wishart scale matrix (p x p). Value

dwish evaluates the density at positive definite matrix W. rwish generates one random draw from the distribution.

Examples

library(MCMCpack) # install.packages('MCMCpack')
## 필요한 패키지를 로딩중입니다: coda
## 필요한 패키지를 로딩중입니다: MASS
## ##
## ## Markov Chain Monte Carlo Package (MCMCpack)
## ## Copyright (C) 2003-2017 Andrew D. Martin, Kevin M. Quinn, and Jong Hee Park
## ##
## ## Support provided by the U.S. National Science Foundation
## ## (Grants SES-0350646 and SES-0350613)
## ##
density <- dwish(
  W = matrix(c(2,-.3,-.3,4),2,2), 
  v = 3, 
  S = matrix(c(1,.3,.3,1),2,2)
)
density
## [1] 0.003072811
draw <- rwish(
  v = 3, 
  S = matrix(c(1,.3,.3,1),2,2)
)
draw
##           [,1]      [,2]
## [1,]  2.159571 -2.428155
## [2,] -2.428155  3.110081