Automatic Differentiation
 
Loading...
Searching...
No Matches
laplace_marginal_bernoulli_logit_lpmf.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_MIX_PROB_LAPLACE_MARGINAL_BERNOULLI_LOGIT_LPMF_HPP
2#define STAN_MATH_MIX_PROB_LAPLACE_MARGINAL_BERNOULLI_LOGIT_LPMF_HPP
3
20
21namespace stan {
22namespace math {
23
25 template <typename ThetaVec, typename YVec, typename Mean>
26 inline auto operator()(const ThetaVec& theta, const YVec& y,
27 const std::vector<int>& delta_int, Mean&& mean,
28 std::ostream* pstream) const {
29 auto theta_offset = to_ref(add(theta, mean));
30 return sum(elt_multiply(theta_offset, y)
31 - elt_multiply(to_vector(delta_int), log1p_exp(theta_offset)));
32 }
33};
34
55template <bool propto = false, typename Mean, typename CovarFun,
56 typename CovarArgs, typename OpsTuple>
58 const std::vector<int>& y, const std::vector<int>& n_samples, Mean&& mean,
59 CovarFun&& covariance_function, CovarArgs&& covar_args, OpsTuple&& ops,
60 std::ostream* msgs) {
63 std::forward_as_tuple(to_vector(y), n_samples, std::forward<Mean>(mean)),
64 std::forward<CovarFun>(covariance_function),
65 std::forward<CovarArgs>(covar_args),
66 internal::tuple_to_laplace_options(std::forward<OpsTuple>(ops)), msgs);
67}
68
86template <bool propto = false, typename Mean, typename CovarFun,
87 typename CovarArgs>
89 const std::vector<int>& y, const std::vector<int>& n_samples, Mean&& mean,
90 CovarFun&& covariance_function, CovarArgs&& covar_args,
91 std::ostream* msgs) {
94 std::forward_as_tuple(to_vector(y), n_samples, std::forward<Mean>(mean)),
95 std::forward<CovarFun>(covariance_function),
96 std::forward<CovarArgs>(covar_args), laplace_options_default{}, msgs);
97}
98
99} // namespace math
100} // namespace stan
101
102#endif
elt_multiply_< as_operation_cl_t< T_a >, as_operation_cl_t< T_b > > elt_multiply(T_a &&a, T_b &&b)
addition_< as_operation_cl_t< T_a >, as_operation_cl_t< T_b > > add(T_a &&a, T_b &&b)
auto to_vector(T_x &&x)
Returns input matrix reshaped into a vector.
Definition to_vector.hpp:21
Reference for calculations of marginal and its gradients: Margossian et al (2020),...
constexpr auto tuple_to_laplace_options(Options &&ops)
scalar_type_t< T > mean(const T &m)
Returns the sample mean (i.e., average) of the coefficients in the specified std vector,...
Definition mean.hpp:20
auto laplace_marginal_density(LLFun &&ll_fun, LLTupleArgs &&ll_args, CovarFun &&covariance_function, CovarArgs &&covar_args, const laplace_options< InitTheta > &options, std::ostream *msgs)
For a latent Gaussian model with global parameters phi, latent variables theta, and observations y,...
fvar< T > log1p_exp(const fvar< T > &x)
Definition log1p_exp.hpp:14
auto sum(const std::vector< T > &m)
Return the sum of the entries of the specified standard vector.
Definition sum.hpp:23
auto laplace_marginal_bernoulli_logit_lpmf(const std::vector< int > &y, const std::vector< int > &n_samples, Mean &&mean, CovarFun &&covariance_function, CovarArgs &&covar_args, std::ostream *msgs)
Wrapper function around the laplace_marginal function for a logistic Bernoulli likelihood.
auto laplace_marginal_tol_bernoulli_logit_lpmf(const std::vector< int > &y, const std::vector< int > &n_samples, Mean &&mean, CovarFun &&covariance_function, CovarArgs &&covar_args, OpsTuple &&ops, std::ostream *msgs)
Wrapper function around the laplace_marginal function for a logistic Bernoulli likelihood.
ref_type_t< T && > to_ref(T &&a)
This evaluates expensive Eigen expressions.
Definition to_ref.hpp:18
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...
auto operator()(const ThetaVec &theta, const YVec &y, const std::vector< int > &delta_int, Mean &&mean, std::ostream *pstream) const