Description Usage Arguments Details Value See Also Examples
Creates a flattened, rotated grid that incorporates correlation through an eigenvalue decomposition of the covariance matrix.
1 2 |
Q |
Number of dimensions. Defaults to 2. Only required when |
prior |
List of prior mean |
adapt |
List of adaptive mean |
ip |
Number of quadrature points per dimension. Defaults to 6. Note that the total number of quadrature points is |
prune |
Logical, should quadrature points with a very low weight be removed? Defaults to false. See details. |
forcePD |
Logical, should |
debug |
Logical, draws debugging plots when true. |
Creates a Q-dimensional grid by calling expand.grid
on Q vectors of unidimensional quadrature points obtained with gaussHermiteData
.
The grid is then corrected for a prior distribution, and can optionally be adapted around a previous estimate. The resultant grid can be pruned to remove quadrature points that are unlikely to add information.
A list with a matrix X
of ip^Q
by Q
quadrature points and a vector W
of length ip^Q
associated weights.
gaussHermiteData
, used to create unidimensional quadrature points, and eval.quad
for evaluating the integral.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | ### basic quadrature grid /w pruning.
mu <- c(0,0)
sigma <- matrix(c(1,.5,.5,1),2,2)
grid <- init.quad(Q = 2, prior = list(mu = mu, Sigma = sigma), ip = 10, prune = FALSE)
grid2 <- init.quad(Q = 2, prior = list(mu = mu, Sigma = sigma), ip = 10, prune = TRUE)
library(mvtnorm)
normal <- rmvnorm(1000, mu, sigma)
# noise
plot(normal, xlim = c(-6,6), ylim = c(-6,6), pch = 19, col = rgb(0,0,0,.5))
# full quad grid
points(grid$X, cex = exp(grid$W)/max(exp(grid$W))*4, col = 'red', pch = 20)
# pruned quad grid
points(grid2$X, cex = exp(grid2$W)/max(exp(grid2$W))*4, col = 'green', pch = 20)
### Adaptive quadrature grid
prior <- list(mu = c(0,0), Sigma = matrix(c(1,.5,.5,1),2,2))
adapt <- list(mu = c(-2,2), Sigma = prior$Sigma / 2)
grid <- init.quad(Q = 2, prior, ip = 10, prune = FALSE)
library(mvtnorm)
normal <- rmvnorm(1000, adapt$mu, adapt$Sigma)
# noise, centered at (-2, 2)
plot(normal, xlim = c(-6,6), ylim = c(-6,6), pch = 19, col = rgb(0,0,0,.5))
# initial quad grid, centered at (0, 0)
points(grid$X, cex = exp(grid$W)/max(exp(grid$W))*4, col = 'red', pch = 20)
# adapted grid
grid2 <- init.quad(Q =2, prior, adapt = adapt, ip = 10, prune = TRUE)
points(grid2$X, cex = exp(grid2$W)/max(exp(grid2$W))*4, col = 'green', pch = 20)
# the grid is adapted to the latest estimate, but weighted towards the prior
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.