| nested_quadrature {aghq} | R Documentation |
Nested, sparse Gaussian quadrature in AGHQ
Description
Compute a whole sequence of log normalizing constants
for 1,3,5,...,k points,
using only the function evaluations from the k-point nested rule.
Usage
nested_quadrature(optresults, k, ndConstruction = "product", ...)
adaptive_nested_quadrature(optresults, k, ndConstruction = "product", ...)
get_quadtable(p, k, ndConstruction = "product", ...)
Arguments
optresults |
The results of calling |
k |
Integer, the number of quadrature points to use. |
ndConstruction |
Create a multivariate grid using a product or sparse construction?
Passed directly to |
... |
Additional arguments to be passed to |
p |
Dimension of the variable of integration. |
Details
get_quadtable currently uses mvQuad to compute the nodes and weights. This will be replaced
by a manual reading of the pre-tabulated nodes and weights.
nested_quadrature and adaptive_nested_quadrature take the log function values, just like optimize_theta(),
and return the log of the base/adapted quadrature rule.
Value
For get_quadtable, a pre-computed table of nodes for the k-point rule,
with weights for the points from each of the 1,3,...,k-point rules, for passing to
nested_quadrature. For nested_quadrature and adaptive_nested_quadrature, a named numeric vector of optresults$fn
values for each k.
See Also
Other quadrature:
aghq(),
get_hessian(),
get_log_normconst(),
get_mode(),
get_nodesandweights(),
get_numquadpoints(),
get_opt_results(),
get_param_dim(),
laplace_approximation(),
marginal_laplace_tmb(),
marginal_laplace(),
normalize_logpost(),
optimize_theta(),
plot.aghq(),
print.aghqsummary(),
print.aghq(),
print.laplacesummary(),
print.laplace(),
print.marginallaplacesummary(),
summary.aghq(),
summary.laplace(),
summary.marginallaplace()
Examples
# Same setup as optimize_theta
logfteta <- function(eta,y) {
sum(y) * eta - (length(y) + 1) * exp(eta) - sum(lgamma(y+1)) + eta
}
set.seed(84343124)
y <- rpois(10,5) # Mode should be sum(y) / (10 + 1)
truemode <- log((sum(y) + 1)/(length(y) + 1))
objfunc <- function(x) logfteta(x,y)
funlist <- list(
fn = objfunc,
gr = function(x) numDeriv::grad(objfunc,x),
he = function(x) numDeriv::hessian(objfunc,x)
)
opt_sparsetrust <- optimize_theta(funlist,1.5)