On various occasions I've used many of the mvnormal(...) functions to simulate multivariate normal orthant probabilities and related quantities.
A recent simulation exercise convinced me that if your task can afford the additional computation time required then instead of mvnormal(...) using mvnormalqp(...) with a large number of quadrature points is recommended.
(In a nutshell I was quite confident but not 100% certain about a result involving probability inequalities and decided to do "proof-by-Stata." Most of the time, but not always, mvnormal(...) returned results consistent with my expectations. mvnormalqp(...) with the number of quadrature points set at 5,000 returned the "correct" results in each instance.)
Depending on the nature of your task the additional computation time may or may not be problematic. Here's a simple illustration.
which returned
Of course there may be a happy middle ground that delivers sufficient accuracy with fewer than 5,000 quadrature points.
A recent simulation exercise convinced me that if your task can afford the additional computation time required then instead of mvnormal(...) using mvnormalqp(...) with a large number of quadrature points is recommended.
(In a nutshell I was quite confident but not 100% certain about a result involving probability inequalities and decided to do "proof-by-Stata." Most of the time, but not always, mvnormal(...) returned results consistent with my expectations. mvnormalqp(...) with the number of quadrature points set at 5,000 returned the "correct" results in each instance.)
Depending on the nature of your task the additional computation time may or may not be problematic. Here's a simple illustration.
Code:
mata reps=1000 m=4 corrmat=J(m,m,.25)+.75*I(m) mvec=J(1,m,0) timer_clear() timer_on(1) for (j=1;j<=reps;j++) { p=mvnormal(mvec,vech(corrmat)') } timer_off(1) timer_on(2) for (j=1;j<=reps;j++) { p=mvnormalqp(mvec,vech(corrmat)',5000) } timer_off(2) timer() end
Code:
: timer() --------------------------------------------------------------------------------------------- timer report 1. .099 / 1 = .099 2. 6.4 / 1 = 6.404 ---------------------------------------------------------------------------------------------
Comment