Automatic Differentiation
 
Loading...
Searching...
No Matches

◆ laplace_marginal_density()

template<typename LLFun , typename LLTupleArgs , typename CovarFun , typename CovarArgs , bool InitTheta, require_t< is_all_arithmetic_scalar< CovarArgs, LLTupleArgs > > * = nullptr>
auto stan::math::laplace_marginal_density ( LLFun &&  ll_fun,
LLTupleArgs &&  ll_args,
CovarFun &&  covariance_function,
CovarArgs &&  covar_args,
const laplace_options< InitTheta > &  options,
std::ostream *  msgs 
)
inline

For a latent Gaussian model with global parameters phi, latent variables theta, and observations y, this function computes an approximation of the log marginal density, p(y | phi).

This is done by marginalizing out theta, using a Laplace approximation. The latter is obtained by finding the mode, using a custom Newton method, and the Hessian of the likelihood.

The convergence criterion for the Newton/Wolfe loop is a small change in the optimization objective (not the final Laplace-corrected log marginal density). The user controls the tolerance (i.e. threshold under which the change is deemed small enough) and maximum number of steps.

Wrapper for when the hyperparameters are passed as a double.

Template Parameters
LLFunType with a valid operator(ThetaVec, InnerLLTupleArgs) where InnerLLTupleArgs are the elements of LLTupleArgs
LLTupleArgsA tuple whose elements follow the types required for LLFun
CovarFunA functor with an operator()(CovarArgsElements..., {TrainTupleElements...| PredTupleElements...}) method. The operator() method should accept as arguments the inner elements of CovarArgs. The return type of the operator() method should be a type inheriting from Eigen::EigenBase with dynamic sized rows and columns.
CovarArgsA tuple of types to passed as the first arguments of CovarFun::operator()
OpsTupleA tuple of laplace_options types
Parameters
[in]ll_funA log likelihood functor
[in]ll_argsTuple containing parameters for LLFun
[in]covariance_functiona function which returns the prior covariance.
[in]covar_argsarguments for the covariance function.
[in]optionsA set of options for tuning the solver
[in,out]msgsstream for messages from likelihood and covariance
Returns
the log marginal density, p(y | phi)

This is done by marginalizing out theta, using a Laplace approximation. The latter is obtained by finding the mode, using a custom Newton method, and the Hessian of the likelihood.

The convergence criterion for the Newton/Wolfe loop is a small change in the optimization objective (not the final Laplace-corrected log marginal density). The user controls the tolerance (i.e. threshold under which the change is deemed small enough) and maximum number of steps.

Wrapper for when the global parameter is passed as a double.

Template Parameters
LLFunType with a valid operator(ThetaVec, InnerLLTupleArgs) where InnerLLTupleArgs are the elements of LLTupleArgs
LLTupleArgsA tuple whose elements follow the types required for LLFun
CovarFunA functor with an operator()(CovarArgsElements..., {TrainTupleElements...| PredTupleElements...}) method. The operator() method should accept as arguments the inner elements of CovarArgs. The return type of the operator() method should be a type inheriting from Eigen::EigenBase with dynamic sized rows and columns.
CovarArgsA tuple of types to passed as the first arguments of CovarFun::operator()
OpsTupleA tuple of laplace_options types
Parameters
[in]ll_funA log likelihood functor
[in]ll_argsTuple containing parameters for LLFun
[in]covariance_functiona function which returns the prior covariance.
[in]covar_argsarguments for the covariance function.
[in]optionsA set of options for tuning the solver
[in,out]msgsstream for messages from likelihood and covariance
Returns
the log marginal density, p(y | phi)

Definition at line 57 of file laplace_marginal_density.hpp.