@@ -19,30 +19,34 @@ namespace math {
19
19
* where the likelihood is a Bernoulli with logit link.
20
20
* @tparam ThetaVec A type inheriting from `Eigen::EigenBase`
21
21
* with dynamic sized rows and 1 column.
22
+ * @tparam Mean type of the mean of the latent normal distribution
22
23
* \laplace_common_template_args
23
24
* @tparam RNG A valid boost rng type
24
25
* @param[in] y Vector Vector of total number of trials with a positive outcome.
25
26
* @param[in] n_samples Vector of number of trials.
27
+ * @param[in] mean the mean of the latent normal variable.
26
28
* \laplace_common_args
27
29
* \laplace_options
28
30
* \rng_arg
29
31
* \msg_arg
30
32
*/
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 >
33
36
inline 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,
35
38
CovarFun&& covariance_function, CovarArgs&& covar_args, ThetaVec&& theta_0,
36
39
const double tolerance, const int max_num_steps,
37
40
const int hessian_block_size, const int solver,
38
41
const int max_steps_line_search, RNG& rng, std::ostream* msgs) {
39
42
laplace_options_user_supplied ops{hessian_block_size, solver,
40
43
max_steps_line_search, tolerance,
41
44
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);
46
50
}
47
51
48
52
/* *
@@ -54,24 +58,27 @@ inline Eigen::VectorXd laplace_latent_tol_bernoulli_logit_rng(
54
58
* return a multivariate normal random variate sampled
55
59
* from the gaussian approximation of p(theta | y, phi),
56
60
* where the likelihood is a Bernoulli with logit link.
61
+ * @tparam Mean type of the mean of the latent normal distribution
57
62
* \laplace_common_template_args
58
63
* @tparam RNG A valid boost rng type
59
64
* @param[in] y Vector Vector of total number of trials with a positive outcome.
60
65
* @param[in] n_samples Vector of number of trials.
66
+ * @param[in] mean the mean of the latent normal variable.
61
67
* \laplace_common_args
62
68
* \rng_arg
63
69
* \msg_arg
64
70
*/
65
- template <typename CovarFun, typename CovarArgs, typename RNG>
71
+ template <typename Mean, typename CovarFun, typename CovarArgs, typename RNG>
66
72
inline 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,
68
74
CovarFun&& covariance_function, CovarArgs&& covar_args, RNG& rng,
69
75
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);
75
82
}
76
83
77
84
} // namespace math
0 commit comments