stan-dev / stan

Stan development repository. The master branch contains the current release. The develop branch contains the latest stable development. See the Developer Process Wiki for details.
https://mc-stan.org
BSD 3-Clause "New" or "Revised" License
2.6k stars 370 forks source link

Cannot compile examples #368

Closed ojessen closed 11 years ago

ojessen commented 11 years ago

Hi,

I installed rstan as per your install description and tried compiling your two examples (8 schools and rats). They do not compile successfully.

My system is Windows 8.1 with

R version 3.0.2 (2013-09-25) -- "Frisbee Sailing" Copyright (C) 2013 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 (64-bit)

Rtools version 3.1.0.1936

Here are the outputs:

fit <- stan(model_code = schools_code, data = schools_dat,

  • iter = 1000, chains = 4)

TRANSLATING MODEL 'schools_code' FROM Stan CODE TO C++ CODE NOW. COMPILING THE C++ CODE FOR MODEL 'schools_code' NOW.

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: // Code generated by Stan version 2.0 7: 8: #include <stan/model/model_header.hpp> 9: 10: namespace model9c84ab61ca0_schools_code_namespace { 11: 12: using std::vector; 13: using std::string; 14: using std::stringstream; 15: using stan::model::prob_grad; 16: using stan::math::get_base1; 17: using stan::math::initialize; 18: using stan::math::stan_print; 19: using stan::io::dump; 20: using std::istream; 21: using namespace stan::math; 22: using namespace stan::prob; 23: 24: typedef Eigen::Matrix<double,Eigen::Dynamic,1> vector_d; 25: typedef Eigen::Matrix<double,1,Eigen::Dynamic> row_vector_d; 26: typedef Eigen::Matrix<double,Eigen::Dynamic,Eigen::Dynamic> matrix_d; 27: 28: class model9c84ab61ca0_schools_code : public prob_grad { 29: private: 30: int J; 31: vector y; 32: vector sigma; 33: public: 34: model9c84ab61ca0_schools_code(stan::io::var_context& context, 35: std::ostream* pstream = 0) 36: : prob_grad::prob_grad(0) { 37: static const char* function = "model9c84ab61ca0_schools_code_namespace::model9c84ab61ca0_schools_code(%1%)"; 38: (void) function__; // dummy call to supress warning 39: size_t pos; 40: (void) pos; // dummy call to supress warning 41: std::vector vals_i__; 42: std::vector 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: stan::math::validate_non_negative_index("y", "J", J); 50: y = std::vector(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: stan::math::validate_non_negative_index("sigma", "J", J); 59: sigma = std::vector(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: try { 69: check_greater_or_equal(function,J,0,"J"); 70: } catch (std::domain_error& e) { 71: throw std::domain_error(std::string("Invalid value of J: ") + std::string(e.what())); 72: }; 73: for (int k0 = 0; k0 < J; ++k0) { 74: try { 75: check_greater_or_equal(function,sigma[k0],0,"sigma[k0]"); 76: } catch (std::domain_error& e) { 77: throw std::domain_error(std::string("Invalid value of sigma: ") + std::string(e.what())); 78: }; 79: } 80: 81: 82: // validate transformed data 83: 84: // set parameter ranges 85: num_params_r = 0U; 86: param_ranges_i.clear(); 87: ++num_params_r; 88: ++num_params_r; 89: num_params_r += J; 90: } 91: 92: ~model9c84ab61ca0_schools_code() { } 93: 94: 95: void transform_inits(const stan::io::var_context& context, 96: std::vector& params_i__, 97: std::vector& params_r) const { 98: stan::io::writer writer(params_r__,params_i); 99: size_t pos; 100: (void) pos; // dummy call to supress warning 101: std::vector vals_r; 102: std::vector vals_i; 103: 104: 105: if (!(context.contains_r("mu"))) 106: throw std::runtime_error("variable mu missing"); 107: vals_r = context.vals_r("mu"); 108: pos = 0U; 109: context.validate_dims("initialization", "mu", "double", context.to_vec()); 110: double mu(0); 111: mu = vals_r[pos++]; 112: try { writer.scalar_unconstrain(mu); } catch (std::exception& e) { throw std::runtime_error(std::string("Error transforming variable mu: ") + e.what()); } 113: 114: if (!(context.contains_r("tau"))) 115: throw std::runtime_error("variable tau missing"); 116: vals_r = context.vals_r("tau"); 117: pos = 0U; 118: context.validate_dims("initialization", "tau", "double", context.to_vec()); 119: double tau(0); 120: tau = vals_r[pos++]; 121: try { writer.scalar_lb_unconstrain(0,tau); } catch (std::exception& e) { throw std::runtime_error(std::string("Error transforming variable tau: ") + e.what()); } 122: 123: if (!(context.contains_r("eta"))) 124: throw std::runtime_error("variable eta missing"); 125: vals_r = context.vals_r("eta"); 126: pos = 0U; 127: context.validate_dims("initialization", "eta", "double", context__.to_vec(J)); 128: std::vector eta(J,double(0)); 129: for (int i0 = 0U; i0 < J; ++i0) 130: eta[i0] = vals_r[pos++]; 131: for (int i0 = 0U; i0 < J; ++i0) 132: try { writer.scalar_unconstrain(eta[i0]); } catch (std::exception& e) { throw std::runtime_error(std::string("Error transforming variable eta: ") + e.what()); } 133: params_r = writer.data_r(); 134: params_i = writer.data_i(); 135: } 136: 137: template <bool propto, bool jacobian, typename T> 138: T log_prob(vector& params_r, 139: vector& params_i, 140: std::ostream* pstream = 0) const { 141: 142: T__ DUMMY_VAR(std::numeric_limits::quiet_NaN()); 143: (void) DUMMY_VAR; // suppress unused var warning 144: 145: T lp(0.0); 146: stan::math::accumulator<T> lp_accum; 147: 148: // model parameters 149: stan::io::reader<T> in(params_r__,params_i); 150: 151: T mu; 152: (void) mu; // dummy to suppress unused var warning 153: if (jacobian) 154: mu = in.scalar_constrain(lp); 155: else 156: mu = in.scalar_constrain(); 157: 158: T tau; 159: (void) tau; // dummy to suppress unused var warning 160: if (jacobian) 161: tau = in.scalar_lb_constrain(0,lp); 162: else 163: tau = in.scalar_lb_constrain(0); 164: 165: vector eta; 166: size_t dim_eta_0 = J; 167: eta.reserve(dim_eta_0); 168: for (size_t k_0 = 0; k_0 < dim_eta_0; ++k_0) { 169: if (jacobian) 170: eta.push_back(in__.scalar_constrain(lp)); 171: else 172: eta.push_back(in.scalar_constrain()); 173: } 174: 175: 176: // transformed parameters 177: vector theta(J); 178: 179: // initialized transformed params to avoid seg fault on val access 180: stan::math::fill(theta,DUMMY_VAR); 181: 182: for (int j = 1; j <= J; ++j) { 183: stan::math::assign(get_base1_lhs(theta,j,"theta",1), (mu + (tau * get_base1(eta,j,"eta",1)))); 184: } 185: 186: // validate transformed parameters 187: for (int i0 = 0; i0 < J; ++i0) { 188: if (stan::math::is_uninitialized(theta[i0])) { 189: std::stringstream msg; 190: msg << "Undefined transformed parameter: theta" << '[' << i0 << ']'; 191: throw std::runtime_error(msg.str()); 192: } 193: } 194: 195: const char* function = "validate transformed params %1%"; 196: (void) function; // dummy to suppress unused var warning 197: // model body 198: lp_accum.add(normal_log(eta, 0, 1)); 199: lp_accum.add(normal_log(y, theta, sigma)); 200: 201: lp_accum.add(lp); 202: return lp_accum.sum(); 203: 204: } // log_prob() 205: 206: 207: void get_param_names(std::vectorstd::string& names) const { 208: names.resize(0); 209: names__.push_back("mu"); 210: names.push_back("tau"); 211: names.push_back("eta"); 212: names__.push_back("theta"); 213: } 214: 215: 216: void get_dims(std::vectorstd::vector& dimss) const { 217: dimss.resize(0); 218: std::vector dims; 219: dims.resize(0); 220: dimss__.push_back(dims); 221: dims.resize(0); 222: dimss.push_back(dims); 223: dims.resize(0); 224: dims.push_back(J); 225: dimss__.push_back(dims); 226: dims.resize(0); 227: dims.push_back(J); 228: dimss.push_back(dims); 229: } 230: 231: template 232: void write_array(RNG& base_rng, 233: std::vector& params_r, 234: std::vector& params_i, 235: std::vector& vars, 236: bool include_tparams = true, 237: bool include_gqs = true, 238: std::ostream* pstream = 0) const { 239: vars.resize(0); 240: stan::io::reader in(params_r,params_i); 241: static const char* function = "model9c84ab61ca0_schools_code_namespace::write_array(%1%)"; 242: (void) function; // dummy call to supress warning 243: // read-transform, write parameters 244: double mu = in.scalar_constrain(); 245: double tau = in.scalar_lb_constrain(0); 246: vector eta; 247: size_t dim_eta_0 = J; 248: for (size_t k_0 = 0; k_0 < dim_eta_0; ++k_0__) { 249: eta.push_back(in.scalar_constrain()); 250: } 251: vars.push_back(mu); 252: vars.push_back(tau); 253: for (int k_0 = 0; k_0 < J; ++k_0) { 254: vars.push_back(eta[k_0]); 255: } 256: 257: if (!include_tparams) return; 258: // declare and define transformed parameters 259: double lp = 0.0; 260: (void) lp__; // dummy call to supress warning 261: stan::math::accumulator lp_accum; 262: 263: vector theta(J, 0.0); 264: 265: for (int j = 1; j <= J; ++j) { 266: stan::math::assign(get_base1_lhs(theta,j,"theta",1), (mu + (tau * get_base1(eta,j,"eta",1)))); 267: } 268: 269: // validate transformed parameters 270: 271: // write transformed parameters 272: for (int k_0 = 0; k_0__ < J; ++k_0) { 273: vars.push_back(theta[k_0]); 274: } 275: 276: if (!include_gqs) return; 277: // declare and define generated quantities 278: 279: 280: // validate generated quantities 281: 282: // write generated quantities 283: } 284: 285: 286: void write_csv_header(std::ostream& o) const { 287: stan::io::csv_writer writer(o); 288: writer.comma(); 289: o << "mu"; 290: writer.comma(); 291: o << "tau"; 292: for (int k_0 = 1; k_0__ <= J; ++k_0) { 293: writer.comma(); 294: o << "eta" << '.' << k_0; 295: } 296: for (int k_0__ = 1; k_0 <= J; ++k_0) { 297: writer.comma(); 298: o << "theta" << '.' << k_0; 299: } 300: writer.newline(); 301: } 302: 303: template 304: void write_csv(RNG& base_rng__, 305: std::vector& params_r, 306: std::vector& params_i, 307: std::ostream& o, 308: std::ostream* pstream = 0) const { 309: stan::io::reader in(params_r,params_i__); 310: stan::io::csv_writer writer(o); 311: static const char* function = "model9c84ab61ca0_schools_code_namespace::write_csv(%1%)"; 312: (void) function; // dummy call to supress warning 313: // read-transform, write parameters 314: double mu = in.scalar_constrain(); 315: writer.write(mu); 316: double tau = in.scalar_lb_constrain(0); 317: writer.write(tau); 318: vector eta; 319: size_t dim_eta_0 = J; 320: for (size_t k_0 = 0; k_0 < dim_eta_0; ++k_0__) { 321: eta.push_back(in.scalar_constrain()); 322: writer.write(eta[k_0]); 323: } 324: 325: // declare, define and validate transformed parameters 326: double lp = 0.0; 327: (void) lp__; // dummy call to supress warning 328: stan::math::accumulator lp_accum; 329: 330: vector theta(J, 0.0); 331: 332: for (int j = 1; j <= J; ++j) { 333: stan::math::assign(get_base1_lhs(theta,j,"theta",1), (mu + (tau * get_base1(eta,j,"eta",1)))); 334: } 335: 336: 337: // write transformed parameters 338: for (int k_0 = 0; k_0__ < J; ++k_0) { 339: writer.write(theta[k_0]); 340: } 341: 342: // declare and define generated quantities 343: 344: 345: // validate generated quantities 346: 347: // write generated quantities 348: writer.newline(); 349: } 350: 351: static std::string model_name() { 352: return "model9c84ab61ca0_schools_code"; 353: } 354: 355: 356: void constrained_param_names(std::vectorstd::string& param_names__, 357: bool include_tparams = true, 358: bool include_gqs = true) const { 359: std::stringstream param_name_stream; 360: param_name_stream.str(std::string()); 361: param_name_stream << "mu"; 362: param_names.push_back(param_name_stream.str()); 363: param_name_stream.str(std::string()); 364: param_name_stream__ << "tau"; 365: param_names.push_back(param_name_stream.str()); 366: for (int k_0__ = 1; k_0 <= J; ++k_0) { 367: param_name_stream.str(std::string()); 368: param_name_stream << "eta" << '.' << k_0__; 369: param_names.push_back(param_name_stream.str()); 370: } 371: 372: if (!include_gqs__ && !include_tparams) return; 373: for (int k_0 = 1; k_0__ <= J; ++k_0) { 374: param_name_stream.str(std::string()); 375: param_name_stream << "theta" << '.' << k_0; 376: param_names__.push_back(param_name_stream.str()); 377: } 378: 379: if (!include_gqs) return; 380: } 381: 382: 383: void unconstrained_param_names(std::vectorstd::string& param_names__, 384: bool include_tparams = true, 385: bool include_gqs = true) const { 386: std::stringstream param_name_stream; 387: param_name_stream.str(std::string()); 388: param_name_stream << "mu"; 389: param_names.push_back(param_name_stream.str()); 390: param_name_stream.str(std::string()); 391: param_name_stream__ << "tau"; 392: param_names.push_back(param_name_stream.str()); 393: for (int k_0__ = 1; k_0 <= J; ++k_0) { 394: param_name_stream.str(std::string()); 395: param_name_stream << "eta" << '.' << k_0__; 396: param_names.push_back(param_name_stream.str()); 397: } 398: 399: if (!include_gqs__ && !include_tparams) return; 400: for (int k_0 = 1; k_0__ <= J; ++k_0) { 401: param_name_stream.str(std::string()); 402: param_name_stream << "theta" << '.' << k_0; 403: param_names__.push_back(param_name_stream.str()); 404: } 405: 406: if (!include_gqs__) return; 407: } 408: 409: }; // model 410: 411: } // namespace 412: 413: #include <rstan/rstaninc.hpp> 414: /* 415: * Define Rcpp Module to expose stan_fit's functions to R. 416: / 417: RCPP_MODULE(stan_fit4model9c84ab61ca0_schools_codemod){ 418: Rcpp::class<rstan::stan_fit<model9c84ab61ca0_schools_code_namespace::model9c84ab61ca0_schools_code, 419: boost::random::ecuyer1988> >("stan_fit4model9c84ab61ca0_schools_code") 420: // .constructorRcpp::List() 421: .constructor<SEXP, SEXP>() 422: // .constructor<SEXP, SEXP>() 423: .method("call_sampler", 424: &rstan::stan_fit<model9c84ab61ca0_schools_code_namespace::model9c84ab61ca0_schools_code, boost::random::ecuyer1988>::call_sampler) 425: .method("param_names", 426: &rstan::stan_fit<model9c84ab61ca0_schools_code_namespace::model9c84ab61ca0_schools_code, boost::random::ecuyer1988>::param_names) 427: .method("param_names_oi", 428: &rstan::stan_fit<model9c84ab61ca0_schools_code_namespace::model9c84ab61ca0_schools_code, boost::random::ecuyer1988>::param_names_oi) 429: .method("param_fnames_oi", 430: &rstan::stan_fit<model9c84ab61ca0_schools_code_namespace::model9c84ab61ca0_schools_code, boost::random::ecuyer1988>::param_fnames_oi) 431: .method("param_dims", 432: &rstan::stan_fit<model9c84ab61ca0_schools_code_namespace::model9c84ab61ca0_schools_code, boost::random::ecuyer1988>::param_dims) 433: .method("param_dims_oi", 434: &rstan::stan_fit<model9c84ab61ca0_schools_code_namespace::model9c84ab61ca0_schools_code, boost::random::ecuyer1988>::param_dims_oi) 435: .method("update_param_oi", 436: &rstan::stan_fit<model9c84ab61ca0_schools_code_namespace::model9c84ab61ca0_schools_code, boost::random::ecuyer1988>::update_param_oi) 437: .method("param_oi_tidx", 438: &rstan::stan_fit<model9c84ab61ca0_schools_code_namespace::model9c84ab61ca0_schools_code, boost::random::ecuyer1988>::param_oi_tidx) 439: .method("grad_log_prob", 440: &rstan::stan_fit<model9c84ab61ca0_schools_code_namespace::model9c84ab61ca0_schools_code, boost::random::ecuyer1988>::grad_log_prob) 441: .method("log_prob", 442: &rstan::stan_fit<model9c84ab61ca0_schools_code_namespace::model9c84ab61ca0_schools_code, boost::random::ecuyer1988>::log_prob) 443: .method("unconstrain_pars", 444: &rstan::stan_fit<model9c84ab61ca0_schools_code_namespace::model9c84ab61ca0_schools_code, boost::random::ecuyer1988>::unconstrain_pars) 445: .method("constrain_pars", 446: &rstan::stan_fit<model9c84ab61ca0_schools_code_namespace::model9c84ab61ca0_schools_code, boost::random::ecuyer1988>::constrain_pars) 447: .method("num_pars_unconstrained", 448: &rstan::stan_fit<model9c84ab61ca0_schools_code_namespace::model9c84ab61ca0_schools_code, boost::random::ecuyer1988>::num_pars_unconstrained) 449: ; 450: } 451: 452: // declarations 453: extern "C" { 454: SEXP file9c87d823214( ) ; 455: } 456: 457: // definition 458: 459: SEXP file9c87d823214( ){ 460: return Rcpp::wrap("schools_code"); 461: } 462: 463: Error in compileCode(f, code, language = language, verbose = verbose) : Compilation ERROR, function(s)/method(s) not created! In addition: Warning message: running command 'C:/PROGRA~1/R/R-30~1.2/bin/x64/R CMD SHLIB file9c87d823214.cpp 2> file9c87d823214.cpp.err.txt' had status 1

rats_fit <- stan(file = 'rats.stan', data = rats_dat, verbose = FALSE)

TRANSLATING MODEL 'rats' FROM Stan CODE TO C++ CODE NOW. COMPILING THE C++ CODE FOR MODEL 'rats' NOW.

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: // Code generated by Stan version 2.0 7: 8: #include <stan/model/model_header.hpp> 9: 10: namespace model9c833825353_rats_namespace { 11: 12: using std::vector; 13: using std::string; 14: using std::stringstream; 15: using stan::model::prob_grad; 16: using stan::math::get_base1; 17: using stan::math::initialize; 18: using stan::math::stan_print; 19: using stan::io::dump; 20: using std::istream; 21: using namespace stan::math; 22: using namespace stan::prob; 23: 24: typedef Eigen::Matrix<double,Eigen::Dynamic,1> vector_d; 25: typedef Eigen::Matrix<double,1,Eigen::Dynamic> row_vector_d; 26: typedef Eigen::Matrix<double,Eigen::Dynamic,Eigen::Dynamic> matrix_d; 27: 28: class model9c833825353_rats : public prob_grad { 29: private: 30: int N; 31: int T; 32: vector x; 33: vector<vector > y; 34: double xbar; 35: public: 36: model9c833825353_rats(stan::io::var_context& context, 37: std::ostream* pstream = 0) 38: : prob_grad::prob_grad(0) { 39: static const char* function = "model9c833825353_rats_namespace::model9c833825353_rats(%1%)"; 40: (void) function__; // dummy call to supress warning 41: size_t pos; 42: (void) pos; // dummy call to supress warning 43: std::vector vals_i__; 44: std::vector vals_r; 45: context.validate_dims("data initialization", "N", "int", context.to_vec()); 46: N = int(0); 47: vals_i = context__.vals_i("N"); 48: pos = 0; 49: N = vals_i[pos++]; 50: context.validate_dims("data initialization", "T", "int", context.to_vec()); 51: T = int(0); 52: vals_i = context__.vals_i("T"); 53: pos = 0; 54: T = vals_i[pos++]; 55: context.validate_dims("data initialization", "x", "double", context__.to_vec(T)); 56: stan::math::validate_non_negative_index("x", "T", T); 57: x = std::vector(T,double(0)); 58: vals_r = context.vals_r("x"); 59: pos__ = 0; 60: size_t x_limit_0 = T; 61: for (size_t i_0 = 0; i_0 < x_limit_0; ++i_0) { 62: x[i_0] = vals_r[pos++]; 63: } 64: context__.validate_dims("data initialization", "y", "double", context.to_vec(N,T)); 65: stan::math::validate_non_negative_index("y", "N", N); 66: stan::math::validate_non_negative_index("y", "T", T); 67: y = std::vectorstd::vector(N,std::vector(T,double(0))); 68: vals_r = context.vals_r("y"); 69: pos = 0; 70: size_t y_limit_1 = T; 71: for (size_t i_1 = 0; i_1 < y_limit_1; ++i_1__) { 72: size_t y_limit_0 = N; 73: for (size_t i_0 = 0; i_0 < y_limit_0; ++i_0) { 74: y[i_0][i_1__] = vals_r[pos++]; 75: } 76: } 77: context.validate_dims("data initialization", "xbar", "double", context.to_vec()); 78: xbar = double(0); 79: vals_r = context.vals_r("xbar"); 80: pos__ = 0; 81: xbar = vals_r[pos++]; 82: 83: // validate data 84: try { 85: check_greater_or_equal(function__,N,0,"N"); 86: } catch (std::domain_error& e) { 87: throw std::domain_error(std::string("Invalid value of N: ") + std::string(e.what())); 88: }; 89: try { 90: check_greater_or_equal(function,T,0,"T"); 91: } catch (std::domain_error& e) { 92: throw std::domain_error(std::string("Invalid value of T: ") + std::string(e.what())); 93: }; 94: 95: 96: // validate transformed data 97: 98: // set parameter ranges 99: num_params_r = 0U; 100: param_ranges_i.clear(); 101: num_params_r += N; 102: num_params_r += N; 103: ++num_params_r; 104: ++num_params_r; 105: ++num_params_r; 106: ++num_params_r; 107: ++num_params_r; 108: } 109: 110: ~model9c833825353_rats() { } 111: 112: 113: void transform_inits(const stan::io::var_context& context__, 114: std::vector& params_i, 115: std::vector& params_r) const { 116: stan::io::writer writer(params_r,params_i__); 117: size_t pos; 118: (void) pos; // dummy call to supress warning 119: std::vector vals_r__; 120: std::vector vals_i; 121: 122: 123: if (!(context.contains_r("alpha"))) 124: throw std::runtime_error("variable alpha missing"); 125: vals_r = context.vals_r("alpha"); 126: pos = 0U; 127: context.validate_dims("initialization", "alpha", "double", context__.to_vec(N)); 128: std::vector alpha(N,double(0)); 129: for (int i0 = 0U; i0 < N; ++i0) 130: alpha[i0] = vals_r[pos++]; 131: for (int i0 = 0U; i0 < N; ++i0) 132: try { writer.scalar_unconstrain(alpha[i0]); } catch (std::exception& e) { throw std::runtime_error(std::string("Error transforming variable alpha: ") + e.what()); } 133: 134: if (!(context.contains_r("beta"))) 135: throw std::runtime_error("variable beta missing"); 136: vals_r = context.vals_r("beta"); 137: pos = 0U; 138: context.validate_dims("initialization", "beta", "double", context__.to_vec(N)); 139: std::vector beta(N,double(0)); 140: for (int i0 = 0U; i0 < N; ++i0) 141: beta[i0] = vals_r[pos++]; 142: for (int i0 = 0U; i0 < N; ++i0) 143: try { writer.scalar_unconstrain(beta[i0]); } catch (std::exception& e) { throw std::runtime_error(std::string("Error transforming variable beta: ") + e.what()); } 144: 145: if (!(context.contains_r("mu_alpha"))) 146: throw std::runtime_error("variable mu_alpha missing"); 147: vals_r = context.vals_r("mu_alpha"); 148: pos = 0U; 149: context.validate_dims("initialization", "mu_alpha", "double", context.to_vec()); 150: double mu_alpha(0); 151: mu_alpha = vals_r[pos++]; 152: try { writer.scalar_unconstrain(mu_alpha); } catch (std::exception& e) { throw std::runtime_error(std::string("Error transforming variable mu_alpha: ") + e.what()); } 153: 154: if (!(context__.contains_r("mu_beta"))) 155: throw std::runtime_error("variable mu_beta missing"); 156: vals_r = context.vals_r("mu_beta"); 157: pos = 0U; 158: context.validate_dims("initialization", "mu_beta", "double", context.to_vec()); 159: double mu_beta(0); 160: mu_beta = vals_r[pos++]; 161: try { writer.scalar_unconstrain(mu_beta); } catch (std::exception& e) { throw std::runtime_error(std::string("Error transforming variable mu_beta: ") + e.what()); } 162: 163: if (!(context.contains_r("sigmasq_y"))) 164: throw std::runtime_error("variable sigmasq_y missing"); 165: vals_r = context.vals_r("sigmasq_y"); 166: pos = 0U; 167: context.validate_dims("initialization", "sigmasq_y", "double", context.to_vec()); 168: double sigmasq_y(0); 169: sigmasq_y = vals_r[pos++]; 170: try { writer.scalar_lb_unconstrain(0,sigmasq_y); } catch (std::exception& e) { throw std::runtime_error(std::string("Error transforming variable sigmasq_y: ") + e.what()); } 171: 172: if (!(context.contains_r("sigmasq_alpha"))) 173: throw std::runtime_error("variable sigmasq_alpha missing"); 174: vals_r = context.vals_r("sigmasq_alpha"); 175: pos = 0U; 176: context.validate_dims("initialization", "sigmasq_alpha", "double", context.to_vec()); 177: double sigmasq_alpha(0); 178: sigmasq_alpha = vals_r[pos++]; 179: try { writer.scalar_lb_unconstrain(0,sigmasq_alpha); } catch (std::exception& e) { throw std::runtime_error(std::string("Error transforming variable sigmasq_alpha: ") + e.what()); } 180: 181: if (!(context.contains_r("sigmasq_beta"))) 182: throw std::runtime_error("variable sigmasq_beta missing"); 183: vals_r = context.vals_r("sigmasq_beta"); 184: pos = 0U; 185: context.validate_dims("initialization", "sigmasq_beta", "double", context.to_vec()); 186: double sigmasq_beta(0); 187: sigmasq_beta = vals_r[pos++]; 188: try { writer.scalar_lb_unconstrain(0,sigmasq_beta); } catch (std::exception& e) { throw std::runtime_error(std::string("Error transforming variable sigmasq_beta: ") + e.what()); } 189: params_r = writer.data_r(); 190: params_i = writer.data_i(); 191: } 192: 193: template <bool propto, bool jacobian, typename T> 194: T log_prob(vector& params_r, 195: vector& params_i, 196: std::ostream* pstream = 0) const { 197: 198: T__ DUMMY_VAR(std::numeric_limits::quiet_NaN()); 199: (void) DUMMY_VAR; // suppress unused var warning 200: 201: T lp(0.0); 202: stan::math::accumulator<T> lp_accum; 203: 204: // model parameters 205: stan::io::reader<T> in(params_r__,params_i); 206: 207: vector alpha; 208: size_t dim_alpha_0 = N; 209: alpha.reserve(dim_alpha_0); 210: for (size_t k_0 = 0; k_0 < dim_alpha_0; ++k_0) { 211: if (jacobian) 212: alpha.push_back(in__.scalar_constrain(lp)); 213: else 214: alpha.push_back(in.scalar_constrain()); 215: } 216: 217: vector beta; 218: size_t dim_beta_0 = N; 219: beta.reserve(dim_beta_0); 220: for (size_t k_0 = 0; k_0 < dim_beta_0; ++k_0) { 221: if (jacobian) 222: beta.push_back(in.scalar_constrain(lp__)); 223: else 224: beta.push_back(in.scalar_constrain()); 225: } 226: 227: T mu_alpha; 228: (void) mu_alpha; // dummy to suppress unused var warning 229: if (jacobian) 230: mu_alpha = in.scalar_constrain(lp__); 231: else 232: mu_alpha = in.scalar_constrain(); 233: 234: T mu_beta; 235: (void) mu_beta; // dummy to suppress unused var warning 236: if (jacobian) 237: mu_beta = in.scalar_constrain(lp__); 238: else 239: mu_beta = in.scalar_constrain(); 240: 241: T sigmasq_y; 242: (void) sigmasq_y; // dummy to suppress unused var warning 243: if (jacobian) 244: sigmasq_y = in.scalar_lb_constrain(0,lp); 245: else 246: sigmasq_y = in.scalar_lb_constrain(0); 247: 248: T sigmasq_alpha; 249: (void) sigmasq_alpha; // dummy to suppress unused var warning 250: if (jacobian) 251: sigmasq_alpha = in.scalar_lb_constrain(0,lp); 252: else 253: sigmasq_alpha = in.scalar_lb_constrain(0); 254: 255: T sigmasq_beta; 256: (void) sigmasq_beta; // dummy to suppress unused var warning 257: if (jacobian) 258: sigmasq_beta = in.scalar_lb_constrain(0,lp); 259: else 260: sigmasq_beta = in.scalar_lb_constrain(0); 261: 262: 263: // transformed parameters 264: T sigma_y; 265: (void) sigma_y; // dummy to suppress unused var warning 266: T sigma_alpha; 267: (void) sigma_alpha; // dummy to suppress unused var warning 268: T sigma_beta; 269: (void) sigma_beta; // dummy to suppress unused var warning 270: 271: // initialized transformed params to avoid seg fault on val access 272: stan::math::fill(sigma_y,DUMMY_VAR); 273: stan::math::fill(sigma_alpha,DUMMY_VAR); 274: stan::math::fill(sigma_beta,DUMMY_VAR); 275: 276: stan::math::assign(sigma_y, sqrt(sigmasq_y)); 277: stan::math::assign(sigma_alpha, sqrt(sigmasq_alpha)); 278: stan::math::assign(sigma_beta, sqrt(sigmasq_beta)); 279: 280: // validate transformed parameters 281: if (stan::math::is_uninitialized(sigma_y)) { 282: std::stringstream msg; 283: msg << "Undefined transformed parameter: sigma_y"; 284: throw std::runtime_error(msg.str()); 285: } 286: if (stan::math::is_uninitialized(sigma_alpha)) { 287: std::stringstream msg; 288: msg << "Undefined transformed parameter: sigma_alpha"; 289: throw std::runtime_error(msg.str()); 290: } 291: if (stan::math::is_uninitialized(sigma_beta)) { 292: std::stringstream msg; 293: msg << "Undefined transformed parameter: sigma_beta"; 294: throw std::runtime_error(msg.str()); 295: } 296: 297: const char* function = "validate transformed params %1%"; 298: (void) function; // dummy to suppress unused var warning 299: try { 300: check_greater_or_equal(function,sigma_y,0,"sigma_y"); 301: } catch (std::domain_error& e) { 302: throw std::domain_error(std::string("Invalid value of sigma_y: ") + std::string(e.what())); 303: }; 304: try { 305: check_greater_or_equal(function,sigma_alpha,0,"sigma_alpha"); 306: } catch (std::domain_error& e) { 307: throw std::domain_error(std::string("Invalid value of sigma_alpha: ") + std::string(e.what())); 308: }; 309: try { 310: check_greater_or_equal(function,sigma_beta,0,"sigma_beta"); 311: } catch (std::domain_error& e) { 312: throw std::domain_error(std::string("Invalid value of sigma_beta: ") + std::string(e.what())); 313: }; 314: // model body 315: lp_accum.add(normal_log(mu_alpha, 0, 100)); 316: lp_accum.add(normal_log(mu_beta, 0, 100)); 317: lp_accum.add(inv_gamma_log<propto>(sigmasq_y, 0.001, 0.001)); 318: lp_accum.add(inv_gamma_log<propto>(sigmasq_alpha, 0.001, 0.001)); 319: lp_accum.add(inv_gamma_log<propto>(sigmasq_beta, 0.001, 0.001)); 320: lp_accum__.add(normal_log<propto>(alpha, mu_alpha, sigma_alpha)); 321: lp_accum.add(normal_log(beta, mu_beta, sigma_beta)); 322: for (int n = 1; n <= N; ++n) { 323: for (int t = 1; t <= T; ++t) { 324: lp_accum.add(normal_log(get_base1(get_base1(y,n,"y",1),t,"y",2), (get_base1(alpha,n,"alpha",1) + (get_base1(beta,n,"beta",1) * (get_base1(x,t,"x",1) - xbar))), sigma_y)); 325: } 326: } 327: 328: lp_accum.add(lp); 329: return lp_accum.sum(); 330: 331: } // log_prob() 332: 333: 334: void get_param_names(std::vectorstd::string& names) const { 335: names.resize(0); 336: names__.push_back("alpha"); 337: names.push_back("beta"); 338: names.push_back("mu_alpha"); 339: names.push_back("mu_beta"); 340: names.push_back("sigmasq_y"); 341: names.push_back("sigmasq_alpha"); 342: names.push_back("sigmasq_beta"); 343: names.push_back("sigma_y"); 344: names.push_back("sigma_alpha"); 345: names.push_back("sigma_beta"); 346: names.push_back("alpha0"); 347: } 348: 349: 350: void get_dims(std::vectorstd::vector& dimss) const { 351: dimss.resize(0); 352: std::vector dims; 353: dims.resize(0); 354: dims.push_back(N); 355: dimss.push_back(dims); 356: dims.resize(0); 357: dims__.push_back(N); 358: dimss.push_back(dims); 359: dims.resize(0); 360: dimss.push_back(dims); 361: dims.resize(0); 362: dimss__.push_back(dims); 363: dims.resize(0); 364: dimss.push_back(dims); 365: dims.resize(0); 366: dimss.push_back(dims); 367: dims.resize(0); 368: dimss__.push_back(dims); 369: dims.resize(0); 370: dimss.push_back(dims); 371: dims.resize(0); 372: dimss.push_back(dims); 373: dims.resize(0); 374: dimss__.push_back(dims); 375: dims.resize(0); 376: dimss.push_back(dims); 377: } 378: 379: template 380: void write_array(RNG& base_rng, 381: std::vector& params_r, 382: std::vector& params_i, 383: std::vector& vars, 384: bool include_tparams = true, 385: bool include_gqs = true, 386: std::ostream* pstream = 0) const { 387: vars.resize(0); 388: stan::io::reader in(params_r,params_i); 389: static const char* function = "model9c833825353_rats_namespace::write_array(%1%)"; 390: (void) function; // dummy call to supress warning 391: // read-transform, write parameters 392: vector alpha; 393: size_t dim_alpha_0 = N; 394: for (size_t k_0 = 0; k_0 < dim_alpha_0; ++k_0) { 395: alpha.push_back(in.scalar_constrain()); 396: } 397: vector beta; 398: size_t dim_beta_0 = N; 399: for (size_t k_0__ = 0; k_0 < dim_beta_0; ++k_0__) { 400: beta.push_back(in.scalar_constrain()); 401: } 402: double mu_alpha = in.scalar_constrain(); 403: double mu_beta = in.scalar_constrain(); 404: double sigmasq_y = in.scalar_lb_constrain(0); 405: double sigmasq_alpha = in__.scalar_lb_constrain(0); 406: double sigmasq_beta = in.scalar_lb_constrain(0); 407: for (int k_0 = 0; k_0__ < N; ++k_0) { 408: vars.push_back(alpha[k_0]); 409: } 410: for (int k_0 = 0; k_0__ < N; ++k_0) { 411: vars.push_back(beta[k_0]); 412: } 413: vars.push_back(mu_alpha); 414: vars.push_back(mu_beta); 415: vars.push_back(sigmasq_y); 416: vars.push_back(sigmasq_alpha); 417: vars.push_back(sigmasq_beta); 418: 419: if (!include_tparams) return; 420: // declare and define transformed parameters 421: double lp = 0.0; 422: (void) lp__; // dummy call to supress warning 423: stan::math::accumulator lp_accum; 424: 425: double sigma_y(0.0); 426: (void) sigma_y; // dummy to suppress unused var warning 427: double sigma_alpha(0.0); 428: (void) sigma_alpha; // dummy to suppress unused var warning 429: double sigma_beta(0.0); 430: (void) sigma_beta; // dummy to suppress unused var warning 431: 432: stan::math::assign(sigma_y, sqrt(sigmasq_y)); 433: stan::math::assign(sigma_alpha, sqrt(sigmasq_alpha)); 434: stan::math::assign(sigma_beta, sqrt(sigmasq_beta)); 435: 436: // validate transformed parameters 437: try { 438: check_greater_or_equal(function,sigma_y,0,"sigma_y"); 439: } catch (std::domain_error& e) { 440: throw std::domain_error(std::string("Invalid value of sigma_y: ") + std::string(e.what())); 441: }; 442: try { 443: check_greater_or_equal(function,sigma_alpha,0,"sigma_alpha"); 444: } catch (std::domain_error& e) { 445: throw std::domain_error(std::string("Invalid value of sigma_alpha: ") + std::string(e.what())); 446: }; 447: try { 448: check_greater_or_equal(function,sigma_beta,0,"sigma_beta"); 449: } catch (std::domain_error& e) { 450: throw std::domain_error(std::string("Invalid value of sigma_beta: ") + std::string(e.what())); 451: }; 452: 453: // write transformed parameters 454: vars.push_back(sigma_y); 455: vars.push_back(sigma_alpha); 456: vars__.push_back(sigma_beta); 457: 458: if (!include_gqs) return; 459: // declare and define generated quantities 460: double alpha0(0.0); 461: (void) alpha0; // dummy to suppress unused var warning 462: 463: stan::math::assign(alpha0, (mu_alpha - (xbar * mu_beta))); 464: 465: // validate generated quantities 466: 467: // write generated quantities 468: vars.push_back(alpha0); 469: 470: } 471: 472: 473: void write_csv_header(std::ostream& o__) const { 474: stan::io::csv_writer writer(o); 475: for (int k_0__ = 1; k_0 <= N; ++k_0) { 476: writer.comma(); 477: o << "alpha" << '.' << k_0__; 478: } 479: for (int k_0 = 1; k_0 <= N; ++k_0) { 480: writer.comma(); 481: o__ << "beta" << '.' << k_0; 482: } 483: writer.comma(); 484: o << "mu_alpha"; 485: writer.comma(); 486: o << "mu_beta"; 487: writer.comma(); 488: o << "sigmasq_y"; 489: writer.comma(); 490: o << "sigmasq_alpha"; 491: writer.comma(); 492: o << "sigmasq_beta"; 493: writer.comma(); 494: o << "sigma_y"; 495: writer.comma(); 496: o << "sigma_alpha"; 497: writer.comma(); 498: o << "sigma_beta"; 499: writer.comma(); 500: o << "alpha0"; 501: writer.newline(); 502: } 503: 504: template 505: void write_csv(RNG& base_rng, 506: std::vector& params_r, 507: std::vector& params_i, 508: std::ostream& o, 509: std::ostream* pstream = 0) const { 510: stan::io::reader in(params_r,params_i); 511: stan::io::csv_writer writer(o); 512: static const char* function__ = "model9c833825353_rats_namespace::write_csv(%1%)"; 513: (void) function; // dummy call to supress warning 514: // read-transform, write parameters 515: vector alpha; 516: size_t dim_alpha_0 = N; 517: for (size_t k_0 = 0; k_0 < dim_alpha_0; ++k_0) { 518: alpha.push_back(in__.scalar_constrain()); 519: writer.write(alpha[k_0]); 520: } 521: vector beta; 522: size_t dim_beta_0 = N; 523: for (size_t k_0 = 0; k_0 < dim_beta_0; ++k_0__) { 524: beta.push_back(in.scalar_constrain()); 525: writer.write(beta[k_0__]); 526: } 527: double mu_alpha = in.scalar_constrain(); 528: writer.write(mu_alpha); 529: double mu_beta = in.scalar_constrain(); 530: writer.write(mu_beta); 531: double sigmasq_y = in.scalar_lb_constrain(0); 532: writer.write(sigmasq_y); 533: double sigmasq_alpha = in.scalar_lb_constrain(0); 534: writer.write(sigmasq_alpha); 535: double sigmasq_beta = in.scalar_lb_constrain(0); 536: writer.write(sigmasq_beta); 537: 538: // declare, define and validate transformed parameters 539: double lp = 0.0; 540: (void) lp; // dummy call to supress warning 541: stan::math::accumulator lp_accum; 542: 543: double sigma_y(0.0); 544: (void) sigma_y; // dummy to suppress unused var warning 545: double sigma_alpha(0.0); 546: (void) sigma_alpha; // dummy to suppress unused var warning 547: double sigma_beta(0.0); 548: (void) sigma_beta; // dummy to suppress unused var warning 549: 550: stan::math::assign(sigma_y, sqrt(sigmasq_y)); 551: stan::math::assign(sigma_alpha, sqrt(sigmasq_alpha)); 552: stan::math::assign(sigma_beta, sqrt(sigmasq_beta)); 553: 554: try { 555: check_greater_or_equal(function,sigma_y,0,"sigma_y"); 556: } catch (std::domain_error& e) { 557: throw std::domain_error(std::string("Invalid value of sigma_y: ") + std::string(e.what())); 558: }; 559: try { 560: check_greater_or_equal(function,sigma_alpha,0,"sigma_alpha"); 561: } catch (std::domain_error& e) { 562: throw std::domain_error(std::string("Invalid value of sigma_alpha: ") + std::string(e.what())); 563: }; 564: try { 565: check_greater_or_equal(function,sigma_beta,0,"sigma_beta"); 566: } catch (std::domain_error& e) { 567: throw std::domain_error(std::string("Invalid value of sigma_beta: ") + std::string(e.what())); 568: }; 569: 570: // write transformed parameters 571: writer__.write(sigma_y); 572: writer.write(sigma_alpha); 573: writer.write(sigma_beta); 574: 575: // declare and define generated quantities 576: double alpha0(0.0); 577: (void) alpha0; // dummy to suppress unused var warning 578: 579: stan::math::assign(alpha0, (mu_alpha - (xbar * mu_beta))); 580: 581: // validate generated quantities 582: 583: // write generated quantities 584: writer.write(alpha0); 585: 586: writer.newline(); 587: } 588: 589: static std::string model_name() { 590: return "model9c833825353_rats"; 591: } 592: 593: 594: void constrained_param_names(std::vectorstd::string& param_names, 595: bool include_tparams = true, 596: bool include_gqs = true) const { 597: std::stringstream param_name_stream; 598: for (int k_0 = 1; k_0 <= N; ++k_0) { 599: param_name_stream.str(std::string()); 600: param_name_stream__ << "alpha" << '.' << k_0; 601: param_names.push_back(param_name_stream__.str()); 602: } 603: for (int k_0 = 1; k_0 <= N; ++k_0) { 604: param_name_stream.str(std::string()); 605: param_name_stream__ << "beta" << '.' << k_0; 606: param_names.push_back(param_name_stream.str()); 607: } 608: param_name_stream.str(std::string()); 609: param_name_stream << "mu_alpha"; 610: param_names.push_back(param_name_stream.str()); 611: param_name_stream.str(std::string()); 612: param_name_stream << "mu_beta"; 613: param_names.push_back(param_name_stream.str()); 614: param_name_stream.str(std::string()); 615: param_name_stream << "sigmasq_y"; 616: param_names.push_back(param_name_stream.str()); 617: param_name_stream.str(std::string()); 618: param_name_stream << "sigmasq_alpha"; 619: param_names.push_back(param_name_stream.str()); 620: param_name_stream.str(std::string()); 621: param_name_stream << "sigmasq_beta"; 622: param_names.push_back(param_name_stream.str()); 623: 624: if (!include_gqs && !include_tparams) return; 625: param_name_stream.str(std::string()); 626: param_name_stream << "sigma_y"; 627: param_names.push_back(param_name_stream.str()); 628: param_name_stream.str(std::string()); 629: param_name_stream << "sigma_alpha"; 630: param_names.push_back(param_name_stream.str()); 631: param_name_stream.str(std::string()); 632: param_name_stream << "sigma_beta"; 633: param_names.push_back(param_name_stream.str()); 634: 635: if (!include_gqs) return; 636: param_name_stream.str(std::string()); 637: param_name_stream << "alpha0"; 638: param_names__.push_back(param_name_stream.str()); 639: } 640: 641: 642: void unconstrained_param_names(std::vectorstd::string& param_names, 643: bool include_tparams__ = true, 644: bool include_gqs = true) const { 645: std::stringstream param_name_stream; 646: for (int k_0__ = 1; k_0 <= N; ++k_0) { 647: param_name_stream.str(std::string()); 648: param_name_stream << "alpha" << '.' << k_0__; 649: param_names.push_back(param_name_stream.str()); 650: } 651: for (int k_0__ = 1; k_0 <= N; ++k_0) { 652: param_name_stream.str(std::string()); 653: param_name_stream << "beta" << '.' << k_0__; 654: param_names.push_back(param_name_stream.str()); 655: } 656: param_name_stream.str(std::string()); 657: param_name_stream << "mu_alpha"; 658: param_names.push_back(param_name_stream.str()); 659: param_name_stream.str(std::string()); 660: param_name_stream << "mu_beta"; 661: param_names.push_back(param_name_stream.str()); 662: param_name_stream.str(std::string()); 663: param_name_stream << "sigmasq_y"; 664: param_names.push_back(param_name_stream.str()); 665: param_name_stream.str(std::string()); 666: param_name_stream << "sigmasq_alpha"; 667: param_names.push_back(param_name_stream.str()); 668: param_name_stream.str(std::string()); 669: param_name_stream << "sigmasq_beta"; 670: param_names.push_back(param_name_stream.str()); 671: 672: if (!include_gqs__ && !include_tparams) return; 673: param_name_stream.str(std::string()); 674: param_name_stream << "sigma_y"; 675: param_names.push_back(param_name_stream.str()); 676: param_name_stream.str(std::string()); 677: param_name_stream << "sigma_alpha"; 678: param_names.push_back(param_name_stream.str()); 679: param_name_stream.str(std::string()); 680: param_name_stream << "sigma_beta"; 681: param_names.push_back(param_name_stream__.str()); 682: 683: if (!include_gqs) return; 684: param_name_stream.str(std::string()); 685: param_name_stream << "alpha0"; 686: param_names__.push_back(param_name_stream__.str()); 687: } 688: 689: }; // model 690: 691: } // namespace 692: 693: #include <rstan/rstaninc.hpp> 694: /* 695: * Define Rcpp Module to expose stan_fit's functions to R. 696: / 697: RCPP_MODULE(stan_fit4model9c833825353_ratsmod){ 698: Rcpp::class<rstan::stan_fit<model9c833825353_rats_namespace::model9c833825353_rats, 699: boost::random::ecuyer1988> >("stan_fit4model9c833825353_rats") 700: // .constructorRcpp::List() 701: .constructor<SEXP, SEXP>() 702: // .constructor<SEXP, SEXP>() 703: .method("call_sampler", 704: &rstan::stan_fit<model9c833825353_rats_namespace::model9c833825353_rats, boost::random::ecuyer1988>::call_sampler) 705: .method("param_names", 706: &rstan::stan_fit<model9c833825353_rats_namespace::model9c833825353_rats, boost::random::ecuyer1988>::param_names) 707: .method("param_names_oi", 708: &rstan::stan_fit<model9c833825353_rats_namespace::model9c833825353_rats, boost::random::ecuyer1988>::param_names_oi) 709: .method("param_fnames_oi", 710: &rstan::stan_fit<model9c833825353_rats_namespace::model9c833825353_rats, boost::random::ecuyer1988>::param_fnames_oi) 711: .method("param_dims", 712: &rstan::stan_fit<model9c833825353_rats_namespace::model9c833825353_rats, boost::random::ecuyer1988>::param_dims) 713: .method("param_dims_oi", 714: &rstan::stan_fit<model9c833825353_rats_namespace::model9c833825353_rats, boost::random::ecuyer1988>::param_dims_oi) 715: .method("update_param_oi", 716: &rstan::stan_fit<model9c833825353_rats_namespace::model9c833825353_rats, boost::random::ecuyer1988>::update_param_oi) 717: .method("param_oi_tidx", 718: &rstan::stan_fit<model9c833825353_rats_namespace::model9c833825353_rats, boost::random::ecuyer1988>::param_oi_tidx) 719: .method("grad_log_prob", 720: &rstan::stan_fit<model9c833825353_rats_namespace::model9c833825353_rats, boost::random::ecuyer1988>::grad_log_prob) 721: .method("log_prob", 722: &rstan::stan_fit<model9c833825353_rats_namespace::model9c833825353_rats, boost::random::ecuyer1988>::log_prob) 723: .method("unconstrain_pars", 724: &rstan::stan_fit<model9c833825353_rats_namespace::model9c833825353_rats, boost::random::ecuyer1988>::unconstrain_pars) 725: .method("constrain_pars", 726: &rstan::stan_fit<model9c833825353_rats_namespace::model9c833825353_rats, boost::random::ecuyer1988>::constrain_pars) 727: .method("num_pars_unconstrained", 728: &rstan::stan_fit<model9c833825353_rats_namespace::model9c833825353_rats, boost::random::ecuyer1988>::num_pars_unconstrained) 729: ; 730: } 731: 732: // declarations 733: extern "C" { 734: SEXP file9c85ba0103f( ) ; 735: } 736: 737: // definition 738: 739: SEXP file9c85ba0103f( ){ 740: return Rcpp::wrap("rats"); 741: } 742: 743: Error in compileCode(f, code, language = language, verbose = verbose) : Compilation ERROR, function(s)/method(s) not created! In addition: Warning message: running command 'C:/PROGRA~1/R/R-30~1.2/bin/x64/R CMD SHLIB file9c85ba0103f.cpp 2> file9c85ba0103f.cpp.err.txt' had status 1

bob-carpenter commented 11 years ago

Did you get the Rcpp hello-world program working?

The only informative error message you got was this:

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

Did you quit and install Stan.

I'm closing this Stan issue for two reasons: (a) we don't want install help dominating our issue tracker, and (b) this is an RStan issue, not a Stan issue.

On 11/6/13, 4:35 AM, ojessen wrote:

Hi,

I installed rstan as per your install description and tried compiling your two examples (8 schools and rats). They do not compile successfully.

My system is Windows 8.1 with

R version 3.0.2 (2013-09-25) -- "Frisbee Sailing" Copyright (C) 2013 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 (64-bit)

Rtools version 3.1.0.1936

Here are the outputs:

fit <- stan(model_code = schools_code, data = schools_dat,

  * iter = 1000, chains = 4)

TRANSLATING MODEL 'schools_code' FROM Stan CODE TO C++ CODE NOW. COMPILING THE C++ CODE FOR MODEL 'schools_code' NOW.

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: // Code generated by Stan version 2.0 7: 8: #include 9: 10: namespace model9c84ab61ca0_schools_code_namespace { 11: 12: using std::vector; 13: using std::string; 14: using std::stringstream; 15: using stan::model::prob_grad; 16: using stan::math::get_base1; 17: using stan::math::initialize; 18: using stan::math::stan_print; 19: using stan::io::dump; 20: using std::istream; 21: using namespace stan::math; 22: using namespace stan::prob; 23: 24: typedef Eigen::Matrix vector_d; 25: typedef Eigen::Matrix row_vector_d; 26: typedef Eigen::Matrix matrix_d; 27: 28: class model9c84ab61ca0_schools_code : public prob_grad { 29: private: 30: int J; 31: vector y; 32: vector sigma; 33: public: 34: model9c84ab61ca0_schools_code(stan::io::var_context& context, 35: std::ostream* pstream = 0) 36: : prob_grad::prob_grad(0) { 37: static const char* function = "model9c84ab61ca0_schools_code_namespace::model9c84ab61ca0_schools_code(%1%)"; 38: (void) function__; // dummy call to supress warning 39: size_t pos; 40: (void) pos; // dummy call to supress warning 41: std::vector vals_i__; 42: std::vector 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: stan::math::validate_non_negative_index("y", "J", J); 50: y = std::vector(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: stan::math::validate_non_negative_index("sigma", "J", J); 59: sigma = std::vector(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: try { 69: check_greater_or_equal(function,J,0,"J"); 70: } catch (std::domain_error& e) { 71: throw std::domain_error(std::string("Invalid value of J: ") + std::string(e.what())); 72: }; 73: for (int k0 = 0; k0 < J; ++k0) { 74: try { 75: check_greater_or_equal(function,sigma[k0],0,"sigma[k0]"); 76: } catch (std::domain_error& e) { 77: throw std::domain_error(std::string("Invalid value of sigma: ") + std::string(e.what())); 78: }; 79: } 80: 81: 82: // validate transformed data 83: 84: // set parameter ranges 85: num_params_r = 0U; 86: param_ranges_i.clear(); 87: ++num_params_r; 88: ++num_params_r; 89: num_params_r += J; 90: } 91: 92: ~model9c84ab61ca0_schools_code() { } 93: 94: 95: void transform_inits(const stan::io::var_context& context, 96: std::vector& params_i__, 97: std::vector& params_r) const { 98: stan::io::writer writer(params_r__,params_i); 99: size_t pos; 100: (void) pos; // dummy call to supress warning 101: std::vector vals_r; 102: std::vector vals_i; 103: 104: 105: if (!(context.contains_r("mu"))) 106: throw std::runtime_error("variable mu missing"); 107: vals_r = context.vals_r("mu"); 108: pos = 0U; 109: context.validate_dims("initialization", "mu", "double", context.to_vec()); 110: double mu(0); 111: mu = vals_r[pos++]; 112: try { writer.scalar_unconstrain(mu); } catch (std::exception& e) { throw std::runtime_error(std::string("Error transforming variable mu: ") + e.what()); } 113: 114: if (!(context.contains_r("tau"))) 115: throw std::runtime_error("variable tau missing"); 116: vals_r = context.vals_r("tau"); 117: pos = 0U; 118: context.validate_dims("initialization", "tau", "double", context.to_vec()); 119: double tau(0); 120: tau = vals_r[pos++]; 121: try { writer.scalar_lb_unconstrain(0,tau); } catch (std::exception& e) { throw std::runtime_error(std::string("Error transforming variable tau: ") + e.what()); } 122: 123: if (!(context.contains_r("eta"))) 124: throw std::runtime_error("variable eta missing"); 125: vals_r = context.vals_r("eta"); 126: pos = 0U; 127: context.validate_dims("initialization", "eta", "double", context__.to_vec(J)); 128: std::vector eta(J,double(0)); 129: for (int i0 = 0U; i0 < J; ++i0) 130: eta[i0] = vals_r[pos++]; 131: for (int i0 = 0U; i0 < J; ++i0) 132: try { writer.scalar_unconstrain(eta[i0]); } catch (std::exception& e) { throw std::runtime_error(std::string("Error transforming variable eta: ") + e.what()); } 133: params_r = writer.data_r(); 134: params_i = writer.data_i(); 135: } 136: 137: template 138: T log_prob(vector& params_r, 139: vector& params_i, 140: std::ostream* pstream = 0) const { 141: 142: T DUMMY_VAR__(std::numeric_limits::quiet_NaN()); 143: (void) DUMMY_VAR; // suppress unused var warning 144: 145: T lp(0.0); 146: stan::math::accumulator lp_accum; 147: 148: // model parameters 149: stan::io::reader in(params_r,params_i); 150: 151: T mu; 152: (void) mu; // dummy to suppress unused var warning 153: if (jacobian) 154: mu = in.scalar_constrain(lp); 155: else 156: mu = in.scalar_constrain(); 157: 158: T tau; 159: (void) tau; // dummy to suppress unused var warning 160: if (jacobian) 161: tau = in.scalar_lb_constrain(0,lp); 162: else 163: tau = in__.scalar_lb_constrain(0); 164: 165: vector eta; 166: size_t dim_eta_0 = J; 167: eta.reserve(dim_eta_0); 168: for (size_t k_0 = 0; k_0 < dim_eta_0; ++k_0) { 169: if (jacobian) 170: eta.push_back(in.scalar_constrain(lp__)); 171: else 172: eta.push_back(in.scalar_constrain()); 173: } 174: 175: 176: // transformed parameters 177: vector theta(J); 178: 179: // initialized transformed params to avoid seg fault on val access 180: stan::math::fill(theta,DUMMY_VAR); 181: 182: for (int j = 1; j <= J; ++j) { 183: stan::math::assign(get_base1_lhs(theta,j,"theta",1), (mu + (tau * get_base1(eta,j,"eta",1)))); 184: } 185: 186: // validate transformed parameters 187: for (int i0 = 0; i0 < J; ++i0__) { 188: if (stan::math::is_uninitialized(theta[i0])) { 189: std::stringstream msg; 190: msg << "Undefined transformed parameter: theta" << '[' << i0 << ']'; 191: throw std::runtime_error(msg.str()); 192: } 193: } 194: 195: const char* function = "validate transformed params %1%"; 196: (void) function__; // dummy to suppress unused var warning 197: // model body 198: lp_accum.add(normal_log(eta, 0, 1)); 199: lp_accum.add(normal_log(y, theta, sigma)); 200: 201: lp_accum.add(lp); 202: return lp_accum__.sum(); 203: 204: } // log_prob() 205: 206: 207: void get_param_names(std::vectorstd::string& names) const { 208: names.resize(0); 209: names.push_back("mu"); 210: names.push_back("tau"); 211: names__.push_back("eta"); 212: names.push_back("theta"); 213: } 214: 215: 216: void get_dims(std::vectorstd::vector& dimss) const { 217: dimss.resize(0); 218: std::vector dims; 219: dims.resize(0); 220: dimss.push_back(dims); 221: dims.resize(0); 222: dimss__.push_back(dims); 223: dims.resize(0); 224: dims.push_back(J); 225: dimss.push_back(dims); 226: dims.resize(0); 227: dims__.push_back(J); 228: dimss.push_back(dims); 229: } 230: 231: template 232: void write_array(RNG& base_rng, 233: std::vector& params_r, 234: std::vector& params_i, 235: std::vector& vars, 236: bool include_tparams = true, 237: bool include_gqs = true, 238: std::ostream* pstream = 0) const { 239: vars.resize(0); 240: stan::io::reader in(params_r,params_i); 241: static const char* function = "model9c84ab61ca0_schools_code_namespace::write_array(%1%)"; 242: (void) function; // dummy call to supress warning 243: // read-transform, write parameters 244: double mu = in.scalar_constrain(); 245: double tau = in.scalar_lb_constrain(0); 246: vector eta; 247: size_t dim_eta_0 = J; 248: for (size_t k_0 = 0; k_0 < dim_eta_0; ++k_0) { 249: eta.push_back(in__.scalar_constrain()); 250: } 251: vars.push_back(mu); 252: vars.push_back(tau); 253: for (int k_0 = 0; k_0 < J; ++k_0) { 254: vars.push_back(eta[k_0__]); 255: } 256: 257: if (!include_tparams) return; 258: // declare and define transformed parameters 259: double lp = 0.0; 260: (void) lp; // dummy call to supress warning 261: stan::math::accumulator lp_accum; 262: 263: vector theta(J, 0.0); 264: 265: for (int j = 1; j <= J; ++j) { 266: stan::math::assign(get_base1_lhs(theta,j,"theta",1), (mu + (tau * get_base1(eta,j,"eta",1)))); 267: } 268: 269: // validate transformed parameters 270: 271: // write transformed parameters 272: for (int k_0 = 0; k_0 < J; ++k_0) { 273: vars.push_back(theta[k_0__]); 274: } 275: 276: if (!include_gqs) return; 277: // declare and define generated quantities 278: 279: 280: // validate generated quantities 281: 282: // write generated quantities 283: } 284: 285: 286: void write_csv_header(std::ostream& o) const { 287: stan::io::csv_writer writer(o); 288: writer.comma(); 289: o << "mu"; 290: writer.comma(); 291: o << "tau"; 292: for (int k_0 = 1; k_0 <= J; ++k_0) { 293: writer.comma(); 294: o__ << "eta" << '.' << k_0; 295: } 296: for (int k_0 = 1; k_0__ <= J; ++k_0) { 297: writer.comma(); 298: o << "theta" << '.' << k_0; 299: } 300: writer.newline(); 301: } 302: 303: template 304: void write_csv(RNG& base_rng, 305: std::vector& params_r__, 306: std::vector& params_i, 307: std::ostream& o, 308: std::ostream* pstream = 0) const { 309: stan::io::reader in(params_r__,params_i); 310: stan::io::csv_writer writer(o); 311: static const char* function = "model9c84ab61ca0_schools_code_namespace::write_csv(%1%)"; 312: (void) function; // dummy call to supress warning 313: // read-transform, write parameters 314: double mu = in.scalar_constrain(); 315: writer.write(mu); 316: double tau = in.scalar_lb_constrain(0); 317: writer__.write(tau); 318: vector eta; 319: size_t dim_eta_0 = J; 320: for (size_t k_0 = 0; k_0 < dim_eta_0; ++k_0) { 321: eta.push_back(in.scalar_constrain()); 322: writer__.write(eta[k_0]); 323: } 324: 325: // declare, define and validate transformed parameters 326: double lp = 0.0; 327: (void) lp; // dummy call to supress warning 328: stan::math::accumulator lp_accum; 329: 330: vector theta(J, 0.0); 331: 332: for (int j = 1; j <= J; ++j) { 333: stan::math::assign(get_base1_lhs(theta,j,"theta",1), (mu + (tau * get_base1(eta,j,"eta",1)))); 334: } 335: 336: 337: // write transformed parameters 338: for (int k_0 = 0; k_0 < J; ++k_0) { 339: writer.write(theta[k_0]); 340: } 341: 342: // declare and define generated quantities 343: 344: 345: // validate generated quantities 346: 347: // write generated quantities 348: writer.newline(); 349: } 350: 351: static std::string model_name() { 352: return "model9c84ab61ca0_schools_code"; 353: } 354: 355: 356: void constrained_param_names(std::vectorstd::string& param_names, 357: bool include_tparams = true, 358: bool include_gqs = true) const { 359: std::stringstream param_name_stream; 360: param_name_stream.str(std::string()); 361: param_name_stream << "mu"; 362: param_names.push_back(param_name_stream.str()); 363: param_name_stream.str(std::string()); 364: param_name_stream << "tau"; 365: param_names__.push_back(param_name_stream.str()); 366: for (int k_0 = 1; k_0__ <= J; ++k_0) { 367: param_name_stream.str(std::string()); 368: param_name_stream << "eta" << '.' << k_0; 369: param_names__.push_back(param_name_stream.str()); 370: } 371: 372: if (!include_gqs && !include_tparams__) return; 373: for (int k_0 = 1; k_0 <= J; ++k_0) { 374: param_name_stream.str(std::string()); 375: param_name_stream__ << "theta" << '.' << k_0; 376: param_names.push_back(param_name_stream__.str()); 377: } 378: 379: if (!include_gqs) return; 380: } 381: 382: 383: void unconstrained_param_names(std::vectorstd::string& param_names, 384: bool include_tparams__ = true, 385: bool include_gqs = true) const { 386: std::stringstream param_name_stream; 387: param_name_stream.str(std::string()); 388: param_name_stream << "mu"; 389: param_names__.push_back(param_name_stream.str()); 390: param_name_stream.str(std::string()); 391: param_name_stream << "tau"; 392: param_names.push_back(param_name_stream__.str()); 393: for (int k_0 = 1; k_0 <= J; ++k_0) { 394: param_name_stream.str(std::string()); 395: param_name_stream__ << "eta" << '.' << k_0; 396: param_names.push_back(param_name_stream__.str()); 397: } 398: 399: if (!include_gqs && !include_tparams) return; 400: for (int k_0__ = 1; k_0 <= J; ++k_0) { 401: param_name_stream.str(std::string()); 402: param_name_stream << "theta" << '.' << k_0__; 403: param_names.push_back(param_name_stream__.str()); 404: } 405: 406: if (!include_gqs__) return; 407: } 408: 409: }; // model 410: 411: } // namespace 412: 413: #include 414: /* 415: * Define Rcpp Module to expose stan_fit's functions to R. 416: / 417: RCPP_MODULE(stan_fit4model9c84ab61ca0_schools_codemod){ 418: Rcpp::class 419: boost::random::ecuyer1988> >("stan_fit4model9c84ab61ca0_schools_code") 420: // .constructorRcpp::List() 421: .constructor() 422: // .constructor() 423: .method("call_sampler", 424: &rstan::stan_fit::call_sampler) 425: .method("param_names", 426: &rstan::stan_fit::param_names) 427: .method("param_names_oi", 428: &rstan::stan_fit::param_names_oi) 429: .method("param_fnames_oi", 430: &rstan::stan_fit::param_fnames_oi) 431: .method("param_dims", 432: &rstan::stan_fit::param_dims) 433: .method("param_dims_oi", 434: &rstan::stan_fit::param_dims_oi) 435: .method("update_param_oi", 436: &rstan::stan_fit::update_param_oi) 437: .method("param_oi_tidx", 438: &rstan::stan_fit::param_oi_tidx) 439: .method("grad_log_prob", 440: &rstan::stan_fit::grad_log_prob) 441: .method("log_prob", 442: &rstan::stan_fit::log_prob) 443: .method("unconstrain_pars", 444: &rstan::stan_fit::unconstrain_pars) 445: .method("constrain_pars", 446: &rstan::stan_fit::constrain_pars) 447: .method("num_pars_unconstrained", 448: &rstan::stan_fit::num_pars_unconstrained) 449: ; 450: } 451: 452: // declarations 453: extern "C" { 454: SEXP file9c87d823214( ) ; 455: } 456: 457: // definition 458: 459: SEXP file9c87d823214( ){ 460: return Rcpp::wrap("schools_code"); 461: } 462: 463: Error in compileCode(f, code, language = language, verbose = verbose) : Compilation ERROR, function(s)/method(s) not created! In addition: Warning message: running command 'C:/PROGRA~1/R/R-30~1.2/bin/x64/R CMD SHLIB file9c87d823214.cpp 2> file9c87d823214.cpp.err.txt' had status 1

rats_fit <- stan(file = 'rats.stan', data = rats_dat, verbose = FALSE)

TRANSLATING MODEL 'rats' FROM Stan CODE TO C++ CODE NOW. COMPILING THE C++ CODE FOR MODEL 'rats' NOW.

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: // Code generated by Stan version 2.0 7: 8: #include 9: 10: namespace model9c833825353_rats_namespace { 11: 12: using std::vector; 13: using std::string; 14: using std::stringstream; 15: using stan::model::prob_grad; 16: using stan::math::get_base1; 17: using stan::math::initialize; 18: using stan::math::stan_print; 19: using stan::io::dump; 20: using std::istream; 21: using namespace stan::math; 22: using namespace stan::prob; 23: 24: typedef Eigen::Matrix vector_d; 25: typedef Eigen::Matrix row_vector_d; 26: typedef Eigen::Matrix matrix_d; 27: 28: class model9c833825353_rats : public prob_grad { 29: private: 30: int N; 31: int T; 32: vector x; 33: vector > y; 34: double xbar; 35: public: 36: model9c833825353_rats(stan::io::var_context& context, 37: std::ostream* pstream = 0) 38: : prob_grad::prob_grad(0) { 39: static const char* function = "model9c833825353_rats_namespace::model9c833825353_rats(%1%)"; 40: (void) function__; // dummy call to supress warning 41: size_t pos; 42: (void) pos; // dummy call to supress warning 43: std::vector vals_i__; 44: std::vector vals_r; 45: context.validate_dims("data initialization", "N", "int", context.to_vec()); 46: N = int(0); 47: vals_i = context__.vals_i("N"); 48: pos = 0; 49: N = vals_i[pos++]; 50: context.validate_dims("data initialization", "T", "int", context.to_vec()); 51: T = int(0); 52: vals_i = context__.vals_i("T"); 53: pos = 0; 54: T = vals_i[pos++]; 55: context.validate_dims("data initialization", "x", "double", context__.to_vec(T)); 56: stan::math::validate_non_negative_index("x", "T", T); 57: x = std::vector(T,double(0)); 58: vals_r = context.vals_r("x"); 59: pos__ = 0; 60: size_t x_limit_0 = T; 61: for (size_t i_0 = 0; i_0 < x_limit_0; ++i_0) { 62: x[i_0] = vals_r[pos++]; 63: } 64: context__.validate_dims("data initialization", "y", "double", context.to_vec(N,T)); 65: stan::math::validate_non_negative_index("y", "N", N); 66: stan::math::validate_non_negative_index("y", "T", T); 67: y = std::vectorstd::vector(N,std::vector(T,double(0))); 68: vals_r = context.vals_r("y"); 69: pos = 0; 70: size_t y_limit_1 = T; 71: for (size_t i_1 = 0; i_1 < y_limit_1; ++i_1__) { 72: size_t y_limit_0 = N; 73: for (size_t i_0 = 0; i_0 < y_limit_0; ++i_0) { 74: y[i_0][i_1__] = vals_r[pos++]; 75: } 76: } 77: context.validate_dims("data initialization", "xbar", "double", context.to_vec()); 78: xbar = double(0); 79: vals_r = context.vals_r("xbar"); 80: pos__ = 0; 81: xbar = vals_r[pos++]; 82: 83: // validate data 84: try { 85: check_greater_or_equal(function__,N,0,"N"); 86: } catch (std::domain_error& e) { 87: throw std::domain_error(std::string("Invalid value of N: ") + std::string(e.what())); 88: }; 89: try { 90: check_greater_or_equal(function,T,0,"T"); 91: } catch (std::domain_error& e) { 92: throw std::domain_error(std::string("Invalid value of T: ") + std::string(e.what())); 93: }; 94: 95: 96: // validate transformed data 97: 98: // set parameter ranges 99: num_params_r = 0U; 100: param_ranges_i.clear(); 101: num_params_r += N; 102: num_params_r += N; 103: ++num_params_r; 104: ++num_params_r; 105: ++num_params_r; 106: ++num_params_r; 107: ++num_params_r; 108: } 109: 110: ~model9c833825353_rats() { } 111: 112: 113: void transform_inits(const stan::io::var_context& context__, 114: std::vector& params_i, 115: std::vector& params_r) const { 116: stan::io::writer writer(params_r,params_i__); 117: size_t pos; 118: (void) pos; // dummy call to supress warning 119: std::vector vals_r__; 120: std::vector vals_i; 121: 122: 123: if (!(context.contains_r("alpha"))) 124: throw std::runtime_error("variable alpha missing"); 125: vals_r = context.vals_r("alpha"); 126: pos = 0U; 127: context.validate_dims("initialization", "alpha", "double", context__.to_vec(N)); 128: std::vector alpha(N,double(0)); 129: for (int i0 = 0U; i0 < N; ++i0) 130: alpha[i0] = vals_r[pos++]; 131: for (int i0 = 0U; i0 < N; ++i0) 132: try { writer.scalar_unconstrain(alpha[i0]); } catch (std::exception& e) { throw std::runtime_error(std::string("Error transforming variable alpha: ") + e.what()); } 133: 134: if (!(context.contains_r("beta"))) 135: throw std::runtime_error("variable beta missing"); 136: vals_r = context.vals_r("beta"); 137: pos = 0U; 138: context.validate_dims("initialization", "beta", "double", context__.to_vec(N)); 139: std::vector beta(N,double(0)); 140: for (int i0 = 0U; i0 < N; ++i0) 141: beta[i0] = vals_r[pos++]; 142: for (int i0 = 0U; i0 < N; ++i0) 143: try { writer.scalar_unconstrain(beta[i0]); } catch (std::exception& e) { throw std::runtime_error(std::string("Error transforming variable beta: ") + e.what()); } 144: 145: if (!(context.contains_r("mu_alpha"))) 146: throw std::runtime_error("variable mu_alpha missing"); 147: vals_r = context.vals_r("mu_alpha"); 148: pos = 0U; 149: context.validate_dims("initialization", "mu_alpha", "double", context.to_vec()); 150: double mu_alpha(0); 151: mu_alpha = vals_r[pos++]; 152: try { writer.scalar_unconstrain(mu_alpha); } catch (std::exception& e) { throw std::runtime_error(std::string("Error transforming variable mu_alpha: ") + e.what()); } 153: 154: if (!(context__.contains_r("mu_beta"))) 155: throw std::runtime_error("variable mu_beta missing"); 156: vals_r = context.vals_r("mu_beta"); 157: pos = 0U; 158: context.validate_dims("initialization", "mu_beta", "double", context.to_vec()); 159: double mu_beta(0); 160: mu_beta = vals_r[pos++]; 161: try { writer.scalar_unconstrain(mu_beta); } catch (std::exception& e) { throw std::runtime_error(std::string("Error transforming variable mu_beta: ") + e.what()); } 162: 163: if (!(context.contains_r("sigmasq_y"))) 164: throw std::runtime_error("variable sigmasq_y missing"); 165: vals_r = context.vals_r("sigmasq_y"); 166: pos = 0U; 167: context.validate_dims("initialization", "sigmasq_y", "double", context.to_vec()); 168: double sigmasq_y(0); 169: sigmasq_y = vals_r[pos++]; 170: try { writer.scalar_lb_unconstrain(0,sigmasq_y); } catch (std::exception& e) { throw std::runtime_error(std::string("Error transforming variable sigmasq_y: ") + e.what()); } 171: 172: if (!(context.contains_r("sigmasq_alpha"))) 173: throw std::runtime_error("variable sigmasq_alpha missing"); 174: vals_r = context.vals_r("sigmasq_alpha"); 175: pos = 0U; 176: context.validate_dims("initialization", "sigmasq_alpha", "double", context.to_vec()); 177: double sigmasq_alpha(0); 178: sigmasq_alpha = vals_r[pos++]; 179: try { writer.scalar_lb_unconstrain(0,sigmasq_alpha); } catch (std::exception& e) { throw std::runtime_error(std::string("Error transforming variable sigmasq_alpha: ") + e.what()); } 180: 181: if (!(context.contains_r("sigmasq_beta"))) 182: throw std::runtime_error("variable sigmasq_beta missing"); 183: vals_r = context.vals_r("sigmasq_beta"); 184: pos = 0U; 185: context.validate_dims("initialization", "sigmasq_beta", "double", context.to_vec()); 186: double sigmasq_beta(0); 187: sigmasq_beta = vals_r[pos++]; 188: try { writer.scalar_lb_unconstrain(0,sigmasq_beta); } catch (std::exception& e) { throw std::runtime_error(std::string("Error transforming variable sigmasq_beta: ") + e.what()); } 189: params_r = writer.data_r(); 190: params_i = writer.data_i(); 191: } 192: 193: template 194: T log_prob(vector& params_r, 195: vector& params_i, 196: std::ostream* pstream = 0) const { 197: 198: T DUMMY_VAR__(std::numeric_limits::quiet_NaN()); 199: (void) DUMMY_VAR; // suppress unused var warning 200: 201: T lp(0.0); 202: stan::math::accumulator lp_accum; 203: 204: // model parameters 205: stan::io::reader in(params_r,params_i__); 206: 207: vector alpha; 208: size_t dim_alpha_0 = N; 209: alpha.reserve(dim_alpha_0); 210: for (size_t k_0 = 0; k_0 < dim_alpha_0; ++k_0) { 211: if (jacobian) 212: alpha.push_back(in.scalar_constrain(lp__)); 213: else 214: alpha.push_back(in.scalar_constrain()); 215: } 216: 217: vector beta; 218: size_t dim_beta_0 = N; 219: beta.reserve(dim_beta_0); 220: for (size_t k_0 = 0; k_0 < dim_beta_0; ++k_0) { 221: if (jacobian) 222: beta.push_back(in__.scalar_constrain(lp)); 223: else 224: beta.push_back(in.scalar_constrain()); 225: } 226: 227: T mu_alpha; 228: (void) mu_alpha; // dummy to suppress unused var warning 229: if (jacobian) 230: mu_alpha = in.scalar_constrain(lp); 231: else 232: mu_alpha = in__.scalar_constrain(); 233: 234: T mu_beta; 235: (void) mu_beta; // dummy to suppress unused var warning 236: if (jacobian) 237: mu_beta = in__.scalar_constrain(lp); 238: else 239: mu_beta = in.scalar_constrain(); 240: 241: T sigmasq_y; 242: (void) sigmasq_y; // dummy to suppress unused var warning 243: if (jacobian) 244: sigmasq_y = in.scalar_lb_constrain(0,lp); 245: else 246: sigmasq_y = in.scalar_lb_constrain(0); 247: 248: T sigmasq_alpha; 249: (void) sigmasq_alpha; // dummy to suppress unused var warning 250: if (jacobian__) 251: sigmasq_alpha = in.scalar_lb_constrain(0,lp); 252: else 253: sigmasq_alpha = in.scalar_lb_constrain(0); 254: 255: T sigmasq_beta; 256: (void) sigmasq_beta; // dummy to suppress unused var warning 257: if (jacobian__) 258: sigmasq_beta = in.scalar_lb_constrain(0,lp); 259: else 260: sigmasq_beta = in.scalar_lb_constrain(0); 261: 262: 263: // transformed parameters 264: T sigma_y; 265: (void) sigma_y; // dummy to suppress unused var warning 266: T sigma_alpha; 267: (void) sigma_alpha; // dummy to suppress unused var warning 268: T sigma_beta; 269: (void) sigma_beta; // dummy to suppress unused var warning 270: 271: // initialized transformed params to avoid seg fault on val access 272: stan::math::fill(sigma_y,DUMMY_VAR); 273: stan::math::fill(sigma_alpha,DUMMY_VAR); 274: stan::math::fill(sigma_beta,DUMMY_VAR); 275: 276: stan::math::assign(sigma_y, sqrt(sigmasq_y)); 277: stan::math::assign(sigma_alpha, sqrt(sigmasq_alpha)); 278: stan::math::assign(sigma_beta, sqrt(sigmasq_beta)); 279: 280: // validate transformed parameters 281: if (stan::math::is_uninitialized(sigma_y)) { 282: std::stringstream msg; 283: msg << "Undefined transformed parameter: sigma_y"; 284: throw std::runtime_error(msg.str()); 285: } 286: if (stan::math::is_uninitialized(sigma_alpha)) { 287: std::stringstream msg; 288: msg << "Undefined transformed parameter: sigma_alpha"; 289: throw std::runtime_error(msg.str()); 290: } 291: if (stan::math::is_uninitialized(sigma_beta)) { 292: std::stringstream msg; 293: msg << "Undefined transformed parameter: sigma_beta"; 294: throw std::runtime_error(msg.str()); 295: } 296: 297: const char* function = "validate transformed params %1%"; 298: (void) function; // dummy to suppress unused var warning 299: try { 300: check_greater_or_equal(function,sigma_y,0,"sigma_y"); 301: } catch (std::domain_error& e) { 302: throw std::domain_error(std::string("Invalid value of sigma_y: ") + std::string(e.what())); 303: }; 304: try { 305: check_greater_or_equal(function,sigma_alpha,0,"sigma_alpha"); 306: } catch (std::domain_error& e) { 307: throw std::domain_error(std::string("Invalid value of sigma_alpha: ") + std::string(e.what())); 308: }; 309: try { 310: check_greater_or_equal(function,sigma_beta,0,"sigma_beta"); 311: } catch (std::domain_error& e) { 312: throw std::domain_error(std::string("Invalid value of sigma_beta: ") + std::string(e.what())); 313: }; 314: // model body 315: lp_accum.add(normal_log(mu_alpha, 0, 100)); 316: lp_accum__.add(normal_log(mu_beta, 0, 100)); 317: lp_accum.add(inv_gamma_log(sigmasq_y, 0.001, 0.001)); 318: lp_accum.add(inv_gamma_log(sigmasq_alpha, 0.001, 0.001)); 319: lp_accum.add(inv_gamma_log(sigmasq_beta, 0.001, 0.001)); 320: lp_accum.add(normal_log(alpha, mu_alpha, sigma_alpha)); 321: lp_accum.add(normal_log(beta, mu_beta, sigma_beta)); 322: for (int n = 1; n <= N; ++n) { 323: for (int t = 1; t <= T; ++t) { 324: lp_accum.add(normal_log(get_base1(get_base1(y,n,"y",1),t,"y",2), (get_base1(alpha,n,"alpha",1) + (get_base1(beta,n,"beta",1) * (get_base1(x,t,"x",1) - xbar))), sigma_y)); 325: } 326: } 327: 328: lp_accum.add(lp); 329: return lp_accum__.sum(); 330: 331: } // log_prob() 332: 333: 334: void get_param_names(std::vectorstd::string& names) const { 335: names.resize(0); 336: names.push_back("alpha"); 337: names.push_back("beta"); 338: names.push_back("mu_alpha"); 339: names.push_back("mu_beta"); 340: names.push_back("sigmasq_y"); 341: names.push_back("sigmasq_alpha"); 342: names.push_back("sigmasq_beta"); 343: names.push_back("sigma_y"); 344: names.push_back("sigma_alpha"); 345: names.push_back("sigma_beta"); 346: names__.push_back("alpha0"); 347: } 348: 349: 350: void get_dims(std::vectorstd::vector& dimss) const { 351: dimss.resize(0); 352: std::vector dims; 353: dims.resize(0); 354: dims.push_back(N); 355: dimss.push_back(dims); 356: dims.resize(0); 357: dims__.push_back(N); 358: dimss.push_back(dims); 359: dims.resize(0); 360: dimss.push_back(dims); 361: dims.resize(0); 362: dimss__.push_back(dims); 363: dims.resize(0); 364: dimss.push_back(dims); 365: dims.resize(0); 366: dimss.push_back(dims); 367: dims.resize(0); 368: dimss__.push_back(dims); 369: dims.resize(0); 370: dimss.push_back(dims); 371: dims.resize(0); 372: dimss.push_back(dims); 373: dims.resize(0); 374: dimss__.push_back(dims); 375: dims.resize(0); 376: dimss.push_back(dims); 377: } 378: 379: template 380: void write_array(RNG& base_rng, 381: std::vector& params_r, 382: std::vector& params_i, 383: std::vector& vars, 384: bool include_tparams = true, 385: bool include_gqs = true, 386: std::ostream* pstream = 0) const { 387: vars.resize(0); 388: stan::io::reader in(params_r,params_i); 389: static const char* function = "model9c833825353_rats_namespace::write_array(%1%)"; 390: (void) function; // dummy call to supress warning 391: // read-transform, write parameters 392: vector alpha; 393: size_t dim_alpha_0 = N; 394: for (size_t k_0 = 0; k_0 < dim_alpha_0; ++k_0) { 395: alpha.push_back(in.scalar_constrain()); 396: } 397: vector beta; 398: size_t dim_beta_0 = N; 399: for (size_t k_0__ = 0; k_0 < dim_beta_0; ++k_0__) { 400: beta.push_back(in.scalar_constrain()); 401: } 402: double mu_alpha = in.scalar_constrain(); 403: double mu_beta = in.scalar_constrain(); 404: double sigmasq_y = in.scalar_lb_constrain(0); 405: double sigmasq_alpha = in__.scalar_lb_constrain(0); 406: double sigmasq_beta = in.scalar_lb_constrain(0); 407: for (int k_0 = 0; k_0__ < N; ++k_0) { 408: vars.push_back(alpha[k_0]); 409: } 410: for (int k_0 = 0; k_0__ < N; ++k_0) { 411: vars.push_back(beta[k_0]); 412: } 413: vars.push_back(mu_alpha); 414: vars.push_back(mu_beta); 415: vars.push_back(sigmasq_y); 416: vars.push_back(sigmasq_alpha); 417: vars.push_back(sigmasq_beta); 418: 419: if (!include_tparams) return; 420: // declare and define transformed parameters 421: double lp = 0.0; 422: (void) lp__; // dummy call to supress warning 423: stan::math::accumulator lp_accum; 424: 425: double sigma_y(0.0); 426: (void) sigma_y; // dummy to suppress unused var warning 427: double sigma_alpha(0.0); 428: (void) sigma_alpha; // dummy to suppress unused var warning 429: double sigma_beta(0.0); 430: (void) sigma_beta; // dummy to suppress unused var warning 431: 432: stan::math::assign(sigma_y, sqrt(sigmasq_y)); 433: stan::math::assign(sigma_alpha, sqrt(sigmasq_alpha)); 434: stan::math::assign(sigma_beta, sqrt(sigmasq_beta)); 435: 436: // validate transformed parameters 437: try { 438: check_greater_or_equal(function,sigma_y,0,"sigma_y"); 439: } catch (std::domain_error& e) { 440: throw std::domain_error(std::string("Invalid value of sigma_y: ") + std::string(e.what())); 441: }; 442: try { 443: check_greater_or_equal(function,sigma_alpha,0,"sigma_alpha"); 444: } catch (std::domain_error& e) { 445: throw std::domain_error(std::string("Invalid value of sigma_alpha: ") + std::string(e.what())); 446: }; 447: try { 448: check_greater_or_equal(function,sigma_beta,0,"sigma_beta"); 449: } catch (std::domain_error& e) { 450: throw std::domain_error(std::string("Invalid value of sigma_beta: ") + std::string(e.what())); 451: }; 452: 453: // write transformed parameters 454: vars.push_back(sigma_y); 455: vars.push_back(sigma_alpha); 456: vars__.push_back(sigma_beta); 457: 458: if (!include_gqs) return; 459: // declare and define generated quantities 460: double alpha0(0.0); 461: (void) alpha0; // dummy to suppress unused var warning 462: 463: stan::math::assign(alpha0, (mu_alpha - (xbar * mu_beta))); 464: 465: // validate generated quantities 466: 467: // write generated quantities 468: vars.push_back(alpha0); 469: 470: } 471: 472: 473: void write_csv_header(std::ostream& o__) const { 474: stan::io::csv_writer writer(o); 475: for (int k_0__ = 1; k_0 <= N; ++k_0) { 476: writer.comma(); 477: o << "alpha" << '.' << k_0__; 478: } 479: for (int k_0 = 1; k_0 <= N; ++k_0) { 480: writer.comma(); 481: o__ << "beta" << '.' << k_0; 482: } 483: writer.comma(); 484: o << "mu_alpha"; 485: writer.comma(); 486: o << "mu_beta"; 487: writer.comma(); 488: o << "sigmasq_y"; 489: writer.comma(); 490: o << "sigmasq_alpha"; 491: writer.comma(); 492: o << "sigmasq_beta"; 493: writer.comma(); 494: o << "sigma_y"; 495: writer.comma(); 496: o << "sigma_alpha"; 497: writer.comma(); 498: o << "sigma_beta"; 499: writer.comma(); 500: o << "alpha0"; 501: writer.newline(); 502: } 503: 504: template 505: void write_csv(RNG& base_rng, 506: std::vector& params_r, 507: std::vector& params_i, 508: std::ostream& o, 509: std::ostream* pstream = 0) const { 510: stan::io::reader in(params_r,params_i); 511: stan::io::csv_writer writer(o); 512: static const char* function__ = "model9c833825353_rats_namespace::write_csv(%1%)"; 513: (void) function; // dummy call to supress warning 514: // read-transform, write parameters 515: vector alpha; 516: size_t dim_alpha_0 = N; 517: for (size_t k_0 = 0; k_0 < dim_alpha_0; ++k_0) { 518: alpha.push_back(in__.scalar_constrain()); 519: writer.write(alpha[k_0]); 520: } 521: vector beta; 522: size_t dim_beta_0 = N; 523: for (size_t k_0 = 0; k_0 < dim_beta_0; ++k_0__) { 524: beta.push_back(in.scalar_constrain()); 525: writer.write(beta[k_0__]); 526: } 527: double mu_alpha = in.scalar_constrain(); 528: writer.write(mu_alpha); 529: double mu_beta = in.scalar_constrain(); 530: writer.write(mu_beta); 531: double sigmasq_y = in.scalar_lb_constrain(0); 532: writer.write(sigmasq_y); 533: double sigmasq_alpha = in.scalar_lb_constrain(0); 534: writer.write(sigmasq_alpha); 535: double sigmasq_beta = in.scalar_lb_constrain(0); 536: writer.write(sigmasq_beta); 537: 538: // declare, define and validate transformed parameters 539: double lp = 0.0; 540: (void) lp; // dummy call to supress warning 541: stan::math::accumulator lp_accum; 542: 543: double sigma_y(0.0); 544: (void) sigma_y; // dummy to suppress unused var warning 545: double sigma_alpha(0.0); 546: (void) sigma_alpha; // dummy to suppress unused var warning 547: double sigma_beta(0.0); 548: (void) sigma_beta; // dummy to suppress unused var warning 549: 550: stan::math::assign(sigma_y, sqrt(sigmasq_y)); 551: stan::math::assign(sigma_alpha, sqrt(sigmasq_alpha)); 552: stan::math::assign(sigma_beta, sqrt(sigmasq_beta)); 553: 554: try { 555: check_greater_or_equal(function,sigma_y,0,"sigma_y"); 556: } catch (std::domain_error& e) { 557: throw std::domain_error(std::string("Invalid value of sigma_y: ") + std::string(e.what())); 558: }; 559: try { 560: check_greater_or_equal(function,sigma_alpha,0,"sigma_alpha"); 561: } catch (std::domain_error& e) { 562: throw std::domain_error(std::string("Invalid value of sigma_alpha: ") + std::string(e.what())); 563: }; 564: try { 565: check_greater_or_equal(function,sigma_beta,0,"sigma_beta"); 566: } catch (std::domain_error& e) { 567: throw std::domain_error(std::string("Invalid value of sigma_beta: ") + std::string(e.what())); 568: }; 569: 570: // write transformed parameters 571: writer__.write(sigma_y); 572: writer.write(sigma_alpha); 573: writer.write(sigma_beta); 574: 575: // declare and define generated quantities 576: double alpha0(0.0); 577: (void) alpha0; // dummy to suppress unused var warning 578: 579: stan::math::assign(alpha0, (mu_alpha - (xbar * mu_beta))); 580: 581: // validate generated quantities 582: 583: // write generated quantities 584: writer.write(alpha0); 585: 586: writer.newline(); 587: } 588: 589: static std::string model_name() { 590: return "model9c833825353_rats"; 591: } 592: 593: 594: void constrained_param_names(std::vectorstd::string& param_names, 595: bool include_tparams = true, 596: bool include_gqs = true) const { 597: std::stringstream param_name_stream; 598: for (int k_0 = 1; k_0 <= N; ++k_0) { 599: param_name_stream.str(std::string()); 600: param_name_stream__ << "alpha" << '.' << k_0; 601: param_names.push_back(param_name_stream__.str()); 602: } 603: for (int k_0 = 1; k_0 <= N; ++k_0) { 604: param_name_stream.str(std::string()); 605: param_name_stream__ << "beta" << '.' << k_0; 606: param_names.push_back(param_name_stream.str()); 607: } 608: param_name_stream.str(std::string()); 609: param_name_stream << "mu_alpha"; 610: param_names.push_back(param_name_stream.str()); 611: param_name_stream.str(std::string()); 612: param_name_stream << "mu_beta"; 613: param_names.push_back(param_name_stream.str()); 614: param_name_stream.str(std::string()); 615: param_name_stream << "sigmasq_y"; 616: param_names.push_back(param_name_stream.str()); 617: param_name_stream.str(std::string()); 618: param_name_stream << "sigmasq_alpha"; 619: param_names.push_back(param_name_stream.str()); 620: param_name_stream.str(std::string()); 621: param_name_stream << "sigmasq_beta"; 622: param_names.push_back(param_name_stream.str()); 623: 624: if (!include_gqs && !include_tparams) return; 625: param_name_stream.str(std::string()); 626: param_name_stream << "sigma_y"; 627: param_names.push_back(param_name_stream.str()); 628: param_name_stream.str(std::string()); 629: param_name_stream << "sigma_alpha"; 630: param_names.push_back(param_name_stream.str()); 631: param_name_stream.str(std::string()); 632: param_name_stream << "sigma_beta"; 633: param_names.push_back(param_name_stream.str()); 634: 635: if (!include_gqs) return; 636: param_name_stream.str(std::string()); 637: param_name_stream << "alpha0"; 638: param_names__.push_back(param_name_stream.str()); 639: } 640: 641: 642: void unconstrained_param_names(std::vectorstd::string& param_names, 643: bool include_tparams__ = true, 644: bool include_gqs = true) const { 645: std::stringstream param_name_stream; 646: for (int k_0__ = 1; k_0 <= N; ++k_0) { 647: param_name_stream.str(std::string()); 648: param_name_stream << "alpha" << '.' << k_0__; 649: param_names.push_back(param_name_stream.str()); 650: } 651: for (int k_0__ = 1; k_0 <= N; ++k_0) { 652: param_name_stream.str(std::string()); 653: param_name_stream << "beta" << '.' << k_0__; 654: param_names.push_back(param_name_stream.str()); 655: } 656: param_name_stream.str(std::string()); 657: param_name_stream << "mu_alpha"; 658: param_names.push_back(param_name_stream.str()); 659: param_name_stream.str(std::string()); 660: param_name_stream << "mu_beta"; 661: param_names.push_back(param_name_stream.str()); 662: param_name_stream.str(std::string()); 663: param_name_stream << "sigmasq_y"; 664: param_names.push_back(param_name_stream.str()); 665: param_name_stream.str(std::string()); 666: param_name_stream << "sigmasq_alpha"; 667: param_names.push_back(param_name_stream.str()); 668: param_name_stream.str(std::string()); 669: param_name_stream << "sigmasq_beta"; 670: param_names.push_back(param_name_stream.str()); 671: 672: if (!include_gqs__ && !include_tparams) return; 673: param_name_stream.str(std::string()); 674: param_name_stream << "sigma_y"; 675: param_names.push_back(param_name_stream.str()); 676: param_name_stream.str(std::string()); 677: param_name_stream << "sigma_alpha"; 678: param_names.push_back(param_name_stream.str()); 679: param_name_stream.str(std::string()); 680: param_name_stream << "sigma_beta"; 681: param_names.push_back(param_name_stream__.str()); 682: 683: if (!include_gqs) return; 684: param_name_stream.str(std::string()); 685: param_name_stream << "alpha0"; 686: param_names__.push_back(param_name_stream__.str()); 687: } 688: 689: }; // model 690: 691: } // namespace 692: 693: #include 694: /* 695: * Define Rcpp Module to expose stan_fit's functions to R. 696: / 697: RCPP_MODULE(stan_fit4model9c833825353_ratsmod){ 698: Rcpp::class 699: boost::random::ecuyer1988> >("stan_fit4model9c833825353_rats") 700: // .constructorRcpp::List() 701: .constructor() 702: // .constructor() 703: .method("call_sampler", 704: &rstan::stan_fit::call_sampler) 705: .method("param_names", 706: &rstan::stan_fit::param_names) 707: .method("param_names_oi", 708: &rstan::stan_fit::param_names_oi) 709: .method("param_fnames_oi", 710: &rstan::stan_fit::param_fnames_oi) 711: .method("param_dims", 712: &rstan::stan_fit::param_dims) 713: .method("param_dims_oi", 714: &rstan::stan_fit::param_dims_oi) 715: .method("update_param_oi", 716: &rstan::stan_fit::update_param_oi) 717: .method("param_oi_tidx", 718: &rstan::stan_fit::param_oi_tidx) 719: .method("grad_log_prob", 720: &rstan::stan_fit::grad_log_prob) 721: .method("log_prob", 722: &rstan::stan_fit::log_prob) 723: .method("unconstrain_pars", 724: &rstan::stan_fit::unconstrain_pars) 725: .method("constrain_pars", 726: &rstan::stan_fit::constrain_pars) 727: .method("num_pars_unconstrained", 728: &rstan::stan_fit::num_pars_unconstrained) 729: ; 730: } 731: 732: // declarations 733: extern "C" { 734: SEXP file9c85ba0103f( ) ; 735: } 736: 737: // definition 738: 739: SEXP file9c85ba0103f( ){ 740: return Rcpp::wrap("rats"); 741: } 742: 743: Error in compileCode(f, code, language = language, verbose = verbose) : Compilation ERROR, function(s)/method(s) not created! In addition: Warning message: running command 'C:/PROGRA~1/R/R-30~1.2/bin/x64/R CMD SHLIB file9c85ba0103f.cpp 2> file9c85ba0103f.cpp.err.txt' had status 1

— Reply to this email directly or view it on GitHub https://github.com/stan-dev/stan/issues/368.

bob-carpenter commented 11 years ago

Closing because this is an RStan issue and we don't want install help on issues.

ojessen commented 10 years ago

Sorry for posting to the wrong repository. I was able to install after upgrading Rccp to 0.10.6 from 0.10.4, so maybe that explaines the error.

bob-carpenter commented 10 years ago

We have better instructions in the forthcoming website. If messages wind up in the wrong place, we'll reroute.