Deconding a long C++ error log

I get this error that I could not decode to find the reason

The log

error_log.txt (76.2 KB)

...
             
filefc649e8a84b.cpp: In instantiation of ‘typename boost::math::tools::promote_args<T_y, T_dof, T_scale>::type modelfc638a850cf_poisson_inverseGaussian_namespace::poisson_inverse_gaussian_log_original_lpmf(const int&, const T1__&, const T2__&, const T3__&, std::ostream*) [with bool propto = true; T1__ = stan::math::var; T2__ = stan::math::var; T3__ = stan::math::var; typename boost::math::tools::promote_args<T_y, T_dof, T_scale>::type = stan::math::var; std::ostream = std::basic_ostream<char>]’:
filefc649e8a84b.cpp:455:92:   required from ‘T__ modelfc638a850cf_poisson_inverseGaussian_namespace::modelfc638a850cf_poisson_inverseGaussian::log_prob(std::vector<T_l>&, std::vector<int>&, std::ostream*) const [with bool propto__ = true; bool jacobian__ = true; T__ = stan::math::var; std::ostream = std::basic_ostream<char>]’
/wehisan/general/system/bioinf-software/bioinfsoftware/R/R-3.5.1/lib64/R/library/StanHeaders/include/src/stan/model/log_prob_grad.hpp:43:13:   required from ‘double stan::model::log_prob_grad(const M&, std::vector<double>&, std::vector<int>&, std::vector<double>&, std::ostream*) [with bool propto = true; bool jacobian_adjust_transform = true; M = modelfc638a850cf_poisson_inverseGaussian_namespace::modelfc638a850cf_poisson_inverseGaussian; std::ostream = std::basic_ostream<char>]’
/wehisan/general/system/bioinf-software/bioinfsoftware/R/R-3.5.1/lib64/R/library/rstan/include/rstan/stan_fit.hpp:1168:49:   required from ‘SEXPREC* rstan::stan_fit<Model, RNG_t>::grad_log_prob(SEXP, SEXP) [with Model = modelfc638a850cf_poisson_inverseGaussian_namespace::modelfc638a850cf_poisson_inverseGaussian; RNG_t = boost::random::additive_combine_engine<boost::random::linear_congruential_engine<unsigned int, 40014, 0, 2147483563>, boost::random::linear_congruential_engine<unsigned int, 40692, 0, 2147483399> >; SEXP = SEXPREC*]’
filefc649e8a84b.cpp:707:152:   required from here
filefc649e8a84b.cpp:90:153: error: no matching function for call to ‘poisson_inverse_gaussian_log_original_lpmf(int, const stan::math::var&, const stan::math::var&, const stan::math::var&, std::ostream*&)’
             stan::math::assign(prob, ((exp_mu * pow((1 + exp_mu_beta_tau_exp_mu_2),-(0.5))) * stan::math::exp(poisson_inverse_gaussian_log_original_lpmf(0,mu,beta,tau, pstream__))));
                                                                                                               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
filefc649e8a84b.cpp:39:1: note: candidate: ‘template<bool propto, class T1__, class T2__, class T3__> typename boost::math::tools::promote_args<T_y, T_dof, T_scale>::type modelfc638a850cf_poisson_inverseGaussian_namespace::poisson_inverse_gaussian_log_original_lpmf(const int&, const T1__&, const T2__&, const T3__&, std::ostream*)’
 poisson_inverse_gaussian_log_original_lpmf(const int& y,
 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
filefc649e8a84b.cpp:39:1: note:   template argument deduction/substitution failed:
filefc649e8a84b.cpp:90:153: note:   couldn't deduce template parameter ‘propto’
             stan::math::assign(prob, ((exp_mu * pow((1 + exp_mu_beta_tau_exp_mu_2),-(0.5))) * stan::math::exp(poisson_inverse_gaussian_log_original_lpmf(0,mu,beta,tau, pstream__))));
                                                                                                               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
filefc649e8a84b.cpp:93:186: error: no matching function for call to ‘poisson_inverse_gaussian_log_original_lpmf(int, const stan::math::var&, const stan::math::var&, const stan::math::var&, std::ostream*&)’
         stan::math::assign(prob, ((((exp_mu_beta_tau_exp_mu_2 / (1 + exp_mu_beta_tau_exp_mu_2)) * (1.0 - (3.0 / (2.0 * y)))) * stan::math::exp(poisson_inverse_gaussian_log_original_lpmf((y - 1),mu,beta,tau, pstream__))) + (((pow(exp_mu,2) / (1 + exp_mu_beta_tau_exp_mu_2)) / (y * (y - 1))) * stan::math::exp(poisson_inverse_gaussian_log_original_lpmf((y - 2),mu,beta,tau, pstream__)))));
                                                                                                                                                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
filefc649e8a84b.cpp:39:1: note: candidate: ‘template<bool propto, class T1__, class T2__, class T3__> typename boost::math::tools::promote_args<T_y, T_dof, T_scale>::type modelfc638a850cf_poisson_inverseGaussian_namespace::poisson_inverse_gaussian_log_original_lpmf(const int&, const T1__&, const T2__&, const T3__&, std::ostream*)’
 poisson_inverse_gaussian_log_original_lpmf(const int& y,
 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
filefc649e8a84b.cpp:39:1: note:   template argument deduction/substitution failed:
filefc649e8a84b.cpp:93:186: note:   couldn't deduce template parameter ‘propto’
         stan::math::assign(prob, ((((exp_mu_beta_tau_exp_mu_2 / (1 + exp_mu_beta_tau_exp_mu_2)) * (1.0 - (3.0 / (2.0 * y)))) * stan::math::exp(poisson_inverse_gaussian_log_original_lpmf((y - 1),mu,beta,tau, pstream__))) + (((pow(exp_mu,2) / (1 + exp_mu_beta_tau_exp_mu_2)) / (y * (y - 1))) * stan::math::exp(poisson_inverse_gaussian_log_original_lpmf((y - 2),mu,beta,tau, pstream__)))));
                                                                                                                                                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
filefc649e8a84b.cpp:93:351: error: no matching function for call to ‘poisson_inverse_gaussian_log_original_lpmf(int, const stan::math::var&, const stan::math::var&, const stan::math::var&, std::ostream*&)’
         stan::math::assign(prob, ((((exp_mu_beta_tau_exp_mu_2 / (1 + exp_mu_beta_tau_exp_mu_2)) * (1.0 - (3.0 / (2.0 * y)))) * stan::math::exp(poisson_inverse_gaussian_log_original_lpmf((y - 1),mu,beta,tau, pstream__))) + (((pow(exp_mu,2) / (1 + exp_mu_beta_tau_exp_mu_2)) / (y * (y - 1))) * stan::math::exp(poisson_inverse_gaussian_log_original_lpmf((y - 2),mu,beta,tau, pstream__)))));
                                                                                                                                                                                                                                                                                                                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
filefc649e8a84b.cpp:39:1: note: candidate: ‘template<bool propto, class T1__, class T2__, class T3__> typename boost::math::tools::promote_args<T_y, T_dof, T_scale>::type modelfc638a850cf_poisson_inverseGaussian_namespace::poisson_inverse_gaussian_log_original_lpmf(const int&, const T1__&, const T2__&, const T3__&, std::ostream*)’
 poisson_inverse_gaussian_log_original_lpmf(const int& y,
 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
filefc649e8a84b.cpp:39:1: note:   template argument deduction/substitution failed:
filefc649e8a84b.cpp:93:351: note:   couldn't deduce template parameter ‘propto’
         stan::math::assign(prob, ((((exp_mu_beta_tau_exp_mu_2 / (1 + exp_mu_beta_tau_exp_mu_2)) * (1.0 - (3.0 / (2.0 * y)))) * stan::math::exp(poisson_inverse_gaussian_log_original_lpmf((y - 1),mu,beta,tau, pstream__))) + (((pow(exp_mu,2) / (1 + exp_mu_beta_tau_exp_mu_2)) / (y * (y - 1))) * stan::math::exp(poisson_inverse_gaussian_log_original_lpmf((y - 2),mu,beta,tau, pstream__)))));
                                                                                                                                                                                                                                                                                                                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
filefc649e8a84b.cpp: In instantiation of ‘typename boost::math::tools::promote_args<T_y, T_dof, T_scale>::type modelfc638a850cf_poisson_inverseGaussian_namespace::poisson_inverse_gaussian_log_original_lpmf(const int&, const T1__&, const T2__&, const T3__&, std::ostream*) [with bool propto = false; T1__ = double; T2__ = double; T3__ = double; typename boost::math::tools::promote_args<T_y, T_dof, T_scale>::type = double; std::ostream = std::basic_ostream<char>]’:
filefc649e8a84b.cpp:455:92:   required from ‘T__ modelfc638a850cf_poisson_inverseGaussian_namespace::modelfc638a850cf_poisson_inverseGaussian::log_prob(std::vector<T_l>&, std::vector<int>&, std::ostream*) const [with bool propto__ = false; bool jacobian__ = false; T__ = double; std::ostream = std::basic_ostream<char>]’
/wehisan/general/system/bioinf-software/bioinfsoftware/R/R-3.5.1/lib64/R/library/StanHeaders/include/src/stan/services/optimize/newton.hpp:61:14:   required from ‘int stan::services::optimize::newton(Model&, stan::io::var_context&, unsigned int, unsigned int, double, int, bool, stan::callbacks::interrupt&, stan::callbacks::logger&, stan::callbacks::writer&, stan::callbacks::writer&) [with Model = modelfc638a850cf_poisson_inverseGaussian_namespace::modelfc638a850cf_poisson_inverseGaussian]’
/wehisan/general/system/bioinf-software/bioinfsoftware/R/R-3.5.1/lib64/R/library/rstan/include/rstan/stan_fit.hpp:487:41:   required from ‘int rstan::{anonymous}::command(rstan::stan_args&, Model&, Rcpp::List&, const std::vector<long unsigned int>&, const std::vector<std::__cxx11::basic_string<char> >&, RNG_t&) [with Model = modelfc638a850cf_poisson_inverseGaussian_namespace::modelfc638a850cf_poisson_inverseGaussian; RNG_t = boost::random::additive_combine_engine<boost::random::linear_congruential_engine<unsigned int, 40014, 0, 2147483563>, boost::random::linear_congruential_engine<unsigned int, 40692, 0, 2147483399> >; Rcpp::List = Rcpp::Vector<19>]’
/wehisan/general/system/bioinf-software/bioinfsoftware/R/R-3.5.1/lib64/R/library/rstan/include/rstan/stan_fit.hpp:1200:18:   required from ‘SEXPREC* rstan::stan_fit<Model, RNG_t>::call_sampler(SEXP) [with Model = modelfc638a850cf_poisson_inverseGaussian_namespace::modelfc638a850cf_poisson_inverseGaussian; RNG_t = boost::random::additive_combine_engine<boost::random::linear_congruential_engine<unsigned int, 40014, 0, 2147483563>, boost::random::linear_congruential_engine<unsigned int, 40692, 0, 2147483399> >; SEXP = SEXPREC*]’
filefc649e8a84b.cpp:691:152:   required from here
filefc649e8a84b.cpp:90:153: error: no matching function for call to ‘poisson_inverse_gaussian_log_original_lpmf(int, const double&, const double&, const double&, std::ostream*&)’
             stan::math::assign(prob, ((exp_mu * pow((1 + exp_mu_beta_tau_exp_mu_2),-(0.5))) * stan::math::exp(poisson_inverse_gaussian_log_original_lpmf(0,mu,beta,tau, pstream__))));
                                                                                                               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
filefc649e8a84b.cpp:39:1: note: candidate: ‘template<bool propto, class T1__, class T2__, class T3__> typename boost::math::tools::promote_args<T_y, T_dof, T_scale>::type modelfc638a850cf_poisson_inverseGaussian_namespace::poisson_inverse_gaussian_log_original_lpmf(const int&, const T1__&, const T2__&, const T3__&, std::ostream*)’
 poisson_inverse_gaussian_log_original_lpmf(const int& y,
 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
filefc649e8a84b.cpp:39:1: note:   template argument deduction/substitution failed:
filefc649e8a84b.cpp:90:153: note:   couldn't deduce template parameter ‘propto’
             stan::math::assign(prob, ((exp_mu * pow((1 + exp_mu_beta_tau_exp_mu_2),-(0.5))) * stan::math::exp(poisson_inverse_gaussian_log_original_lpmf(0,mu,beta,tau, pstream__))));
                                                                                                               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
filefc649e8a84b.cpp:93:186: error: no matching function for call to ‘poisson_inverse_gaussian_log_original_lpmf(int, const double&, const double&, const double&, std::ostream*&)’
         stan::math::assign(prob, ((((exp_mu_beta_tau_exp_mu_2 / (1 + exp_mu_beta_tau_exp_mu_2)) * (1.0 - (3.0 / (2.0 * y)))) * stan::math::exp(poisson_inverse_gaussian_log_original_lpmf((y - 1),mu,beta,tau, pstream__))) + (((pow(exp_mu,2) / (1 + exp_mu_beta_tau_exp_mu_2)) / (y * (y - 1))) * stan::math::exp(poisson_inverse_gaussian_log_original_lpmf((y - 2),mu,beta,tau, pstream__)))));
                                                                                                                                                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
filefc649e8a84b.cpp:39:1: note: candidate: ‘template<bool propto, class T1__, class T2__, class T3__> typename boost::math::tools::promote_args<T_y, T_dof, T_scale>::type modelfc638a850cf_poisson_inverseGaussian_namespace::poisson_inverse_gaussian_log_original_lpmf(const int&, const T1__&, const T2__&, const T3__&, std::ostream*)’
 poisson_inverse_gaussian_log_original_lpmf(const int& y,
 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
filefc649e8a84b.cpp:39:1: note:   template argument deduction/substitution failed:
filefc649e8a84b.cpp:93:186: note:   couldn't deduce template parameter ‘propto’
         stan::math::assign(prob, ((((exp_mu_beta_tau_exp_mu_2 / (1 + exp_mu_beta_tau_exp_mu_2)) * (1.0 - (3.0 / (2.0 * y)))) * stan::math::exp(poisson_inverse_gaussian_log_original_lpmf((y - 1),mu,beta,tau, pstream__))) + (((pow(exp_mu,2) / (1 + exp_mu_beta_tau_exp_mu_2)) / (y * (y - 1))) * stan::math::exp(poisson_inverse_gaussian_log_original_lpmf((y - 2),mu,beta,tau, pstream__)))));
                                                                                                                                                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
filefc649e8a84b.cpp:93:351: error: no matching function for call to ‘poisson_inverse_gaussian_log_original_lpmf(int, const double&, const double&, const double&, std::ostream*&)’
         stan::math::assign(prob, ((((exp_mu_beta_tau_exp_mu_2 / (1 + exp_mu_beta_tau_exp_mu_2)) * (1.0 - (3.0 / (2.0 * y)))) * stan::math::exp(poisson_inverse_gaussian_log_original_lpmf((y - 1),mu,beta,tau, pstream__))) + (((pow(exp_mu,2) / (1 + exp_mu_beta_tau_exp_mu_2)) / (y * (y - 1))) * stan::math::exp(poisson_inverse_gaussian_log_original_lpmf((y - 2),mu,beta,tau, pstream__)))));
                                                                                                                                                                                                                                                                                                                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
filefc649e8a84b.cpp:39:1: note: candidate: ‘template<bool propto, class T1__, class T2__, class T3__> typename boost::math::tools::promote_args<T_y, T_dof, T_scale>::type modelfc638a850cf_poisson_inverseGaussian_namespace::poisson_inverse_gaussian_log_original_lpmf(const int&, const T1__&, const T2__&, const T3__&, std::ostream*)’
 poisson_inverse_gaussian_log_original_lpmf(const int& y,
 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
filefc649e8a84b.cpp:39:1: note:   template argument deduction/substitution failed:
filefc649e8a84b.cpp:93:351: note:   couldn't deduce template parameter ‘propto’
         stan::math::assign(prob, ((((exp_mu_beta_tau_exp_mu_2 / (1 + exp_mu_beta_tau_exp_mu_2)) * (1.0 - (3.0 / (2.0 * y)))) * stan::math::exp(poisson_inverse_gaussian_log_original_lpmf((y - 1),mu,beta,tau, pstream__))) + (((pow(exp_mu,2) / (1 + exp_mu_beta_tau_exp_mu_2)) / (y * (y - 1))) * stan::math::exp(poisson_inverse_gaussian_log_original_lpmf((y - 2),mu,beta,tau, pstream__)))));
                                                                                                                                                                                                                                                                                                                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
make: *** [filefc649e8a84b.o] Error 1

ERROR(s) during compilation: source code errors or compiler configuration errors!

Program source:
  1: 
  2: // includes from the plugin
  3: // [[Rcpp::plugins(cpp14)]]
  4: 
  5: // user includes
  6: #define STAN__SERVICES__COMMAND_HPP// Code generated by Stan version 2.18.0
  7: 
  8: #include <stan/model/model_header.hpp>
  9: 
 10: namespace modelfc638a850cf_poisson_inverseGaussian_namespace {
 11: 
 12: using std::istream;
 13: using std::string;
 14: using std::stringstream;
 15: using std::vector;
 16: using stan::io::dump;
 17: using stan::math::lgamma;
 18: using stan::model::prob_grad;
 19: using namespace stan::math;
 20: 
 21: static int current_statement_begin__;
 22: 
 23: stan::io::program_reader prog_reader__() {
 24:     stan::io::program_reader reader;
 25:     reader.add_event(0, 0, "start", "modelfc638a850cf_poisson_inverseGaussian");
 26:     reader.add_event(172, 170, "end", "modelfc638a850cf_poisson_inverseGaussian");
 27:     return reader;
 28: }
 29: 
 30: template <bool propto, typename T1__, typename T2__, typename T3__>
 31: typename boost::math::tools::promote_args<T1__, T2__, T3__>::type
 32: poisson_inverse_gaussian_log_original_lpmf(const int& y,
 33:                                                const T1__& mu,
 34:                                                const T2__& beta,
 35:                                                const T3__& tau, std::ostream* pstream__);
 36: 
 37: template <bool propto, typename T1__, typename T2__, typename T3__>
 38: typename boost::math::tools::promote_args<T1__, T2__, T3__>::type
 39: poisson_inverse_gaussian_log_original_lpmf(const int& y,
 40:                                                const T1__& mu,
 41:                                                const T2__& beta,
 42:                                                const T3__& tau, std::ostream* pstream__) {
 43:     typedef typename boost::math::tools::promote_args<T1__, T2__, T3__>::type local_scalar_t__;
 44:     typedef local_scalar_t__ fun_return_scalar_t__;
 45:     const static bool propto__ = true;
 46:     (void) propto__;
 47:         local_scalar_t__ DUMMY_VAR__(std::numeric_limits<double>::quiet_NaN());
 48:         (void) DUMMY_VAR__;  // suppress unused var warning
 49: 
 50:     int current_statement_begin__ = -1;
 51:     try {
 52:         {
 53:         current_statement_begin__ = 38;
 54:         local_scalar_t__ exp_mu;
 55:         (void) exp_mu;  // dummy to suppress unused var warning
 56: 
 57:         stan::math::initialize(exp_mu, DUMMY_VAR__);
 58:         stan::math::fill(exp_mu,DUMMY_VAR__);
 59:         stan::math::assign(exp_mu,stan::math::exp(mu));
 60:         current_statement_begin__ = 39;
 61:         local_scalar_t__ exp_mu_beta_tau;
 62:         (void) exp_mu_beta_tau;  // dummy to suppress unused var warning
 63: 
 64:         stan::math::initialize(exp_mu_beta_tau, DUMMY_VAR__);
 65:         stan::math::fill(exp_mu_beta_tau,DUMMY_VAR__);
 66:         stan::math::assign(exp_mu_beta_tau,((exp_mu * beta) + tau));
 67:         current_statement_begin__ = 40;
 68:         local_scalar_t__ exp_mu_beta_tau_exp_mu_2;
 69:         (void) exp_mu_beta_tau_exp_mu_2;  // dummy to suppress unused var warning
 70: 
 71:         stan::math::initialize(exp_mu_beta_tau_exp_mu_2, DUMMY_VAR__);
 72:         stan::math::fill(exp_mu_beta_tau_exp_mu_2,DUMMY_VAR__);
 73:         stan::math::assign(exp_mu_beta_tau_exp_mu_2,((exp_mu_beta_tau * exp_mu) * 2.0));
 74:         current_statement_begin__ = 41;
 75:         local_scalar_t__ prob;
 76:         (void) prob;  // dummy to suppress unused var warning
 77: 
 78:         stan::math::initialize(prob, DUMMY_VAR__);
 79:         stan::math::fill(prob,DUMMY_VAR__);
 80: 
 81: 

...

581: 
582:     template <typename RNG>
583:     void write_array(RNG& base_rng,
584:                      Eigen::Matrix<double,Eigen::Dynamic,1>& params_r,
585:                      Eigen::Matrix<double,Eigen::Dynamic,1>& vars,
586:                      bool include_tparams = true,
587:                      bool include_gqs = true,
588:                      std::ostream* pstream = 0) const {
589:       std::vector<double> params_r_vec(params_r.size());
590:       for (int i = 0; i < params_r.size(); ++i)
591:         params_r_vec[i] = params_r(i);
592:       std::vector<double> vars_vec;
593:       std::vector<int> params_i_vec;
594:       write_array(base_rng,params_r_vec,params_i_vec,vars_vec,include_tparams,include_gqs,pstream);
595:       vars.resize(vars_vec.size());
596:       for (int i = 0; i < vars.size(); ++i)
597:         vars(i) = vars_vec[i];
598:     }
599: 
600:     static std::string model_name() {
601:         return "modelfc638a850cf_poisson_inverseGaussian";
602:     }
603: 
604: 
605:     void constrained_param_names(std::vector<std::string>& param_names__,
606:                                  bool include_tparams__ = true,
607:                                  bool include_gqs__ = true) const {
608:         std::stringstream param_name_stream__;
609:         param_name_stream__.str(std::string());
610:         param_name_stream__ << "lambda_mu";
611:         param_names__.push_back(param_name_stream__.str());
612:         param_name_stream__.str(std::string());
613:         param_name_stream__ << "lambda_sigma_raw";
614:         param_names__.push_back(param_name_stream__.str());
615:         param_name_stream__.str(std::string());
616:         param_name_stream__ << "sigma";
617:         param_names__.push_back(param_name_stream__.str());
618:         param_name_stream__.str(std::string());
619:         param_name_stream__ << "tau";
620:         param_names__.push_back(param_name_stream__.str());
621:         for (int k_0__ = 1; k_0__ <= G; ++k_0__) {
622:             param_name_stream__.str(std::string());
623:             param_name_stream__ << "lambda" << '.' << k_0__;
624:             param_names__.push_back(param_name_stream__.str());
625:         }
626: 
627:         if (!include_gqs__ && !include_tparams__) return;
628: 
629:         if (include_tparams__) {
630:             param_name_stream__.str(std::string());
631:             param_name_stream__ << "lambda_sigma";
632:             param_names__.push_back(param_name_stream__.str());
633:         }
634: 
635: 
636:         if (!include_gqs__) return;
637:     }
638: 
639: 
640:     void unconstrained_param_names(std::vector<std::string>& param_names__,
641:                                    bool include_tparams__ = true,
642:                                    bool include_gqs__ = true) const {
643:         std::stringstream param_name_stream__;
644:         param_name_stream__.str(std::string());
645:         param_name_stream__ << "lambda_mu";
646:         param_names__.push_back(param_name_stream__.str());
647:         param_name_stream__.str(std::string());
648:         param_name_stream__ << "lambda_sigma_raw";
649:         param_names__.push_back(param_name_stream__.str());
650:         param_name_stream__.str(std::string());
651:         param_name_stream__ << "sigma";
652:         param_names__.push_back(param_name_stream__.str());
653:         param_name_stream__.str(std::string());
654:         param_name_stream__ << "tau";
655:         param_names__.push_back(param_name_stream__.str());
656:         for (int k_0__ = 1; k_0__ <= G; ++k_0__) {
657:             param_name_stream__.str(std::string());
658:             param_name_stream__ << "lambda" << '.' << k_0__;
659:             param_names__.push_back(param_name_stream__.str());
660:         }
661: 
662:         if (!include_gqs__ && !include_tparams__) return;
663: 
664:         if (include_tparams__) {
665:             param_name_stream__.str(std::string());
666:             param_name_stream__ << "lambda_sigma";
667:             param_names__.push_back(param_name_stream__.str());
668:         }
669: 
670: 
671:         if (!include_gqs__) return;
672:     }
673: 
674: }; // model
675: 
676: }
677: 
678: typedef modelfc638a850cf_poisson_inverseGaussian_namespace::modelfc638a850cf_poisson_inverseGaussian stan_model;
679: 
680: #include <rstan/rstaninc.hpp>
681: /**
682:  * Define Rcpp Module to expose stan_fit's functions to R.
683:  */
684: RCPP_MODULE(stan_fit4modelfc638a850cf_poisson_inverseGaussian_mod){
685:   Rcpp::class_<rstan::stan_fit<modelfc638a850cf_poisson_inverseGaussian_namespace::modelfc638a850cf_poisson_inverseGaussian,
686:                boost::random::ecuyer1988> >("stan_fit4modelfc638a850cf_poisson_inverseGaussian")
687:     // .constructor<Rcpp::List>()
688:     .constructor<SEXP, SEXP, SEXP>()
689:     // .constructor<SEXP, SEXP>()
690:     .method("call_sampler",
691:             &rstan::stan_fit<modelfc638a850cf_poisson_inverseGaussian_namespace::modelfc638a850cf_poisson_inverseGaussian, boost::random::ecuyer1988>::call_sampler)
692:     .method("param_names",
693:             &rstan::stan_fit<modelfc638a850cf_poisson_inverseGaussian_namespace::modelfc638a850cf_poisson_inverseGaussian, boost::random::ecuyer1988>::param_names)
694:     .method("param_names_oi",
695:             &rstan::stan_fit<modelfc638a850cf_poisson_inverseGaussian_namespace::modelfc638a850cf_poisson_inverseGaussian, boost::random::ecuyer1988>::param_names_oi)
696:     .method("param_fnames_oi",
697:             &rstan::stan_fit<modelfc638a850cf_poisson_inverseGaussian_namespace::modelfc638a850cf_poisson_inverseGaussian, boost::random::ecuyer1988>::param_fnames_oi)
698:     .method("param_dims",
699:             &rstan::stan_fit<modelfc638a850cf_poisson_inverseGaussian_namespace::modelfc638a850cf_poisson_inverseGaussian, boost::random::ecuyer1988>::param_dims)
700:     .method("param_dims_oi",
701:             &rstan::stan_fit<modelfc638a850cf_poisson_inverseGaussian_namespace::modelfc638a850cf_poisson_inverseGaussian, boost::random::ecuyer1988>::param_dims_oi)
702:     .method("update_param_oi",
703:             &rstan::stan_fit<modelfc638a850cf_poisson_inverseGaussian_namespace::modelfc638a850cf_poisson_inverseGaussian, boost::random::ecuyer1988>::update_param_oi)
704:     .method("param_oi_tidx",
705:             &rstan::stan_fit<modelfc638a850cf_poisson_inverseGaussian_namespace::modelfc638a850cf_poisson_inverseGaussian, boost::random::ecuyer1988>::param_oi_tidx)
706:     .method("grad_log_prob",
707:             &rstan::stan_fit<modelfc638a850cf_poisson_inverseGaussian_namespace::modelfc638a850cf_poisson_inverseGaussian, boost::random::ecuyer1988>::grad_log_prob)
708:     .method("log_prob",
709:             &rstan::stan_fit<modelfc638a850cf_poisson_inverseGaussian_namespace::modelfc638a850cf_poisson_inverseGaussian, boost::random::ecuyer1988>::log_prob)
710:     .method("unconstrain_pars",
711:             &rstan::stan_fit<modelfc638a850cf_poisson_inverseGaussian_namespace::modelfc638a850cf_poisson_inverseGaussian, boost::random::ecuyer1988>::unconstrain_pars)
712:     .method("constrain_pars",
713:             &rstan::stan_fit<modelfc638a850cf_poisson_inverseGaussian_namespace::modelfc638a850cf_poisson_inverseGaussian, boost::random::ecuyer1988>::constrain_pars)
714:     .method("num_pars_unconstrained",
715:             &rstan::stan_fit<modelfc638a850cf_poisson_inverseGaussian_namespace::modelfc638a850cf_poisson_inverseGaussian, boost::random::ecuyer1988>::num_pars_unconstrained)
716:     .method("unconstrained_param_names",
717:             &rstan::stan_fit<modelfc638a850cf_poisson_inverseGaussian_namespace::modelfc638a850cf_poisson_inverseGaussian, boost::random::ecuyer1988>::unconstrained_param_names)
718:     .method("constrained_param_names",
719:             &rstan::stan_fit<modelfc638a850cf_poisson_inverseGaussian_namespace::modelfc638a850cf_poisson_inverseGaussian, boost::random::ecuyer1988>::constrained_param_names)
720:     .method("standalone_gqs",
721:             &rstan::stan_fit<modelfc638a850cf_poisson_inverseGaussian_namespace::modelfc638a850cf_poisson_inverseGaussian, boost::random::ecuyer1988>::standalone_gqs)
722:   ;
723: }
724: 
725: // declarations
726: extern "C" {
727: SEXP filefc649e8a84b( ) ;
728: }
729: 
730: // definition
731: 
732: SEXP filefc649e8a84b(  ){
733:  return Rcpp::wrap("poisson_inverseGaussian");
734: }
735: 
736: 
Error in compileCode(f, code, language = language, verbose = verbose) : 
  Compilation ERROR, function(s)/method(s) not created! In file included from /wehisan/general/system/bioinf-software/bioinfsoftware/R/R-3.5.1/lib64/R/library/BH/include/boost/smart_ptr/shared_ptr.hpp:28,
                 from /wehisan/general/system/bioinf-software/bioinfsoftware/R/R-3.5.1/lib64/R/library/BH/include/boost/shared_ptr.hpp:17,
                 from /wehisan/general/system/bioinf-software/bioinfsoftware/R/R-3.5.1/lib64/R/library/StanHeaders/include/stan/math/prim/mat/fun/LDLT_factor.hpp:7,
                 from /wehisan/general/system/bioinf-software/bioinfsoftware/R/R-3.5.1/lib64/R/library/StanHeaders/include/stan/math/prim/mat/err/check_ldlt_factor.hpp:6,
                 from /wehisan/general/system/bioinf-software/bioinfsoftware/R/R-3.5.1/lib64/R/library/StanHeaders/include/stan/math/prim/mat.hpp:33,
                 from /wehisan/general/system/bioinf-software/bioinfsoftware/R/R-3.5.1/lib64/R/library/StanHeaders/include/stan/math/rev/mat.hpp:12,
             
In addition: Warning message:
In system(cmd, intern = !verbose) :
  running command '/usr/local/bioinfsoftware/R/R-3.5.1/lib64/R/bin/R CMD SHLIB filefc649e8a84b.cpp 2> filefc649e8a84b.cpp.err.txt' had status 1


the model

functions{
  	
real poisson_inverse_gaussian_log_original_lpmf(int y, real mu, real beta, real tau);

  	real poisson_inverse_gaussian_log_original_lpmf(int y, real mu, real beta, real tau) {

  	  real exp_mu = exp(mu);
  	  real exp_mu_beta_tau = exp_mu*beta+tau;
  	  real exp_mu_beta_tau_exp_mu_2 = exp_mu_beta_tau*exp_mu*2.0;
  	  real prob;

      if(y==0) prob =
        exp(1/exp_mu_beta_tau*(1-(1+exp_mu_beta_tau_exp_mu_2)^0.5));

      if(y==1) prob =
        exp_mu*(1+exp_mu_beta_tau_exp_mu_2)^-0.5 *
        exp(poisson_inverse_gaussian_log_original_lpmf(0 | mu,beta, tau));

      prob =
        exp_mu_beta_tau_exp_mu_2 /
        (1+exp_mu_beta_tau_exp_mu_2) *
        (1. - 3. /(2.*y)) *
        exp(poisson_inverse_gaussian_log_original_lpmf(y-1 | mu,beta, tau)) +
        exp_mu^2 /
        (1+exp_mu_beta_tau_exp_mu_2) /
        (y*(y-1)) *
        exp(poisson_inverse_gaussian_log_original_lpmf(y-2 | mu,beta, tau));

      return log(prob);
    }
}
data {
  int<lower=0> N;
  int<lower=0> G;
  int<lower=0> counts[N,G];
  real my_prior[2];
  int<lower=0, upper=1> omit_data;

  // Alternative models
  int<lower=0, upper=1> is_prior_asymetric;
}
parameters {

  // Overall properties of the data
  real<lower=0> lambda_mu; // So is compatible with logGamma prior
  real<lower=0> lambda_sigma_raw;
  real<lower=0> sigma;
  real<lower=0> tau;

  // Gene-wise properties of the data
  vector[G] lambda;
}
transformed parameters {
  real<lower=0> lambda_sigma = lambda_sigma_raw;
}
model {

  // Overall properties of the data
  lambda_mu ~ gamma(3,2);
  lambda_sigma_raw ~ normal(0,1);
  sigma ~ normal(0,2);
  tau ~ normal(0,2);


  // Gene-wise properties of the data
  lambda ~ normal(lambda_mu, lambda_sigma);

  // Sample from data
  if(omit_data==0) for(n in 1:N) for(g in 1:G) counts[n,g] ~ poisson_inverse_gaussian_log_original(lambda[g], sigma, tau);

}


It looks like a bug. I am not sure if recursive functions ending in _lpmf are tested thoroughly. The error messages from clang++-7 are:

file123c6173810f.cpp:85:111: error: call to function 'poisson_inverse_gaussian_original_lpmf' that is neither visible in the template definition nor found by argument-dependent lookup
            stan::math::assign(prob, ((exp_mu * pow((1 + exp_mu_beta_tau_exp_mu_2),-(0.5))) * stan::math::exp(poisson_inverse_gaussian_original_lpmf(0,mu,beta,tau, pstream__))));
                                                                                                              ^
file123c6173810f.cpp:128:40: note: in instantiation of function template specialization 'user_448c62bcb7d21454f7c5982929b828d9::poisson_inverse_gaussian_original_lpmf<false, double, double,
      double>' requested here
user_448c62bcb7d21454f7c5982929b828d9::poisson_inverse_gaussian_original_lpmf<false, double, double, double>(y, mu, beta, tau, pstream__);
                                       ^
file123c6173810f.cpp:100:1: note: 'poisson_inverse_gaussian_original_lpmf' should be declared prior to the call site
poisson_inverse_gaussian_original_lpmf(const int& y,
^
file123c6173810f.cpp:88:144: error: call to function 'poisson_inverse_gaussian_original_lpmf' that is neither visible in the template definition nor found by argument-dependent lookup
        stan::math::assign(prob, ((((exp_mu_beta_tau_exp_mu_2 / (1 + exp_mu_beta_tau_exp_mu_2)) * (1.0 - (3.0 / (2.0 * y)))) * stan::math::exp(poisson_inverse_gaussian_original_lpmf...
                                                                                                                                               ^
file123c6173810f.cpp:100:1: note: 'poisson_inverse_gaussian_original_lpmf' should be declared prior to the call site
poisson_inverse_gaussian_original_lpmf(const int& y,
^
file123c6173810f.cpp:88:305: error: call to function 'poisson_inverse_gaussian_original_lpmf' that is neither visible in the template definition nor found by argument-dependent lookup
  ...- 1),mu,beta,tau, pstream__))) + (((pow(exp_mu,2) / (1 + exp_mu_beta_tau_exp_mu_2)) / (y * (y - 1))) * stan::math::exp(poisson_inverse_gaussian_original_lpmf((y - 2),mu,beta,tau, ps...
                                                                                                                            ^
file123c6173810f.cpp:100:1: note: 'poisson_inverse_gaussian_original_lpmf' should be declared prior to the call site
poisson_inverse_gaussian_original_lpmf(const int& y,
^

You can work around this problem by changing poisson_inverse_gaussian_log_original_lpmf to poisson_inverse_gaussian_log_original, changing all the vertical bars to commas, and changing the last line to target += poisson_inverse_gaussian_log_original(counts[n,g], lambda[g], sigma, tau);. However, I don’t think your function is right to begin with. You have

real prob;
if (y == 0) prob = ...;
if (y == 1) prob = ...;
prob = ...;
return log(prob);

For starters, this will always do the calculation for the y > 1 case even if y is zero or one. You should be returning early in those two cases. Additionally, in the case where y is zero or one, you should be calculating the log-probability analytically by simplifying rather than calculating the probability and then taking its logarithm. Finally, I would guess it is true that you could calculate the y > 1 case, using log_sum_exp for much better numerical stability.

1 Like

looking into this now.

1 Like

minimal example of a recursive lpmf function which tickles this bug:

functions {
  real fib_lpmf(int n, real y);
  real fib_lpmf(int n, real y) {
    real prob;
    if (n <= 2)
      prob =  1.0;
    else
      prob = fib_lpmf(n - 1 | y) + fib_lpmf(n - 2 | y);
    return prob;
  }
}
transformed data {
  int n = 5;
}
parameters {
  real y;
}
model {
  y ~ normal(0,1);
  n ~ fib(y);
}

yes it’s a bug, don’t have a fix yet - continuing discussion here: