Learn R Programming

bayesm (version 3.1-6)

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)

Value

Approximation to integral

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) on an element by element basis

r

number of draws to use in GHK

HALTON

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

pn

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

Author

Peter Rossi, Anderson School, UCLA, perossichi@gmail.com.
Keunwoo Kim, Anderson School, UCLA, keunwoo.kim@gmail.com.

References

For further discussion, see Bayesian Statistics and Marketing by Rossi, Allenby, and McCulloch, Chapter 2.

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, 0.5, 0.5, 1), ncol=2)
L = t(chol(Sigma))
trunpt = c(0,0,1,1)
above = c(1,1) 
# here we have a two dimensional integral with two different truncation points
#    (0,0) and (1,1)
# however, there is only one vector of "above" indicators for each integral
#     above=c(1,1) is applied to both integrals.  

# 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