@@ -19,30 +19,34 @@ namespace math {
1919 * where the likelihood is a Bernoulli with logit link.
2020 * @tparam ThetaVec A type inheriting from `Eigen::EigenBase`
2121 * with dynamic sized rows and 1 column.
22+ * @tparam Mean type of the mean of the latent normal distribution
2223 * \laplace_common_template_args
2324 * @tparam RNG A valid boost rng type
2425 * @param[in] y Vector Vector of total number of trials with a positive outcome.
2526 * @param[in] n_samples Vector of number of trials.
27+ * @param[in] mean the mean of the latent normal variable.
2628 * \laplace_common_args
2729 * \laplace_options
2830 * \rng_arg
2931 * \msg_arg
3032 */
31- template <typename ThetaVec, typename CovarFun, typename CovarArgs,
32- typename RNG, require_eigen_t <ThetaVec>* = nullptr >
33+ template <typename ThetaVec, typename Mean, typename CovarFun,
34+ typename CovarArgs, typename RNG,
35+ require_eigen_vector_t <ThetaVec>* = nullptr >
3336inline Eigen::VectorXd laplace_latent_tol_bernoulli_logit_rng (
34- const std::vector<int >& y, const std::vector<int >& n_samples,
37+ const std::vector<int >& y, const std::vector<int >& n_samples, Mean&& mean,
3538 CovarFun&& covariance_function, CovarArgs&& covar_args, ThetaVec&& theta_0,
3639 const double tolerance, const int max_num_steps,
3740 const int hessian_block_size, const int solver,
3841 const int max_steps_line_search, RNG& rng, std::ostream* msgs) {
3942 laplace_options_user_supplied ops{hessian_block_size, solver,
4043 max_steps_line_search, tolerance,
4144 max_num_steps, value_of (theta_0)};
42- return laplace_base_rng (bernoulli_logit_likelihood{},
43- std::forward_as_tuple (to_vector (y), n_samples),
44- std::forward<CovarFun>(covariance_function),
45- std::forward<CovarArgs>(covar_args), ops, rng, msgs);
45+ return laplace_base_rng (
46+ bernoulli_logit_likelihood{},
47+ std::forward_as_tuple (to_vector (y), n_samples, std::forward<Mean>(mean)),
48+ std::forward<CovarFun>(covariance_function),
49+ std::forward<CovarArgs>(covar_args), ops, rng, msgs);
4650}
4751
4852/* *
@@ -54,24 +58,27 @@ inline Eigen::VectorXd laplace_latent_tol_bernoulli_logit_rng(
5458 * return a multivariate normal random variate sampled
5559 * from the gaussian approximation of p(theta | y, phi),
5660 * where the likelihood is a Bernoulli with logit link.
61+ * @tparam Mean type of the mean of the latent normal distribution
5762 * \laplace_common_template_args
5863 * @tparam RNG A valid boost rng type
5964 * @param[in] y Vector Vector of total number of trials with a positive outcome.
6065 * @param[in] n_samples Vector of number of trials.
66+ * @param[in] mean the mean of the latent normal variable.
6167 * \laplace_common_args
6268 * \rng_arg
6369 * \msg_arg
6470 */
65- template <typename CovarFun, typename CovarArgs, typename RNG>
71+ template <typename Mean, typename CovarFun, typename CovarArgs, typename RNG>
6672inline Eigen::VectorXd laplace_latent_bernoulli_logit_rng (
67- const std::vector<int >& y, const std::vector<int >& n_samples,
73+ const std::vector<int >& y, const std::vector<int >& n_samples, Mean&& mean,
6874 CovarFun&& covariance_function, CovarArgs&& covar_args, RNG& rng,
6975 std::ostream* msgs) {
70- return laplace_base_rng (bernoulli_logit_likelihood{},
71- std::forward_as_tuple (to_vector (y), n_samples),
72- std::forward<CovarFun>(covariance_function),
73- std::forward<CovarArgs>(covar_args),
74- laplace_options_default{}, rng, msgs);
76+ return laplace_base_rng (
77+ bernoulli_logit_likelihood{},
78+ std::forward_as_tuple (to_vector (y), n_samples, std::forward<Mean>(mean)),
79+ std::forward<CovarFun>(covariance_function),
80+ std::forward<CovarArgs>(covar_args), laplace_options_default{}, rng,
81+ msgs);
7582}
7683
7784} // namespace math
0 commit comments