Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiling Error for C++ Code #210

Closed
mrdevlar opened this issue Sep 17, 2015 · 20 comments
Closed

Compiling Error for C++ Code #210

mrdevlar opened this issue Sep 17, 2015 · 20 comments

Comments

@mrdevlar
Copy link

Hi Everyone,

I recently completed the instructions for installing rstan and ran the example code. This is what popped out. I cannot seem to find a reference to it in your issues, so I concluded it may be a new one.

COMPILING THE C++ CODE FOR MODEL '8schools' NOW.
file122072322cc8.cpp:8:39: fatal error: stan/model/model_header.hpp: No such file or directory
compilation terminated.
make: *** [file122072322cc8.o] Error 1
Warning message:
running command 'make -f "C:/PROGRA~1/R/R-32~1.2/etc/x64/Makeconf" -f "C:/PROGRA~1/R/R-32~1.2/share/make/winshlib.mk" -f "C:\RETNLSO-NT0002\RIPOD1$\Document/.R/Makevars" SHLIB_LDFLAGS='$(SHLIB_CXXLDFLAGS)' SHLIB_LD='$(SHLIB_CXXLD)' SHLIB="file122072322cc8.dll" WIN=64 TCLBIN=64 OBJECTS="file122072322cc8.o"' had status 2 

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: #define STAN__SERVICES__COMMAND_HPP// Code generated by Stan version 2.7
  7: 
  8: #include <stan/model/model_header.hpp>
  9: 
 10: namespace model12204deb62b7_8schools_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: typedef Eigen::Matrix<double,Eigen::Dynamic,1> vector_d;
 22: typedef Eigen::Matrix<double,1,Eigen::Dynamic> row_vector_d;
 23: typedef Eigen::Matrix<double,Eigen::Dynamic,Eigen::Dynamic> matrix_d;
 24: 
 25: static int current_statement_begin__;
 26: class model12204deb62b7_8schools : public prob_grad {
 27: private:
 28:     int J;
 29:     vector<double> y;
 30:     vector<double> sigma;
 31: public:
 32:     model12204deb62b7_8schools(stan::io::var_context& context__,
 33:         std::ostream* pstream__ = 0)
 34:         : prob_grad(0) {
 35:         current_statement_begin__ = -1;
 36: 
 37:         static const char* function__ = "model12204deb62b7_8schools_namespace::model12204deb62b7_8schools";
 38:         (void) function__; // dummy call to supress warning
 39:         size_t pos__;
 40:         (void) pos__; // dummy call to supress warning
 41:         std::vector<int> vals_i__;
 42:         std::vector<double> vals_r__;
 43:         context__.validate_dims("data initialization", "J", "int", context__.to_vec());
 44:         J = int(0);
 45:         vals_i__ = context__.vals_i("J");
 46:         pos__ = 0;
 47:         J = vals_i__[pos__++];
 48:         context__.validate_dims("data initialization", "y", "double", context__.to_vec(J));
 49:         validate_non_negative_index("y", "J", J);
 50:         y = std::vector<double>(J,double(0));
 51:         vals_r__ = context__.vals_r("y");
 52:         pos__ = 0;
 53:         size_t y_limit_0__ = J;
 54:         for (size_t i_0__ = 0; i_0__ < y_limit_0__; ++i_0__) {
 55:             y[i_0__] = vals_r__[pos__++];
 56:         }
 57:         context__.validate_dims("data initialization", "sigma", "double", context__.to_vec(J));
 58:         validate_non_negative_index("sigma", "J", J);
 59:         sigma = std::vector<double>(J,double(0));
 60:         vals_r__ = context__.vals_r("sigma");
 61:         pos__ = 0;
 62:         size_t sigma_limit_0__ = J;
 63:         for (size_t i_0__ = 0; i_0__ < sigma_limit_0__; ++i_0__) {
 64:             sigma[i_0__] = vals_r__[pos__++];
 65:         }
 66: 
 67:         // validate data
 68:         check_greater_or_equal(function__,"J",J,0);
 69:         for (int k0__ = 0; k0__ < J; ++k0__) {
 70:             check_greater_or_equal(function__,"sigma[k0__]",sigma[k0__],0);
 71:         }
 72: 
 73:         double DUMMY_VAR__(std::numeric_limits<double>::quiet_NaN());
 74:         (void) DUMMY_VAR__;  // suppress unused var warning
 75: 
 76: 
 77:         // initialize transformed variables to avoid seg fault on val access
 78: 
 79:         try {
 80:         } catch (const std::exception& e) {
 81:             stan::lang::rethrow_located(e,current_statement_begin__);
 82:             // Next line prevents compiler griping about no return
 83: throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***");
 84:         }
 85: 
 86:         // validate transformed data
 87: 
 88:         // set parameter ranges
 89:         num_params_r__ = 0U;
 90:         param_ranges_i__.clear();
 91:         ++num_params_r__;
 92:         ++num_params_r__;
 93:         num_params_r__ += J;
 94:     }
 95: 
 96:     ~model12204deb62b7_8schools() { }
 97: 
 98: 
 99:     void transform_inits(const stan::io::var_context& context__,
100:                          std::vector<int>& params_i__,
101:                          std::vector<double>& params_r__,
102:                          std::ostream* pstream__) const {
103:         stan::io::writer<double> writer__(params_r__,params_i__);
104:         size_t pos__;
105:         (void) pos__; // dummy call to supress warning
106:         std::vector<double> vals_r__;
107:         std::vector<int> vals_i__;
108: 
109:         if (!(context__.contains_r("mu")))
110:             throw std::runtime_error("variable mu missing");
111:         vals_r__ = context__.vals_r("mu");
112:         pos__ = 0U;
113:         context__.validate_dims("initialization", "mu", "double", context__.to_vec());
114:         double mu(0);
115:         mu = vals_r__[pos__++];
116:         try {
117:             writer__.scalar_unconstrain(mu);
118:         } catch (const std::exception& e) { 
119:             throw std::runtime_error(std::string("Error transforming variable mu: ") + e.what());
120:         }
121: 
122:         if (!(context__.contains_r("tau")))
123:             throw std::runtime_error("variable tau missing");
124:         vals_r__ = context__.vals_r("tau");
125:         pos__ = 0U;
126:         context__.validate_dims("initialization", "tau", "double", context__.to_vec());
127:         double tau(0);
128:         tau = vals_r__[pos__++];
129:         try {
130:             writer__.scalar_lb_unconstrain(0,tau);
131:         } catch (const std::exception& e) { 
132:             throw std::runtime_error(std::string("Error transforming variable tau: ") + e.what());
133:         }
134: 
135:         if (!(context__.contains_r("eta")))
136:             throw std::runtime_error("variable eta missing");
137:         vals_r__ = context__.vals_r("eta");
138:         pos__ = 0U;
139:         context__.validate_dims("initialization", "eta", "double", context__.to_vec(J));
140:         std::vector<double> eta(J,double(0));
141:         for (int i0__ = 0U; i0__ < J; ++i0__)
142:             eta[i0__] = vals_r__[pos__++];
143:         for (int i0__ = 0U; i0__ < J; ++i0__)
144:             try {
145:             writer__.scalar_unconstrain(eta[i0__]);
146:         } catch (const std::exception& e) { 
147:             throw std::runtime_error(std::string("Error transforming variable eta: ") + e.what());
148:         }
149: 
150:         params_r__ = writer__.data_r();
151:         params_i__ = writer__.data_i();
152:     }
153: 
154:     void transform_inits(const stan::io::var_context& context,
155:                          Eigen::Matrix<double,Eigen::Dynamic,1>& params_r,
156:                          std::ostream* pstream__) const {
157:       std::vector<double> params_r_vec;
158:       std::vector<int> params_i_vec;
159:       transform_inits(context, params_i_vec, params_r_vec, pstream__);
160:       params_r.resize(params_r_vec.size());
161:       for (int i = 0; i < params_r.size(); ++i)
162:         params_r(i) = params_r_vec[i];
163:     }
164: 
165: 
166:     template <bool propto__, bool jacobian__, typename T__>
167:     T__ log_prob(vector<T__>& params_r__,
168:                  vector<int>& params_i__,
169:                  std::ostream* pstream__ = 0) const {
170: 
171:         T__ DUMMY_VAR__(std::numeric_limits<double>::quiet_NaN());
172:         (void) DUMMY_VAR__;  // suppress unused var warning
173: 
174:         T__ lp__(0.0);
175:         stan::math::accumulator<T__> lp_accum__;
176: 
177:         // model parameters
178:         stan::io::reader<T__> in__(params_r__,params_i__);
179: 
180:         T__ mu;
181:         (void) mu;   // dummy to suppress unused var warning
182:         if (jacobian__)
183:             mu = in__.scalar_constrain(lp__);
184:         else
185:             mu = in__.scalar_constrain();
186: 
187:         T__ tau;
188:         (void) tau;   // dummy to suppress unused var warning
189:         if (jacobian__)
190:             tau = in__.scalar_lb_constrain(0,lp__);
191:         else
192:             tau = in__.scalar_lb_constrain(0);
193: 
194:         vector<T__> eta;
195:         size_t dim_eta_0__ = J;
196:         eta.reserve(dim_eta_0__);
197:         for (size_t k_0__ = 0; k_0__ < dim_eta_0__; ++k_0__) {
198:             if (jacobian__)
199:                 eta.push_back(in__.scalar_constrain(lp__));
200:             else
201:                 eta.push_back(in__.scalar_constrain());
202:         }
203: 
204: 
205:         // transformed parameters
206:         vector<T__> theta(J);
207: 
208:         // initialize transformed variables to avoid seg fault on val access
209:         stan::math::fill(theta,DUMMY_VAR__);
210: 
211:         try {
212:             current_statement_begin__ = 13;
213:             for (int j = 1; j <= J; ++j) {
214:                 current_statement_begin__ = 14;
215:                 stan::math::assign(get_base1_lhs(theta,j,"theta",1), (mu + (tau * get_base1(eta,j,"eta",1))));
216:             }
217:         } catch (const std::exception& e) {
218:             stan::lang::rethrow_located(e,current_statement_begin__);
219:             // Next line prevents compiler griping about no return
220: throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***");
221:         }
222: 
223:         // validate transformed parameters
224:         for (int i0__ = 0; i0__ < J; ++i0__) {
225:             if (stan::math::is_uninitialized(theta[i0__])) {
226:                 std::stringstream msg__;
227:                 msg__ << "Undefined transformed parameter: theta" << '[' << i0__ << ']';
228:                 throw std::runtime_error(msg__.str());
229:             }
230:         }
231: 
232:         const char* function__ = "validate transformed params";
233:         (void) function__; // dummy to suppress unused var warning
234: 
235:         // model body
236:         try {
237:             current_statement_begin__ = 17;
238:             lp_accum__.add(normal_log<propto__>(eta, 0, 1));
239:             current_statement_begin__ = 18;
240:             lp_accum__.add(normal_log<propto__>(y, theta, sigma));
241:         } catch (const std::exception& e) {
242:             stan::lang::rethrow_located(e,current_statement_begin__);
243:             // Next line prevents compiler griping about no return
244: throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***");
245:         }
246: 
247:         lp_accum__.add(lp__);
248:         return lp_accum__.sum();
249: 
250:     } // log_prob()
251: 
252:     template <bool propto, bool jacobian, typename T_>
253:     T_ log_prob(Eigen::Matrix<T_,Eigen::Dynamic,1>& params_r,
254:                std::ostream* pstream = 0) const {
255:       std::vector<T_> vec_params_r;
256:       vec_params_r.reserve(params_r.size());
257:       for (int i = 0; i < params_r.size(); ++i)
258:         vec_params_r.push_back(params_r(i));
259:       std::vector<int> vec_params_i;
260:       return log_prob<propto,jacobian,T_>(vec_params_r, vec_params_i, pstream);
261:     }
262: 
263: 
264:     void get_param_names(std::vector<std::string>& names__) const {
265:         names__.resize(0);
266:         names__.push_back("mu");
267:         names__.push_back("tau");
268:         names__.push_back("eta");
269:         names__.push_back("theta");
270:     }
271: 
272: 
273:     void get_dims(std::vector<std::vector<size_t> >& dimss__) const {
274:         dimss__.resize(0);
275:         std::vector<size_t> dims__;
276:         dims__.resize(0);
277:         dimss__.push_back(dims__);
278:         dims__.resize(0);
279:         dimss__.push_back(dims__);
280:         dims__.resize(0);
281:         dims__.push_back(J);
282:         dimss__.push_back(dims__);
283:         dims__.resize(0);
284:         dims__.push_back(J);
285:         dimss__.push_back(dims__);
286:     }
287: 
288:     template <typename RNG>
289:     void write_array(RNG& base_rng__,
290:                      std::vector<double>& params_r__,
291:                      std::vector<int>& params_i__,
292:                      std::vector<double>& vars__,
293:                      bool include_tparams__ = true,
294:                      bool include_gqs__ = true,
295:                      std::ostream* pstream__ = 0) const {
296:         vars__.resize(0);
297:         stan::io::reader<double> in__(params_r__,params_i__);
298:         static const char* function__ = "model12204deb62b7_8schools_namespace::write_array";
299:         (void) function__; // dummy call to supress warning
300:         // read-transform, write parameters
301:         double mu = in__.scalar_constrain();
302:         double tau = in__.scalar_lb_constrain(0);
303:         vector<double> eta;
304:         size_t dim_eta_0__ = J;
305:         for (size_t k_0__ = 0; k_0__ < dim_eta_0__; ++k_0__) {
306:             eta.push_back(in__.scalar_constrain());
307:         }
308:         vars__.push_back(mu);
309:         vars__.push_back(tau);
310:         for (int k_0__ = 0; k_0__ < J; ++k_0__) {
311:             vars__.push_back(eta[k_0__]);
312:         }
313: 
314:         if (!include_tparams__) return;
315:         // declare and define transformed parameters
316:         double lp__ = 0.0;
317:         (void) lp__; // dummy call to supress warning
318:         stan::math::accumulator<double> lp_accum__;
319: 
320:         vector<double> theta(J, 0.0);
321: 
322:         try {
323:             current_statement_begin__ = 13;
324:             for (int j = 1; j <= J; ++j) {
325:                 current_statement_begin__ = 14;
326:                 stan::math::assign(get_base1_lhs(theta,j,"theta",1), (mu + (tau * get_base1(eta,j,"eta",1))));
327:             }
328:         } catch (const std::exception& e) {
329:             stan::lang::rethrow_located(e,current_statement_begin__);
330:             // Next line prevents compiler griping about no return
331: throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***");
332:         }
333: 
334:         // validate transformed parameters
335: 
336:         // write transformed parameters
337:         for (int k_0__ = 0; k_0__ < J; ++k_0__) {
338:             vars__.push_back(theta[k_0__]);
339:         }
340: 
341:         if (!include_gqs__) return;
342:         // declare and define generated quantities
343: 
344:         double DUMMY_VAR__(std::numeric_limits<double>::quiet_NaN());
345:         (void) DUMMY_VAR__;  // suppress unused var warning
346: 
347: 
348:         // initialize transformed variables to avoid seg fault on val access
349: 
350:         try {
351:         } catch (const std::exception& e) {
352:             stan::lang::rethrow_located(e,current_statement_begin__);
353:             // Next line prevents compiler griping about no return
354: throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***");
355:         }
356: 
357:         // validate generated quantities
358: 
359:         // write generated quantities
360:     }
361: 
362:     template <typename RNG>
363:     void write_array(RNG& base_rng,
364:                      Eigen::Matrix<double,Eigen::Dynamic,1>& params_r,
365:                      Eigen::Matrix<double,Eigen::Dynamic,1>& vars,
366:                      bool include_tparams = true,
367:                      bool include_gqs = true,
368:                      std::ostream* pstream = 0) const {
369:       std::vector<double> params_r_vec(params_r.size());
370:       for (int i = 0; i < params_r.size(); ++i)
371:         params_r_vec[i] = params_r(i);
372:       std::vector<double> vars_vec;
373:       std::vector<int> params_i_vec;
374:       write_array(base_rng,params_r_vec,params_i_vec,vars_vec,include_tparams,include_gqs,pstream);
375:       vars.resize(vars_vec.size());
376:       for (int i = 0; i < vars.size(); ++i)
377:         vars(i) = vars_vec[i];
378:     }
379: 
380:     static std::string model_name() {
381:         return "model12204deb62b7_8schools";
382:     }
383: 
384: 
385:     void constrained_param_names(std::vector<std::string>& param_names__,
386:                                  bool include_tparams__ = true,
387:                                  bool include_gqs__ = true) const {
388:         std::stringstream param_name_stream__;
389:         param_name_stream__.str(std::string());
390:         param_name_stream__ << "mu";
391:         param_names__.push_back(param_name_stream__.str());
392:         param_name_stream__.str(std::string());
393:         param_name_stream__ << "tau";
394:         param_names__.push_back(param_name_stream__.str());
395:         for (int k_0__ = 1; k_0__ <= J; ++k_0__) {
396:             param_name_stream__.str(std::string());
397:             param_name_stream__ << "eta" << '.' << k_0__;
398:             param_names__.push_back(param_name_stream__.str());
399:         }
400: 
401:         if (!include_gqs__ && !include_tparams__) return;
402:         for (int k_0__ = 1; k_0__ <= J; ++k_0__) {
403:             param_name_stream__.str(std::string());
404:             param_name_stream__ << "theta" << '.' << k_0__;
405:             param_names__.push_back(param_name_stream__.str());
406:         }
407: 
408:         if (!include_gqs__) return;
409:     }
410: 
411: 
412:     void unconstrained_param_names(std::vector<std::string>& param_names__,
413:                                    bool include_tparams__ = true,
414:                                    bool include_gqs__ = true) const {
415:         std::stringstream param_name_stream__;
416:         param_name_stream__.str(std::string());
417:         param_name_stream__ << "mu";
418:         param_names__.push_back(param_name_stream__.str());
419:         param_name_stream__.str(std::string());
420:         param_name_stream__ << "tau";
421:         param_names__.push_back(param_name_stream__.str());
422:         for (int k_0__ = 1; k_0__ <= J; ++k_0__) {
423:             param_name_stream__.str(std::string());
424:             param_name_stream__ << "eta" << '.' << k_0__;
425:             param_names__.push_back(param_name_stream__.str());
426:         }
427: 
428:         if (!include_gqs__ && !include_tparams__) return;
429:         for (int k_0__ = 1; k_0__ <= J; ++k_0__) {
430:             param_name_stream__.str(std::string());
431:             param_name_stream__ << "theta" << '.' << k_0__;
432:             param_names__.push_back(param_name_stream__.str());
433:         }
434: 
435:         if (!include_gqs__) return;
436:     }
437: 
438: }; // model
439: 
440: } // namespace
441: 
442: typedef model12204deb62b7_8schools_namespace::model12204deb62b7_8schools stan_model;
443: 
444: #include <rstan/rstaninc.hpp>
445: /**
446:  * Define Rcpp Module to expose stan_fit's functions to R.
447:  */
448: RCPP_MODULE(stan_fit4model12204deb62b7_8schools_mod){
449:   Rcpp::class_<rstan::stan_fit<model12204deb62b7_8schools_namespace::model12204deb62b7_8schools,
450:                boost::random::ecuyer1988> >("stan_fit4model12204deb62b7_8schools")
451:     // .constructor<Rcpp::List>()
452:     .constructor<SEXP, SEXP>()
453:     // .constructor<SEXP, SEXP>()
454:     .method("call_sampler",
455:             &rstan::stan_fit<model12204deb62b7_8schools_namespace::model12204deb62b7_8schools, boost::random::ecuyer1988>::call_sampler)
456:     .method("param_names",
457:             &rstan::stan_fit<model12204deb62b7_8schools_namespace::model12204deb62b7_8schools, boost::random::ecuyer1988>::param_names)
458:     .method("param_names_oi",
459:             &rstan::stan_fit<model12204deb62b7_8schools_namespace::model12204deb62b7_8schools, boost::random::ecuyer1988>::param_names_oi)
460:     .method("param_fnames_oi",
461:             &rstan::stan_fit<model12204deb62b7_8schools_namespace::model12204deb62b7_8schools, boost::random::ecuyer1988>::param_fnames_oi)
462:     .method("param_dims",
463:             &rstan::stan_fit<model12204deb62b7_8schools_namespace::model12204deb62b7_8schools, boost::random::ecuyer1988>::param_dims)
464:     .method("param_dims_oi",
465:             &rstan::stan_fit<model12204deb62b7_8schools_namespace::model12204deb62b7_8schools, boost::random::ecuyer1988>::param_dims_oi)
466:     .method("update_param_oi",
467:             &rstan::stan_fit<model12204deb62b7_8schools_namespace::model12204deb62b7_8schools, boost::random::ecuyer1988>::update_param_oi)
468:     .method("param_oi_tidx",
469:             &rstan::stan_fit<model12204deb62b7_8schools_namespace::model12204deb62b7_8schools, boost::random::ecuyer1988>::param_oi_tidx)
470:     .method("grad_log_prob",
471:             &rstan::stan_fit<model12204deb62b7_8schools_namespace::model12204deb62b7_8schools, boost::random::ecuyer1988>::grad_log_prob)
472:     .method("log_prob",
473:             &rstan::stan_fit<model12204deb62b7_8schools_namespace::model12204deb62b7_8schools, boost::random::ecuyer1988>::log_prob)
474:     .method("unconstrain_pars",
475:             &rstan::stan_fit<model12204deb62b7_8schools_namespace::model12204deb62b7_8schools, boost::random::ecuyer1988>::unconstrain_pars)
476:     .method("constrain_pars",
477:             &rstan::stan_fit<model12204deb62b7_8schools_namespace::model12204deb62b7_8schools, boost::random::ecuyer1988>::constrain_pars)
478:     .method("num_pars_unconstrained",
479:             &rstan::stan_fit<model12204deb62b7_8schools_namespace::model12204deb62b7_8schools, boost::random::ecuyer1988>::num_pars_unconstrained)
480:     .method("unconstrained_param_names",
481:             &rstan::stan_fit<model12204deb62b7_8schools_namespace::model12204deb62b7_8schools, boost::random::ecuyer1988>::unconstrained_param_names)
482:     .method("constrained_param_names",
483:             &rstan::stan_fit<model12204deb62b7_8schools_namespace::model12204deb62b7_8schools, boost::random::ecuyer1988>::constrained_param_names)
484:     ;
485: }
486: 
487: // declarations
488: extern "C" {
489: SEXP file122072322cc8( ) ;
490: }
491: 
492: // definition
493: 
494: SEXP file122072322cc8(  ){
495:  return Rcpp::wrap("8schools");
496: }
497: 
498: 
Error in compileCode(f, code, language = language, verbose = verbose) : 
  Compilation ERROR, function(s)/method(s) not created! file122072322cc8.cpp:8:39: fatal error: stan/model/model_header.hpp: No such file or directory
compilation terminated.
make: *** [file122072322cc8.o] Error 1
Warning message:
running command 'make -f "C:/PROGRA~1/R/R-32~1.2/etc/x64/Makeconf" -f "C:/PROGRA~1/R/R-32~1.2/share/make/winshlib.mk" -f "C:\RETNLSO-NT0002\RIPOD1$\Document/.R/Makevars" SHLIB_LDFLAGS='$(SHLIB_CXXLDFLAGS)' SHLIB_LD='$(SHLIB_CXXLD)' SHLIB="file122072322cc8.dll" WIN=64 TCLBIN=64 OBJECTS="file122072322cc8.o"' had status 2 
In addition: Warning message:
running command 'C:/PROGRA~1/R/R-32~1.2/bin/x64/R CMD SHLIB file122072322cc8.cpp 2> file122072322cc8.cpp.err.txt' had status 1 
@maverickg
Copy link
Contributor

Please double check that StanHeaders is installed?

@bgoodri
Copy link
Contributor

bgoodri commented Sep 17, 2015

My guess is #175 . This is already fixed in GitHub and should be on CRAN in a couple of days.

@rlumor
Copy link

rlumor commented Sep 18, 2015

I need help!!!!

COMPILING THE C++ CODE FOR MODEL 'poisson(log) brms-model' NOW.
In file included from file7f3759f9fa3.cpp:826:
In file included from /Library/Frameworks/R.framework/Versions/3.2/Resources/library/rstan/include/rstan/rstaninc.hpp:3:
In file included from /Library/Frameworks/R.framework/Versions/3.2/Resources/library/rstan/include/rstan/stan_fit.hpp:80:
/Library/Frameworks/R.framework/Versions/3.2/Resources/library/rstan/include/rstan/io/rlist_ref_var_context_factory.hpp:4:10: fatal error: 'stan/interface/var_context_factory/dump_factory.hpp' file not found
#include <stan/interface/var_context_factory/dump_factory.hpp>
^
1 error generated.
make: *** [file7f3759f9fa3.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: #define STAN__SERVICES__COMMAND_HPP// Code generated by Stan version 2.7
7:
8: #include <stan/model/model_header.hpp>
9:
10: namespace model7f35c2aac72_poisson_log__brms_model_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: typedef Eigen::Matrix<double,Eigen::Dynamic,1> vector_d;
22: typedef Eigen::Matrix<double,1,Eigen::Dynamic> row_vector_d;
23: typedef Eigen::Matrix<double,Eigen::Dynamic,Eigen::Dynamic> matrix_d;
24:
25: static int current_statement_begin__;
26: class model7f35c2aac72_poisson_log__brms_model : public prob_grad {
27: private:
28: int N;
29: vector Y;
30: int K;
31: matrix_d X;
32: vector J_1;
33: int N_1;
34: int K_1;
35: vector Z_1;
36: vector J_2;
37: int N_2;
38: int K_2;
39: vector Z_2;
40: vector J_3;
41: int N_3;
42: int K_3;
43: vector Z_3;
44: public:
45: model7f35c2aac72_poisson_log__brms_model(stan::io::var_context& context__,
46: std::ostream* pstream__ = 0)
47: : prob_grad(0) {
48: current_statement_begin__ = -1;
49:
50: static const char* function__ = "model7f35c2aac72_poisson_log__brms_model_namespace::model7f35c2aac72_poisson_log__brms_model";
51: (void) function__; // dummy call to supress warning
52: size_t pos__;
53: (void) pos__; // dummy call to supress warning
54: std::vector vals_i__;
55: std::vector vals_r__;
56: context__.validate_dims("data initialization", "N", "int", context__.to_vec());
57: N = int(0);
58: vals_i__ = context__.vals_i("N");
59: pos__ = 0;
60: N = vals_i__[pos__++];
61: context__.validate_dims("data initialization", "Y", "int", context__.to_vec(N));
62: validate_non_negative_index("Y", "N", N);
63: Y = std::vector(N,int(0));
64: vals_i__ = context__.vals_i("Y");
65: pos__ = 0;
66: size_t Y_limit_0__ = N;
67: for (size_t i_0__ = 0; i_0__ < Y_limit_0__; ++i_0__) {
68: Y[i_0__] = vals_i__[pos__++];
69: }
70: context__.validate_dims("data initialization", "K", "int", context__.to_vec());
71: K = int(0);
72: vals_i__ = context__.vals_i("K");
73: pos__ = 0;
74: K = vals_i__[pos__++];
75: context__.validate_dims("data initialization", "X", "matrix_d", context__.to_vec(N,K));
76: validate_non_negative_index("X", "N", N);
77: validate_non_negative_index("X", "K", K);
78: X = matrix_d(N,K);
79: vals_r__ = context__.vals_r("X");
80: pos__ = 0;
81: size_t X_m_mat_lim__ = N;
82: size_t X_n_mat_lim__ = K;
83: for (size_t n_mat__ = 0; n_mat__ < X_n_mat_lim__; ++n_mat__) {
84: for (size_t m_mat__ = 0; m_mat__ < X_m_mat_lim__; ++m_mat__) {
85: X(m_mat__,n_mat__) = vals_r__[pos__++];
86: }
87: }
88: context__.validate_dims("data initialization", "J_1", "int", context__.to_vec(N));
89: validate_non_negative_index("J_1", "N", N);
90: J_1 = std::vector(N,int(0));
91: vals_i__ = context__.vals_i("J_1");
92: pos__ = 0;
93: size_t J_1_limit_0__ = N;
94: for (size_t i_0__ = 0; i_0__ < J_1_limit_0__; ++i_0__) {
95: J_1[i_0__] = vals_i__[pos__++];
96: }
97: context__.validate_dims("data initialization", "N_1", "int", context__.to_vec());
98: N_1 = int(0);
99: vals_i__ = context__.vals_i("N_1");
100: pos__ = 0;
101: N_1 = vals_i__[pos__++];
102: context__.validate_dims("data initialization", "K_1", "int", context__.to_vec());
103: K_1 = int(0);
104: vals_i__ = context__.vals_i("K_1");
105: pos__ = 0;
106: K_1 = vals_i__[pos__++];
107: context__.validate_dims("data initialization", "Z_1", "double", context__.to_vec(N));
108: validate_non_negative_index("Z_1", "N", N);
109: Z_1 = std::vector(N,double(0));
110: vals_r__ = context__.vals_r("Z_1");
111: pos__ = 0;
112: size_t Z_1_limit_0__ = N;
113: for (size_t i_0__ = 0; i_0__ < Z_1_limit_0__; ++i_0__) {
114: Z_1[i_0__] = vals_r__[pos__++];
115: }
116: context__.validate_dims("data initialization", "J_2", "int", context__.to_vec(N));
117: validate_non_negative_index("J_2", "N", N);
118: J_2 = std::vector(N,int(0));
119: vals_i__ = context__.vals_i("J_2");
120: pos__ = 0;
121: size_t J_2_limit_0__ = N;
122: for (size_t i_0__ = 0; i_0__ < J_2_limit_0__; ++i_0__) {
123: J_2[i_0__] = vals_i__[pos__++];
124: }
125: context__.validate_dims("data initialization", "N_2", "int", context__.to_vec());
126: N_2 = int(0);
127: vals_i__ = context__.vals_i("N_2");
128: pos__ = 0;
129: N_2 = vals_i__[pos__++];
130: context__.validate_dims("data initialization", "K_2", "int", context__.to_vec());
131: K_2 = int(0);
132: vals_i__ = context__.vals_i("K_2");
133: pos__ = 0;
134: K_2 = vals_i__[pos__++];
135: context__.validate_dims("data initialization", "Z_2", "double", context__.to_vec(N));
136: validate_non_negative_index("Z_2", "N", N);
137: Z_2 = std::vector(N,double(0));
138: vals_r__ = context__.vals_r("Z_2");
139: pos__ = 0;
140: size_t Z_2_limit_0__ = N;
141: for (size_t i_0__ = 0; i_0__ < Z_2_limit_0__; ++i_0__) {
142: Z_2[i_0__] = vals_r__[pos__++];
143: }
144: context__.validate_dims("data initialization", "J_3", "int", context__.to_vec(N));
145: validate_non_negative_index("J_3", "N", N);
146: J_3 = std::vector(N,int(0));
147: vals_i__ = context__.vals_i("J_3");
148: pos__ = 0;
149: size_t J_3_limit_0__ = N;
150: for (size_t i_0__ = 0; i_0__ < J_3_limit_0__; ++i_0__) {
151: J_3[i_0__] = vals_i__[pos__++];
152: }
153: context__.validate_dims("data initialization", "N_3", "int", context__.to_vec());
154: N_3 = int(0);
155: vals_i__ = context__.vals_i("N_3");
156: pos__ = 0;
157: N_3 = vals_i__[pos__++];
158: context__.validate_dims("data initialization", "K_3", "int", context__.to_vec());
159: K_3 = int(0);
160: vals_i__ = context__.vals_i("K_3");
161: pos__ = 0;
162: K_3 = vals_i__[pos__++];
163: context__.validate_dims("data initialization", "Z_3", "double", context__.to_vec(N));
164: validate_non_negative_index("Z_3", "N", N);
165: Z_3 = std::vector(N,double(0));
166: vals_r__ = context__.vals_r("Z_3");
167: pos__ = 0;
168: size_t Z_3_limit_0__ = N;
169: for (size_t i_0__ = 0; i_0__ < Z_3_limit_0__; ++i_0__) {
170: Z_3[i_0__] = vals_r__[pos__++];
171: }
172:
173: // validate data
174: check_greater_or_equal(function__,"N",N,1);
175: check_greater_or_equal(function__,"K",K,1);
176: for (int k0__ = 0; k0__ < N; ++k0__) {
177: check_greater_or_equal(function__,"J_1[k0__]",J_1[k0__],1);
178: }
179: check_greater_or_equal(function__,"N_1",N_1,1);
180: check_greater_or_equal(function__,"K_1",K_1,1);
181: for (int k0__ = 0; k0__ < N; ++k0__) {
182: check_greater_or_equal(function__,"J_2[k0__]",J_2[k0__],1);
183: }
184: check_greater_or_equal(function__,"N_2",N_2,1);
185: check_greater_or_equal(function__,"K_2",K_2,1);
186: for (int k0__ = 0; k0__ < N; ++k0__) {
187: check_greater_or_equal(function__,"J_3[k0__]",J_3[k0__],1);
188: }
189: check_greater_or_equal(function__,"N_3",N_3,1);
190: check_greater_or_equal(function__,"K_3",K_3,1);
191:
192: double DUMMY_VAR__(std::numeric_limits::quiet_NaN());
193: (void) DUMMY_VAR__; // suppress unused var warning
194:
195:
196: // initialize transformed variables to avoid seg fault on val access
197:
198: try {
199: } catch (const std::exception& e) {
200: stan::lang::rethrow_located(e,current_statement_begin__);
201: // Next line prevents compiler griping about no return
202: throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ");
203: }
204:
205: // validate transformed data
206:
207: // set parameter ranges
208: num_params_r__ = 0U;
209: param_ranges_i__.clear();
210: num_params_r__ += K;
211: num_params_r__ += N_1;
212: ++num_params_r__;
213: num_params_r__ += N_2;
214: ++num_params_r__;
215: num_params_r__ += N_3;
216: ++num_params_r__;
217: }
218:
219: ~model7f35c2aac72_poisson_log__brms_model() { }
220:
221:
222: void transform_inits(const stan::io::var_context& context__,
223: std::vector& params_i__,
224: std::vector& params_r__,
225: std::ostream
pstream__) const {
226: stan::io::writer writer__(params_r__,params_i__);
227: size_t pos__;
228: (void) pos__; // dummy call to supress warning
229: std::vector vals_r__;
230: std::vector vals_i__;
231:
232: if (!(context__.contains_r("b")))
233: throw std::runtime_error("variable b missing");
234: vals_r__ = context__.vals_r("b");
235: pos__ = 0U;
236: context__.validate_dims("initialization", "b", "vector_d", context__.to_vec(K));
237: vector_d b(K);
238: for (int j1__ = 0U; j1__ < K; ++j1__)
239: b(j1__) = vals_r__[pos__++];
240: try {
241: writer__.vector_unconstrain(b);
242: } catch (const std::exception& e) {
243: throw std::runtime_error(std::string("Error transforming variable b: ") + e.what());
244: }
245:
246: if (!(context__.contains_r("pre_1")))
247: throw std::runtime_error("variable pre_1 missing");
248: vals_r__ = context__.vals_r("pre_1");
249: pos__ = 0U;
250: context__.validate_dims("initialization", "pre_1", "vector_d", context__.to_vec(N_1));
251: vector_d pre_1(N_1);
252: for (int j1__ = 0U; j1__ < N_1; ++j1__)
253: pre_1(j1__) = vals_r__[pos__++];
254: try {
255: writer__.vector_unconstrain(pre_1);
256: } catch (const std::exception& e) {
257: throw std::runtime_error(std::string("Error transforming variable pre_1: ") + e.what());
258: }
259:
260: if (!(context__.contains_r("sd_1")))
261: throw std::runtime_error("variable sd_1 missing");
262: vals_r__ = context__.vals_r("sd_1");
263: pos__ = 0U;
264: context__.validate_dims("initialization", "sd_1", "double", context__.to_vec());
265: double sd_1(0);
266: sd_1 = vals_r__[pos__++];
267: try {
268: writer__.scalar_lb_unconstrain(0,sd_1);
269: } catch (const std::exception& e) {
270: throw std::runtime_error(std::string("Error transforming variable sd_1: ") + e.what());
271: }
272:
273: if (!(context__.contains_r("pre_2")))
274: throw std::runtime_error("variable pre_2 missing");
275: vals_r__ = context__.vals_r("pre_2");
276: pos__ = 0U;
277: context__.validate_dims("initialization", "pre_2", "vector_d", context__.to_vec(N_2));
278: vector_d pre_2(N_2);
279: for (int j1__ = 0U; j1__ < N_2; ++j1__)
280: pre_2(j1__) = vals_r__[pos__++];
281: try {
282: writer__.vector_unconstrain(pre_2);
283: } catch (const std::exception& e) {
284: throw std::runtime_error(std::string("Error transforming variable pre_2: ") + e.what());
285: }
286:
287: if (!(context__.contains_r("sd_2")))
288: throw std::runtime_error("variable sd_2 missing");
289: vals_r__ = context__.vals_r("sd_2");
290: pos__ = 0U;
291: context__.validate_dims("initialization", "sd_2", "double", context__.to_vec());
292: double sd_2(0);
293: sd_2 = vals_r__[pos__++];
294: try {
295: writer__.scalar_lb_unconstrain(0,sd_2);
296: } catch (const std::exception& e) {
297: throw std::runtime_error(std::string("Error transforming variable sd_2: ") + e.what());
298: }
299:
300: if (!(context__.contains_r("pre_3")))
301: throw std::runtime_error("variable pre_3 missing");
302: vals_r__ = context__.vals_r("pre_3");
303: pos__ = 0U;
304: context__.validate_dims("initialization", "pre_3", "vector_d", context__.to_vec(N_3));
305: vector_d pre_3(N_3);
306: for (int j1__ = 0U; j1__ < N_3; ++j1__)
307: pre_3(j1__) = vals_r__[pos__++];
308: try {
309: writer__.vector_unconstrain(pre_3);
310: } catch (const std::exception& e) {
311: throw std::runtime_error(std::string("Error transforming variable pre_3: ") + e.what());
312: }
313:
314: if (!(context__.contains_r("sd_3")))
315: throw std::runtime_error("variable sd_3 missing");
316: vals_r__ = context__.vals_r("sd_3");
317: pos__ = 0U;
318: context__.validate_dims("initialization", "sd_3", "double", context__.to_vec());
319: double sd_3(0);
320: sd_3 = vals_r__[pos__++];
321: try {
322: writer__.scalar_lb_unconstrain(0,sd_3);
323: } catch (const std::exception& e) {
324: throw std::runtime_error(std::string("Error transforming variable sd_3: ") + e.what());
325: }
326:
327: params_r__ = writer__.data_r();
328: params_i__ = writer__.data_i();
329: }
330:
331: void transform_inits(const stan::io::var_context& context,
332: Eigen::Matrix<double,Eigen::Dynamic,1>& params_r,
333: std::ostream* pstream__) const {
334: std::vector params_r_vec;
335: std::vector params_i_vec;
336: transform_inits(context, params_i_vec, params_r_vec, pstream__);
337: params_r.resize(params_r_vec.size());
338: for (int i = 0; i < params_r.size(); ++i)
339: params_r(i) = params_r_vec[i];
340: }
341:
342:
343: template <bool propto__, bool jacobian__, typename T__>
344: T__ log_prob(vector<T__>& params_r__,
345: vector& params_i__,
346: std::ostream* pstream__ = 0) const {
347:
348: T__ DUMMY_VAR__(std::numeric_limits::quiet_NaN());
349: (void) DUMMY_VAR__; // suppress unused var warning
350:
351: T__ lp__(0.0);
352: stan::math::accumulator<T__> lp_accum__;
353:
354: // model parameters
355: stan::io::reader<T__> in__(params_r__,params_i__);
356:
357: Eigen::Matrix<T__,Eigen::Dynamic,1> b;
358: (void) b; // dummy to suppress unused var warning
359: if (jacobian__)
360: b = in__.vector_constrain(K,lp__);
361: else
362: b = in__.vector_constrain(K);
363:
364: Eigen::Matrix<T__,Eigen::Dynamic,1> pre_1;
365: (void) pre_1; // dummy to suppress unused var warning
366: if (jacobian__)
367: pre_1 = in__.vector_constrain(N_1,lp__);
368: else
369: pre_1 = in__.vector_constrain(N_1);
370:
371: T__ sd_1;
372: (void) sd_1; // dummy to suppress unused var warning
373: if (jacobian__)
374: sd_1 = in__.scalar_lb_constrain(0,lp__);
375: else
376: sd_1 = in__.scalar_lb_constrain(0);
377:
378: Eigen::Matrix<T__,Eigen::Dynamic,1> pre_2;
379: (void) pre_2; // dummy to suppress unused var warning
380: if (jacobian__)
381: pre_2 = in__.vector_constrain(N_2,lp__);
382: else
383: pre_2 = in__.vector_constrain(N_2);
384:
385: T__ sd_2;
386: (void) sd_2; // dummy to suppress unused var warning
387: if (jacobian__)
388: sd_2 = in__.scalar_lb_constrain(0,lp__);
389: else
390: sd_2 = in__.scalar_lb_constrain(0);
391:
392: Eigen::Matrix<T__,Eigen::Dynamic,1> pre_3;
393: (void) pre_3; // dummy to suppress unused var warning
394: if (jacobian__)
395: pre_3 = in__.vector_constrain(N_3,lp__);
396: else
397: pre_3 = in__.vector_constrain(N_3);
398:
399: T__ sd_3;
400: (void) sd_3; // dummy to suppress unused var warning
401: if (jacobian__)
402: sd_3 = in__.scalar_lb_constrain(0,lp__);
403: else
404: sd_3 = in__.scalar_lb_constrain(0);
405:
406:
407: // transformed parameters
408: Eigen::Matrix<T__,Eigen::Dynamic,1> eta(N);
409: (void) eta; // dummy to suppress unused var warning
410: stan::math::fill(eta,DUMMY_VAR__);
411: Eigen::Matrix<T__,Eigen::Dynamic,1> r_1(N_1);
412: (void) r_1; // dummy to suppress unused var warning
413: stan::math::fill(r_1,DUMMY_VAR__);
414: Eigen::Matrix<T__,Eigen::Dynamic,1> r_2(N_2);
415: (void) r_2; // dummy to suppress unused var warning
416: stan::math::fill(r_2,DUMMY_VAR__);
417: Eigen::Matrix<T__,Eigen::Dynamic,1> r_3(N_3);
418: (void) r_3; // dummy to suppress unused var warning
419: stan::math::fill(r_3,DUMMY_VAR__);
420:
421: // initialize transformed variables to avoid seg fault on val access
422: stan::math::fill(eta,DUMMY_VAR__);
423: stan::math::fill(r_1,DUMMY_VAR__);
424: stan::math::fill(r_2,DUMMY_VAR__);
425: stan::math::fill(r_3,DUMMY_VAR__);
426:
427: try {
428: current_statement_begin__ = 41;
429: stan::math::assign(eta, multiply(X,b));
430: current_statement_begin__ = 42;
431: stan::math::assign(r_1, multiply(sd_1,pre_1));
432: current_statement_begin__ = 43;
433: stan::math::assign(r_2, multiply(sd_2,pre_2));
434: current_statement_begin__ = 44;
435: stan::math::assign(r_3, multiply(sd_3,pre_3));
436: current_statement_begin__ = 46;
437: for (int n = 1; n <= N; ++n) {
438: current_statement_begin__ = 47;
439: stan::math::assign(get_base1_lhs(eta,n,"eta",1), (((get_base1(eta,n,"eta",1) + (get_base1(Z_1,n,"Z_1",1) * get_base1(r_1,get_base1(J_1,n,"J_1",1),"r_1",1))) + (get_base1(Z_2,n,"Z_2",1) * get_base1(r_2,get_base1(J_2,n,"J_2",1),"r_2",1))) + (get_base1(Z_3,n,"Z_3",1) * get_base1(r_3,get_base1(J_3,n,"J_3",1),"r_3",1))));
440: }
441: } catch (const std::exception& e) {
442: stan::lang::rethrow_located(e,current_statement_begin__);
443: // Next line prevents compiler griping about no return
444: throw std::runtime_error("
* IF YOU SEE THIS, PLEASE REPORT A BUG ");
445: }
446:
447: // validate transformed parameters
448: for (int i0__ = 0; i0__ < N; ++i0__) {
449: if (stan::math::is_uninitialized(eta(i0__))) {
450: std::stringstream msg__;
451: msg__ << "Undefined transformed parameter: eta" << '[' << i0__ << ']';
452: throw std::runtime_error(msg__.str());
453: }
454: }
455: for (int i0__ = 0; i0__ < N_1; ++i0__) {
456: if (stan::math::is_uninitialized(r_1(i0__))) {
457: std::stringstream msg__;
458: msg__ << "Undefined transformed parameter: r_1" << '[' << i0__ << ']';
459: throw std::runtime_error(msg__.str());
460: }
461: }
462: for (int i0__ = 0; i0__ < N_2; ++i0__) {
463: if (stan::math::is_uninitialized(r_2(i0__))) {
464: std::stringstream msg__;
465: msg__ << "Undefined transformed parameter: r_2" << '[' << i0__ << ']';
466: throw std::runtime_error(msg__.str());
467: }
468: }
469: for (int i0__ = 0; i0__ < N_3; ++i0__) {
470: if (stan::math::is_uninitialized(r_3(i0__))) {
471: std::stringstream msg__;
472: msg__ << "Undefined transformed parameter: r_3" << '[' << i0__ << ']';
473: throw std::runtime_error(msg__.str());
474: }
475: }
476:
477: const char
function__ = "validate transformed params";
478: (void) function__; // dummy to suppress unused var warning
479:
480: // model body
481: try {
482: current_statement_begin__ = 52;
483: lp_accum__.add(cauchy_log<propto__>(sd_1, 0, 5));
484: current_statement_begin__ = 53;
485: lp_accum__.add(normal_log<propto__>(pre_1, 0, 1));
486: current_statement_begin__ = 54;
487: lp_accum__.add(cauchy_log<propto__>(sd_2, 0, 5));
488: current_statement_begin__ = 55;
489: lp_accum__.add(normal_log<propto__>(pre_2, 0, 1));
490: current_statement_begin__ = 56;
491: lp_accum__.add(cauchy_log<propto__>(sd_3, 0, 5));
492: current_statement_begin__ = 57;
493: lp_accum__.add(normal_log<propto__>(pre_3, 0, 1));
494: current_statement_begin__ = 59;
495: lp_accum__.add(poisson_log_log<propto__>(Y, eta));
496: } catch (const std::exception& e) {
497: stan::lang::rethrow_located(e,current_statement_begin__);
498: // Next line prevents compiler griping about no return
499: throw std::runtime_error("
* IF YOU SEE THIS, PLEASE REPORT A BUG ");
500: }
501:
502: lp_accum__.add(lp__);
503: return lp_accum__.sum();
504:
505: } // log_prob()
506:
507: template <bool propto, bool jacobian, typename T
>
508: T_ log_prob(Eigen::Matrix<T_,Eigen::Dynamic,1>& params_r,
509: std::ostream_ pstream = 0) const {
510: std::vector<T_> vec_params_r;
511: vec_params_r.reserve(params_r.size());
512: for (int i = 0; i < params_r.size(); ++i)
513: vec_params_r.push_back(params_r(i));
514: std::vector vec_params_i;
515: return log_prob<propto,jacobian,T_>(vec_params_r, vec_params_i, pstream);
516: }
517:
518:
519: void get_param_names(std::vectorstd::string& names__) const {
520: names__.resize(0);
521: names__.push_back("b");
522: names__.push_back("pre_1");
523: names__.push_back("sd_1");
524: names__.push_back("pre_2");
525: names__.push_back("sd_2");
526: names__.push_back("pre_3");
527: names__.push_back("sd_3");
528: names__.push_back("eta");
529: names__.push_back("r_1");
530: names__.push_back("r_2");
531: names__.push_back("r_3");
532: }
533:
534:
535: void get_dims(std::vectorstd::vector<size_t >& dimss__) const {
536: dimss__.resize(0);
537: std::vector<size_t> dims__;
538: dims__.resize(0);
539: dims__.push_back(K);
540: dimss__.push_back(dims__);
541: dims__.resize(0);
542: dims__.push_back(N_1);
543: dimss__.push_back(dims__);
544: dims__.resize(0);
545: dimss__.push_back(dims__);
546: dims__.resize(0);
547: dims__.push_back(N_2);
548: dimss__.push_back(dims__);
549: dims__.resize(0);
550: dimss__.push_back(dims__);
551: dims__.resize(0);
552: dims__.push_back(N_3);
553: dimss__.push_back(dims__);
554: dims__.resize(0);
555: dimss__.push_back(dims__);
556: dims__.resize(0);
557: dims__.push_back(N);
558: dimss__.push_back(dims__);
559: dims__.resize(0);
560: dims__.push_back(N_1);
561: dimss__.push_back(dims__);
562: dims__.resize(0);
563: dims__.push_back(N_2);
564: dimss__.push_back(dims__);
565: dims__.resize(0);
566: dims__.push_back(N_3);
567: dimss__.push_back(dims__);
568: }
569:
570: template
571: void write_array(RNG& base_rng__,
572: std::vector& params_r__,
573: std::vector& params_i__,
574: std::vector& vars__,
575: bool include_tparams__ = true,
576: bool include_gqs__ = true,
577: std::ostream* pstream__ = 0) const {
578: vars__.resize(0);
579: stan::io::reader in__(params_r__,params_i__);
580: static const char* function__ = "model7f35c2aac72_poisson_log__brms_model_namespace::write_array";
581: (void) function__; // dummy call to supress warning
582: // read-transform, write parameters
583: vector_d b = in__.vector_constrain(K);
584: vector_d pre_1 = in__.vector_constrain(N_1);
585: double sd_1 = in__.scalar_lb_constrain(0);
586: vector_d pre_2 = in__.vector_constrain(N_2);
587: double sd_2 = in__.scalar_lb_constrain(0);
588: vector_d pre_3 = in__.vector_constrain(N_3);
589: double sd_3 = in__.scalar_lb_constrain(0);
590: for (int k_0__ = 0; k_0__ < K; ++k_0__) {
591: vars__.push_back(b[k_0__]);
592: }
593: for (int k_0__ = 0; k_0__ < N_1; ++k_0__) {
594: vars__.push_back(pre_1[k_0__]);
595: }
596: vars__.push_back(sd_1);
597: for (int k_0__ = 0; k_0__ < N_2; ++k_0__) {
598: vars__.push_back(pre_2[k_0__]);
599: }
600: vars__.push_back(sd_2);
601: for (int k_0__ = 0; k_0__ < N_3; ++k_0__) {
602: vars__.push_back(pre_3[k_0__]);
603: }
604: vars__.push_back(sd_3);
605:
606: if (!include_tparams__) return;
607: // declare and define transformed parameters
608: double lp__ = 0.0;
609: (void) lp__; // dummy call to supress warning
610: stan::math::accumulator lp_accum__;
611:
612: vector_d eta(N);
613: (void) eta; // dummy to suppress unused var warning
614: vector_d r_1(N_1);
615: (void) r_1; // dummy to suppress unused var warning
616: vector_d r_2(N_2);
617: (void) r_2; // dummy to suppress unused var warning
618: vector_d r_3(N_3);
619: (void) r_3; // dummy to suppress unused var warning
620:
621: try {
622: current_statement_begin__ = 41;
623: stan::math::assign(eta, multiply(X,b));
624: current_statement_begin__ = 42;
625: stan::math::assign(r_1, multiply(sd_1,pre_1));
626: current_statement_begin__ = 43;
627: stan::math::assign(r_2, multiply(sd_2,pre_2));
628: current_statement_begin__ = 44;
629: stan::math::assign(r_3, multiply(sd_3,pre_3));
630: current_statement_begin__ = 46;
631: for (int n = 1; n <= N; ++n) {
632: current_statement_begin__ = 47;
633: stan::math::assign(get_base1_lhs(eta,n,"eta",1), (((get_base1(eta,n,"eta",1) + (get_base1(Z_1,n,"Z_1",1) * get_base1(r_1,get_base1(J_1,n,"J_1",1),"r_1",1))) + (get_base1(Z_2,n,"Z_2",1) * get_base1(r_2,get_base1(J_2,n,"J_2",1),"r_2",1))) + (get_base1(Z_3,n,"Z_3",1) * get_base1(r_3,get_base1(J_3,n,"J_3",1),"r_3",1))));
634: }
635: } catch (const std::exception& e) {
636: stan::lang::rethrow_located(e,current_statement_begin__);
637: // Next line prevents compiler griping about no return
638: throw std::runtime_error("
* IF YOU SEE THIS, PLEASE REPORT A BUG _");
639: }
640:
641: // validate transformed parameters
642:
643: // write transformed parameters
644: for (int k_0__ = 0; k_0__ < N; ++k_0__) {
645: vars__.push_back(eta[k_0__]);
646: }
647: for (int k_0__ = 0; k_0__ < N_1; ++k_0__) {
648: vars__.push_back(r_1[k_0__]);
649: }
650: for (int k_0__ = 0; k_0__ < N_2; ++k_0__) {
651: vars__.push_back(r_2[k_0__]);
652: }
653: for (int k_0__ = 0; k_0__ < N_3; ++k_0__) {
654: vars__.push_back(r_3[k_0__]);
655: }
656:
657: if (!include_gqs__) return;
658: // declare and define generated quantities
659:
660: double DUMMY_VAR__(std::numeric_limits::quiet_NaN());
661: (void) DUMMY_VAR__; // suppress unused var warning
662:
663:
664: // initialize transformed variables to avoid seg fault on val access
665:
666: try {
667: } catch (const std::exception& e) {
668: stan::lang::rethrow_located(e,current_statement_begin__);
669: // Next line prevents compiler griping about no return
670: throw std::runtime_error("
_ IF YOU SEE THIS, PLEASE REPORT A BUG ");
671: }
672:
673: // validate generated quantities
674:
675: // write generated quantities
676: }
677:
678: template
679: void write_array(RNG& base_rng,
680: Eigen::Matrix<double,Eigen::Dynamic,1>& params_r,
681: Eigen::Matrix<double,Eigen::Dynamic,1>& vars,
682: bool include_tparams = true,
683: bool include_gqs = true,
684: std::ostream
pstream = 0) const {
685: std::vector params_r_vec(params_r.size());
686: for (int i = 0; i < params_r.size(); ++i)
687: params_r_vec[i] = params_r(i);
688: std::vector vars_vec;
689: std::vector params_i_vec;
690: write_array(base_rng,params_r_vec,params_i_vec,vars_vec,include_tparams,include_gqs,pstream);
691: vars.resize(vars_vec.size());
692: for (int i = 0; i < vars.size(); ++i)
693: vars(i) = vars_vec[i];
694: }
695:
696: static std::string model_name() {
697: return "model7f35c2aac72_poisson_log__brms_model";
698: }
699:
700:
701: void constrained_param_names(std::vectorstd::string& param_names__,
702: bool include_tparams__ = true,
703: bool include_gqs__ = true) const {
704: std::stringstream param_name_stream__;
705: for (int k_0__ = 1; k_0__ <= K; ++k_0__) {
706: param_name_stream__.str(std::string());
707: param_name_stream__ << "b" << '.' << k_0__;
708: param_names__.push_back(param_name_stream__.str());
709: }
710: for (int k_0__ = 1; k_0__ <= N_1; ++k_0__) {
711: param_name_stream__.str(std::string());
712: param_name_stream__ << "pre_1" << '.' << k_0__;
713: param_names__.push_back(param_name_stream__.str());
714: }
715: param_name_stream__.str(std::string());
716: param_name_stream__ << "sd_1";
717: param_names__.push_back(param_name_stream__.str());
718: for (int k_0__ = 1; k_0__ <= N_2; ++k_0__) {
719: param_name_stream__.str(std::string());
720: param_name_stream__ << "pre_2" << '.' << k_0__;
721: param_names__.push_back(param_name_stream__.str());
722: }
723: param_name_stream__.str(std::string());
724: param_name_stream__ << "sd_2";
725: param_names__.push_back(param_name_stream__.str());
726: for (int k_0__ = 1; k_0__ <= N_3; ++k_0__) {
727: param_name_stream__.str(std::string());
728: param_name_stream__ << "pre_3" << '.' << k_0__;
729: param_names__.push_back(param_name_stream__.str());
730: }
731: param_name_stream__.str(std::string());
732: param_name_stream__ << "sd_3";
733: param_names__.push_back(param_name_stream__.str());
734:
735: if (!include_gqs__ && !include_tparams__) return;
736: for (int k_0__ = 1; k_0__ <= N; ++k_0__) {
737: param_name_stream__.str(std::string());
738: param_name_stream__ << "eta" << '.' << k_0__;
739: param_names__.push_back(param_name_stream__.str());
740: }
741: for (int k_0__ = 1; k_0__ <= N_1; ++k_0__) {
742: param_name_stream__.str(std::string());
743: param_name_stream__ << "r_1" << '.' << k_0__;
744: param_names__.push_back(param_name_stream__.str());
745: }
746: for (int k_0__ = 1; k_0__ <= N_2; ++k_0__) {
747: param_name_stream__.str(std::string());
748: param_name_stream__ << "r_2" << '.' << k_0__;
749: param_names__.push_back(param_name_stream__.str());
750: }
751: for (int k_0__ = 1; k_0__ <= N_3; ++k_0__) {
752: param_name_stream__.str(std::string());
753: param_name_stream__ << "r_3" << '.' << k_0__;
754: param_names__.push_back(param_name_stream__.str());
755: }
756:
757: if (!include_gqs__) return;
758: }
759:
760:
761: void unconstrained_param_names(std::vectorstd::string& param_names__,
762: bool include_tparams__ = true,
763: bool include_gqs__ = true) const {
764: std::stringstream param_name_stream__;
765: for (int k_0__ = 1; k_0__ <= K; ++k_0__) {
766: param_name_stream__.str(std::string());
767: param_name_stream__ << "b" << '.' << k_0__;
768: param_names__.push_back(param_name_stream__.str());
769: }
770: for (int k_0__ = 1; k_0__ <= N_1; ++k_0__) {
771: param_name_stream__.str(std::string());
772: param_name_stream__ << "pre_1" << '.' << k_0__;
773: param_names__.push_back(param_name_stream__.str());
774: }
775: param_name_stream__.str(std::string());
776: param_name_stream__ << "sd_1";
777: param_names__.push_back(param_name_stream__.str());
778: for (int k_0__ = 1; k_0__ <= N_2; ++k_0__) {
779: param_name_stream__.str(std::string());
780: param_name_stream__ << "pre_2" << '.' << k_0__;
781: param_names__.push_back(param_name_stream__.str());
782: }
783: param_name_stream__.str(std::string());
784: param_name_stream__ << "sd_2";
785: param_names__.push_back(param_name_stream__.str());
786: for (int k_0__ = 1; k_0__ <= N_3; ++k_0__) {
787: param_name_stream__.str(std::string());
788: param_name_stream__ << "pre_3" << '.' << k_0__;
789: param_names__.push_back(param_name_stream__.str());
790: }
791: param_name_stream__.str(std::string());
792: param_name_stream__ << "sd_3";
793: param_names__.push_back(param_name_stream__.str());
794:
795: if (!include_gqs__ && !include_tparams__) return;
796: for (int k_0__ = 1; k_0__ <= N; ++k_0__) {
797: param_name_stream__.str(std::string());
798: param_name_stream__ << "eta" << '.' << k_0__;
799: param_names__.push_back(param_name_stream__.str());
800: }
801: for (int k_0__ = 1; k_0__ <= N_1; ++k_0__) {
802: param_name_stream__.str(std::string());
803: param_name_stream__ << "r_1" << '.' << k_0__;
804: param_names__.push_back(param_name_stream__.str());
805: }
806: for (int k_0__ = 1; k_0__ <= N_2; ++k_0__) {
807: param_name_stream__.str(std::string());
808: param_name_stream__ << "r_2" << '.' << k_0__;
809: param_names__.push_back(param_name_stream__.str());
810: }
811: for (int k_0__ = 1; k_0__ <= N_3; ++k_0__) {
812: param_name_stream__.str(std::string());
813: param_name_stream__ << "r_3" << '.' << k_0__;
814: param_names__.push_back(param_name_stream__.str());
815: }
816:
817: if (!include_gqs__) return;
818: }
819:
820: }; // model
821:
822: } // namespace
823:
824: typedef model7f35c2aac72_poisson_log__brms_model_namespace::model7f35c2aac72_poisson_log__brms_model stan_model;
825:
826: #include <rstan/rstaninc.hpp>
827: /

828: * Define Rcpp Module to expose stan_fit's functions to R.
829: /
830: RCPP_MODULE(stan_fit4model7f35c2aac72_poisson_log__brms_model_mod){
831: Rcpp::class
<rstan::stan_fit<model7f35c2aac72_poisson_log__brms_model_namespace::model7f35c2aac72_poisson_log__brms_model,
832: boost::random::ecuyer1988> >("stan_fit4model7f35c2aac72_poisson_log__brms_model")
833: // .constructorRcpp::List()
834: .constructor<SEXP, SEXP>()
835: // .constructor<SEXP, SEXP>()
836: .method("call_sampler",
837: &rstan::stan_fit<model7f35c2aac72_poisson_log__brms_model_namespace::model7f35c2aac72_poisson_log__brms_model, boost::random::ecuyer1988>::call_sampler)
838: .method("param_names",
839: &rstan::stan_fit<model7f35c2aac72_poisson_log__brms_model_namespace::model7f35c2aac72_poisson_log__brms_model, boost::random::ecuyer1988>::param_names)
840: .method("param_names_oi",
841: &rstan::stan_fit<model7f35c2aac72_poisson_log__brms_model_namespace::model7f35c2aac72_poisson_log__brms_model, boost::random::ecuyer1988>::param_names_oi)
842: .method("param_fnames_oi",
843: &rstan::stan_fit<model7f35c2aac72_poisson_log__brms_model_namespace::model7f35c2aac72_poisson_log__brms_model, boost::random::ecuyer1988>::param_fnames_oi)
844: .method("param_dims",
845: &rstan::stan_fit<model7f35c2aac72_poisson_log__brms_model_namespace::model7f35c2aac72_poisson_log__brms_model, boost::random::ecuyer1988>::param_dims)
846: .method("param_dims_oi",
847: &rstan::stan_fit<model7f35c2aac72_poisson_log__brms_model_namespace::model7f35c2aac72_poisson_log__brms_model, boost::random::ecuyer1988>::param_dims_oi)
848: .method("update_param_oi",
849: &rstan::stan_fit<model7f35c2aac72_poisson_log__brms_model_namespace::model7f35c2aac72_poisson_log__brms_model, boost::random::ecuyer1988>::update_param_oi)
850: .method("param_oi_tidx",
851: &rstan::stan_fit<model7f35c2aac72_poisson_log__brms_model_namespace::model7f35c2aac72_poisson_log__brms_model, boost::random::ecuyer1988>::param_oi_tidx)
852: .method("grad_log_prob",
853: &rstan::stan_fit<model7f35c2aac72_poisson_log__brms_model_namespace::model7f35c2aac72_poisson_log__brms_model, boost::random::ecuyer1988>::grad_log_prob)
854: .method("log_prob",
855: &rstan::stan_fit<model7f35c2aac72_poisson_log__brms_model_namespace::model7f35c2aac72_poisson_log__brms_model, boost::random::ecuyer1988>::log_prob)
856: .method("unconstrain_pars",
857: &rstan::stan_fit<model7f35c2aac72_poisson_log__brms_model_namespace::model7f35c2aac72_poisson_log__brms_model, boost::random::ecuyer1988>::unconstrain_pars)
858: .method("constrain_pars",
859: &rstan::stan_fit<model7f35c2aac72_poisson_log__brms_model_namespace::model7f35c2aac72_poisson_log__brms_model, boost::random::ecuyer1988>::constrain_pars)
860: .method("num_pars_unconstrained",
861: &rstan::stan_fit<model7f35c2aac72_poisson_log__brms_model_namespace::model7f35c2aac72_poisson_log__brms_model, boost::random::ecuyer1988>::num_pars_unconstrained)
862: .method("unconstrained_param_names",
863: &rstan::stan_fit<model7f35c2aac72_poisson_log__brms_model_namespace::model7f35c2aac72_poisson_log__brms_model, boost::random::ecuyer1988>::unconstrained_param_names)
864: .method("constrained_param_names",
865: &rstan::stan_fit<model7f35c2aac72_poisson_log__brms_model_namespace::model7f35c2aac72_poisson_log__brms_model, boost::random::ecuyer1988>::constrained_param_names)
866: ;
867: }
868:
869: // declarations
870: extern "C" {
871: SEXP file7f3759f9fa3( ) ;
872: }
873:
874: // definition
875:
876: SEXP file7f3759f9fa3( ){
877: return Rcpp::wrap("poisson(log) brms-model");
878: }
879:
880:
Error in compileCode(f, code, language = language, verbose = verbose) :
Compilation ERROR, function(s)/method(s) not created! In file included from file7f3759f9fa3.cpp:826:
In file included from /Library/Frameworks/R.framework/Versions/3.2/Resources/library/rstan/include/rstan/rstaninc.hpp:3:
In file included from /Library/Frameworks/R.framework/Versions/3.2/Resources/library/rstan/include/rstan/stan_fit.hpp:80:
/Library/Frameworks/R.framework/Versions/3.2/Resources/library/rstan/include/rstan/io/rlist_ref_var_context_factory.hpp:4:10: fatal error: 'stan/interface/var_context_factory/dump_factory.hpp' file not found
#include <stan/interface/var_context_factory/dump_factory.hpp>
^
1 error generated.
make: *_* [file7f3759f9fa3.o] Error 1
In addition: Warning message:
running command '/Library/Frameworks/R.framework/Resources/bin/R CMD SHLIB file7f3759f9fa3.cpp 2> file7f3759f9fa3.cpp.err.txt' had status 1

sessionInfo()
R version 3.2.2 (2015-08-14)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X 10.10.5 (Yosemite)

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats graphics grDevices utils datasets methods
[7] base

other attached packages:
[1] brms_0.5.0 ggplot2_1.0.1 rstan_2.7.0-1 inline_0.3.14
[5] Rcpp_0.12.1

loaded via a namespace (and not attached):
[1] digest_0.6.8 MASS_7.3-44 grid_3.2.2 plyr_1.8.3
[5] gtable_0.1.2 stats4_3.2.2 magrittr_1.5 scales_0.3.0
[9] stringi_0.5-5 reshape2_1.4.1 proto_0.3-10 tools_3.2.2
[13] stringr_1.0.0 munsell_0.4.2 parallel_3.2.2 abind_1.4-3
[17] colorspace_1.2-6 gridExtra_2.0.0

@mrdevlar
Copy link
Author

So if Steamheaders isn't building from CRAN, what is the correct method of building it prior to the fix?

@bgoodri
Copy link
Contributor

bgoodri commented Sep 18, 2015

rstan 2.7.0-1 should work fine with StanHeaders 2.7.0. If necessary, you can install that version with

devtools::install_url("https://cran.r-project.org/src/contrib/Archive/StanHeaders/StanHeaders_2.7.0.tar.gz")

The develop branch of rstan should work fine with StanHeaders 2.8.0 on CRAN if you do

devtools::install_github("stan-dev/rstan", subdir = "rstan/rstan", ref = "develop")

and that is what will be uploaded to CRAN later today.

@rlumor
Copy link

rlumor commented Sep 18, 2015

After installing the packages, I still get the same errors.

Error in compileCode(f, code, language = language, verbose = verbose) :
Compilation ERROR, function(s)/method(s) not created! In file included from filea4a5c9dd50.cpp:826:
In file included from /Library/Frameworks/R.framework/Versions/3.2/Resources/library/rstan/include/rstan/rstaninc.hpp:3:
In file included from /Library/Frameworks/R.framework/Versions/3.2/Resources/library/rstan/include/rstan/stan_fit.hpp:80:
/Library/Frameworks/R.framework/Versions/3.2/Resources/library/rstan/include/rstan/io/rlist_ref_var_context_factory.hpp:4:10: fatal error: 'stan/interface/var_context_factory/dump_factory.hpp' file not found
#include <stan/interface/var_context_factory/dump_factory.hpp>
^
1 error generated.
make: *** [filea4a5c9dd50.o] Error 1
In addition: Warning message:
running command '/Library/Frameworks/R.framework/Resources/bin/R CMD SHLIB filea4a5c9dd50.cpp 2> filea4a5c9dd50.cpp.err.txt' had status 1

@bgoodri
Copy link
Contributor

bgoodri commented Sep 18, 2015

Installing which packages exactly?

On Fri, Sep 18, 2015 at 9:12 AM, rlumor notifications@github.com wrote:

After installing the packages, I still get the same errors.

Error in compileCode(f, code, language = language, verbose = verbose) :
Compilation ERROR, function(s)/method(s) not created! In file included
from filea4a5c9dd50.cpp:826:
In file included from
/Library/Frameworks/R.framework/Versions/3.2/Resources/library/rstan/include/rstan/rstaninc.hpp:3:
In file included from
/Library/Frameworks/R.framework/Versions/3.2/Resources/library/rstan/include/rstan/stan_fit.hpp:80:
/Library/Frameworks/R.framework/Versions/3.2/Resources/library/rstan/include/rstan/io/rlist_ref_var_context_factory.hpp:4:10:
fatal error: 'stan/interface/var_context_factory/dump_factory.hpp' file not
found
#include
^
1 error generated.
make: *** [filea4a5c9dd50.o] Error 1
In addition: Warning message:
running command '/Library/Frameworks/R.framework/Resources/bin/R CMD SHLIB
filea4a5c9dd50.cpp 2> filea4a5c9dd50.cpp.err.txt' had status 1


Reply to this email directly or view it on GitHub
#210 (comment).

@rlumor
Copy link

rlumor commented Sep 18, 2015

this two
devtools::install_url("https://cran.rproject.org/src/contrib/Archive/StanHeaders/StanHeaders_2.7.0.tar.gz")
devtools::install_github("stan-dev/rstan", subdir = "rstan/rstan", ref = "develop")

I use another function called "brms' to run my models.

R version 3.2.2 (2015-08-14)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X 10.10.5 (Yosemite)

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats graphics grDevices utils datasets methods
[7] base

other attached packages:
[1] brms_0.5.0 ggplot2_1.0.1 rstan_2.7.0-1 inline_0.3.14
[5] Rcpp_0.12.1

loaded via a namespace (and not attached):
[1] digest_0.6.8 MASS_7.3-44 grid_3.2.2 plyr_1.8.3
[5] gtable_0.1.2 stats4_3.2.2 magrittr_1.5 scales_0.3.0
[9] stringi_0.5-5 reshape2_1.4.1 proto_0.3-10 tools_3.2.2
[13] stringr_1.0.0 munsell_0.4.2 parallel_3.2.2 abind_1.4-3
[17] colorspace_1.2-6 gridExtra_2.0.0

@bgoodri
Copy link
Contributor

bgoodri commented Sep 18, 2015

Those two are incompatible. You can do one or the other and it will probably work.
Choice 1

 devtools::install_url("https://cran.rproject.org/src/contrib/Archive/StanHeaders/StanHeaders_2.7.0.tar.gz")
install.packages("rstan", dependencies = TRUE) # from CRAN

Choice 2

install.packages("StanHeaders") # from CRAN
devtools::install_github("stan-dev/rstan", subdir = "rstan/rstan", ref = "develop")

the latter may also require that you install ggplot2 and gridExtra from CRAN.

@rlumor
Copy link

rlumor commented Sep 18, 2015

Thank you!!!!!!....the second option made it work!!!!

@mrdevlar
Copy link
Author

I didn't mean to close it.

The first option causes the same as the original crash.
The second option results in a build failure.

Downloading GitHub repo stan-dev/rstan@develop
Installing rstan
"C:/PROGRA~1/R/R-32~1.2/bin/x64/R" --no-site-file --no-environ --no-save --no-restore CMD INSTALL  \
  "C:/Users/ripod1/AppData/Local/Temp/Rtmp6xBIBR/devtools15f8433f5be5/stan-dev-rstan-ced2b8f/rstan/rstan"  \
  --library="C:/RETNLSO-NT0002/RIPOD1$/Document/Library" --install-tests 

* installing *source* package 'rstan' ...
** libs

*** arch - i386
g++ -m32 -I"C:/PROGRA~1/R/R-32~1.2/include" -DNDEBUG -I"../inst/include" -I"../inst/include/boost_not_in_BH" -I"`"C:/PROGRA~1/R/R-32~1.2/bin/i386/Rscript" --vanilla -e "cat(system.file('include', 'src', package = 'StanHeaders'))"`" -DBOOST_RESULT_OF_USE_TR1 -DBOOST_NO_DECLTYPE -DBOOST_DISABLE_ASSERTS   -I"C:/RETNLSO-NT0002/RIPOD1Document/Library/Rcpp/include" -I"C:/RETNLSO-NT0002/RIPOD1Document/Library/RcppEigen/include" -I"C:/RETNLSO-NT0002/RIPOD1Document/Library/BH/include" -I"C:/RETNLSO-NT0002/RIPOD1Document/Library/StanHeaders/include" -I"d:/RCompile/r-compiling/local/local320/include"     -O3 -c chains.cpp -o chains.o
chains.cpp:19:43: fatal error: stan/math/prim/mat/fun/mean.hpp: No such file or directory
compilation terminated.
make: *** [chains.o] Error 1
Warning: running command 'make -f "Makevars.win" -f "C:/PROGRA~1/R/R-32~1.2/etc/i386/Makeconf" -f "C:/PROGRA~1/R/R-32~1.2/share/make/winshlib.mk" -f "C:\RETNLSO-NT0002\RIPOD1$\Document/.R/Makevars" SHLIB_LDFLAGS='$(SHLIB_CXXLDFLAGS)' SHLIB_LD='$(SHLIB_CXXLD)' SHLIB="rstan.dll" OBJECTS="chains.o init.o lang__ast_def.o lang__grammars__bare_type_grammar_inst.o lang__grammars__expression07_grammar_inst.o lang__grammars__expression_grammar_inst.o lang__grammars__functions_grammar_inst.o lang__grammars__program_grammar_inst.o lang__grammars__statement_2_grammar_inst.o lang__grammars__statement_grammar_inst.o lang__grammars__term_grammar_inst.o lang__grammars__var_deccls_grammar_inst.o lang__grammars__whitespace_grammar_inst.o misc.o stanc.o"' had status 2
ERROR: compilation failed for package 'rstan'
* removing 'C:/RETNLSO-NT0002/RIPOD1$/Document/Library/rstan'
Error: Command failed (1)
In addition: Warning message:
GitHub repo contains submodules, may not function as expected! 

@bgoodri
Copy link
Contributor

bgoodri commented Sep 18, 2015

For the second option, make sure you have StanHeaders 2.8.0 plus ggplot2
and gridExtra, all of which can be gotten from CRAN

install.packages(c("StanHeaders", "ggplot2", "gridExtra"))

then do

devtools::install_github("stan-dev/rstan", subdir = "rstan/rstan", ref =
"develop")

On Fri, Sep 18, 2015 at 10:36 AM, Richard Podkolinski <
notifications@github.com> wrote:

I didn't mean to close it.

The first option causes the same as the original crash.
The second option results in a build failure.

Downloading GitHub repo stan-dev/rstan@develop
Installing rstan
"C:/PROGRA1/R/R-321.2/bin/x64/R" --no-site-file --no-environ --no-save --no-restore CMD INSTALL
"C:/Users/ripod1/AppData/Local/Temp/Rtmp6xBIBR/devtools15f8433f5be5/stan-dev-rstan-ced2b8f/rstan/rstan"
--library="C:/RETNLSO-NT0002/RIPOD1$/Document/Library" --install-tests

  • installing source package 'rstan' ...
    ** libs

*** arch - i386
g++ -m32 -I"C:/PROGRA1/R/R-321.2/include" -DNDEBUG -I"../inst/include" -I"../inst/include/boost_not_in_BH" -I""C:/PROGRA~1/R/R-32~1.2/bin/i386/Rscript" --vanilla -e "cat(system.file('include', 'src', package = 'StanHeaders'))"" -DBOOST_RESULT_OF_USE_TR1 -DBOOST_NO_DECLTYPE -DBOOST_DISABLE_ASSERTS -I"C:/RETNLSO-NT0002/RIPOD1Document/Library/Rcpp/include" -I"C:/RETNLSO-NT0002/RIPOD1Document/Library/RcppEigen/include" -I"C:/RETNLSO-NT0002/RIPOD1Document/Library/BH/include" -I"C:/RETNLSO-NT0002/RIPOD1Document/Library/StanHeaders/include" -I"d:/RCompile/r-compiling/local/local320/include" -O3 -c chains.cpp -o chains.o
chains.cpp:19:43: fatal error: stan/math/prim/mat/fun/mean.hpp: No such file or directory
compilation terminated.
make: *** [chains.o] Error 1
Warning: running command 'make -f "Makevars.win" -f "C:/PROGRA1/R/R-321.2/etc/i386/Makeconf" -f "C:/PROGRA1/R/R-321.2/share/make/winshlib.mk" -f "C:\RETNLSO-NT0002\RIPOD1$\Document/.R/Makevars" SHLIB_LDFLAGS='$(SHLIB_CXXLDFLAGS)' SHLIB_LD='$(SHLIB_CXXLD)' SHLIB="rstan.dll" OBJECTS="chains.o init.o lang__ast_def.o lang__grammars__bare_type_grammar_inst.o lang__grammars__expression07_grammar_inst.o lang__grammars__expression_grammar_inst.o lang__grammars__functions_grammar_inst.o lang__grammars__program_grammar_inst.o lang__grammars__statement_2_grammar_inst.o lang__grammars__statement_grammar_inst.o lang__grammars__term_grammar_inst.o lang__grammars__var_deccls_grammar_inst.o lang__grammars__whitespace_grammar_inst.o misc.o stanc.o"' had status 2
ERROR: compilation failed for package 'rstan'

  • removing 'C:/RETNLSO-NT0002/RIPOD1$/Document/Library/rstan'
    Error: Command failed (1)
    In addition: Warning message:
    GitHub repo contains submodules, may not function as expected!


Reply to this email directly or view it on GitHub
#210 (comment).

@mrdevlar
Copy link
Author

It still failed on build.

Downloading GitHub repo stan-dev/rstan@develop
Installing rstan
"C:/PROGRA~1/R/R-32~1.2/bin/x64/R" --no-site-file --no-environ --no-save --no-restore CMD INSTALL  \
  "C:/Users/ripod1/AppData/Local/Temp/RtmpWqVTe2/devtoolsd243c8d6d28/stan-dev-rstan-ced2b8f/rstan/rstan"  \
  --library="C:/RETNLSO-NT0002/RIPOD1$/Document/Library" --install-tests 

* installing *source* package 'rstan' ...
** libs

*** arch - i386
g++ -m32 -I"C:/PROGRA~1/R/R-32~1.2/include" -DNDEBUG -I"../inst/include" -I"../inst/include/boost_not_in_BH" -I"`"C:/PROGRA~1/R/R-32~1.2/bin/i386/Rscript" --vanilla -e "cat(system.file('include', 'src', package = 'StanHeaders'))"`" -DBOOST_RESULT_OF_USE_TR1 -DBOOST_NO_DECLTYPE -DBOOST_DISABLE_ASSERTS   -I"C:/RETNLSO-NT0002/RIPOD1Document/Library/Rcpp/include" -I"C:/RETNLSO-NT0002/RIPOD1Document/Library/RcppEigen/include" -I"C:/RETNLSO-NT0002/RIPOD1Document/Library/BH/include" -I"C:/RETNLSO-NT0002/RIPOD1Document/Library/StanHeaders/include" -I"d:/RCompile/r-compiling/local/local320/include"     -O3 -c chains.cpp -o chains.o
chains.cpp:19:43: fatal error: stan/math/prim/mat/fun/mean.hpp: No such file or directory
compilation terminated.
make: *** [chains.o] Error 1
Warning: running command 'make -f "Makevars.win" -f "C:/PROGRA~1/R/R-32~1.2/etc/i386/Makeconf" -f "C:/PROGRA~1/R/R-32~1.2/share/make/winshlib.mk" -f "C:\RETNLSO-NT0002\RIPOD1$\Document/.R/Makevars" SHLIB_LDFLAGS='$(SHLIB_CXXLDFLAGS)' SHLIB_LD='$(SHLIB_CXXLD)' SHLIB="rstan.dll" OBJECTS="chains.o init.o lang__ast_def.o lang__grammars__bare_type_grammar_inst.o lang__grammars__expression07_grammar_inst.o lang__grammars__expression_grammar_inst.o lang__grammars__functions_grammar_inst.o lang__grammars__program_grammar_inst.o lang__grammars__statement_2_grammar_inst.o lang__grammars__statement_grammar_inst.o lang__grammars__term_grammar_inst.o lang__grammars__var_deccls_grammar_inst.o lang__grammars__whitespace_grammar_inst.o misc.o stanc.o"' had status 2
ERROR: compilation failed for package 'rstan'
* removing 'C:/RETNLSO-NT0002/RIPOD1$/Document/Library/rstan'
Error: Command failed (1)
In addition: Warning message:
GitHub repo contains submodules, may not function as expected! 

@bgoodri
Copy link
Contributor

bgoodri commented Sep 18, 2015

I don't know what is going on. Maybe try remove.packages(c("StanHeaders",
"rstan")) first? Or, you can install a binary of rstan with

install.packages("
http://win-builder.r-project.org/OTFoAU8URMkZ/rstan_2.8.0.zip", repos =
NULL)

On Fri, Sep 18, 2015 at 10:53 AM, Richard Podkolinski <
notifications@github.com> wrote:

It still failed on build.

Downloading GitHub repo stan-dev/rstan@develop
Installing rstan
"C:/PROGRA1/R/R-321.2/bin/x64/R" --no-site-file --no-environ --no-save --no-restore CMD INSTALL
"C:/Users/ripod1/AppData/Local/Temp/RtmpWqVTe2/devtoolsd243c8d6d28/stan-dev-rstan-ced2b8f/rstan/rstan"
--library="C:/RETNLSO-NT0002/RIPOD1$/Document/Library" --install-tests

  • installing source package 'rstan' ...
    ** libs

*** arch - i386
g++ -m32 -I"C:/PROGRA1/R/R-321.2/include" -DNDEBUG -I"../inst/include" -I"../inst/include/boost_not_in_BH" -I""C:/PROGRA~1/R/R-32~1.2/bin/i386/Rscript" --vanilla -e "cat(system.file('include', 'src', package = 'StanHeaders'))"" -DBOOST_RESULT_OF_USE_TR1 -DBOOST_NO_DECLTYPE -DBOOST_DISABLE_ASSERTS -I"C:/RETNLSO-NT0002/RIPOD1Document/Library/Rcpp/include" -I"C:/RETNLSO-NT0002/RIPOD1Document/Library/RcppEigen/include" -I"C:/RETNLSO-NT0002/RIPOD1Document/Library/BH/include" -I"C:/RETNLSO-NT0002/RIPOD1Document/Library/StanHeaders/include" -I"d:/RCompile/r-compiling/local/local320/include" -O3 -c chains.cpp -o chains.o
chains.cpp:19:43: fatal error: stan/math/prim/mat/fun/mean.hpp: No such file or directory
compilation terminated.
make: *** [chains.o] Error 1
Warning: running command 'make -f "Makevars.win" -f "C:/PROGRA1/R/R-321.2/etc/i386/Makeconf" -f "C:/PROGRA1/R/R-321.2/share/make/winshlib.mk" -f "C:\RETNLSO-NT0002\RIPOD1$\Document/.R/Makevars" SHLIB_LDFLAGS='$(SHLIB_CXXLDFLAGS)' SHLIB_LD='$(SHLIB_CXXLD)' SHLIB="rstan.dll" OBJECTS="chains.o init.o lang__ast_def.o lang__grammars__bare_type_grammar_inst.o lang__grammars__expression07_grammar_inst.o lang__grammars__expression_grammar_inst.o lang__grammars__functions_grammar_inst.o lang__grammars__program_grammar_inst.o lang__grammars__statement_2_grammar_inst.o lang__grammars__statement_grammar_inst.o lang__grammars__term_grammar_inst.o lang__grammars__var_deccls_grammar_inst.o lang__grammars__whitespace_grammar_inst.o misc.o stanc.o"' had status 2
ERROR: compilation failed for package 'rstan'

  • removing 'C:/RETNLSO-NT0002/RIPOD1$/Document/Library/rstan'
    Error: Command failed (1)
    In addition: Warning message:
    GitHub repo contains submodules, may not function as expected!


Reply to this email directly or view it on GitHub
#210 (comment).

@mrdevlar
Copy link
Author

I did that every time, and it still fails on me.

Anyway, thank you for taking the time to help me, I guess I will wait for the CRAN code to be updated and give it another shot.

@mrdevlar
Copy link
Author

Despite the update, I am still getting the same error as before

> schools_dat <- list(J = 8, 
+                     y = c(28,  8, -3,  7, -1,  1, 18, 12),
+                     sigma = c(15, 10, 16, 11,  9, 11, 10, .... [TRUNCATED] 

> fit <- stan(file = '8schools.stan', data = schools_dat, 
+             iter = 1000, chains = 4)
file191077307f07.cpp:8:39: fatal error: stan/model/model_header.hpp: No such file or directory
compilation terminated.
make: *** [file191077307f07.o] Error 1
Warning message:
running command 'make -f "C:/PROGRA~1/R/R-32~1.2/etc/x64/Makeconf" -f "C:/PROGRA~1/R/R-32~1.2/share/make/winshlib.mk" -f "C:\RETNLSO-NT0002\RIPOD1$\Document/.R/Makevars" SHLIB_LDFLAGS='$(SHLIB_CXXLDFLAGS)' SHLIB_LD='$(SHLIB_CXXLD)' SHLIB="file191077307f07.dll" WIN=64 TCLBIN=64 OBJECTS="file191077307f07.o"' had status 2 

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: #define STAN__SERVICES__COMMAND_HPP// Code generated by Stan version 2.8
  7: 
  8: #include <stan/model/model_header.hpp>
  9: 
 10: namespace model19104aa74803_8schools_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: typedef Eigen::Matrix<double,Eigen::Dynamic,1> vector_d;
 22: typedef Eigen::Matrix<double,1,Eigen::Dynamic> row_vector_d;
 23: typedef Eigen::Matrix<double,Eigen::Dynamic,Eigen::Dynamic> matrix_d;
 24: 
 25: static int current_statement_begin__;
 26: class model19104aa74803_8schools : public prob_grad {
 27: private:
 28:     int J;
 29:     vector<double> y;
 30:     vector<double> sigma;
 31: public:
 32:     model19104aa74803_8schools(stan::io::var_context& context__,
 33:         std::ostream* pstream__ = 0)
 34:         : prob_grad(0) {
 35:         current_statement_begin__ = -1;
 36: 
 37:         static const char* function__ = "model19104aa74803_8schools_namespace::model19104aa74803_8schools";
 38:         (void) function__; // dummy call to supress warning
 39:         size_t pos__;
 40:         (void) pos__; // dummy call to supress warning
 41:         std::vector<int> vals_i__;
 42:         std::vector<double> vals_r__;
 43:         context__.validate_dims("data initialization", "J", "int", context__.to_vec());
 44:         J = int(0);
 45:         vals_i__ = context__.vals_i("J");
 46:         pos__ = 0;
 47:         J = vals_i__[pos__++];
 48:         context__.validate_dims("data initialization", "y", "double", context__.to_vec(J));
 49:         validate_non_negative_index("y", "J", J);
 50:         y = std::vector<double>(J,double(0));
 51:         vals_r__ = context__.vals_r("y");
 52:         pos__ = 0;
 53:         size_t y_limit_0__ = J;
 54:         for (size_t i_0__ = 0; i_0__ < y_limit_0__; ++i_0__) {
 55:             y[i_0__] = vals_r__[pos__++];
 56:         }
 57:         context__.validate_dims("data initialization", "sigma", "double", context__.to_vec(J));
 58:         validate_non_negative_index("sigma", "J", J);
 59:         sigma = std::vector<double>(J,double(0));
 60:         vals_r__ = context__.vals_r("sigma");
 61:         pos__ = 0;
 62:         size_t sigma_limit_0__ = J;
 63:         for (size_t i_0__ = 0; i_0__ < sigma_limit_0__; ++i_0__) {
 64:             sigma[i_0__] = vals_r__[pos__++];
 65:         }
 66: 
 67:         // validate data
 68:         check_greater_or_equal(function__,"J",J,0);
 69:         for (int k0__ = 0; k0__ < J; ++k0__) {
 70:             check_greater_or_equal(function__,"sigma[k0__]",sigma[k0__],0);
 71:         }
 72: 
 73:         double DUMMY_VAR__(std::numeric_limits<double>::quiet_NaN());
 74:         (void) DUMMY_VAR__;  // suppress unused var warning
 75: 
 76: 
 77:         // initialize transformed variables to avoid seg fault on val access
 78: 
 79:         try {
 80:         } catch (const std::exception& e) {
 81:             stan::lang::rethrow_located(e,current_statement_begin__);
 82:             // Next line prevents compiler griping about no return
 83: throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***");
 84:         }
 85: 
 86:         // validate transformed data
 87: 
 88:         // set parameter ranges
 89:         num_params_r__ = 0U;
 90:         param_ranges_i__.clear();
 91:         ++num_params_r__;
 92:         ++num_params_r__;
 93:         num_params_r__ += J;
 94:     }
 95: 
 96:     ~model19104aa74803_8schools() { }
 97: 
 98: 
 99:     void transform_inits(const stan::io::var_context& context__,
100:                          std::vector<int>& params_i__,
101:                          std::vector<double>& params_r__,
102:                          std::ostream* pstream__) const {
103:         stan::io::writer<double> writer__(params_r__,params_i__);
104:         size_t pos__;
105:         (void) pos__; // dummy call to supress warning
106:         std::vector<double> vals_r__;
107:         std::vector<int> vals_i__;
108: 
109:         if (!(context__.contains_r("mu")))
110:             throw std::runtime_error("variable mu missing");
111:         vals_r__ = context__.vals_r("mu");
112:         pos__ = 0U;
113:         context__.validate_dims("initialization", "mu", "double", context__.to_vec());
114:         double mu(0);
115:         mu = vals_r__[pos__++];
116:         try {
117:             writer__.scalar_unconstrain(mu);
118:         } catch (const std::exception& e) { 
119:             throw std::runtime_error(std::string("Error transforming variable mu: ") + e.what());
120:         }
121: 
122:         if (!(context__.contains_r("tau")))
123:             throw std::runtime_error("variable tau missing");
124:         vals_r__ = context__.vals_r("tau");
125:         pos__ = 0U;
126:         context__.validate_dims("initialization", "tau", "double", context__.to_vec());
127:         double tau(0);
128:         tau = vals_r__[pos__++];
129:         try {
130:             writer__.scalar_lb_unconstrain(0,tau);
131:         } catch (const std::exception& e) { 
132:             throw std::runtime_error(std::string("Error transforming variable tau: ") + e.what());
133:         }
134: 
135:         if (!(context__.contains_r("eta")))
136:             throw std::runtime_error("variable eta missing");
137:         vals_r__ = context__.vals_r("eta");
138:         pos__ = 0U;
139:         context__.validate_dims("initialization", "eta", "double", context__.to_vec(J));
140:         std::vector<double> eta(J,double(0));
141:         for (int i0__ = 0U; i0__ < J; ++i0__)
142:             eta[i0__] = vals_r__[pos__++];
143:         for (int i0__ = 0U; i0__ < J; ++i0__)
144:             try {
145:             writer__.scalar_unconstrain(eta[i0__]);
146:         } catch (const std::exception& e) { 
147:             throw std::runtime_error(std::string("Error transforming variable eta: ") + e.what());
148:         }
149: 
150:         params_r__ = writer__.data_r();
151:         params_i__ = writer__.data_i();
152:     }
153: 
154:     void transform_inits(const stan::io::var_context& context,
155:                          Eigen::Matrix<double,Eigen::Dynamic,1>& params_r,
156:                          std::ostream* pstream__) const {
157:       std::vector<double> params_r_vec;
158:       std::vector<int> params_i_vec;
159:       transform_inits(context, params_i_vec, params_r_vec, pstream__);
160:       params_r.resize(params_r_vec.size());
161:       for (int i = 0; i < params_r.size(); ++i)
162:         params_r(i) = params_r_vec[i];
163:     }
164: 
165: 
166:     template <bool propto__, bool jacobian__, typename T__>
167:     T__ log_prob(vector<T__>& params_r__,
168:                  vector<int>& params_i__,
169:                  std::ostream* pstream__ = 0) const {
170: 
171:         T__ DUMMY_VAR__(std::numeric_limits<double>::quiet_NaN());
172:         (void) DUMMY_VAR__;  // suppress unused var warning
173: 
174:         T__ lp__(0.0);
175:         stan::math::accumulator<T__> lp_accum__;
176: 
177:         // model parameters
178:         stan::io::reader<T__> in__(params_r__,params_i__);
179: 
180:         T__ mu;
181:         (void) mu;   // dummy to suppress unused var warning
182:         if (jacobian__)
183:             mu = in__.scalar_constrain(lp__);
184:         else
185:             mu = in__.scalar_constrain();
186: 
187:         T__ tau;
188:         (void) tau;   // dummy to suppress unused var warning
189:         if (jacobian__)
190:             tau = in__.scalar_lb_constrain(0,lp__);
191:         else
192:             tau = in__.scalar_lb_constrain(0);
193: 
194:         vector<T__> eta;
195:         size_t dim_eta_0__ = J;
196:         eta.reserve(dim_eta_0__);
197:         for (size_t k_0__ = 0; k_0__ < dim_eta_0__; ++k_0__) {
198:             if (jacobian__)
199:                 eta.push_back(in__.scalar_constrain(lp__));
200:             else
201:                 eta.push_back(in__.scalar_constrain());
202:         }
203: 
204: 
205:         // transformed parameters
206:         vector<T__> theta(J);
207: 
208:         // initialize transformed variables to avoid seg fault on val access
209:         stan::math::fill(theta,DUMMY_VAR__);
210: 
211:         try {
212:             current_statement_begin__ = 13;
213:             for (int j = 1; j <= J; ++j) {
214:                 current_statement_begin__ = 14;
215:                 stan::math::assign(get_base1_lhs(theta,j,"theta",1), (mu + (tau * get_base1(eta,j,"eta",1))));
216:             }
217:         } catch (const std::exception& e) {
218:             stan::lang::rethrow_located(e,current_statement_begin__);
219:             // Next line prevents compiler griping about no return
220: throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***");
221:         }
222: 
223:         // validate transformed parameters
224:         for (int i0__ = 0; i0__ < J; ++i0__) {
225:             if (stan::math::is_uninitialized(theta[i0__])) {
226:                 std::stringstream msg__;
227:                 msg__ << "Undefined transformed parameter: theta" << '[' << i0__ << ']';
228:                 throw std::runtime_error(msg__.str());
229:             }
230:         }
231: 
232:         const char* function__ = "validate transformed params";
233:         (void) function__; // dummy to suppress unused var warning
234: 
235:         // model body
236:         try {
237:             current_statement_begin__ = 17;
238:             lp_accum__.add(normal_log<propto__>(eta, 0, 1));
239:             current_statement_begin__ = 18;
240:             lp_accum__.add(normal_log<propto__>(y, theta, sigma));
241:         } catch (const std::exception& e) {
242:             stan::lang::rethrow_located(e,current_statement_begin__);
243:             // Next line prevents compiler griping about no return
244: throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***");
245:         }
246: 
247:         lp_accum__.add(lp__);
248:         return lp_accum__.sum();
249: 
250:     } // log_prob()
251: 
252:     template <bool propto, bool jacobian, typename T_>
253:     T_ log_prob(Eigen::Matrix<T_,Eigen::Dynamic,1>& params_r,
254:                std::ostream* pstream = 0) const {
255:       std::vector<T_> vec_params_r;
256:       vec_params_r.reserve(params_r.size());
257:       for (int i = 0; i < params_r.size(); ++i)
258:         vec_params_r.push_back(params_r(i));
259:       std::vector<int> vec_params_i;
260:       return log_prob<propto,jacobian,T_>(vec_params_r, vec_params_i, pstream);
261:     }
262: 
263: 
264:     void get_param_names(std::vector<std::string>& names__) const {
265:         names__.resize(0);
266:         names__.push_back("mu");
267:         names__.push_back("tau");
268:         names__.push_back("eta");
269:         names__.push_back("theta");
270:     }
271: 
272: 
273:     void get_dims(std::vector<std::vector<size_t> >& dimss__) const {
274:         dimss__.resize(0);
275:         std::vector<size_t> dims__;
276:         dims__.resize(0);
277:         dimss__.push_back(dims__);
278:         dims__.resize(0);
279:         dimss__.push_back(dims__);
280:         dims__.resize(0);
281:         dims__.push_back(J);
282:         dimss__.push_back(dims__);
283:         dims__.resize(0);
284:         dims__.push_back(J);
285:         dimss__.push_back(dims__);
286:     }
287: 
288:     template <typename RNG>
289:     void write_array(RNG& base_rng__,
290:                      std::vector<double>& params_r__,
291:                      std::vector<int>& params_i__,
292:                      std::vector<double>& vars__,
293:                      bool include_tparams__ = true,
294:                      bool include_gqs__ = true,
295:                      std::ostream* pstream__ = 0) const {
296:         vars__.resize(0);
297:         stan::io::reader<double> in__(params_r__,params_i__);
298:         static const char* function__ = "model19104aa74803_8schools_namespace::write_array";
299:         (void) function__; // dummy call to supress warning
300:         // read-transform, write parameters
301:         double mu = in__.scalar_constrain();
302:         double tau = in__.scalar_lb_constrain(0);
303:         vector<double> eta;
304:         size_t dim_eta_0__ = J;
305:         for (size_t k_0__ = 0; k_0__ < dim_eta_0__; ++k_0__) {
306:             eta.push_back(in__.scalar_constrain());
307:         }
308:         vars__.push_back(mu);
309:         vars__.push_back(tau);
310:         for (int k_0__ = 0; k_0__ < J; ++k_0__) {
311:             vars__.push_back(eta[k_0__]);
312:         }
313: 
314:         if (!include_tparams__) return;
315:         // declare and define transformed parameters
316:         double lp__ = 0.0;
317:         (void) lp__; // dummy call to supress warning
318:         stan::math::accumulator<double> lp_accum__;
319: 
320:         vector<double> theta(J, 0.0);
321: 
322:         try {
323:             current_statement_begin__ = 13;
324:             for (int j = 1; j <= J; ++j) {
325:                 current_statement_begin__ = 14;
326:                 stan::math::assign(get_base1_lhs(theta,j,"theta",1), (mu + (tau * get_base1(eta,j,"eta",1))));
327:             }
328:         } catch (const std::exception& e) {
329:             stan::lang::rethrow_located(e,current_statement_begin__);
330:             // Next line prevents compiler griping about no return
331: throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***");
332:         }
333: 
334:         // validate transformed parameters
335: 
336:         // write transformed parameters
337:         for (int k_0__ = 0; k_0__ < J; ++k_0__) {
338:             vars__.push_back(theta[k_0__]);
339:         }
340: 
341:         if (!include_gqs__) return;
342:         // declare and define generated quantities
343: 
344:         double DUMMY_VAR__(std::numeric_limits<double>::quiet_NaN());
345:         (void) DUMMY_VAR__;  // suppress unused var warning
346: 
347: 
348:         // initialize transformed variables to avoid seg fault on val access
349: 
350:         try {
351:         } catch (const std::exception& e) {
352:             stan::lang::rethrow_located(e,current_statement_begin__);
353:             // Next line prevents compiler griping about no return
354: throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***");
355:         }
356: 
357:         // validate generated quantities
358: 
359:         // write generated quantities
360:     }
361: 
362:     template <typename RNG>
363:     void write_array(RNG& base_rng,
364:                      Eigen::Matrix<double,Eigen::Dynamic,1>& params_r,
365:                      Eigen::Matrix<double,Eigen::Dynamic,1>& vars,
366:                      bool include_tparams = true,
367:                      bool include_gqs = true,
368:                      std::ostream* pstream = 0) const {
369:       std::vector<double> params_r_vec(params_r.size());
370:       for (int i = 0; i < params_r.size(); ++i)
371:         params_r_vec[i] = params_r(i);
372:       std::vector<double> vars_vec;
373:       std::vector<int> params_i_vec;
374:       write_array(base_rng,params_r_vec,params_i_vec,vars_vec,include_tparams,include_gqs,pstream);
375:       vars.resize(vars_vec.size());
376:       for (int i = 0; i < vars.size(); ++i)
377:         vars(i) = vars_vec[i];
378:     }
379: 
380:     static std::string model_name() {
381:         return "model19104aa74803_8schools";
382:     }
383: 
384: 
385:     void constrained_param_names(std::vector<std::string>& param_names__,
386:                                  bool include_tparams__ = true,
387:                                  bool include_gqs__ = true) const {
388:         std::stringstream param_name_stream__;
389:         param_name_stream__.str(std::string());
390:         param_name_stream__ << "mu";
391:         param_names__.push_back(param_name_stream__.str());
392:         param_name_stream__.str(std::string());
393:         param_name_stream__ << "tau";
394:         param_names__.push_back(param_name_stream__.str());
395:         for (int k_0__ = 1; k_0__ <= J; ++k_0__) {
396:             param_name_stream__.str(std::string());
397:             param_name_stream__ << "eta" << '.' << k_0__;
398:             param_names__.push_back(param_name_stream__.str());
399:         }
400: 
401:         if (!include_gqs__ && !include_tparams__) return;
402:         for (int k_0__ = 1; k_0__ <= J; ++k_0__) {
403:             param_name_stream__.str(std::string());
404:             param_name_stream__ << "theta" << '.' << k_0__;
405:             param_names__.push_back(param_name_stream__.str());
406:         }
407: 
408:         if (!include_gqs__) return;
409:     }
410: 
411: 
412:     void unconstrained_param_names(std::vector<std::string>& param_names__,
413:                                    bool include_tparams__ = true,
414:                                    bool include_gqs__ = true) const {
415:         std::stringstream param_name_stream__;
416:         param_name_stream__.str(std::string());
417:         param_name_stream__ << "mu";
418:         param_names__.push_back(param_name_stream__.str());
419:         param_name_stream__.str(std::string());
420:         param_name_stream__ << "tau";
421:         param_names__.push_back(param_name_stream__.str());
422:         for (int k_0__ = 1; k_0__ <= J; ++k_0__) {
423:             param_name_stream__.str(std::string());
424:             param_name_stream__ << "eta" << '.' << k_0__;
425:             param_names__.push_back(param_name_stream__.str());
426:         }
427: 
428:         if (!include_gqs__ && !include_tparams__) return;
429:         for (int k_0__ = 1; k_0__ <= J; ++k_0__) {
430:             param_name_stream__.str(std::string());
431:             param_name_stream__ << "theta" << '.' << k_0__;
432:             param_names__.push_back(param_name_stream__.str());
433:         }
434: 
435:         if (!include_gqs__) return;
436:     }
437: 
438: }; // model
439: 
440: } // namespace
441: 
442: typedef model19104aa74803_8schools_namespace::model19104aa74803_8schools stan_model;
443: 
444: #include <rstan/rstaninc.hpp>
445: /**
446:  * Define Rcpp Module to expose stan_fit's functions to R.
447:  */
448: RCPP_MODULE(stan_fit4model19104aa74803_8schools_mod){
449:   Rcpp::class_<rstan::stan_fit<model19104aa74803_8schools_namespace::model19104aa74803_8schools,
450:                boost::random::ecuyer1988> >("stan_fit4model19104aa74803_8schools")
451:     // .constructor<Rcpp::List>()
452:     .constructor<SEXP, SEXP>()
453:     // .constructor<SEXP, SEXP>()
454:     .method("call_sampler",
455:             &rstan::stan_fit<model19104aa74803_8schools_namespace::model19104aa74803_8schools, boost::random::ecuyer1988>::call_sampler)
456:     .method("param_names",
457:             &rstan::stan_fit<model19104aa74803_8schools_namespace::model19104aa74803_8schools, boost::random::ecuyer1988>::param_names)
458:     .method("param_names_oi",
459:             &rstan::stan_fit<model19104aa74803_8schools_namespace::model19104aa74803_8schools, boost::random::ecuyer1988>::param_names_oi)
460:     .method("param_fnames_oi",
461:             &rstan::stan_fit<model19104aa74803_8schools_namespace::model19104aa74803_8schools, boost::random::ecuyer1988>::param_fnames_oi)
462:     .method("param_dims",
463:             &rstan::stan_fit<model19104aa74803_8schools_namespace::model19104aa74803_8schools, boost::random::ecuyer1988>::param_dims)
464:     .method("param_dims_oi",
465:             &rstan::stan_fit<model19104aa74803_8schools_namespace::model19104aa74803_8schools, boost::random::ecuyer1988>::param_dims_oi)
466:     .method("update_param_oi",
467:             &rstan::stan_fit<model19104aa74803_8schools_namespace::model19104aa74803_8schools, boost::random::ecuyer1988>::update_param_oi)
468:     .method("param_oi_tidx",
469:             &rstan::stan_fit<model19104aa74803_8schools_namespace::model19104aa74803_8schools, boost::random::ecuyer1988>::param_oi_tidx)
470:     .method("grad_log_prob",
471:             &rstan::stan_fit<model19104aa74803_8schools_namespace::model19104aa74803_8schools, boost::random::ecuyer1988>::grad_log_prob)
472:     .method("log_prob",
473:             &rstan::stan_fit<model19104aa74803_8schools_namespace::model19104aa74803_8schools, boost::random::ecuyer1988>::log_prob)
474:     .method("unconstrain_pars",
475:             &rstan::stan_fit<model19104aa74803_8schools_namespace::model19104aa74803_8schools, boost::random::ecuyer1988>::unconstrain_pars)
476:     .method("constrain_pars",
477:             &rstan::stan_fit<model19104aa74803_8schools_namespace::model19104aa74803_8schools, boost::random::ecuyer1988>::constrain_pars)
478:     .method("num_pars_unconstrained",
479:             &rstan::stan_fit<model19104aa74803_8schools_namespace::model19104aa74803_8schools, boost::random::ecuyer1988>::num_pars_unconstrained)
480:     .method("unconstrained_param_names",
481:             &rstan::stan_fit<model19104aa74803_8schools_namespace::model19104aa74803_8schools, boost::random::ecuyer1988>::unconstrained_param_names)
482:     .method("constrained_param_names",
483:             &rstan::stan_fit<model19104aa74803_8schools_namespace::model19104aa74803_8schools, boost::random::ecuyer1988>::constrained_param_names)
484:     ;
485: }
486: 
487: // declarations
488: extern "C" {
489: SEXP file191077307f07( ) ;
490: }
491: 
492: // definition
493: 
494: SEXP file191077307f07(  ){
495:  return Rcpp::wrap("8schools");
496: }
497: 
498: 
Error in compileCode(f, code, language = language, verbose = verbose) : 
  Compilation ERROR, function(s)/method(s) not created! file191077307f07.cpp:8:39: fatal error: stan/model/model_header.hpp: No such file or directory
compilation terminated.
make: *** [file191077307f07.o] Error 1
Warning message:
running command 'make -f "C:/PROGRA~1/R/R-32~1.2/etc/x64/Makeconf" -f "C:/PROGRA~1/R/R-32~1.2/share/make/winshlib.mk" -f "C:\RETNLSO-NT0002\RIPOD1$\Document/.R/Makevars" SHLIB_LDFLAGS='$(SHLIB_CXXLDFLAGS)' SHLIB_LD='$(SHLIB_CXXLD)' SHLIB="file191077307f07.dll" WIN=64 TCLBIN=64 OBJECTS="file191077307f07.o"' had status 2 
In addition: Warning message:
running command 'C:/PROGRA~1/R/R-32~1.2/bin/x64/R CMD SHLIB file191077307f07.cpp 2> file191077307f07.cpp.err.txt' had status 1 

@maverickg
Copy link
Contributor

  1. try install.packages('StanHeaders') and take a careful look of the output (check if there is any warnings and failures, or post it here).
  2. and verbose=TRUE to function call of stan and provide output

@mrdevlar
Copy link
Author

  1. So this doesn't provide anything out of the ordinary
Installing package into ‘C:/RETNLSO-NT0002/RIPOD1$/Document/Library’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.2/StanHeaders_2.8.0.zip'
Content type 'application/zip' length 1038125 bytes (1013 KB)
downloaded 1013 KB

package ‘StanHeaders’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in
    C:\Users\ripod1\AppData\Local\Temp\RtmpuGUoXc\downloaded_packages
  1. It's pretty big, but here goes:

TRANSLATING MODEL '8schools' FROM Stan CODE TO C++ CODE NOW.
successful in parsing the Stan model '8schools'.
COMPILING THE C++ CODE FOR MODEL '8schools' NOW.
OS: x86_64, mingw32; rstan: 2.8.0; Rcpp: 0.12.1; inline: 0.3.14 
 >> setting environment variables: 
PKG_LIBS = 
PKG_CPPFLAGS =   -isystem"C:/RETNLSO-NT0002/RIPOD1$/Document/Library/Rcpp/include/"  -isystem"C:/RETNLSO-NT0002/RIPOD1$/Document/Library/RcppEigen/include/"  -isystem"C:/RETNLSO-NT0002/RIPOD1$/Document/Library/RcppEigen/include/unsupported"  -isystem"C:/RETNLSO-NT0002/RIPOD1$/Document/Library/rstan/include/boost_not_in_BH" -isystem"C:/RETNLSO-NT0002/RIPOD1$/Document/Library/BH/include" -isystem"C:/RETNLSO-NT0002/RIPOD1$/Document/Library/StanHeaders/include/src/"  -isystem"C:/RETNLSO-NT0002/RIPOD1$/Document/Library/StanHeaders/include/"  -I"C:/RETNLSO-NT0002/RIPOD1$/Document/Library/rstan/include" -O3 -DEIGEN_NO_DEBUG -Wno-unused-function -Wno-uninitialized -DBOOST_RESULT_OF_USE_TR1 -DBOOST_NO_DECLTYPE -DBOOST_DISABLE_ASSERTS -DEIGEN_NO_DEBUG
 >> Program source :

   1 : 
   2 : // includes from the plugin
   3 : 
   4 : 
   5 : // user includes
   6 : #define STAN__SERVICES__COMMAND_HPP// Code generated by Stan version 2.8
   7 : 
   8 : #include <stan/model/model_header.hpp>
   9 : 
  10 : namespace model1cd04f987d27_8schools_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 : typedef Eigen::Matrix<double,Eigen::Dynamic,1> vector_d;
  22 : typedef Eigen::Matrix<double,1,Eigen::Dynamic> row_vector_d;
  23 : typedef Eigen::Matrix<double,Eigen::Dynamic,Eigen::Dynamic> matrix_d;
  24 : 
  25 : static int current_statement_begin__;
  26 : class model1cd04f987d27_8schools : public prob_grad {
  27 : private:
  28 :     int J;
  29 :     vector<double> y;
  30 :     vector<double> sigma;
  31 : public:
  32 :     model1cd04f987d27_8schools(stan::io::var_context& context__,
  33 :         std::ostream* pstream__ = 0)
  34 :         : prob_grad(0) {
  35 :         current_statement_begin__ = -1;
  36 : 
  37 :         static const char* function__ = "model1cd04f987d27_8schools_namespace::model1cd04f987d27_8schools";
  38 :         (void) function__; // dummy call to supress warning
  39 :         size_t pos__;
  40 :         (void) pos__; // dummy call to supress warning
  41 :         std::vector<int> vals_i__;
  42 :         std::vector<double> vals_r__;
  43 :         context__.validate_dims("data initialization", "J", "int", context__.to_vec());
  44 :         J = int(0);
  45 :         vals_i__ = context__.vals_i("J");
  46 :         pos__ = 0;
  47 :         J = vals_i__[pos__++];
  48 :         context__.validate_dims("data initialization", "y", "double", context__.to_vec(J));
  49 :         validate_non_negative_index("y", "J", J);
  50 :         y = std::vector<double>(J,double(0));
  51 :         vals_r__ = context__.vals_r("y");
  52 :         pos__ = 0;
  53 :         size_t y_limit_0__ = J;
  54 :         for (size_t i_0__ = 0; i_0__ < y_limit_0__; ++i_0__) {
  55 :             y[i_0__] = vals_r__[pos__++];
  56 :         }
  57 :         context__.validate_dims("data initialization", "sigma", "double", context__.to_vec(J));
  58 :         validate_non_negative_index("sigma", "J", J);
  59 :         sigma = std::vector<double>(J,double(0));
  60 :         vals_r__ = context__.vals_r("sigma");
  61 :         pos__ = 0;
  62 :         size_t sigma_limit_0__ = J;
  63 :         for (size_t i_0__ = 0; i_0__ < sigma_limit_0__; ++i_0__) {
  64 :             sigma[i_0__] = vals_r__[pos__++];
  65 :         }
  66 : 
  67 :         // validate data
  68 :         check_greater_or_equal(function__,"J",J,0);
  69 :         for (int k0__ = 0; k0__ < J; ++k0__) {
  70 :             check_greater_or_equal(function__,"sigma[k0__]",sigma[k0__],0);
  71 :         }
  72 : 
  73 :         double DUMMY_VAR__(std::numeric_limits<double>::quiet_NaN());
  74 :         (void) DUMMY_VAR__;  // suppress unused var warning
  75 : 
  76 : 
  77 :         // initialize transformed variables to avoid seg fault on val access
  78 : 
  79 :         try {
  80 :         } catch (const std::exception& e) {
  81 :             stan::lang::rethrow_located(e,current_statement_begin__);
  82 :             // Next line prevents compiler griping about no return
  83 : throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***");
  84 :         }
  85 : 
  86 :         // validate transformed data
  87 : 
  88 :         // set parameter ranges
  89 :         num_params_r__ = 0U;
  90 :         param_ranges_i__.clear();
  91 :         ++num_params_r__;
  92 :         ++num_params_r__;
  93 :         num_params_r__ += J;
  94 :     }
  95 : 
  96 :     ~model1cd04f987d27_8schools() { }
  97 : 
  98 : 
  99 :     void transform_inits(const stan::io::var_context& context__,
 100 :                          std::vector<int>& params_i__,
 101 :                          std::vector<double>& params_r__,
 102 :                          std::ostream* pstream__) const {
 103 :         stan::io::writer<double> writer__(params_r__,params_i__);
 104 :         size_t pos__;
 105 :         (void) pos__; // dummy call to supress warning
 106 :         std::vector<double> vals_r__;
 107 :         std::vector<int> vals_i__;
 108 : 
 109 :         if (!(context__.contains_r("mu")))
 110 :             throw std::runtime_error("variable mu missing");
 111 :         vals_r__ = context__.vals_r("mu");
 112 :         pos__ = 0U;
 113 :         context__.validate_dims("initialization", "mu", "double", context__.to_vec());
 114 :         double mu(0);
 115 :         mu = vals_r__[pos__++];
 116 :         try {
 117 :             writer__.scalar_unconstrain(mu);
 118 :         } catch (const std::exception& e) { 
 119 :             throw std::runtime_error(std::string("Error transforming variable mu: ") + e.what());
 120 :         }
 121 : 
 122 :         if (!(context__.contains_r("tau")))
 123 :             throw std::runtime_error("variable tau missing");
 124 :         vals_r__ = context__.vals_r("tau");
 125 :         pos__ = 0U;
 126 :         context__.validate_dims("initialization", "tau", "double", context__.to_vec());
 127 :         double tau(0);
 128 :         tau = vals_r__[pos__++];
 129 :         try {
 130 :             writer__.scalar_lb_unconstrain(0,tau);
 131 :         } catch (const std::exception& e) { 
 132 :             throw std::runtime_error(std::string("Error transforming variable tau: ") + e.what());
 133 :         }
 134 : 
 135 :         if (!(context__.contains_r("eta")))
 136 :             throw std::runtime_error("variable eta missing");
 137 :         vals_r__ = context__.vals_r("eta");
 138 :         pos__ = 0U;
 139 :         context__.validate_dims("initialization", "eta", "double", context__.to_vec(J));
 140 :         std::vector<double> eta(J,double(0));
 141 :         for (int i0__ = 0U; i0__ < J; ++i0__)
 142 :             eta[i0__] = vals_r__[pos__++];
 143 :         for (int i0__ = 0U; i0__ < J; ++i0__)
 144 :             try {
 145 :             writer__.scalar_unconstrain(eta[i0__]);
 146 :         } catch (const std::exception& e) { 
 147 :             throw std::runtime_error(std::string("Error transforming variable eta: ") + e.what());
 148 :         }
 149 : 
 150 :         params_r__ = writer__.data_r();
 151 :         params_i__ = writer__.data_i();
 152 :     }
 153 : 
 154 :     void transform_inits(const stan::io::var_context& context,
 155 :                          Eigen::Matrix<double,Eigen::Dynamic,1>& params_r,
 156 :                          std::ostream* pstream__) const {
 157 :       std::vector<double> params_r_vec;
 158 :       std::vector<int> params_i_vec;
 159 :       transform_inits(context, params_i_vec, params_r_vec, pstream__);
 160 :       params_r.resize(params_r_vec.size());
 161 :       for (int i = 0; i < params_r.size(); ++i)
 162 :         params_r(i) = params_r_vec[i];
 163 :     }
 164 : 
 165 : 
 166 :     template <bool propto__, bool jacobian__, typename T__>
 167 :     T__ log_prob(vector<T__>& params_r__,
 168 :                  vector<int>& params_i__,
 169 :                  std::ostream* pstream__ = 0) const {
 170 : 
 171 :         T__ DUMMY_VAR__(std::numeric_limits<double>::quiet_NaN());
 172 :         (void) DUMMY_VAR__;  // suppress unused var warning
 173 : 
 174 :         T__ lp__(0.0);
 175 :         stan::math::accumulator<T__> lp_accum__;
 176 : 
 177 :         // model parameters
 178 :         stan::io::reader<T__> in__(params_r__,params_i__);
 179 : 
 180 :         T__ mu;
 181 :         (void) mu;   // dummy to suppress unused var warning
 182 :         if (jacobian__)
 183 :             mu = in__.scalar_constrain(lp__);
 184 :         else
 185 :             mu = in__.scalar_constrain();
 186 : 
 187 :         T__ tau;
 188 :         (void) tau;   // dummy to suppress unused var warning
 189 :         if (jacobian__)
 190 :             tau = in__.scalar_lb_constrain(0,lp__);
 191 :         else
 192 :             tau = in__.scalar_lb_constrain(0);
 193 : 
 194 :         vector<T__> eta;
 195 :         size_t dim_eta_0__ = J;
 196 :         eta.reserve(dim_eta_0__);
 197 :         for (size_t k_0__ = 0; k_0__ < dim_eta_0__; ++k_0__) {
 198 :             if (jacobian__)
 199 :                 eta.push_back(in__.scalar_constrain(lp__));
 200 :             else
 201 :                 eta.push_back(in__.scalar_constrain());
 202 :         }
 203 : 
 204 : 
 205 :         // transformed parameters
 206 :         vector<T__> theta(J);
 207 : 
 208 :         // initialize transformed variables to avoid seg fault on val access
 209 :         stan::math::fill(theta,DUMMY_VAR__);
 210 : 
 211 :         try {
 212 :             current_statement_begin__ = 13;
 213 :             for (int j = 1; j <= J; ++j) {
 214 :                 current_statement_begin__ = 14;
 215 :                 stan::math::assign(get_base1_lhs(theta,j,"theta",1), (mu + (tau * get_base1(eta,j,"eta",1))));
 216 :             }
 217 :         } catch (const std::exception& e) {
 218 :             stan::lang::rethrow_located(e,current_statement_begin__);
 219 :             // Next line prevents compiler griping about no return
 220 : throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***");
 221 :         }
 222 : 
 223 :         // validate transformed parameters
 224 :         for (int i0__ = 0; i0__ < J; ++i0__) {
 225 :             if (stan::math::is_uninitialized(theta[i0__])) {
 226 :                 std::stringstream msg__;
 227 :                 msg__ << "Undefined transformed parameter: theta" << '[' << i0__ << ']';
 228 :                 throw std::runtime_error(msg__.str());
 229 :             }
 230 :         }
 231 : 
 232 :         const char* function__ = "validate transformed params";
 233 :         (void) function__; // dummy to suppress unused var warning
 234 : 
 235 :         // model body
 236 :         try {
 237 :             current_statement_begin__ = 17;
 238 :             lp_accum__.add(normal_log<propto__>(eta, 0, 1));
 239 :             current_statement_begin__ = 18;
 240 :             lp_accum__.add(normal_log<propto__>(y, theta, sigma));
 241 :         } catch (const std::exception& e) {
 242 :             stan::lang::rethrow_located(e,current_statement_begin__);
 243 :             // Next line prevents compiler griping about no return
 244 : throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***");
 245 :         }
 246 : 
 247 :         lp_accum__.add(lp__);
 248 :         return lp_accum__.sum();
 249 : 
 250 :     } // log_prob()
 251 : 
 252 :     template <bool propto, bool jacobian, typename T_>
 253 :     T_ log_prob(Eigen::Matrix<T_,Eigen::Dynamic,1>& params_r,
 254 :                std::ostream* pstream = 0) const {
 255 :       std::vector<T_> vec_params_r;
 256 :       vec_params_r.reserve(params_r.size());
 257 :       for (int i = 0; i < params_r.size(); ++i)
 258 :         vec_params_r.push_back(params_r(i));
 259 :       std::vector<int> vec_params_i;
 260 :       return log_prob<propto,jacobian,T_>(vec_params_r, vec_params_i, pstream);
 261 :     }
 262 : 
 263 : 
 264 :     void get_param_names(std::vector<std::string>& names__) const {
 265 :         names__.resize(0);
 266 :         names__.push_back("mu");
 267 :         names__.push_back("tau");
 268 :         names__.push_back("eta");
 269 :         names__.push_back("theta");
 270 :     }
 271 : 
 272 : 
 273 :     void get_dims(std::vector<std::vector<size_t> >& dimss__) const {
 274 :         dimss__.resize(0);
 275 :         std::vector<size_t> dims__;
 276 :         dims__.resize(0);
 277 :         dimss__.push_back(dims__);
 278 :         dims__.resize(0);
 279 :         dimss__.push_back(dims__);
 280 :         dims__.resize(0);
 281 :         dims__.push_back(J);
 282 :         dimss__.push_back(dims__);
 283 :         dims__.resize(0);
 284 :         dims__.push_back(J);
 285 :         dimss__.push_back(dims__);
 286 :     }
 287 : 
 288 :     template <typename RNG>
 289 :     void write_array(RNG& base_rng__,
 290 :                      std::vector<double>& params_r__,
 291 :                      std::vector<int>& params_i__,
 292 :                      std::vector<double>& vars__,
 293 :                      bool include_tparams__ = true,
 294 :                      bool include_gqs__ = true,
 295 :                      std::ostream* pstream__ = 0) const {
 296 :         vars__.resize(0);
 297 :         stan::io::reader<double> in__(params_r__,params_i__);
 298 :         static const char* function__ = "model1cd04f987d27_8schools_namespace::write_array";
 299 :         (void) function__; // dummy call to supress warning
 300 :         // read-transform, write parameters
 301 :         double mu = in__.scalar_constrain();
 302 :         double tau = in__.scalar_lb_constrain(0);
 303 :         vector<double> eta;
 304 :         size_t dim_eta_0__ = J;
 305 :         for (size_t k_0__ = 0; k_0__ < dim_eta_0__; ++k_0__) {
 306 :             eta.push_back(in__.scalar_constrain());
 307 :         }
 308 :         vars__.push_back(mu);
 309 :         vars__.push_back(tau);
 310 :         for (int k_0__ = 0; k_0__ < J; ++k_0__) {
 311 :             vars__.push_back(eta[k_0__]);
 312 :         }
 313 : 
 314 :         if (!include_tparams__) return;
 315 :         // declare and define transformed parameters
 316 :         double lp__ = 0.0;
 317 :         (void) lp__; // dummy call to supress warning
 318 :         stan::math::accumulator<double> lp_accum__;
 319 : 
 320 :         vector<double> theta(J, 0.0);
 321 : 
 322 :         try {
 323 :             current_statement_begin__ = 13;
 324 :             for (int j = 1; j <= J; ++j) {
 325 :                 current_statement_begin__ = 14;
 326 :                 stan::math::assign(get_base1_lhs(theta,j,"theta",1), (mu + (tau * get_base1(eta,j,"eta",1))));
 327 :             }
 328 :         } catch (const std::exception& e) {
 329 :             stan::lang::rethrow_located(e,current_statement_begin__);
 330 :             // Next line prevents compiler griping about no return
 331 : throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***");
 332 :         }
 333 : 
 334 :         // validate transformed parameters
 335 : 
 336 :         // write transformed parameters
 337 :         for (int k_0__ = 0; k_0__ < J; ++k_0__) {
 338 :             vars__.push_back(theta[k_0__]);
 339 :         }
 340 : 
 341 :         if (!include_gqs__) return;
 342 :         // declare and define generated quantities
 343 : 
 344 :         double DUMMY_VAR__(std::numeric_limits<double>::quiet_NaN());
 345 :         (void) DUMMY_VAR__;  // suppress unused var warning
 346 : 
 347 : 
 348 :         // initialize transformed variables to avoid seg fault on val access
 349 : 
 350 :         try {
 351 :         } catch (const std::exception& e) {
 352 :             stan::lang::rethrow_located(e,current_statement_begin__);
 353 :             // Next line prevents compiler griping about no return
 354 : throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***");
 355 :         }
 356 : 
 357 :         // validate generated quantities
 358 : 
 359 :         // write generated quantities
 360 :     }
 361 : 
 362 :     template <typename RNG>
 363 :     void write_array(RNG& base_rng,
 364 :                      Eigen::Matrix<double,Eigen::Dynamic,1>& params_r,
 365 :                      Eigen::Matrix<double,Eigen::Dynamic,1>& vars,
 366 :                      bool include_tparams = true,
 367 :                      bool include_gqs = true,
 368 :                      std::ostream* pstream = 0) const {
 369 :       std::vector<double> params_r_vec(params_r.size());
 370 :       for (int i = 0; i < params_r.size(); ++i)
 371 :         params_r_vec[i] = params_r(i);
 372 :       std::vector<double> vars_vec;
 373 :       std::vector<int> params_i_vec;
 374 :       write_array(base_rng,params_r_vec,params_i_vec,vars_vec,include_tparams,include_gqs,pstream);
 375 :       vars.resize(vars_vec.size());
 376 :       for (int i = 0; i < vars.size(); ++i)
 377 :         vars(i) = vars_vec[i];
 378 :     }
 379 : 
 380 :     static std::string model_name() {
 381 :         return "model1cd04f987d27_8schools";
 382 :     }
 383 : 
 384 : 
 385 :     void constrained_param_names(std::vector<std::string>& param_names__,
 386 :                                  bool include_tparams__ = true,
 387 :                                  bool include_gqs__ = true) const {
 388 :         std::stringstream param_name_stream__;
 389 :         param_name_stream__.str(std::string());
 390 :         param_name_stream__ << "mu";
 391 :         param_names__.push_back(param_name_stream__.str());
 392 :         param_name_stream__.str(std::string());
 393 :         param_name_stream__ << "tau";
 394 :         param_names__.push_back(param_name_stream__.str());
 395 :         for (int k_0__ = 1; k_0__ <= J; ++k_0__) {
 396 :             param_name_stream__.str(std::string());
 397 :             param_name_stream__ << "eta" << '.' << k_0__;
 398 :             param_names__.push_back(param_name_stream__.str());
 399 :         }
 400 : 
 401 :         if (!include_gqs__ && !include_tparams__) return;
 402 :         for (int k_0__ = 1; k_0__ <= J; ++k_0__) {
 403 :             param_name_stream__.str(std::string());
 404 :             param_name_stream__ << "theta" << '.' << k_0__;
 405 :             param_names__.push_back(param_name_stream__.str());
 406 :         }
 407 : 
 408 :         if (!include_gqs__) return;
 409 :     }
 410 : 
 411 : 
 412 :     void unconstrained_param_names(std::vector<std::string>& param_names__,
 413 :                                    bool include_tparams__ = true,
 414 :                                    bool include_gqs__ = true) const {
 415 :         std::stringstream param_name_stream__;
 416 :         param_name_stream__.str(std::string());
 417 :         param_name_stream__ << "mu";
 418 :         param_names__.push_back(param_name_stream__.str());
 419 :         param_name_stream__.str(std::string());
 420 :         param_name_stream__ << "tau";
 421 :         param_names__.push_back(param_name_stream__.str());
 422 :         for (int k_0__ = 1; k_0__ <= J; ++k_0__) {
 423 :             param_name_stream__.str(std::string());
 424 :             param_name_stream__ << "eta" << '.' << k_0__;
 425 :             param_names__.push_back(param_name_stream__.str());
 426 :         }
 427 : 
 428 :         if (!include_gqs__ && !include_tparams__) return;
 429 :         for (int k_0__ = 1; k_0__ <= J; ++k_0__) {
 430 :             param_name_stream__.str(std::string());
 431 :             param_name_stream__ << "theta" << '.' << k_0__;
 432 :             param_names__.push_back(param_name_stream__.str());
 433 :         }
 434 : 
 435 :         if (!include_gqs__) return;
 436 :     }
 437 : 
 438 : }; // model
 439 : 
 440 : } // namespace
 441 : 
 442 : typedef model1cd04f987d27_8schools_namespace::model1cd04f987d27_8schools stan_model;
 443 : 
 444 : #include <rstan/rstaninc.hpp>
 445 : /**
 446 :  * Define Rcpp Module to expose stan_fit's functions to R.
 447 :  */
 448 : RCPP_MODULE(stan_fit4model1cd04f987d27_8schools_mod){
 449 :   Rcpp::class_<rstan::stan_fit<model1cd04f987d27_8schools_namespace::model1cd04f987d27_8schools,
 450 :                boost::random::ecuyer1988> >("stan_fit4model1cd04f987d27_8schools")
 451 :     // .constructor<Rcpp::List>()
 452 :     .constructor<SEXP, SEXP>()
 453 :     // .constructor<SEXP, SEXP>()
 454 :     .method("call_sampler",
 455 :             &rstan::stan_fit<model1cd04f987d27_8schools_namespace::model1cd04f987d27_8schools, boost::random::ecuyer1988>::call_sampler)
 456 :     .method("param_names",
 457 :             &rstan::stan_fit<model1cd04f987d27_8schools_namespace::model1cd04f987d27_8schools, boost::random::ecuyer1988>::param_names)
 458 :     .method("param_names_oi",
 459 :             &rstan::stan_fit<model1cd04f987d27_8schools_namespace::model1cd04f987d27_8schools, boost::random::ecuyer1988>::param_names_oi)
 460 :     .method("param_fnames_oi",
 461 :             &rstan::stan_fit<model1cd04f987d27_8schools_namespace::model1cd04f987d27_8schools, boost::random::ecuyer1988>::param_fnames_oi)
 462 :     .method("param_dims",
 463 :             &rstan::stan_fit<model1cd04f987d27_8schools_namespace::model1cd04f987d27_8schools, boost::random::ecuyer1988>::param_dims)
 464 :     .method("param_dims_oi",
 465 :             &rstan::stan_fit<model1cd04f987d27_8schools_namespace::model1cd04f987d27_8schools, boost::random::ecuyer1988>::param_dims_oi)
 466 :     .method("update_param_oi",
 467 :             &rstan::stan_fit<model1cd04f987d27_8schools_namespace::model1cd04f987d27_8schools, boost::random::ecuyer1988>::update_param_oi)
 468 :     .method("param_oi_tidx",
 469 :             &rstan::stan_fit<model1cd04f987d27_8schools_namespace::model1cd04f987d27_8schools, boost::random::ecuyer1988>::param_oi_tidx)
 470 :     .method("grad_log_prob",
 471 :             &rstan::stan_fit<model1cd04f987d27_8schools_namespace::model1cd04f987d27_8schools, boost::random::ecuyer1988>::grad_log_prob)
 472 :     .method("log_prob",
 473 :             &rstan::stan_fit<model1cd04f987d27_8schools_namespace::model1cd04f987d27_8schools, boost::random::ecuyer1988>::log_prob)
 474 :     .method("unconstrain_pars",
 475 :             &rstan::stan_fit<model1cd04f987d27_8schools_namespace::model1cd04f987d27_8schools, boost::random::ecuyer1988>::unconstrain_pars)
 476 :     .method("constrain_pars",
 477 :             &rstan::stan_fit<model1cd04f987d27_8schools_namespace::model1cd04f987d27_8schools, boost::random::ecuyer1988>::constrain_pars)
 478 :     .method("num_pars_unconstrained",
 479 :             &rstan::stan_fit<model1cd04f987d27_8schools_namespace::model1cd04f987d27_8schools, boost::random::ecuyer1988>::num_pars_unconstrained)
 480 :     .method("unconstrained_param_names",
 481 :             &rstan::stan_fit<model1cd04f987d27_8schools_namespace::model1cd04f987d27_8schools, boost::random::ecuyer1988>::unconstrained_param_names)
 482 :     .method("constrained_param_names",
 483 :             &rstan::stan_fit<model1cd04f987d27_8schools_namespace::model1cd04f987d27_8schools, boost::random::ecuyer1988>::constrained_param_names)
 484 :     ;
 485 : }
 486 : 
 487 : // declarations
 488 : extern "C" {
 489 : SEXP file1cd01daf372b( ) ;
 490 : }
 491 : 
 492 : // definition
 493 : 
 494 : SEXP file1cd01daf372b(  ){
 495 :  return Rcpp::wrap("8schools");
 496 : }
 497 : 
 498 : 
Compilation argument:
 C:/PROGRA~1/R/R-32~1.2/bin/x64/R CMD SHLIB file1cd01daf372b.cpp 2> file1cd01daf372b.cpp.err.txt 
file1cd01daf372b.cpp:8:39: fatal error: stan/model/model_header.hpp: No such file or directory
compilation terminated.
make: *** [file1cd01daf372b.o] Error 1
Warning message:
running command 'make -f "C:/PROGRA~1/R/R-32~1.2/etc/x64/Makeconf" -f "C:/PROGRA~1/R/R-32~1.2/share/make/winshlib.mk" -f "C:\RETNLSO-NT0002\RIPOD1$\Document/.R/Makevars" SHLIB_LDFLAGS='$(SHLIB_CXXLDFLAGS)' SHLIB_LD='$(SHLIB_CXXLD)' SHLIB="file1cd01daf372b.dll" WIN=64 TCLBIN=64 OBJECTS="file1cd01daf372b.o"' had status 2 

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: #define STAN__SERVICES__COMMAND_HPP// Code generated by Stan version 2.8
  7: 
  8: #include <stan/model/model_header.hpp>
  9: 
 10: namespace model1cd04f987d27_8schools_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: typedef Eigen::Matrix<double,Eigen::Dynamic,1> vector_d;
 22: typedef Eigen::Matrix<double,1,Eigen::Dynamic> row_vector_d;
 23: typedef Eigen::Matrix<double,Eigen::Dynamic,Eigen::Dynamic> matrix_d;
 24: 
 25: static int current_statement_begin__;
 26: class model1cd04f987d27_8schools : public prob_grad {
 27: private:
 28:     int J;
 29:     vector<double> y;
 30:     vector<double> sigma;
 31: public:
 32:     model1cd04f987d27_8schools(stan::io::var_context& context__,
 33:         std::ostream* pstream__ = 0)
 34:         : prob_grad(0) {
 35:         current_statement_begin__ = -1;
 36: 
 37:         static const char* function__ = "model1cd04f987d27_8schools_namespace::model1cd04f987d27_8schools";
 38:         (void) function__; // dummy call to supress warning
 39:         size_t pos__;
 40:         (void) pos__; // dummy call to supress warning
 41:         std::vector<int> vals_i__;
 42:         std::vector<double> vals_r__;
 43:         context__.validate_dims("data initialization", "J", "int", context__.to_vec());
 44:         J = int(0);
 45:         vals_i__ = context__.vals_i("J");
 46:         pos__ = 0;
 47:         J = vals_i__[pos__++];
 48:         context__.validate_dims("data initialization", "y", "double", context__.to_vec(J));
 49:         validate_non_negative_index("y", "J", J);
 50:         y = std::vector<double>(J,double(0));
 51:         vals_r__ = context__.vals_r("y");
 52:         pos__ = 0;
 53:         size_t y_limit_0__ = J;
 54:         for (size_t i_0__ = 0; i_0__ < y_limit_0__; ++i_0__) {
 55:             y[i_0__] = vals_r__[pos__++];
 56:         }
 57:         context__.validate_dims("data initialization", "sigma", "double", context__.to_vec(J));
 58:         validate_non_negative_index("sigma", "J", J);
 59:         sigma = std::vector<double>(J,double(0));
 60:         vals_r__ = context__.vals_r("sigma");
 61:         pos__ = 0;
 62:         size_t sigma_limit_0__ = J;
 63:         for (size_t i_0__ = 0; i_0__ < sigma_limit_0__; ++i_0__) {
 64:             sigma[i_0__] = vals_r__[pos__++];
 65:         }
 66: 
 67:         // validate data
 68:         check_greater_or_equal(function__,"J",J,0);
 69:         for (int k0__ = 0; k0__ < J; ++k0__) {
 70:             check_greater_or_equal(function__,"sigma[k0__]",sigma[k0__],0);
 71:         }
 72: 
 73:         double DUMMY_VAR__(std::numeric_limits<double>::quiet_NaN());
 74:         (void) DUMMY_VAR__;  // suppress unused var warning
 75: 
 76: 
 77:         // initialize transformed variables to avoid seg fault on val access
 78: 
 79:         try {
 80:         } catch (const std::exception& e) {
 81:             stan::lang::rethrow_located(e,current_statement_begin__);
 82:             // Next line prevents compiler griping about no return
 83: throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***");
 84:         }
 85: 
 86:         // validate transformed data
 87: 
 88:         // set parameter ranges
 89:         num_params_r__ = 0U;
 90:         param_ranges_i__.clear();
 91:         ++num_params_r__;
 92:         ++num_params_r__;
 93:         num_params_r__ += J;
 94:     }
 95: 
 96:     ~model1cd04f987d27_8schools() { }
 97: 
 98: 
 99:     void transform_inits(const stan::io::var_context& context__,
100:                          std::vector<int>& params_i__,
101:                          std::vector<double>& params_r__,
102:                          std::ostream* pstream__) const {
103:         stan::io::writer<double> writer__(params_r__,params_i__);
104:         size_t pos__;
105:         (void) pos__; // dummy call to supress warning
106:         std::vector<double> vals_r__;
107:         std::vector<int> vals_i__;
108: 
109:         if (!(context__.contains_r("mu")))
110:             throw std::runtime_error("variable mu missing");
111:         vals_r__ = context__.vals_r("mu");
112:         pos__ = 0U;
113:         context__.validate_dims("initialization", "mu", "double", context__.to_vec());
114:         double mu(0);
115:         mu = vals_r__[pos__++];
116:         try {
117:             writer__.scalar_unconstrain(mu);
118:         } catch (const std::exception& e) { 
119:             throw std::runtime_error(std::string("Error transforming variable mu: ") + e.what());
120:         }
121: 
122:         if (!(context__.contains_r("tau")))
123:             throw std::runtime_error("variable tau missing");
124:         vals_r__ = context__.vals_r("tau");
125:         pos__ = 0U;
126:         context__.validate_dims("initialization", "tau", "double", context__.to_vec());
127:         double tau(0);
128:         tau = vals_r__[pos__++];
129:         try {
130:             writer__.scalar_lb_unconstrain(0,tau);
131:         } catch (const std::exception& e) { 
132:             throw std::runtime_error(std::string("Error transforming variable tau: ") + e.what());
133:         }
134: 
135:         if (!(context__.contains_r("eta")))
136:             throw std::runtime_error("variable eta missing");
137:         vals_r__ = context__.vals_r("eta");
138:         pos__ = 0U;
139:         context__.validate_dims("initialization", "eta", "double", context__.to_vec(J));
140:         std::vector<double> eta(J,double(0));
141:         for (int i0__ = 0U; i0__ < J; ++i0__)
142:             eta[i0__] = vals_r__[pos__++];
143:         for (int i0__ = 0U; i0__ < J; ++i0__)
144:             try {
145:             writer__.scalar_unconstrain(eta[i0__]);
146:         } catch (const std::exception& e) { 
147:             throw std::runtime_error(std::string("Error transforming variable eta: ") + e.what());
148:         }
149: 
150:         params_r__ = writer__.data_r();
151:         params_i__ = writer__.data_i();
152:     }
153: 
154:     void transform_inits(const stan::io::var_context& context,
155:                          Eigen::Matrix<double,Eigen::Dynamic,1>& params_r,
156:                          std::ostream* pstream__) const {
157:       std::vector<double> params_r_vec;
158:       std::vector<int> params_i_vec;
159:       transform_inits(context, params_i_vec, params_r_vec, pstream__);
160:       params_r.resize(params_r_vec.size());
161:       for (int i = 0; i < params_r.size(); ++i)
162:         params_r(i) = params_r_vec[i];
163:     }
164: 
165: 
166:     template <bool propto__, bool jacobian__, typename T__>
167:     T__ log_prob(vector<T__>& params_r__,
168:                  vector<int>& params_i__,
169:                  std::ostream* pstream__ = 0) const {
170: 
171:         T__ DUMMY_VAR__(std::numeric_limits<double>::quiet_NaN());
172:         (void) DUMMY_VAR__;  // suppress unused var warning
173: 
174:         T__ lp__(0.0);
175:         stan::math::accumulator<T__> lp_accum__;
176: 
177:         // model parameters
178:         stan::io::reader<T__> in__(params_r__,params_i__);
179: 
180:         T__ mu;
181:         (void) mu;   // dummy to suppress unused var warning
182:         if (jacobian__)
183:             mu = in__.scalar_constrain(lp__);
184:         else
185:             mu = in__.scalar_constrain();
186: 
187:         T__ tau;
188:         (void) tau;   // dummy to suppress unused var warning
189:         if (jacobian__)
190:             tau = in__.scalar_lb_constrain(0,lp__);
191:         else
192:             tau = in__.scalar_lb_constrain(0);
193: 
194:         vector<T__> eta;
195:         size_t dim_eta_0__ = J;
196:         eta.reserve(dim_eta_0__);
197:         for (size_t k_0__ = 0; k_0__ < dim_eta_0__; ++k_0__) {
198:             if (jacobian__)
199:                 eta.push_back(in__.scalar_constrain(lp__));
200:             else
201:                 eta.push_back(in__.scalar_constrain());
202:         }
203: 
204: 
205:         // transformed parameters
206:         vector<T__> theta(J);
207: 
208:         // initialize transformed variables to avoid seg fault on val access
209:         stan::math::fill(theta,DUMMY_VAR__);
210: 
211:         try {
212:             current_statement_begin__ = 13;
213:             for (int j = 1; j <= J; ++j) {
214:                 current_statement_begin__ = 14;
215:                 stan::math::assign(get_base1_lhs(theta,j,"theta",1), (mu + (tau * get_base1(eta,j,"eta",1))));
216:             }
217:         } catch (const std::exception& e) {
218:             stan::lang::rethrow_located(e,current_statement_begin__);
219:             // Next line prevents compiler griping about no return
220: throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***");
221:         }
222: 
223:         // validate transformed parameters
224:         for (int i0__ = 0; i0__ < J; ++i0__) {
225:             if (stan::math::is_uninitialized(theta[i0__])) {
226:                 std::stringstream msg__;
227:                 msg__ << "Undefined transformed parameter: theta" << '[' << i0__ << ']';
228:                 throw std::runtime_error(msg__.str());
229:             }
230:         }
231: 
232:         const char* function__ = "validate transformed params";
233:         (void) function__; // dummy to suppress unused var warning
234: 
235:         // model body
236:         try {
237:             current_statement_begin__ = 17;
238:             lp_accum__.add(normal_log<propto__>(eta, 0, 1));
239:             current_statement_begin__ = 18;
240:             lp_accum__.add(normal_log<propto__>(y, theta, sigma));
241:         } catch (const std::exception& e) {
242:             stan::lang::rethrow_located(e,current_statement_begin__);
243:             // Next line prevents compiler griping about no return
244: throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***");
245:         }
246: 
247:         lp_accum__.add(lp__);
248:         return lp_accum__.sum();
249: 
250:     } // log_prob()
251: 
252:     template <bool propto, bool jacobian, typename T_>
253:     T_ log_prob(Eigen::Matrix<T_,Eigen::Dynamic,1>& params_r,
254:                std::ostream* pstream = 0) const {
255:       std::vector<T_> vec_params_r;
256:       vec_params_r.reserve(params_r.size());
257:       for (int i = 0; i < params_r.size(); ++i)
258:         vec_params_r.push_back(params_r(i));
259:       std::vector<int> vec_params_i;
260:       return log_prob<propto,jacobian,T_>(vec_params_r, vec_params_i, pstream);
261:     }
262: 
263: 
264:     void get_param_names(std::vector<std::string>& names__) const {
265:         names__.resize(0);
266:         names__.push_back("mu");
267:         names__.push_back("tau");
268:         names__.push_back("eta");
269:         names__.push_back("theta");
270:     }
271: 
272: 
273:     void get_dims(std::vector<std::vector<size_t> >& dimss__) const {
274:         dimss__.resize(0);
275:         std::vector<size_t> dims__;
276:         dims__.resize(0);
277:         dimss__.push_back(dims__);
278:         dims__.resize(0);
279:         dimss__.push_back(dims__);
280:         dims__.resize(0);
281:         dims__.push_back(J);
282:         dimss__.push_back(dims__);
283:         dims__.resize(0);
284:         dims__.push_back(J);
285:         dimss__.push_back(dims__);
286:     }
287: 
288:     template <typename RNG>
289:     void write_array(RNG& base_rng__,
290:                      std::vector<double>& params_r__,
291:                      std::vector<int>& params_i__,
292:                      std::vector<double>& vars__,
293:                      bool include_tparams__ = true,
294:                      bool include_gqs__ = true,
295:                      std::ostream* pstream__ = 0) const {
296:         vars__.resize(0);
297:         stan::io::reader<double> in__(params_r__,params_i__);
298:         static const char* function__ = "model1cd04f987d27_8schools_namespace::write_array";
299:         (void) function__; // dummy call to supress warning
300:         // read-transform, write parameters
301:         double mu = in__.scalar_constrain();
302:         double tau = in__.scalar_lb_constrain(0);
303:         vector<double> eta;
304:         size_t dim_eta_0__ = J;
305:         for (size_t k_0__ = 0; k_0__ < dim_eta_0__; ++k_0__) {
306:             eta.push_back(in__.scalar_constrain());
307:         }
308:         vars__.push_back(mu);
309:         vars__.push_back(tau);
310:         for (int k_0__ = 0; k_0__ < J; ++k_0__) {
311:             vars__.push_back(eta[k_0__]);
312:         }
313: 
314:         if (!include_tparams__) return;
315:         // declare and define transformed parameters
316:         double lp__ = 0.0;
317:         (void) lp__; // dummy call to supress warning
318:         stan::math::accumulator<double> lp_accum__;
319: 
320:         vector<double> theta(J, 0.0);
321: 
322:         try {
323:             current_statement_begin__ = 13;
324:             for (int j = 1; j <= J; ++j) {
325:                 current_statement_begin__ = 14;
326:                 stan::math::assign(get_base1_lhs(theta,j,"theta",1), (mu + (tau * get_base1(eta,j,"eta",1))));
327:             }
328:         } catch (const std::exception& e) {
329:             stan::lang::rethrow_located(e,current_statement_begin__);
330:             // Next line prevents compiler griping about no return
331: throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***");
332:         }
333: 
334:         // validate transformed parameters
335: 
336:         // write transformed parameters
337:         for (int k_0__ = 0; k_0__ < J; ++k_0__) {
338:             vars__.push_back(theta[k_0__]);
339:         }
340: 
341:         if (!include_gqs__) return;
342:         // declare and define generated quantities
343: 
344:         double DUMMY_VAR__(std::numeric_limits<double>::quiet_NaN());
345:         (void) DUMMY_VAR__;  // suppress unused var warning
346: 
347: 
348:         // initialize transformed variables to avoid seg fault on val access
349: 
350:         try {
351:         } catch (const std::exception& e) {
352:             stan::lang::rethrow_located(e,current_statement_begin__);
353:             // Next line prevents compiler griping about no return
354: throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***");
355:         }
356: 
357:         // validate generated quantities
358: 
359:         // write generated quantities
360:     }
361: 
362:     template <typename RNG>
363:     void write_array(RNG& base_rng,
364:                      Eigen::Matrix<double,Eigen::Dynamic,1>& params_r,
365:                      Eigen::Matrix<double,Eigen::Dynamic,1>& vars,
366:                      bool include_tparams = true,
367:                      bool include_gqs = true,
368:                      std::ostream* pstream = 0) const {
369:       std::vector<double> params_r_vec(params_r.size());
370:       for (int i = 0; i < params_r.size(); ++i)
371:         params_r_vec[i] = params_r(i);
372:       std::vector<double> vars_vec;
373:       std::vector<int> params_i_vec;
374:       write_array(base_rng,params_r_vec,params_i_vec,vars_vec,include_tparams,include_gqs,pstream);
375:       vars.resize(vars_vec.size());
376:       for (int i = 0; i < vars.size(); ++i)
377:         vars(i) = vars_vec[i];
378:     }
379: 
380:     static std::string model_name() {
381:         return "model1cd04f987d27_8schools";
382:     }
383: 
384: 
385:     void constrained_param_names(std::vector<std::string>& param_names__,
386:                                  bool include_tparams__ = true,
387:                                  bool include_gqs__ = true) const {
388:         std::stringstream param_name_stream__;
389:         param_name_stream__.str(std::string());
390:         param_name_stream__ << "mu";
391:         param_names__.push_back(param_name_stream__.str());
392:         param_name_stream__.str(std::string());
393:         param_name_stream__ << "tau";
394:         param_names__.push_back(param_name_stream__.str());
395:         for (int k_0__ = 1; k_0__ <= J; ++k_0__) {
396:             param_name_stream__.str(std::string());
397:             param_name_stream__ << "eta" << '.' << k_0__;
398:             param_names__.push_back(param_name_stream__.str());
399:         }
400: 
401:         if (!include_gqs__ && !include_tparams__) return;
402:         for (int k_0__ = 1; k_0__ <= J; ++k_0__) {
403:             param_name_stream__.str(std::string());
404:             param_name_stream__ << "theta" << '.' << k_0__;
405:             param_names__.push_back(param_name_stream__.str());
406:         }
407: 
408:         if (!include_gqs__) return;
409:     }
410: 
411: 
412:     void unconstrained_param_names(std::vector<std::string>& param_names__,
413:                                    bool include_tparams__ = true,
414:                                    bool include_gqs__ = true) const {
415:         std::stringstream param_name_stream__;
416:         param_name_stream__.str(std::string());
417:         param_name_stream__ << "mu";
418:         param_names__.push_back(param_name_stream__.str());
419:         param_name_stream__.str(std::string());
420:         param_name_stream__ << "tau";
421:         param_names__.push_back(param_name_stream__.str());
422:         for (int k_0__ = 1; k_0__ <= J; ++k_0__) {
423:             param_name_stream__.str(std::string());
424:             param_name_stream__ << "eta" << '.' << k_0__;
425:             param_names__.push_back(param_name_stream__.str());
426:         }
427: 
428:         if (!include_gqs__ && !include_tparams__) return;
429:         for (int k_0__ = 1; k_0__ <= J; ++k_0__) {
430:             param_name_stream__.str(std::string());
431:             param_name_stream__ << "theta" << '.' << k_0__;
432:             param_names__.push_back(param_name_stream__.str());
433:         }
434: 
435:         if (!include_gqs__) return;
436:     }
437: 
438: }; // model
439: 
440: } // namespace
441: 
442: typedef model1cd04f987d27_8schools_namespace::model1cd04f987d27_8schools stan_model;
443: 
444: #include <rstan/rstaninc.hpp>
445: /**
446:  * Define Rcpp Module to expose stan_fit's functions to R.
447:  */
448: RCPP_MODULE(stan_fit4model1cd04f987d27_8schools_mod){
449:   Rcpp::class_<rstan::stan_fit<model1cd04f987d27_8schools_namespace::model1cd04f987d27_8schools,
450:                boost::random::ecuyer1988> >("stan_fit4model1cd04f987d27_8schools")
451:     // .constructor<Rcpp::List>()
452:     .constructor<SEXP, SEXP>()
453:     // .constructor<SEXP, SEXP>()
454:     .method("call_sampler",
455:             &rstan::stan_fit<model1cd04f987d27_8schools_namespace::model1cd04f987d27_8schools, boost::random::ecuyer1988>::call_sampler)
456:     .method("param_names",
457:             &rstan::stan_fit<model1cd04f987d27_8schools_namespace::model1cd04f987d27_8schools, boost::random::ecuyer1988>::param_names)
458:     .method("param_names_oi",
459:             &rstan::stan_fit<model1cd04f987d27_8schools_namespace::model1cd04f987d27_8schools, boost::random::ecuyer1988>::param_names_oi)
460:     .method("param_fnames_oi",
461:             &rstan::stan_fit<model1cd04f987d27_8schools_namespace::model1cd04f987d27_8schools, boost::random::ecuyer1988>::param_fnames_oi)
462:     .method("param_dims",
463:             &rstan::stan_fit<model1cd04f987d27_8schools_namespace::model1cd04f987d27_8schools, boost::random::ecuyer1988>::param_dims)
464:     .method("param_dims_oi",
465:             &rstan::stan_fit<model1cd04f987d27_8schools_namespace::model1cd04f987d27_8schools, boost::random::ecuyer1988>::param_dims_oi)
466:     .method("update_param_oi",
467:             &rstan::stan_fit<model1cd04f987d27_8schools_namespace::model1cd04f987d27_8schools, boost::random::ecuyer1988>::update_param_oi)
468:     .method("param_oi_tidx",
469:             &rstan::stan_fit<model1cd04f987d27_8schools_namespace::model1cd04f987d27_8schools, boost::random::ecuyer1988>::param_oi_tidx)
470:     .method("grad_log_prob",
471:             &rstan::stan_fit<model1cd04f987d27_8schools_namespace::model1cd04f987d27_8schools, boost::random::ecuyer1988>::grad_log_prob)
472:     .method("log_prob",
473:             &rstan::stan_fit<model1cd04f987d27_8schools_namespace::model1cd04f987d27_8schools, boost::random::ecuyer1988>::log_prob)
474:     .method("unconstrain_pars",
475:             &rstan::stan_fit<model1cd04f987d27_8schools_namespace::model1cd04f987d27_8schools, boost::random::ecuyer1988>::unconstrain_pars)
476:     .method("constrain_pars",
477:             &rstan::stan_fit<model1cd04f987d27_8schools_namespace::model1cd04f987d27_8schools, boost::random::ecuyer1988>::constrain_pars)
478:     .method("num_pars_unconstrained",
479:             &rstan::stan_fit<model1cd04f987d27_8schools_namespace::model1cd04f987d27_8schools, boost::random::ecuyer1988>::num_pars_unconstrained)
480:     .method("unconstrained_param_names",
481:             &rstan::stan_fit<model1cd04f987d27_8schools_namespace::model1cd04f987d27_8schools, boost::random::ecuyer1988>::unconstrained_param_names)
482:     .method("constrained_param_names",
483:             &rstan::stan_fit<model1cd04f987d27_8schools_namespace::model1cd04f987d27_8schools, boost::random::ecuyer1988>::constrained_param_names)
484:     ;
485: }
486: 
487: // declarations
488: extern "C" {
489: SEXP file1cd01daf372b( ) ;
490: }
491: 
492: // definition
493: 
494: SEXP file1cd01daf372b(  ){
495:  return Rcpp::wrap("8schools");
496: }
497: 
498: 

@maverickg
Copy link
Contributor

@mrdevlar I think your error is due to there is a $ in your path (seen from the following output).

PKG_CPPFLAGS =   -isystem"C:/RETNLSO-NT0002/RIPOD1$/Document/Library/Rcpp/include/" 
 -isystem"C:/RETNLSO-NT0002/RIPOD1$/Document/Library/RcppEigen/include/"  
-isystem"C:/RETNLSO-NT0002/RIPOD1$/Document/Library/RcppEigen/include/unsupported"  
-isystem"C:/RETNLSO-NT0002/RIPOD1$/Document/Library/rstan/include/boost_not_in_BH" -isystem"C:/RETNLSO-NT0002/RIPOD1$/Document/Library/BH/include" -isystem"C:/RETNLSO-NT0002/RIPOD1$/Document/Library/StanHeaders/include/src/"  -isystem"C:/RETNLSO-NT0002/RIPOD1$/Document/Library/StanHeaders/include/"  -I"C:/RETNLSO-NT0002/RIPOD1$/Document/Library/rstan/include" -O3 -DEIGEN_NO_DEBUG -Wno-unused-function -Wno-uninitialized -DBOOST_RESULT_OF_USE_TR1 -DBOOST_NO_DECLTYPE -DBOOST_DISABLE_ASSERTS -DEIGEN_NO_DEBUG

rstan utilizes R's functionality to compile source code and specify the paths of headers. And R uses GNU make to compile the source code, but $ is quite special in make. So I suggest installing your library to a folder that does not have a $ in its name.

@mrdevlar
Copy link
Author

@maverickg I'll talk to my system admin and see if I can get that resolved.
Many thanks for taking the time to troubleshoot this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants