# Issues with tuples in cmdstanr

**URL:** https://discourse.mc-stan.org/t/issues-with-tuples-in-cmdstanr/34626
**Category:** Interfaces
**Tags:** cmdstanr
**Created:** [March 28, 2024, 5:59pm UTC](https://discourse.mc-stan.org/t/issues-with-tuples-in-cmdstanr/34626 "2024-03-28T17:59:16Z")
**Posts on this page:** 1
**Showing post:** 5

<div class="post-metadata">

### Author: ![mhollanders](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/mhollanders/32/17623_2.png) [@mhollanders](https://discourse.mc-stan.org/u/mhollanders)
#### Post date: [March 28, 2024, 9:31pm UTC](https://discourse.mc-stan.org/t/issues-with-tuples-in-cmdstanr/34626/5 "2024-03-28T21:31:22Z")

</div>

Sure.

This one works, where `lambda_mu` and `lambda_hp` are two vectors used in the function:

```no-highlight
real partial_sum_lpmf(
    data array[] int seq_region, data int start, data int end, data int n_date_max, data int n_call_max,
    data array[] int n_site, data array[,] int n_date, data array[,,] int n_call, data array[,,] int dates, data array[,,] int tau, data array[,,] vector y, 
    vector eta, vector gamma, vector phi, vector lambda_mu, vector lambda_hp) {

```

This one doesn’t work, where a tuple `lambda_mu` is created in the `transformed parameters` block consisting of two vectors, previously `lambda_mu` and `lambda_hp`.

```no-highlight
real partial_sum_lpmf(
    data array[] int seq_region, data int start, data int end, data int n_date_max, data int n_call_max,
    data array[] int n_site, data array[,] int n_date, data array[,,] int n_call, data array[,,] int dates, data array[,,] int tau, data array[,,] vector y, 
    vector eta, vector gamma, vector phi, tuple(vector, vector) lambda_mu) {

```

The errors I get in the latter formulation during compilation are (note I had to omit the first part of the messages because of character limits):

```no-highlight
                      ^
/Users/s447341/.cmdstan/cmdstan-2.33.1/stan/lib/stan_math/stan/math/prim/functor/reduce_sum.hpp:207:10: note: in instantiation of member function 'stan::math::internal::reduce_sum_impl<occu_ps_ms_trm_tuple_model_namespace::partial_sum_lpmf_rsfunctor__<true>, void, stan::math::var_value<double>, const std::vector<int> &, const int &, const int &, const std::vector<int> &, const std::vector<std::vector<int>> &, const std::vector<std::vector<std::vector<int>>> &, const std::vector<std::vector<std::vector<int>>> &, const std::vector<std::vector<std::vector<int>>> &, const std::vector<std::vector<std::vector<Eigen::Matrix<double, -1, 1>>>> &, Eigen::Matrix<stan::math::var_value<double>, -1, 1> &, Eigen::Matrix<stan::math::var_value<double>, -1, 1> &, Eigen::Matrix<stan::math::var_value<double>, -1, 1> &, std::tuple<Eigen::Matrix<stan::math::var_value<double>, -1, 1>, Eigen::Matrix<stan::math::var_value<double>, -1, 1>> &>::operator()' requested here
  return internal::reduce_sum_impl<ReduceFunction, void, return_type, Vec,
         ^
/var/folders/gr/hv6k6041275bm9w8vvn4ms3sz23ct8/T/Rtmp0Nghm8
/model-12c15458f3352.hpp:2235:12: note: in instantiation of function template specialization 'occu_ps_ms_trm_tuple_model_namespace::occu_ps_ms_trm_tuple_model::log_prob_impl<true, false, Eigen::Matrix<stan::math::var_value<double>, -1, 1>, Eigen::Matrix<int, -1, 1>, nullptr, nullptr, nullptr>' requested here
    return log_prob_impl<propto __, jacobian__ >(params_r, params_i, pstream);
           ^
/Users/s447341/.cmdstan/cmdstan-2.33.1/stan/src/stan/model/model_base_crtp.hpp:120:50: note: in instantiation of function template specialization 'occu_ps_ms_trm_tuple_model_namespace::occu_ps_ms_trm_tuple_model::log_prob<true, false, stan::math::var_value<double>>' requested here
    return static_cast<const M*>(this)->template log_prob<true, false>(theta,
                                                 ^
/var/folders/gr/hv6k6041275bm9w8vvn4ms3sz23ct8/T/Rtmp0Nghm8/model-12c15458f3352.hpp:983:3: note: in instantiation of member function 'stan::model::model_base_crtp<occu_ps_ms_trm_tuple_model_namespace::occu_ps_ms_trm_tuple_model>::log_prob_propto' requested here
  ~occu_ps_ms_trm_tuple_model() {}
  ^
/Users/s447341/.cmdstan/cmdstan-2.33.1/stan/lib/stan_math/stan/math/rev/core/deep_copy_vars.hpp:33:13: note: candidate function not viable: no known conversion from 'std::tuple<Eigen::Matrix<stan::math::var_value<double>, -1, 1>, Eigen::Matrix<stan::math::var_value<double>, -1, 1>>' to 'const var' (aka 'const var_value<double>') for 1st argument
inline auto deep_copy_vars(const var& arg) {
            ^
/Users/s447341/.cmdstan/cmdstan-2.33.1/stan/lib/stan_math/stan/math/rev/core/deep_copy_vars.hpp:23:14: note: candidate template ignored: requirement 'is_arithmetic<std::tuple<Eigen::Matrix<stan::math::var_value<double, void>, -1, 1, 0, -1, 1>, Eigen::Matrix<stan::math::var_value<double, void>, -1, 1, 0, -1, 1>>>::value' was not satisfied [with Arith = std::tuple<Eigen::Matrix<stan::math::var_value<double>, -1, 1>, Eigen::Matrix<stan::math::var_value<double>, -1, 1>> &]
inline 
Arith deep_copy_vars(Arith&& arg) {
             ^
/Users/s447341/.cmdstan/cmdstan-2.33.1/stan/lib/stan_math/stan/math/rev/core/deep_copy_vars.hpp:45:13: note: candidate template ignored: requirement 'integral_constant<bool, false>::value' was not satisfied [with VarVec = std::tuple<Eigen::Matrix<stan::math::var_value<double>, -1, 1>, Eigen::Matrix<stan::math::var_value<double>, -1, 1>> &]
inline auto deep_copy_vars(VarVec&& arg) {
            ^
/Users/s447341/.cmdstan/cmdstan-2.33.1/stan/lib/stan_math/stan/math/rev/core/deep_copy_vars.hpp:63:13: note: candidate template ignored: requirement 'integral_constant<bool, false>::value' was not satisfied [with VecContainer = std::tuple<Eigen::Matrix<stan::math::var_value<double>, -1, 1>, Eigen::Matrix<stan::math::var_value<double>, -1, 1>> &]
inline auto deep_copy_vars(VecContainer&& arg) {
            ^
/Users/s447341/.cmdstan/cmdstan-2.33.1/stan/lib/stan_math/stan/math/rev/core/deep_copy_vars.hpp:79:13: note: candidate template ignored: requirement 'integral_constant<bool, false>::value' was not satisfied [with EigT = std::tuple<Eigen::Matrix<stan::math::var_value<double>, -1, 1>, Eigen::Matrix<stan::math::var_value<double>, -1, 1>> &]
inline auto deep_copy_vars(EigT&& arg) {
            ^

4 errors generated.

make: *** [/var/folders/gr/hv6k6041275bm9w8vvn4ms3sz23ct8/T/Rtmp0Nghm8/model-12c15458f3352] Error 1

Error: An error occured during compilation! See the message above for more information.

```

---

_[View the full topic](https://discourse.mc-stan.org/t/issues-with-tuples-in-cmdstanr/34626)._
