This function integrates (unnormalized) densities and may be used to compute integration constants for unnormalized densities, or to marginalize a joint density, for example.
kCompute(
f,
init,
method = "BFGS",
maxit = 10000,
level = 2,
log = FALSE,
link = NULL,
linkparams = NULL,
quadError = FALSE,
...
)
(Unnormalized) density to integrate.
the function \(f\) should include an argument log
,
which returns \(log(f(x))\).
Initial guess for the density's mode
method to be used to search for the density's mode
maximum number of iterations optim
should use in
searching for the density's mode
accuracy level (typically number of grid points for the underlying 1D quadrature rule) [description from mvQuad::createNIGrid]
TRUE to return log of integration constant
character vector that specifies transformations used during
optimization and integration of f(theta2 | X). while theta2 may be
defined on arbitrary support, wtdMix
performs optimization and
integration of theta2 on an unconstrained support. the link
vector describes the transformations that must be applied to each
element of theta2. Jacobian functions for the transformations will
automatically be added to the optimization and integration routines.
currently supported link functions are 'log', 'logit', and 'identity'.
Optional list of additional parameters for link functions. For example, the logit function can be extended to allow mappings to any closed interval. There should be one list entry for each link function. Specify NA if no additional arguments are passed.
TRUE if integration nodes and weight should be computed for
the level-1
integration grid, so that quadrature approximation
error can be estimated.
additional arguments to pass to f
# NOT RUN {
kCompute(dgamma, init = 1, shape=2, link='log', level = 5)
# }
Run the code above in your browser using DataLab