aghq::marginal_laplace()
.Run default_control_marglaplace()
to print the list of valid control parameters
and their defaults, and run with named arguments to change the defaults.
default_control_marglaplace(...)
A list of argument values.
You can provide a named value for any control parameter and its
value will be set accordingly. See ?marginal_laplace
and examples here.
Valid options are:
method
: optimization method to use for the theta
optimization:
'BFGS' (default): optim(...,method = "BFGS")
'sparse_trust': trustOptim::trust.optim
'SR1': trustOptim::trust.optim
with method = 'SR1'
'sparse': trust::trust
inner_method
: optimization method to use for the W
optimization; same
options as for method
. Default inner_method
is 'sparse_trust' and default method
is 'BFGS'.
negate
: default FALSE
. Multiply the functions in ff
by -1
?
The reason for having this option is for full compatibility with TMB
:
while of course TMB
allows you to code up your log-posterior any way you like,
all of its excellent features including its automatic Laplace approximation and MCMC
sampling with tmbstan
assume you have coded your template to return the
negated log-posterior. However, by default, aghq
assumes you have
provided the log-posterior without negation. Set negate = TRUE
if you
have provided a template which computes the negated log-posterior and its
derivatives. Note that I don't expect there to be any reason to need this
argument for marginal_laplace
; if you are doing a marginal Laplace approximation
using the automatic Laplace approximation provided by TMB
, you should
check out aghq::marginal_laplace_tmb()
.
interpolation
: how to interpolate the marginal posteriors. The 'auto'
option
(default) chooses for you and should always work well. The 'polynomial'
option uses polynom::poly.calc()
to construct a global polynomial interpolant
and has been observed to be unstable as the number of quadrature points gets larger, which
is obviously a bad thing. Try 'spline'
instead, which uses a cubic B-Spline
interpolant from splines::interpSpline()
.
numhessian: logical, default FALSE
. Replace the ff$he
with a numerically-differentiated
version, by calling numDeriv::jacobian
on ff$gr
. Used mainly for TMB
with the automatic
Laplace approximation, which does not have an automatic Hessian.
onlynormconst: logical, default FALSE
. Skip everything after the calculation of the log integral,
and just return the numeric value of the log integral. Saves computation time, and most useful in cases
where aghq
is being used as a step in a more complicated procedure.
method_summaries: default 'reuse'
, method to use to compute moments and marginals. Choosing
'correct'
corresponds to the approximations suggested in the Stochastic Convergence... paper,
which attain the same rate of convergence as the approximation to the marginal likelihood. See ?compute_moment
.
default_control_marglaplace()
default_control_marglaplace(method = "trust")
default_control_marglaplace(method = "trust",inner_method = "trust")
default_control_marglaplace(negate = TRUE)
Run the code above in your browser using DataLab