Stan 1.0.2 model compilation error

83 views
Skip to first unread message

Marcel Falkiewicz

unread,
Sep 30, 2012, 1:40:21 PM9/30/12
to stan-...@googlegroups.com
Hello,
I've recently upgraded STAN to 1.0.2 and tried to re-run the same
models I was succesfully running on 1.0.1. Unfortunately, this time
the model compilation ended with an error, despite being exactly the
same as before. You will find the data, model and R code that produces
the error attached. The output of the compiler on my machine is
attached in error.txt file. I would be greatful for any tips how to
fix this:)

Cheers,
Marcel
error.txt
data.Rda
reproduce_error.R
SDT_single.stan

FUKAYA Keiichi

unread,
Sep 30, 2012, 2:28:59 PM9/30/12
to stan-...@googlegroups.com
Hi Marcel,

I've had a same experience. You might try installing Stan once again
-- it fixed the problem in my case.

Regards,
Keiichi


2012/10/1 Marcel Falkiewicz <mfalk...@gmail.com>:
----
Keiichi FUKAYA, Ph.D.
Faculty of Environmental Science
Hokkaido University

Ben Goodrich

unread,
Sep 30, 2012, 2:49:48 PM9/30/12
to stan-...@googlegroups.com
Your example works for me. Just to be clear, have you installed rstan 1.0.2 ? Also, I would recommend restarting R afterwards.

Ben


TRANSLATING MODEL 'SDT_single' FROM Stan CODE TO C++ CODE NOW.
COMPILING THE C++ CODE FOR MODEL 'SDT_single' NOW.
cygwin warning:
  MS-DOS style path detected: C:/R/R-215~1.1/etc/x64/Makeconf
  Preferred POSIX equivalent is: /cygdrive/c/R/R-215~1.1/etc/x64/Makeconf
  CYGWIN environment variable option "nodosfilewarning" turns off this warning.
  Consult the user's guide for more details about POSIX paths:
    http://cygwin.com/cygwin-ug-net/using.html#using-pathnames
In file included from C:/R/R-2.15.1/library/rstan/include//stansrc/stan/model/model_header.hpp:18:0,
                 from file129cd8a321b.cpp:9:
C:/R/R-2.15.1/library/rstan/include//stansrc/stan/agrad/matrix.hpp: In static member function 'static double stan::agrad::{anonymous}::dot_product_vv_vari::var_dot(stan::agrad::vari**, stan::agrad::vari**, std::size_t)':
C:/R/R-2.15.1/library/rstan/include//stansrc/stan/agrad/matrix.hpp:689:31: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
In file included from C:/R/R-2.15.1/library/rstan/include/rstan/rstaninc.hpp:4:0,
                 from file129cd8a321b.cpp:6:
C:/R/R-2.15.1/library/rstan/include/rstan/stan_fit.hpp: At global scope:
C:/R/R-2.15.1/library/rstan/include/rstan/stan_fit.hpp: In instantiation of 'rstan::stan_fit<stan_fit129c5caaa12_SDT_single_namespace::stan_fit129c5caaa12_SDT_single, boost::random::additive_combine_engine<boost::random::linear_congruential_engine<unsigned int, 40014u, 0u, 2147483563u>, boost::random::linear_congruential_engine<unsigned int, 40692u, 0u, 2147483399u> > >':
file129cd8a321b.cpp:402:130:   instantiated from here
C:/R/R-2.15.1/library/rstan/include/rstan/stan_fit.hpp:596:11: error: cannot declare field 'rstan::stan_fit<stan_fit129c5caaa12_SDT_single_namespace::stan_fit129c5caaa12_SDT_single, boost::random::additive_combine_engine<boost::random::linear_congruential_engine<unsigned int, 40014u, 0u, 2147483563u>, boost::random::linear_congruential_engine<unsigned int, 40692u, 0u, 2147483399u> > >::model_' to be of abstract type 'stan_fit129c5caaa12_SDT_single_namespace::stan_fit129c5caaa12_SDT_single'
file129cd8a321b.cpp:32:7: note:   because the following virtual functions are pure within 'stan_fit129c5caaa12_SDT_single_namespace::stan_fit129c5caaa12_SDT_single':
C:/R/R-2.15.1/library/rstan/include//stansrc/stan/model/prob_grad_ad.hpp:31:26: note:         virtual stan::agrad::var stan::model::prob_grad_ad::log_prob(std::vector<stan::agrad::var>&, std::vector<int>&, std::ostream*)
C:/R/R-2.15.1/library/rstan/include/rstan/stan_fit.hpp: In function 'void rstan::{anonymous}::sample_from(Sampler&, bool, int, int, int, int, std::ostream&, bool, std::vector<double>&, std::vector<int>&, Model&, std::vector<Rcpp::Vector<14> >&, std::size_t, const std::vector<long long unsigned int>&, std::vector<Rcpp::Vector<14> >&, std::string&) [with Sampler = stan::mcmc::nuts_diag<boost::random::additive_combine_engine<boost::random::linear_congruential_engine<unsigned int, 40014u, 0u, 2147483563u>, boost::random::linear_congruential_engine<unsigned int, 40692u, 0u, 2147483399u> > >, Model = stan_fit129c5caaa12_SDT_single_namespace::stan_fit129c5caaa12_SDT_single, std::ostream = std::basic_ostream<char>, std::size_t = long long unsigned int, std::string = std::basic_string<char>]':
C:/R/R-2.15.1/library/rstan/include/rstan/stan_fit.hpp:519:9:   instantiated from 'int rstan::{anonymous}::sampler_command(const rstan::io::rlist_ref_var_context&, rstan::stan_args&, Model&, std::vector<Rcpp::Vector<14> >&, std::vector<double>&, unsigned int, const std::vector<long long unsigned int>&, std::vector<std::basic_string<char> >&, std::vector<Rcpp::Vector<14> >&, std::string&) [with Model = stan_fit129c5caaa12_SDT_single_namespace::stan_fit129c5caaa12_SDT_single, std::string = std::basic_string<char>]'
C:/R/R-2.15.1/library/rstan/include/rstan/stan_fit.hpp:707:7:   instantiated from 'SEXPREC* rstan::stan_fit<Model, RNG>::call_sampler(SEXP) [with Model = stan_fit129c5caaa12_SDT_single_namespace::stan_fit129c5caaa12_SDT_single, RNG = boost::random::additive_combine_engine<boost::random::linear_congruential_engine<unsigned int, 40014u, 0u, 2147483563u>, boost::random::linear_congruential_engine<unsigned int, 40692u, 0u, 2147483399u> >, SEXP = SEXPREC*]'
file129cd8a321b.cpp:402:132:   instantiated from here
C:/R/R-2.15.1/library/rstan/include/rstan/stan_fit.hpp:355:9: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
C:/R/R-2.15.1/library/rstan/include/rstan/stan_fit.hpp: In function 'void rstan::{anonymous}::sample_from(Sampler&, bool, int, int, int, int, std::ostream&, bool, std::vector<double>&, std::vector<int>&, Model&, std::vector<Rcpp::Vector<14> >&, std::size_t, const std::vector<long long unsigned int>&, std::vector<Rcpp::Vector<14> >&, std::string&) [with Sampler = stan::mcmc::nuts<boost::random::additive_combine_engine<boost::random::linear_congruential_engine<unsigned int, 40014u, 0u, 2147483563u>, boost::random::linear_congruential_engine<unsigned int, 40692u, 0u, 2147483399u> > >, Model = stan_fit129c5caaa12_SDT_single_namespace::stan_fit129c5caaa12_SDT_single, std::ostream = std::basic_ostream<char>, std::size_t = long long unsigned int, std::string = std::basic_string<char>]':
C:/R/R-2.15.1/library/rstan/include/rstan/stan_fit.hpp:545:9:   instantiated from 'int rstan::{anonymous}::sampler_command(const rstan::io::rlist_ref_var_context&, rstan::stan_args&, Model&, std::vector<Rcpp::Vector<14> >&, std::vector<double>&, unsigned int, const std::vector<long long unsigned int>&, std::vector<std::basic_string<char> >&, std::vector<Rcpp::Vector<14> >&, std::string&) [with Model = stan_fit129c5caaa12_SDT_single_namespace::stan_fit129c5caaa12_SDT_single, std::string = std::basic_string<char>]'
C:/R/R-2.15.1/library/rstan/include/rstan/stan_fit.hpp:707:7:   instantiated from 'SEXPREC* rstan::stan_fit<Model, RNG>::call_sampler(SEXP) [with Model = stan_fit129c5caaa12_SDT_single_namespace::stan_fit129c5caaa12_SDT_single, RNG = boost::random::additive_combine_engine<boost::random::linear_congruential_engine<unsigned int, 40014u, 0u, 2147483563u>, boost::random::linear_congruential_engine<unsigned int, 40692u, 0u, 2147483399u> >, SEXP = SEXPREC*]'
file129cd8a321b.cpp:402:132:   instantiated from here
C:/R/R-2.15.1/library/rstan/include/rstan/stan_fit.hpp:355:9: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
C:/R/R-2.15.1/library/rstan/include/rstan/stan_fit.hpp: In function 'void rstan::{anonymous}::sample_from(Sampler&, bool, int, int, int, int, std::ostream&, bool, std::vector<double>&, std::vector<int>&, Model&, std::vector<Rcpp::Vector<14> >&, std::size_t, const std::vector<long long unsigned int>&, std::vector<Rcpp::Vector<14> >&, std::string&) [with Sampler = stan::mcmc::adaptive_hmc<boost::random::additive_combine_engine<boost::random::linear_congruential_engine<unsigned int, 40014u, 0u, 2147483563u>, boost::random::linear_congruential_engine<unsigned int, 40692u, 0u, 2147483399u> > >, Model = stan_fit129c5caaa12_SDT_single_namespace::stan_fit129c5caaa12_SDT_single, std::ostream = std::basic_ostream<char>, std::size_t = long long unsigned int, std::string = std::basic_string<char>]':
C:/R/R-2.15.1/library/rstan/include/rstan/stan_fit.hpp:570:9:   instantiated from 'int rstan::{anonymous}::sampler_command(const rstan::io::rlist_ref_var_context&, rstan::stan_args&, Model&, std::vector<Rcpp::Vector<14> >&, std::vector<double>&, unsigned int, const std::vector<long long unsigned int>&, std::vector<std::basic_string<char> >&, std::vector<Rcpp::Vector<14> >&, std::string&) [with Model = stan_fit129c5caaa12_SDT_single_namespace::stan_fit129c5caaa12_SDT_single, std::string = std::basic_string<char>]'
C:/R/R-2.15.1/library/rstan/include/rstan/stan_fit.hpp:707:7:   instantiated from 'SEXPREC* rstan::stan_fit<Model, RNG>::call_sampler(SEXP) [with Model = stan_fit129c5caaa12_SDT_single_namespace::stan_fit129c5caaa12_SDT_single, RNG = boost::random::additive_combine_engine<boost::random::linear_congruential_engine<unsigned int, 40014u, 0u, 2147483563u>, boost::random::linear_congruential_engine<unsigned int, 40692u, 0u, 2147483399u> >, SEXP = SEXPREC*]'
file129cd8a321b.cpp:402:132:   instantiated from here
C:/R/R-2.15.1/library/rstan/include/rstan/stan_fit.hpp:355:9: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
C:/R/R-2.15.1/library/rstan/include/rstan/stan_fit.hpp: In constructor 'rstan::stan_fit<Model, RNG>::stan_fit(SEXP, SEXP) [with Model = stan_fit129c5caaa12_SDT_single_namespace::stan_fit129c5caaa12_SDT_single, RNG = boost::random::additive_combine_engine<boost::random::linear_congruential_engine<unsigned int, 40014u, 0u, 2147483563u>, boost::random::linear_congruential_engine<unsigned int, 40692u, 0u, 2147483399u> >, SEXP = SEXPREC*]':
C:/R/R-2.15.1/library/Rcpp/include/Rcpp/module/Module_generated_Constructor.h:60:13:   instantiated from 'Class* Rcpp::Constructor_2<Class, U0, U1>::get_new(SEXPREC**, int) [with Class = rstan::stan_fit<stan_fit129c5caaa12_SDT_single_namespace::stan_fit129c5caaa12_SDT_single, boost::random::additive_combine_engine<boost::random::linear_congruential_engine<unsigned int, 40014u, 0u, 2147483563u>, boost::random::linear_congruential_engine<unsigned int, 40692u, 0u, 2147483399u> > >, U0 = SEXPREC*, U1 = SEXPREC*, SEXP = SEXPREC*]'
file129cd8a321b.cpp:432:1:   instantiated from here
C:/R/R-2.15.1/library/rstan/include/rstan/stan_fit.hpp:667:47: error: no matching function for call to 'stan_fit129c5caaa12_SDT_single_namespace::stan_fit129c5caaa12_SDT_single::stan_fit129c5caaa12_SDT_single(rstan::io::rlist_ref_var_context&, rstan::io::r_ostream<rstan::io::r_cout_streambuf>*)'
C:/R/R-2.15.1/library/rstan/include/rstan/stan_fit.hpp:667:47: note: candidates are:
file129cd8a321b.cpp:40:5: note: stan_fit129c5caaa12_SDT_single_namespace::stan_fit129c5caaa12_SDT_single::stan_fit129c5caaa12_SDT_single(stan::io::var_context&)
file129cd8a321b.cpp:40:5: note:   candidate expects 1 argument, 2 provided
file129cd8a321b.cpp:32:7: note: stan_fit129c5caaa12_SDT_single_namespace::stan_fit129c5caaa12_SDT_single::stan_fit129c5caaa12_SDT_single(const stan_fit129c5caaa12_SDT_single_namespace::stan_fit129c5caaa12_SDT_single&)
file129cd8a321b.cpp:32:7: note:   candidate expects 1 argument, 2 provided
C:/R/R-2.15.1/library/rstan/include/rstan/stan_fit.hpp: In constructor 'rstan::stan_fit<Model, RNG>::stan_fit(SEXP) [with Model = stan_fit129c5caaa12_SDT_single_namespace::stan_fit129c5caaa12_SDT_single, RNG = boost::random::additive_combine_engine<boost::random::linear_congruential_engine<unsigned int, 40014u, 0u, 2147483563u>, boost::random::linear_congruential_engine<unsigned int, 40692u, 0u, 2147483399u> >, SEXP = SEXPREC*]':
C:/R/R-2.15.1/library/Rcpp/include/Rcpp/module/Module_generated_Constructor.h:47:43:   instantiated from 'Class* Rcpp::Constructor_1<Class, U0>::get_new(SEXPREC**, int) [with Class = rstan::stan_fit<stan_fit129c5caaa12_SDT_single_namespace::stan_fit129c5caaa12_SDT_single, boost::random::additive_combine_engine<boost::random::linear_congruential_engine<unsigned int, 40014u, 0u, 2147483563u>, boost::random::linear_congruential_engine<unsigned int, 40692u, 0u, 2147483399u> > >, U0 = SEXPREC*, SEXP = SEXPREC*]'
file129cd8a321b.cpp:432:1:   instantiated from here
C:/R/R-2.15.1/library/rstan/include/rstan/stan_fit.hpp:680:31: error: no matching function for call to 'stan_fit129c5caaa12_SDT_single_namespace::stan_fit129c5caaa12_SDT_single::stan_fit129c5caaa12_SDT_single(rstan::io::rlist_ref_var_context&, rstan::io::r_ostream<rstan::io::r_cout_streambuf>*)'
C:/R/R-2.15.1/library/rstan/include/rstan/stan_fit.hpp:680:31: note: candidates are:
file129cd8a321b.cpp:40:5: note: stan_fit129c5caaa12_SDT_single_namespace::stan_fit129c5caaa12_SDT_single::stan_fit129c5caaa12_SDT_single(stan::io::var_context&)
file129cd8a321b.cpp:40:5: note:   candidate expects 1 argument, 2 provided
file129cd8a321b.cpp:32:7: note: stan_fit129c5caaa12_SDT_single_namespace::stan_fit129c5caaa12_SDT_single::stan_fit129c5caaa12_SDT_single(const stan_fit129c5caaa12_SDT_single_namespace::stan_fit129c5caaa12_SDT_single&)
file129cd8a321b.cpp:32:7: note:   candidate expects 1 argument, 2 provided
C:/R/R-2.15.1/library/rstan/include//stansrc/stan/agrad/agrad.hpp: At global scope:
C:/R/R-2.15.1/library/rstan/include//stansrc/stan/agrad/agrad.hpp:2215:17: warning: 'void stan::agrad::free_memory()' defined but not used [-Wunused-function]
C:/R/R-2.15.1/library/rstan/include//stansrc/stan/math/special_functions.hpp:591:19: warning: 'double stan::math::log_sum_exp(const std::vector<double>&)' defined but not used [-Wunused-function]
make: *** [file129cd8a321b.o] Error 1

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

Program source:
  1:
  2: // includes from the plugin
  3:
  4:
  5: // user includes
  6: #include <rstan/rstaninc.hpp>
  7: // Code generated by Stan version 1.0
  8:
  9: #include <stan/model/model_header.hpp>
 10:
 11: namespace stan_fit129c5caaa12_SDT_single_namespace {
 12:
 13: using std::vector;
 14: using std::string;
 15: using std::stringstream;
 16: using stan::agrad::var;
 17: using stan::model::prob_grad_ad;
 18: using stan::math::get_base1;
 19: using stan::io::dump;
 20: using std::istream;
 21: using namespace stan::math;
 22: using namespace stan::prob;
 23: using namespace stan::agrad;
 24:
 25: typedef Eigen::Matrix<double,Eigen::Dynamic,1> vector_d;
 26: typedef Eigen::Matrix<double,1,Eigen::Dynamic> row_vector_d;
 27: typedef Eigen::Matrix<double,Eigen::Dynamic,Eigen::Dynamic> matrix_d;
 28: typedef Eigen::Matrix<stan::agrad::var,Eigen::Dynamic,1> vector_v;
 29: typedef Eigen::Matrix<stan::agrad::var,1,Eigen::Dynamic> row_vector_v;
 30: typedef Eigen::Matrix<stan::agrad::var,Eigen::Dynamic,Eigen::Dynamic> matrix_v;
 31:
 32: class stan_fit129c5caaa12_SDT_single : public prob_grad_ad {
 33: private:
 34:     int k;
 35:     vector<int> h;
 36:     vector<int> f;
 37:     int n;
 38:     int s;
 39: public:
 40:     stan_fit129c5caaa12_SDT_single(stan::io::var_context& context__)
 41:         : prob_grad_ad::prob_grad_ad(0) {
 42:         static const char* function__ = "stan_fit129c5caaa12_SDT_single_namespace::stan_fit129c5caaa12_SDT_single(%1%)";
 43:         (void) function__; // dummy call to supress warning
 44:         size_t pos__;
 45:         (void) pos__; // dummy call to supress warning
 46:         std::vector<int> vals_i__;
 47:         std::vector<double> vals_r__;
 48:         k = int(0);
 49:         if (!context__.contains_i("k"))
 50:             throw std::runtime_error("variable k not found.");
 51:         vals_i__ = context__.vals_i("k");
 52:         pos__ = 0;
 53:         k = vals_i__[pos__++];
 54:         h = std::vector<int>(k,int(0));
 55:         if (!context__.contains_i("h"))
 56:             throw std::runtime_error("variable h not found.");
 57:         vals_i__ = context__.vals_i("h");
 58:         pos__ = 0;
 59:         size_t h_limit_0__ = k;
 60:         for (size_t i_0__ = 0; i_0__ < h_limit_0__; ++i_0__) {
 61:             h[i_0__] = vals_i__[pos__++];
 62:         }
 63:         f = std::vector<int>(k,int(0));
 64:         if (!context__.contains_i("f"))
 65:             throw std::runtime_error("variable f not found.");
 66:         vals_i__ = context__.vals_i("f");
 67:         pos__ = 0;
 68:         size_t f_limit_0__ = k;
 69:         for (size_t i_0__ = 0; i_0__ < f_limit_0__; ++i_0__) {
 70:             f[i_0__] = vals_i__[pos__++];
 71:         }
 72:         n = int(0);
 73:         if (!context__.contains_i("n"))
 74:             throw std::runtime_error("variable n not found.");
 75:         vals_i__ = context__.vals_i("n");
 76:         pos__ = 0;
 77:         n = vals_i__[pos__++];
 78:         s = int(0);
 79:         if (!context__.contains_i("s"))
 80:             throw std::runtime_error("variable s not found.");
 81:         vals_i__ = context__.vals_i("s");
 82:         pos__ = 0;
 83:         s = vals_i__[pos__++];
 84:         // validate data
 85:         check_greater_or_equal(function__,k,1,"k");
 86:         for (int k0__ = 0; k0__ < k; ++k0__) {
 87:             check_greater_or_equal(function__,h[k0__],0,"h[k0__]");
 88:         }
 89:         for (int k0__ = 0; k0__ < k; ++k0__) {
 90:             check_greater_or_equal(function__,f[k0__],0,"f[k0__]");
 91:         }
 92:         check_greater_or_equal(function__,n,1,"n");
 93:         check_greater_or_equal(function__,s,1,"s");
 94:
 95:         // validate transformed data
 96:
 97:         set_param_ranges();
 98:     } // dump ctor
 99:
100:     void set_param_ranges() {
101:         num_params_r__ = 0U;
102:         param_ranges_i__.clear();
103:         ++num_params_r__;
104:         ++num_params_r__;
105:         ++num_params_r__;
106:         ++num_params_r__;
107:         num_params_r__ += k;
108:         num_params_r__ += k;
109:     }
110:
111:     void transform_inits(const stan::io::var_context& var_context__,
112:                          std::vector<int>& params_i__,
113:                          std::vector<double>& params_r__) {
114:         params_r__.clear();
115:         params_i__.clear();
116:         stan::io::writer<double> writer__(params_r__,params_i__);
117:         size_t pos__;
118:         std::vector<double> vals_r__;
119:         std::vector<int> vals_i__;
120:
121:
122:         if (!(var_context__.contains_r("muc")))
123:             throw std::runtime_error("variable muc missing");
124:         if (var_context__.dims_r("muc").size() != 0)
125:             throw std::runtime_error("require 0 dimensions for variable muc");
126:         vals_r__ = var_context__.vals_r("muc");
127:         pos__ = 0U;
128:         double muc(0);
129:         muc = vals_r__[pos__++];
130:         writer__.scalar_unconstrain(muc);
131:
132:         if (!(var_context__.contains_r("mud")))
133:             throw std::runtime_error("variable mud missing");
134:         if (var_context__.dims_r("mud").size() != 0)
135:             throw std::runtime_error("require 0 dimensions for variable mud");
136:         vals_r__ = var_context__.vals_r("mud");
137:         pos__ = 0U;
138:         double mud(0);
139:         mud = vals_r__[pos__++];
140:         writer__.scalar_unconstrain(mud);
141:
142:         if (!(var_context__.contains_r("sigmac")))
143:             throw std::runtime_error("variable sigmac missing");
144:         if (var_context__.dims_r("sigmac").size() != 0)
145:             throw std::runtime_error("require 0 dimensions for variable sigmac");
146:         vals_r__ = var_context__.vals_r("sigmac");
147:         pos__ = 0U;
148:         double sigmac(0);
149:         sigmac = vals_r__[pos__++];
150:         writer__.scalar_lb_unconstrain(0,sigmac);
151:
152:         if (!(var_context__.contains_r("sigmad")))
153:             throw std::runtime_error("variable sigmad missing");
154:         if (var_context__.dims_r("sigmad").size() != 0)
155:             throw std::runtime_error("require 0 dimensions for variable sigmad");
156:         vals_r__ = var_context__.vals_r("sigmad");
157:         pos__ = 0U;
158:         double sigmad(0);
159:         sigmad = vals_r__[pos__++];
160:         writer__.scalar_lb_unconstrain(0,sigmad);
161:
162:         if (!(var_context__.contains_r("c")))
163:             throw std::runtime_error("variable c missing");
164:         if (var_context__.dims_r("c").size() != 1)
165:             throw std::runtime_error("require 1 dimensions for variable c");
166:         vals_r__ = var_context__.vals_r("c");
167:         pos__ = 0U;
168:         std::vector<double> c(k,double(0));
169:         for (int i0__ = 0U; i0__ < k; ++i0__)
170:             c[i0__] = vals_r__[pos__++];
171:         for (int i0__ = 0U; i0__ < k; ++i0__)
172:             writer__.scalar_unconstrain(c[i0__]);
173:
174:         if (!(var_context__.contains_r("d")))
175:             throw std::runtime_error("variable d missing");
176:         if (var_context__.dims_r("d").size() != 1)
177:             throw std::runtime_error("require 1 dimensions for variable d");
178:         vals_r__ = var_context__.vals_r("d");
179:         pos__ = 0U;
180:         std::vector<double> d(k,double(0));
181:         for (int i0__ = 0U; i0__ < k; ++i0__)
182:             d[i0__] = vals_r__[pos__++];
183:         for (int i0__ = 0U; i0__ < k; ++i0__)
184:             writer__.scalar_lb_unconstrain(0,d[i0__]);
185:         params_r__ = writer__.data_r();
186:         params_i__ = writer__.data_i();
187:     }
188:
189:     var log_prob(vector<var>& params_r__,
190:                  vector<int>& params_i__) {
191:
192:         var lp__(0.0);
193:         // model parameters
194:         stan::io::reader<var> in__(params_r__,params_i__);
195:
196:         var muc = in__.scalar_constrain(lp__);
197:         var mud = in__.scalar_constrain(lp__);
198:         var sigmac = in__.scalar_lb_constrain(0,lp__);
199:         var sigmad = in__.scalar_lb_constrain(0,lp__);
200:         vector<var> c;
201:         size_t dim_c_0__ = k;
202:         c.reserve(dim_c_0__);
203:         for (size_t k_0__ = 0; k_0__ < dim_c_0__; ++k_0__) {
204:             c.push_back(in__.scalar_constrain(lp__));
205:         }
206:         vector<var> d;
207:         size_t dim_d_0__ = k;
208:         d.reserve(dim_d_0__);
209:         for (size_t k_0__ = 0; k_0__ < dim_d_0__; ++k_0__) {
210:             d.push_back(in__.scalar_lb_constrain(0,lp__));
211:         }
212:
213:         // transformed parameters
214:
215:         // initialized transformed params to avoid seg fault on val access
216:         var INIT_DUMMY__(std::numeric_limits<double>::quiet_NaN());
217:
218:
219:         // validate transformed parameters
220:
221:         // model body
222:         lp__ += stan::prob::normal_log<true>(muc, 0, 100);
223:         lp__ += stan::prob::normal_log<true>(mud, 0, 100);
224:         lp__ += stan::prob::cauchy_log<true>(sigmac, 0, 1);
225:         lp__ -= log1m(cauchy_cdf(0, 0, 1));
226:         lp__ += stan::prob::cauchy_log<true>(sigmad, 0, 1);
227:         lp__ -= log1m(cauchy_cdf(0, 0, 1));
228:         lp__ += stan::prob::normal_log<true>(c, muc, sigmac);
229:         lp__ += stan::prob::normal_log<true>(d, mud, sigmad);
230:         for (int i = 1; i <= k; ++i) {
231:             lp__ += stan::prob::binomial_log<true>(get_base1(h,i,"h",1), s, Phi(((get_base1(d,i,"d",1) / 2) - get_base1(c,i,"c",1))));
232:             lp__ += stan::prob::binomial_log<true>(get_base1(f,i,"f",1), n, Phi(((-(get_base1(d,i,"d",1)) / 2) - get_base1(c,i,"c",1))));
233:         }
234:
235:         return lp__;
236:
237:     } // log_prob()
238:
239:
240:     void get_param_names(std::vector<std::string>& names__) {
241:         names__.resize(0);
242:         names__.push_back("muc");
243:         names__.push_back("mud");
244:         names__.push_back("sigmac");
245:         names__.push_back("sigmad");
246:         names__.push_back("c");
247:         names__.push_back("d");
248:     }
249:
250:
251:     void get_dims(std::vector<std::vector<size_t> >& dimss__) {
252:         dimss__.resize(0);
253:         std::vector<size_t> dims__;
254:         dims__.resize(0);
255:         dimss__.push_back(dims__);
256:         dims__.resize(0);
257:         dimss__.push_back(dims__);
258:         dims__.resize(0);
259:         dimss__.push_back(dims__);
260:         dims__.resize(0);
261:         dimss__.push_back(dims__);
262:         dims__.resize(0);
263:         dims__.push_back(k);
264:         dimss__.push_back(dims__);
265:         dims__.resize(0);
266:         dims__.push_back(k);
267:         dimss__.push_back(dims__);
268:     }
269:
270:     void write_array(std::vector<double>& params_r__,
271:                      std::vector<int>& params_i__,
272:                      std::vector<double>& vars__) {
273:         vars__.resize(0);
274:         stan::io::reader<double> in__(params_r__,params_i__);
275:         static const char* function__ = "stan_fit129c5caaa12_SDT_single_namespace::write_array(%1%)";
276:         (void) function__; // dummy call to supress warning
277:         // read-transform, write parameters
278:         double muc = in__.scalar_constrain();
279:         double mud = in__.scalar_constrain();
280:         double sigmac = in__.scalar_lb_constrain(0);
281:         double sigmad = in__.scalar_lb_constrain(0);
282:         vector<double> c;
283:         size_t dim_c_0__ = k;
284:         for (size_t k_0__ = 0; k_0__ < dim_c_0__; ++k_0__) {
285:             c.push_back(in__.scalar_constrain());
286:         }
287:         vector<double> d;
288:         size_t dim_d_0__ = k;
289:         for (size_t k_0__ = 0; k_0__ < dim_d_0__; ++k_0__) {
290:             d.push_back(in__.scalar_lb_constrain(0));
291:         }
292:         vars__.push_back(muc);
293:         vars__.push_back(mud);
294:         vars__.push_back(sigmac);
295:         vars__.push_back(sigmad);
296:         for (int k_0__ = 0; k_0__ < k; ++k_0__) {
297:             vars__.push_back(c[k_0__]);
298:         }
299:         for (int k_0__ = 0; k_0__ < k; ++k_0__) {
300:             vars__.push_back(d[k_0__]);
301:         }
302:
303:         // declare and define transformed parameters
304:         double lp__ = 0.0;
305:         (void) lp__; // dummy call to supress warning
306:
307:
308:         // validate transformed parameters
309:
310:         // write transformed parameters
311:
312:         // declare and define generated quantities
313:
314:
315:         // validate generated quantities
316:
317:         // write generated quantities
318:     }
319:
320:
321:     void write_csv_header(std::ostream& o__) {
322:         stan::io::csv_writer writer__(o__);
323:         writer__.comma();
324:         o__ << "muc";
325:         writer__.comma();
326:         o__ << "mud";
327:         writer__.comma();
328:         o__ << "sigmac";
329:         writer__.comma();
330:         o__ << "sigmad";
331:         for (int k_0__ = 1; k_0__ <= k; ++k_0__) {
332:             writer__.comma();
333:             o__ << "c" << '.' << k_0__;
334:         }
335:         for (int k_0__ = 1; k_0__ <= k; ++k_0__) {
336:             writer__.comma();
337:             o__ << "d" << '.' << k_0__;
338:         }
339:         writer__.newline();
340:     }
341:
342:     void write_csv(std::vector<double>& params_r__,
343:                    std::vector<int>& params_i__,
344:                    std::ostream& o__) {
345:         stan::io::reader<double> in__(params_r__,params_i__);
346:         stan::io::csv_writer writer__(o__);
347:         static const char* function__ = "stan_fit129c5caaa12_SDT_single_namespace::write_csv(%1%)";
348:         (void) function__; // dummy call to supress warning
349:         // read-transform, write parameters
350:         double muc = in__.scalar_constrain();
351:         writer__.write(muc);
352:         double mud = in__.scalar_constrain();
353:         writer__.write(mud);
354:         double sigmac = in__.scalar_lb_constrain(0);
355:         writer__.write(sigmac);
356:         double sigmad = in__.scalar_lb_constrain(0);
357:         writer__.write(sigmad);
358:         vector<double> c;
359:         size_t dim_c_0__ = k;
360:         for (size_t k_0__ = 0; k_0__ < dim_c_0__; ++k_0__) {
361:             c.push_back(in__.scalar_constrain());
362:             writer__.write(c[k_0__]);
363:         }
364:         vector<double> d;
365:         size_t dim_d_0__ = k;
366:         for (size_t k_0__ = 0; k_0__ < dim_d_0__; ++k_0__) {
367:             d.push_back(in__.scalar_lb_constrain(0));
368:             writer__.write(d[k_0__]);
369:         }
370:
371:         // declare, define and validate transformed parameters
372:         double lp__ = 0.0;
373:         (void) lp__; // dummy call to supress warning
374:
375:
376:
377:         // write transformed parameters
378:
379:         // declare and define generated quantities
380:
381:
382:         // validate generated quantities
383:
384:         // write generated quantities
385:         writer__.newline();
386:     }
387:
388: }; // model
389:
390: } // namespace
391:
392: /**
393:  * Define Rcpp Module to expose stan_fit's functions to R.
394:  */
395: RCPP_MODULE(stan_fit129c5caaa12_SDT_single){
396:   Rcpp::class_<rstan::stan_fit<stan_fit129c5caaa12_SDT_single_namespace::stan_fit129c5caaa12_SDT_single,
397:                boost::random::ecuyer1988> >("stan_fit129c5caaa12_SDT_single")
398:     // .constructor<Rcpp::List>()
399:     .constructor<SEXP>()
400:     .constructor<SEXP, SEXP>()
401:     .method("call_sampler",
402:             &rstan::stan_fit<stan_fit129c5caaa12_SDT_single_namespace::stan_fit129c5caaa12_SDT_single, boost::random::ecuyer1988>::call_sampler)
403:     .method("param_names",
404:             &rstan::stan_fit<stan_fit129c5caaa12_SDT_single_namespace::stan_fit129c5caaa12_SDT_single, boost::random::ecuyer1988>::param_names)
405:     .method("param_names_oi",
406:             &rstan::stan_fit<stan_fit129c5caaa12_SDT_single_namespace::stan_fit129c5caaa12_SDT_single, boost::random::ecuyer1988>::param_names_oi)
407:     .method("param_fnames_oi",
408:             &rstan::stan_fit<stan_fit129c5caaa12_SDT_single_namespace::stan_fit129c5caaa12_SDT_single, boost::random::ecuyer1988>::param_fnames_oi)
409:     .method("param_dims",
410:             &rstan::stan_fit<stan_fit129c5caaa12_SDT_single_namespace::stan_fit129c5caaa12_SDT_single, boost::random::ecuyer1988>::param_dims)
411:     .method("param_dims_oi",
412:             &rstan::stan_fit<stan_fit129c5caaa12_SDT_single_namespace::stan_fit129c5caaa12_SDT_single, boost::random::ecuyer1988>::param_dims_oi)
413:     .method("permutation",
414:             &rstan::stan_fit<stan_fit129c5caaa12_SDT_single_namespace::stan_fit129c5caaa12_SDT_single, boost::random::ecuyer1988>::permutation)
415:     .method("update_param_oi",
416:             &rstan::stan_fit<stan_fit129c5caaa12_SDT_single_namespace::stan_fit129c5caaa12_SDT_single, boost::random::ecuyer1988>::update_param_oi)
417:     .method("param_oi_tidx",
418:             &rstan::stan_fit<stan_fit129c5caaa12_SDT_single_namespace::stan_fit129c5caaa12_SDT_single, boost::random::ecuyer1988>::param_oi_tidx)
419:     ;
420: }
421:
422:
423: // declarations
424: extern "C" {
425: SEXP file129cd8a321b( ) ;
426: }
427:
428: // definition
429:
430: SEXP file129cd8a321b(  ){
431:  return Rcpp::wrap("SDT_single");
432: }
433:
434:
Błšd w compileCode(f, code, language = language, verbose = verbose) :
  Compilation ERROR, function(s)/method(s) not created! cygwin warning:
  MS-DOS style path detected: C:/R/R-215~1.1/etc/x64/Makeconf
  Preferred POSIX equivalent is: /cygdrive/c/R/R-215~1.1/etc/x64/Makeconf
  CYGWIN environment variable option "nodosfilewarning" turns off this warning.
  Consult the user's guide for more details about POSIX paths:
    http://cygwin.com/cygwin-ug-net/using.html#using-pathnames
In file included from C:/R/R-2.15.1/library/rstan/include//stansrc/stan/model/model_header.hpp:18:0,
                 from file129cd8a321b.cpp:9:
C:/R/R-2.15.1/library/rstan/include//stansrc/stan/agrad/matrix.hpp: In static member function 'static double stan::agrad::{anonymous}::dot_product_vv_vari::var_dot(stan::agrad::vari**, stan::agrad::vari**, std::size_t)':
C:/R/R-2.15.1/library/rstan/include//stansrc/stan/agrad/matrix.hpp:689:31: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
In file included from C:/R/R-2.15.1/library/rstan/inc
Dodatkowo: Komunikat ostrzegawczy:
uruchomione polecenie 'C:/R/R-215~1.1/bin/x64/R CMD SHLIB file129cd8a321b.cpp 2> file129cd8a321b.cpp.err.txt' miało status 1

Marcel Falkiewicz

unread,
Sep 30, 2012, 2:49:56 PM9/30/12
to stan-...@googlegroups.com
Hello Keiichi,
unfortunately, recompiling the source code doesn't help my case, I
still get the same error :-(

Regards,
Marcel

2012/9/30 FUKAYA Keiichi <fuka...@gmail.com>:

Marcel Falkiewicz

unread,
Sep 30, 2012, 2:51:45 PM9/30/12
to stan-...@googlegroups.com
Yes, I have installed the 1.0.2 version. Restarting R didn't help
either :( I will try to re-run the code on another PC...

2012/9/30 Ben Goodrich <goodri...@gmail.com>:

Ben Goodrich

unread,
Sep 30, 2012, 3:05:50 PM9/30/12
to stan-...@googlegroups.com
Does any model work (e.g. the example in ?stan):

     library(rstan)
     scode
<- "
     parameters {
       real y[2];
     }
     model {
       y[1] ~ normal(0, 1);
       y[2] ~ double_exponential(0, 2);
     }
     "

     fit1
<- stan(model_code = scode, iter = 10, verbose = FALSE)
     
print(fit1)
     fit2
<- stan(fit = fit1, iter = 10000, verbose = FALSE)

Ben

Jiqiang Guo

unread,
Sep 30, 2012, 3:59:38 PM9/30/12
to stan-...@googlegroups.com
Thanks for the detailed report though I tried in windows and cannot reproduce the error you have. 

An advice for reporting compiling error in RStan:
1) provide the g++ version (dump from g++ -v)
2) the error dump for function stan with verbose = TRUE

--
Jiqiang

Marcel Falkiewicz

unread,
Sep 30, 2012, 4:08:13 PM9/30/12
to stan-...@googlegroups.com
This one also doesn't run and produces the same error message :(

2012/9/30 Ben Goodrich <goodri...@gmail.com>:

Ben Goodrich

unread,
Sep 30, 2012, 4:41:22 PM9/30/12
to stan-...@googlegroups.com
Okay, rstan is not installed correctly. In a fresh R session, I would do

remove.packages("rstan")

and then reinstall rstan. And then try the example again.

If that still doesn't work, post sessionInfo() and the stuff Jiqiang asked about.

Ben

Marcel Falkiewicz

unread,
Sep 30, 2012, 5:28:33 PM9/30/12
to stan-...@googlegroups.com
Hello,
removing and recompiling worked this time, it works fine! However,
it's surprising it happend in the first place... Cheers!

Best regards,
Marcel

2012/9/30 Ben Goodrich <goodri...@gmail.com>:
Reply all
Reply to author
Forward
0 new messages