Can anyone help me on how to get the nodes and weights of the adaptive quadrature using R. Best wishes Boikanyo. ----- The University of Glasgow, charity number SC004401
ADAPTIVE QUADRATURE WEIGHTS AND NODES
3 messages · Boikanyo Makubate, Douglas Bates, Spencer Graves
On Fri, May 8, 2009 at 7:07 AM, Boikanyo Makubate
<boikanyo at stats.gla.ac.uk> wrote:
Can anyone help me on how to get the nodes and weights of the adaptive quadrature using R.
You need to be more specific about which quadrature formula. I'm guessing that you probably have Gauss-Hermite quadrature in mind because it is used when a density is approximated by a Gaussian density (the "adaptive" modifier refers to a process where the conditional mode and conditional variance are determined, given values of parameters). In that case you could start at http://en.wikipedia.org/wiki/Gauss-Hermite_Quadrature for the theory. There is C code in the lme4 package to compute the nodes and weights for Gauss-Hermite quadrature but we haven't written a public interface to it. You can try, for example
library(lme4)
.Call("lme4_ghq", 7)
[[1]] [1] 2.6519614 1.6735516 0.8162879 0.0000000 -0.8162879 -1.6735516 -2.6519614 [[2]] [1] 0.0009717812 0.0545155828 0.4256072526 0.8102646176 0.4256072526 [6] 0.0545155828 0.0009717812 to get the nodes and the weights for a 7-point Gauss-Hermite quadrature. (There are two versions of the Hermite polynomials, the physicist's version where the kernel is exp(-x^2) and the probabilist's version where the kernel is exp(-(x^2)/2). I'm pretty sure these are from the physicist's version.)
Beyond what Doug said, if you have a specific R function that does
adaptive quadrature, you could read the code for that function. You can
get that without comments by typing the function name at a commands
prompt. To get the source code with comments, you can download the
appropriate source code in *.tar.gz format from your favorite CRAN
mirror. If the function you want is in the base system, click "R
Sources -> R-2.9.0.tar.gz" from your favorite CRAN mirror. For a
contributed packages, click "Packages" two lines below "R Sources".
The following will search help files for "adaptive quadrature":
library(RSiteSearch)
aq <- RSiteSearch.function('adaptive quadrature')
summary(aq)
HTML(aq)
Hope this helps.
Spencer Graves
Douglas Bates wrote:
On Fri, May 8, 2009 at 7:07 AM, Boikanyo Makubate <boikanyo at stats.gla.ac.uk> wrote:
Can anyone help me on how to get the nodes and weights of the adaptive quadrature
using R.
You need to be more specific about which quadrature formula. I'm guessing that you probably have Gauss-Hermite quadrature in mind because it is used when a density is approximated by a Gaussian density (the "adaptive" modifier refers to a process where the conditional mode and conditional variance are determined, given values of parameters). In that case you could start at http://en.wikipedia.org/wiki/Gauss-Hermite_Quadrature for the theory. There is C code in the lme4 package to compute the nodes and weights for Gauss-Hermite quadrature but we haven't written a public interface to it. You can try, for example
library(lme4)
.Call("lme4_ghq", 7)
[[1]] [1] 2.6519614 1.6735516 0.8162879 0.0000000 -0.8162879 -1.6735516 -2.6519614 [[2]] [1] 0.0009717812 0.0545155828 0.4256072526 0.8102646176 0.4256072526 [6] 0.0545155828 0.0009717812 to get the nodes and the weights for a 7-point Gauss-Hermite quadrature. (There are two versions of the Hermite polynomials, the physicist's version where the kernel is exp(-x^2) and the probabilist's version where the kernel is exp(-(x^2)/2). I'm pretty sure these are from the physicist's version.)
______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.