![]() |
Stan Math Library
5.2.0
Automatic Differentiation
|
|
inline |
For a latent Gaussian model with hyperparameters phi and 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, via Newton's method, and computing the Hessian of the likelihood.
The convergence criterion for the Newton/Wolfe loop is a small change in the optimization objective (stored in the Wolfe step state). The user controls the tolerance (i.e. threshold under which the change is deemed small enough) and maximum number of steps.
A description of this algorithm can be found in:
This function returns intermediate quantities needed by laplace_marginal_density (including its reverse-mode implementation) to compute gradients and/or generate quantities. Which fields are populated depends on the solver that converged (see solver_used).
| LLFun | Type with a valid operator(ThetaVec, InnerLLTupleArgs) where InnerLLTupleArgs are the elements of LLTupleArgs |
| LLTupleArgs | A tuple whose elements follow the types required for LLFun |
| CovarFun | A 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. |
| CovarArgs | A tuple of types to passed as the first arguments of CovarFun::operator() |
| OpsTuple | A tuple of laplace_options types |
| [in] | ll_fun | A log likelihood functor |
| [in] | ll_args | Tuple containing parameters for LLFun |
| [in] | covariance | The covariance matrix for the latent Gaussian |
| [in] | covariance_function | a function which returns the prior covariance. |
| [in] | covar_args | arguments for the covariance function. |
| [in] | options | A set of options for tuning the solver |
| [in,out] | msgs | stream for messages from likelihood and covariance |
laplace_density_estimates containing:lmd: the Laplace approximation of the log marginal density, p(y | phi)theta: the mode of the latent variablesa: the mode in the a parameterization (theta = covariance * a)theta_grad: gradient of the log-likelihood w.r.t. theta at the modeW_r: solver-dependent Hessian quantity (see struct docs)L: solver-dependent factorization of B (Cholesky for solvers 1/2)LU: LU factorization of B (solver 3 only)K_root: Cholesky factor of the covariance (solver 2 only)solver_used: the solver policy that produced the result Definition at line 1147 of file laplace_marginal_density_estimator.hpp.