[Rcpp-devel] Recommendations on how to incorporate pmvnorm function
Smith, Dale (Norcross)
Dale.Smith at Fiserv.com
Thu Jan 30 17:40:53 CET 2014
QuantLib has a modification due to Graeme West of Allen Genz's algorithm from pmvnorm. You may be able to call that code in your project by linking with it. Genz also has Fortran code on his web site. Perhaps that would be useful as well.
I think it's easy enough to read the 2004 paper and write up your own. Follow Genz's suggestions for the numerical integration part.
There are other algorithms floating around since 2004. However, I would be skeptical of these unless I could get access to extensive tests, comparing to known verified implementations. Having done work on this topic myself, I would say that the West modification of the Genz algorithm is the fastest and most accurate, especially for the trivariate case. I've not seen any specific algorithms for the quadvariate case, although the quadvariate normal probability integral does show up in quant finance.
http://www.wilmott.com/pdfs/090721_west.pdf
Google my presentation "Bank Capital Models and Bivariate Normal Probability Calculations" for some references.
Dale Smith, Ph.D.
Senior Financial Quantitative Analyst
Financial & Risk Management Solutions
Fiserv
Office: 678-375-5315
www.fiserv.com
-----Original Message-----
From: rcpp-devel-bounces at r-forge.wu-wien.ac.at [mailto:rcpp-devel-bounces at r-forge.wu-wien.ac.at] On Behalf Of Dirk Eddelbuettel
Sent: Sunday, January 26, 2014 2:15 PM
To: Scott Monroe
Cc: rcpp-devel at lists.r-forge.r-project.org
Subject: Re: [Rcpp-devel] Recommendations on how to incorporate pmvnorm function
Scott,
On 26 January 2014 at 10:58, Scott Monroe wrote:
| I was hoping for advice on approaches to accomplishing the following goal.
| I'd like to create an R package using Rcpp that calls the pmvnorm (cdf
| for multivariate normal) function from the mvtnorm library. I'd like
| to avoid calling it through R, as I need to do it many times, and I'd
| like to avoid the overhead in going between C++ and R.
|
| The source code, written by Alan Genz, is in Fortran. I've also found
| on GitHub a C++ wrapped version of the Fortran code:
|
| https://github.com/zhanxw/libMvtnorm
|
| The latter includes a Makefile, which I don't know how to handle.
Sorry to break this to you on a Sunday. You will not make very far in programming if that remains an obstacle for you. You really should buckle down and read a few tutorial or books on this. It. Is. Not. That. Hard.
Especially with R. And Rcpp. And existing packages -- at current count 164 on CRAN alone. Look at their sources. Many/most get by without a Makefile because R knows how to "Do The Right Thing". Including with Fortran.
Now, the proper long-term solution is probably to talk to Torsten to have the relevant functions exported from his mvtnorm package so that other CRAN package can re-use the code.
But it's a big world. Maybe someone will write this for you out of the kindness of their hearts, or maybe you can pay someoone.
Dirk
--
Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com _______________________________________________
Rcpp-devel mailing list
Rcpp-devel at lists.r-forge.r-project.org
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
More information about the Rcpp-devel
mailing list