Learn R Programming

bayesm (version 3.0-2)

ghkvec: Compute GHK approximation to Multivariate Normal Integrals

Description

ghkvec computes the GHK approximation to the integral of a multivariate normal density over a half plane defined by a set of truncation points.

Usage

ghkvec(L, trunpt, above, r, HALTON=TRUE, pn)

Arguments

L

lower triangular Cholesky root of covariance matrix

trunpt

vector of truncation points

above

vector of indicators for truncation above(1) or below(0)

r

number of draws to use in GHK

HALTON

if TRUE, use Halton sequence. If FALSE, use R::runif random number generator (optional / def: TRUE)

pn

prime number used for Halton sequence (optional / def: the smallest prime numbers, i.e. 2, 3, 5, ...)

Value

approximation to integral

References

For further discussion, see Bayesian Statistics and Marketing by Rossi, Allenby and McCulloch, Chapter 2. http://www.perossi.org/home/bsm-1

For Halton sequence, see Halton (1960, Numerische Mathematik), Morokoff and Caflisch (1995, Journal of Computational Physics), and Kocis and Whiten (1997, ACM Transactions on Mathematical Software).

Examples

Run this code
Sigma=matrix(c(1,.5,.5,1),ncol=2)
L=t(chol(Sigma))
trunpt=c(0,0,1,1)
above=c(1,1)

# drawn by Halton sequence
ghkvec(L,trunpt,above,r=100)

# use prime number 11 and 13
ghkvec(L,trunpt,above,r=100,HALTON=TRUE,pn=c(11,13))

# drawn by R::runif
ghkvec(L,trunpt,above,r=100,HALTON=FALSE)

Run the code above in your browser using DataLab