[R] ADAPTIVE QUADRATURE WEIGHTS AND NODES

Douglas Bates bates at stat.wisc.edu
Fri May 8 19:07:05 CEST 2009


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.)




More information about the R-help mailing list