Unable to compile model

Hi stan users:

I came across this problem today and did some research on the forum but still could not find a solution to my problem.

I was able to install Rstan properly but then when compiled the model I received the following error message.

compiled_model <- stan(“QUT_1comp_classical_overall.stan”)
Error in compileCode(f, code, language = language, verbose = verbose) :
Compilation ERROR, function(s)/method(s) not created! In file included from /a pps/R/3.5.3/lib64/R/site-library/BH/include/boost/random/detail/integer_log2.hpp :19:0,
from /apps/R/3.5.3/lib64/R/site-library/BH/include/boost/random /detail/int_float_pair.hpp:26,
from /apps/R/3.5.3/lib64/R/site-library/BH/include/boost/random /exponential_distribution.hpp:27,
from /apps/R/3.5.3/lib64/R/site-library/BH/include/boost/random /gamma_distribution.hpp:25,
from /home/z5038974/R/x86_64-pc-linux-gnu-library/3.5/StanHeade rs/include/stan/math/prim/mat/prob/dirichlet_rng.hpp:5,
from /home/z5038974/R/x86_64-pc-linux-gnu-library/3.5/StanHeade rs/include/stan/math/prim/mat.hpp:292,
from /home/z5038974/R/x86_64-pc-linux-gnu-library/3.5/StanHeade rs/include/stan/math/rev/mat.hpp:12,
from /home/z5038974/R/x86_64-pc-linux-gnu-library/3.5/StanHeade rs/include/stan/math.hpp:4,

In addition: Warning message:
In system(cmd, intern = !verbose) :
running command ‘/apps/R/3.5.3/lib64/R/bin/R CMD SHLIB file5b0a18517620.cpp 2> file5b0a18517620.cpp.err.txt’ had status 1
Error in sink(type = “output”) : invalid connection

I tried modified Makevars file and currently it is
CXX14 = g++ -std=c++1y
CXX14FLAGS = -O3 -Wno-unused-variable -Wno-unused-function
CXX14FLAGS += -fPIC

Can someone please suggest a way for me to fix the problem?

Kind regards

Try it with stan(“QUT_1comp_classical_overall.stan”, verbose = TRUE) and tell us the part of the log that has the string error: (with colon) in it.

Thanks for your reply.

Here is the error message:

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

Program source:
1:
2: // includes from the plugin
3: // [[Rcpp::plugins(cpp14)]]
4:
5: // user includes
6: #define STAN__SERVICES__COMMAND_HPP// Code generated by Stan version 2.19.1
7:
8: #include <stan/model/model_header.hpp>
9:
10: namespace model14996d33f9e0_QUT_1comp_classical_overall_namespace {
11:
12: using std::istream;
13: using std::string;
14: using std::stringstream;
15: using std::vector;
16: using stan::io::dump;
17: using stan::math::lgamma;
18: using stan::model::prob_grad;
19: using namespace stan::math;
20:
21: static int current_statement_begin__;
22:
23: stan::io::program_reader prog_reader__() {
24: stan::io::program_reader reader;
25: reader.add_event(0, 0, “start”, “model14996d33f9e0_QUT_1comp_classical_overall”);
26: reader.add_event(150, 148, “end”, “model14996d33f9e0_QUT_1comp_classical_overall”);
27: return reader;
28: }
29:
30: class model14996d33f9e0_QUT_1comp_classical_overall : public prob_grad {
31: private:
32: int N;
33: int K;
34: int D;
35: int Ncol;
36: std::vector kk;
37: vector_d dat_complete;
38: int num_basis;
39: matrix_d B_annual;
40: matrix_d K_TD;
41: public:
42: model14996d33f9e0_QUT_1comp_classical_overall(stan::io::var_context& context__,
43: std::ostream* pstream__ = 0)
44: : prob_grad(0) {
45: ctor_body(context__, 0, pstream__);
46: }
47:
48: model14996d33f9e0_QUT_1comp_classical_overall(stan::io::var_context& context__,
49: unsigned int random_seed__,
50: std::ostream* pstream__ = 0)
51: : prob_grad(0) {
52: ctor_body(context__, random_seed__, pstream__);
53: }
54:
55: void ctor_body(stan::io::var_context& context__,
56: unsigned int random_seed__,
57: std::ostream* pstream__) {
58: typedef double local_scalar_t__;
59:
60: boost::ecuyer1988 base_rng__ =
61: stan::services::util::create_rng(random_seed__, 0);
62: (void) base_rng__; // suppress unused var warning
63:
64: current_statement_begin__ = -1;
65:
66: static const char* function__ = “model14996d33f9e0_QUT_1comp_classical_overall_namespace::model14996d33f9e0_QUT_1comp_classical_overall”;
67: (void) function__; // dummy to suppress unused var warning
68: size_t pos__;
69: (void) pos__; // dummy to suppress unused var warning
70: std::vector vals_i__;
71: std::vector vals_r__;
72: local_scalar_t__ DUMMY_VAR__(std::numeric_limits::quiet_NaN());
73: (void) DUMMY_VAR__; // suppress unused var warning
74:
75: try {
76: // initialize data block variables from context__
77: current_statement_begin__ = 4;
78: context__.validate_dims(“data initialization”, “N”, “int”, context__.to_vec());
79: N = int(0);
80: vals_i__ = context__.vals_i(“N”);
81: pos__ = 0;
82: N = vals_i__[pos__++];
83: check_greater_or_equal(function__, “N”, N, 1);
84:
85: current_statement_begin__ = 6;
86: context__.validate_dims(“data initialization”, “K”, “int”, context__.to_vec());
87: K = int(0);
88: vals_i__ = context__.vals_i(“K”);
89: pos__ = 0;
90: K = vals_i__[pos__++];
91: check_greater_or_equal(function__, “K”, K, 1);
92:
93: current_statement_begin__ = 8;
94: context__.validate_dims(“data initialization”, “D”, “int”, context__.to_vec());
95: D = int(0);
96: vals_i__ = context__.vals_i(“D”);
97: pos__ = 0;
98: D = vals_i__[pos__++];
99: check_greater_or_equal(function__, “D”, D, 1);
100:
101: current_statement_begin__ = 10;
102: context__.validate_dims(“data initialization”, “Ncol”, “int”, context__.to_vec());
103: Ncol = int(0);
104: vals_i__ = context__.vals_i(“Ncol”);
105: pos__ = 0;
106: Ncol = vals_i__[pos__++];
107: check_greater_or_equal(function__, “Ncol”, Ncol, 1);
108:
109: current_statement_begin__ = 12;
110: validate_non_negative_index(“kk”, “N”, N);
111: context__.validate_dims(“data initialization”, “kk”, “int”, context__.to_vec(N));
112: kk = std::vector(N, int(0));
113: vals_i__ = context__.vals_i(“kk”);
114: pos__ = 0;
115: size_t kk_k_0_max__ = N;
116: for (size_t k_0__ = 0; k_0__ < kk_k_0_max__; ++k_0__) {
117: kk[k_0__] = vals_i__[pos__++];
118: }
119: size_t kk_i_0_max__ = N;
120: for (size_t i_0__ = 0; i_0__ < kk_i_0_max__; ++i_0__) {
121: check_greater_or_equal(function__, “kk[i_0__]”, kk[i_0__], 1);
122: check_less_or_equal(function__, “kk[i_0__]”, kk[i_0__], Ncol);
123: }
124:
125: current_statement_begin__ = 14;
126: validate_non_negative_index(“dat_complete”, “N”, N);
127: context__.validate_dims(“data initialization”, “dat_complete”, “vector_d”, context__.to_vec(N));
128: dat_complete = Eigen::Matrix<double, Eigen::Dynamic, 1>(N);
129: vals_r__ = context__.vals_r(“dat_complete”);
130: pos__ = 0;
131: size_t dat_complete_j_1_max__ = N;
132: for (size_t j_1__ = 0; j_1__ < dat_complete_j_1_max__; ++j_1__) {
133: dat_complete(j_1__) = vals_r__[pos__++];
134: }
135:
136: current_statement_begin__ = 16;
137: context__.validate_dims(“data initialization”, “num_basis”, “int”, context__.to_vec());
138: num_basis = int(0);
139: vals_i__ = context__.vals_i(“num_basis”);
140: pos__ = 0;
141: num_basis = vals_i__[pos__++];
142:
143: current_statement_begin__ = 18;
144: validate_non_negative_index(“B_annual”, “D”, D);
145: validate_non_negative_index(“B_annual”, “num_basis”, num_basis);
146: context__.validate_dims(“data initialization”, “B_annual”, “matrix_d”, context__.to_vec(D,num_basis));
147: B_annual = Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic>(D, num_basis);
148: vals_r__ = context__.vals_r(“B_annual”);
149: pos__ = 0;
150: size_t B_annual_j_2_max__ = num_basis;
151: size_t B_annual_j_1_max__ = D;
152: for (size_t j_2__ = 0; j_2__ < B_annual_j_2_max__; ++j_2__) {
153: for (size_t j_1__ = 0; j_1__ < B_annual_j_1_max__; ++j_1__) {
154: B_annual(j_1__, j_2__) = vals_r__[pos__++];
155: }
156: }
157:
158: current_statement_begin__ = 20;
159: validate_non_negative_index(“K_TD”, “K”, K);
160: validate_non_negative_index(“K_TD”, “K”, K);
161: context__.validate_dims(“data initialization”, “K_TD”, “matrix_d”, context__.to_vec(K,K));
162: K_TD = Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic>(K, K);
163: vals_r__ = context__.vals_r(“K_TD”);
164: pos__ = 0;
165: size_t K_TD_j_2_max__ = K;
166: size_t K_TD_j_1_max__ = K;
167: for (size_t j_2__ = 0; j_2__ < K_TD_j_2_max__; ++j_2__) {
168: for (size_t j_1__ = 0; j_1__ < K_TD_j_1_max__; ++j_1__) {
169: K_TD(j_1__, j_2__) = vals_r__[pos__++];
170: }
171: }
172:
173:
174: // initialize transformed data variables
175: // execute transformed data statements
176:
177: // validate transformed data
178:
179: // validate, set parameter ranges
180: num_params_r__ = 0U;
181: param_ranges_i__.clear();
182: current_statement_begin__ = 27;
183: validate_non_negative_index(“beta”, “K”, K);
184: num_params_r__ += K;
185: current_statement_begin__ = 29;
186: validate_non_negative_index(“beta_annual_raw”, “num_basis”, num_basis);
187: num_params_r__ += num_basis;
188: current_statement_begin__ = 31;
189: num_params_r__ += 1;
190: } catch (const std::exception& e) {
191: stan::lang::rethrow_located(e, current_statement_begin__, prog_reader__());
192: // Next line prevents compiler griping about no return
193: throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ");
194: }
195: }
196:
197: ~model14996d33f9e0_QUT_1comp_classical_overall() { }
198:
199:
200: void transform_inits(const stan::io::var_context& context__,
201: std::vector& params_i__,
202: std::vector& params_r__,
203: std::ostream
pstream__) const {
204: typedef double local_scalar_t__;
205: stan::io::writer writer__(params_r__, params_i__);
206: size_t pos__;
207: (void) pos__; // dummy call to supress warning
208: std::vector vals_r__;
209: std::vector vals_i__;
210:
211: current_statement_begin__ = 27;
212: if (!(context__.contains_r(“beta”)))
213: stan::lang::rethrow_located(std::runtime_error(std::string(“Variable beta missing”)), current_statement_begin__, prog_reader__());
214: vals_r__ = context__.vals_r(“beta”);
215: pos__ = 0U;
216: validate_non_negative_index(“beta”, “K”, K);
217: context__.validate_dims(“parameter initialization”, “beta”, “vector_d”, context__.to_vec(K));
218: Eigen::Matrix<double, Eigen::Dynamic, 1> beta(K);
219: size_t beta_j_1_max__ = K;
220: for (size_t j_1__ = 0; j_1__ < beta_j_1_max__; ++j_1__) {
221: beta(j_1__) = vals_r__[pos__++];
222: }
223: try {
224: writer__.vector_unconstrain(beta);
225: } catch (const std::exception& e) {
226: stan::lang::rethrow_located(std::runtime_error(std::string("Error transforming variable beta: ") + e.what()), current_statement_begin__, prog_reader__());
227: }
228:
229: current_statement_begin__ = 29;
230: if (!(context__.contains_r(“beta_annual_raw”)))
231: stan::lang::rethrow_located(std::runtime_error(std::string(“Variable beta_annual_raw missing”)), current_statement_begin__, prog_reader__());
232: vals_r__ = context__.vals_r(“beta_annual_raw”);
233: pos__ = 0U;
234: validate_non_negative_index(“beta_annual_raw”, “num_basis”, num_basis);
235: context__.validate_dims(“parameter initialization”, “beta_annual_raw”, “vector_d”, context__.to_vec(num_basis));
236: Eigen::Matrix<double, Eigen::Dynamic, 1> beta_annual_raw(num_basis);
237: size_t beta_annual_raw_j_1_max__ = num_basis;
238: for (size_t j_1__ = 0; j_1__ < beta_annual_raw_j_1_max__; ++j_1__) {
239: beta_annual_raw(j_1__) = vals_r__[pos__++];
240: }
241: try {
242: writer__.vector_unconstrain(beta_annual_raw);
243: } catch (const std::exception& e) {
244: stan::lang::rethrow_located(std::runtime_error(std::string("Error transforming variable beta_annual_raw: ") + e.what()), current_statement_begin__, prog_reader__());
245: }
246:
247: current_statement_begin__ = 31;
248: if (!(context__.contains_r(“sigma”)))
249: stan::lang::rethrow_located(std::runtime_error(std::string(“Variable sigma missing”)), current_statement_begin__, prog_reader__());
250: vals_r__ = context__.vals_r(“sigma”);
251: pos__ = 0U;
252: context__.validate_dims(“parameter initialization”, “sigma”, “double”, context__.to_vec());
253: double sigma(0);
254: sigma = vals_r__[pos__++];
255: try {
256: writer__.scalar_lb_unconstrain(0, sigma);
257: } catch (const std::exception& e) {
258: stan::lang::rethrow_located(std::runtime_error(std::string("Error transforming variable sigma: ") + e.what()), current_statement_begin__, prog_reader__());
259: }
260:
261: params_r__ = writer__.data_r();
262: params_i__ = writer__.data_i();
263: }
264:
265: void transform_inits(const stan::io::var_context& context,
266: Eigen::Matrix<double, Eigen::Dynamic, 1>& params_r,
267: std::ostream
pstream__) const {
268: std::vector params_r_vec;
269: std::vector params_i_vec;
270: transform_inits(context, params_i_vec, params_r_vec, pstream__);
271: params_r.resize(params_r_vec.size());
272: for (int i = 0; i < params_r.size(); ++i)
273: params_r(i) = params_r_vec[i];
274: }
275:
276:
277: template <bool propto__, bool jacobian__, typename T__>
278: T__ log_prob(std::vector<T__>& params_r__,
279: std::vector& params_i__,
280: std::ostream
pstream__ = 0) const {
281:
282: typedef T__ local_scalar_t__;
283:
284: local_scalar_t__ DUMMY_VAR__(std::numeric_limits::quiet_NaN());
285: (void) DUMMY_VAR__; // dummy to suppress unused var warning
286:
287: T__ lp__(0.0);
288: stan::math::accumulator<T__> lp_accum__;
289: try {
290: stan::io::reader<local_scalar_t__> in__(params_r__, params_i__);
291:
292: // model parameters
293: current_statement_begin__ = 27;
294: Eigen::Matrix<local_scalar_t__, Eigen::Dynamic, 1> beta;
295: (void) beta; // dummy to suppress unused var warning
296: if (jacobian__)
297: beta = in__.vector_constrain(K, lp__);
298: else
299: beta = in__.vector_constrain(K);
300:
301: current_statement_begin__ = 29;
302: Eigen::Matrix<local_scalar_t__, Eigen::Dynamic, 1> beta_annual_raw;
303: (void) beta_annual_raw; // dummy to suppress unused var warning
304: if (jacobian__)
305: beta_annual_raw = in__.vector_constrain(num_basis, lp__);
306: else
307: beta_annual_raw = in__.vector_constrain(num_basis);
308:
309: current_statement_begin__ = 31;
310: local_scalar_t__ sigma;
311: (void) sigma; // dummy to suppress unused var warning
312: if (jacobian__)
313: sigma = in__.scalar_lb_constrain(0, lp__);
314: else
315: sigma = in__.scalar_lb_constrain(0);
316:
317: // transformed parameters
318: current_statement_begin__ = 37;
319: local_scalar_t__ alpha;
320: (void) alpha; // dummy to suppress unused var warning
321: stan::math::initialize(alpha, DUMMY_VAR__);
322: stan::math::fill(alpha, DUMMY_VAR__);
323:
324: current_statement_begin__ = 39;
325: validate_non_negative_index(“beta_annual”, “num_basis”, num_basis);
326: Eigen::Matrix<local_scalar_t__, Eigen::Dynamic, 1> beta_annual(num_basis);
327: stan::math::initialize(beta_annual, DUMMY_VAR__);
328: stan::math::fill(beta_annual, DUMMY_VAR__);
329:
330: current_statement_begin__ = 41;
331: validate_non_negative_index(“beta_adj”, “K”, K);
332: Eigen::Matrix<local_scalar_t__, Eigen::Dynamic, 1> beta_adj(K);
333: stan::math::initialize(beta_adj, DUMMY_VAR__);
334: stan::math::fill(beta_adj, DUMMY_VAR__);
335:
336: current_statement_begin__ = 43;
337: validate_non_negative_index(“annual_effects_gen”, “Ncol”, Ncol);
338: Eigen::Matrix<local_scalar_t__, Eigen::Dynamic, 1> annual_effects_gen(Ncol);
339: stan::math::initialize(annual_effects_gen, DUMMY_VAR__);
340: stan::math::fill(annual_effects_gen, DUMMY_VAR__);
341:
342: current_statement_begin__ = 45;
343: validate_non_negative_index(“overall_effects_gen”, “Ncol”, Ncol);
344: Eigen::Matrix<local_scalar_t__, Eigen::Dynamic, 1> overall_effects_gen(Ncol);
345: stan::math::initialize(overall_effects_gen, DUMMY_VAR__);
346: stan::math::fill(overall_effects_gen, DUMMY_VAR__);
347:
348: // transformed parameters block statements
349: current_statement_begin__ = 47;
350: stan::math::assign(beta_adj, subtract(beta, mean(beta)));
351: current_statement_begin__ = 49;
352: stan::math::assign(alpha, mean(beta));
353: current_statement_begin__ = 51;
354: stan::math::assign(beta_annual, multiply(beta_annual_raw, sigma));
355: current_statement_begin__ = 54;
356: for (int t = 1; t <= 17; ++t) {
357:
358: current_statement_begin__ = 55;
359: stan::model::assign(annual_effects_gen,
360: stan::model::cons_list(stan::model::index_min_max((1 + ((t - 1) * 8)), (8 * t)), stan::model::nil_index_list()),
361: rep_vector(get_base1(multiply(B_annual, beta_annual), t, “multiply(B_annual, beta_annual)”, 1), 8),
362: “assigning variable annual_effects_gen”);
363: }
364: current_statement_begin__ = 61;
365: for (int t = 18; t <= (D - 1); ++t) {
366:
367: current_statement_begin__ = 62;
368: stan::model::assign(annual_effects_gen,
369: stan::model::cons_list(stan::model::index_min_max((1 + ((t - 1) * 8)), (8 * t)), stan::model::nil_index_list()),
370: rep_vector(get_base1(multiply(B_annual, beta_annual), t, “multiply(B_annual, beta_annual)”, 1), 8),
371: “assigning variable annual_effects_gen”);
372: }
373: current_statement_begin__ = 66;
374: stan::model::assign(annual_effects_gen,
375: stan::model::cons_list(stan::model::index_min_max((1 + ((D - 1) * 8)), Ncol), stan::model::nil_index_list()),
376: rep_vector(get_base1(multiply(B_annual, beta_annual), D, “multiply(B_annual, beta_annual)”, 1), ((Ncol - (1 + ((D - 1) * 8))) + 1)),
377: “assigning variable annual_effects_gen”);
378: current_statement_begin__ = 73;
379: for (int t = 1; t <= K; ++t) {
380:
381: current_statement_begin__ = 74;
382: stan::model::assign(overall_effects_gen,
383: stan::model::cons_list(stan::model::index_uni(t), stan::model::nil_index_list()),
384: ((alpha + get_base1(beta_adj, t, “beta_adj”, 1)) + get_base1(annual_effects_gen, t, “annual_effects_gen”, 1)),
385: “assigning variable overall_effects_gen”);
386: }
387: current_statement_begin__ = 78;
388: for (int t = (K + 1); t <= (K * 2); ++t) {
389:
390: current_statement_begin__ = 79;
391: stan::model::assign(overall_effects_gen,
392: stan::model::cons_list(stan::model::index_uni(t), stan::model::nil_index_list()),
393: ((alpha + get_base1(beta_adj, (t - K), “beta_adj”, 1)) + get_base1(annual_effects_gen, t, “annual_effects_gen”, 1)),
394: “assigning variable overall_effects_gen”);
395: }
396: current_statement_begin__ = 83;
397: for (int t = ((2 * K) + 1); t <= 136; ++t) {
398:
399: current_statement_begin__ = 84;
400: stan::model::assign(overall_effects_gen,
401: stan::model::cons_list(stan::model::index_uni(t), stan::model::nil_index_list()),
402: ((alpha + get_base1(beta_adj, (t - (K * 2)), “beta_adj”, 1)) + get_base1(annual_effects_gen, t, “annual_effects_gen”, 1)),
403: “assigning variable overall_effects_gen”);
404: }
405: current_statement_begin__ = 90;
406: for (int t = 137; t <= (136 + K); ++t) {
407:
408: current_statement_begin__ = 91;
409: stan::model::assign(overall_effects_gen,
410: stan::model::cons_list(stan::model::index_uni(t), stan::model::nil_index_list()),
411: ((alpha + get_base1(beta_adj, (t - 136), “beta_adj”, 1)) + get_base1(annual_effects_gen, t, “annual_effects_gen”, 1)),
412: “assigning variable overall_effects_gen”);
413: }
414: current_statement_begin__ = 95;
415: for (int t = ((136 + K) + 1); t <= (136 + (K * 2)); ++t) {
416:
417: current_statement_begin__ = 96;
418: stan::model::assign(overall_effects_gen,
419: stan::model::cons_list(stan::model::index_uni(t), stan::model::nil_index_list()),
420: ((alpha + get_base1(beta_adj, ((t - K) - 136), “beta_adj”, 1)) + get_base1(annual_effects_gen, t, “annual_effects_gen”, 1)),
421: “assigning variable overall_effects_gen”);
422: }
423: current_statement_begin__ = 100;
424: for (int t = ((136 + (K * 2)) + 1); t <= (136 + (K * 3)); ++t) {
425:
426: current_statement_begin__ = 101;
427: stan::model::assign(overall_effects_gen,
428: stan::model::cons_list(stan::model::index_uni(t), stan::model::nil_index_list()),
429: ((alpha + get_base1(beta_adj, ((t - (2 * K)) - 136), “beta_adj”, 1)) + get_base1(annual_effects_gen, t, “annual_effects_gen”, 1)),
430: “assigning variable overall_effects_gen”);
431: }
432: current_statement_begin__ = 105;
433: for (int t = ((136 + (K * 3)) + 1); t <= Ncol; ++t) {
434:
435: current_statement_begin__ = 106;
436: stan::model::assign(overall_effects_gen,
437: stan::model::cons_list(stan::model::index_uni(t), stan::model::nil_index_list()),
438: ((alpha + get_base1(beta_adj, ((t - (3 * K)) - 136), “beta_adj”, 1)) + get_base1(annual_effects_gen, t, “annual_effects_gen”, 1)),
439: “assigning variable overall_effects_gen”);
440: }
441:
442: // validate transformed parameters
443: const char* function__ = “validate transformed params”;
444: (void) function__; // dummy to suppress unused var warning
445:
446: current_statement_begin__ = 37;
447: if (stan::math::is_uninitialized(alpha)) {
448: std::stringstream msg__;
449: msg__ << “Undefined transformed parameter: alpha”;
450: stan::lang::rethrow_located(std::runtime_error(std::string("Error initializing variable alpha: ") + msg__.str()), current_statement_begin__, prog_reader__());
451: }
452: current_statement_begin__ = 39;
453: size_t beta_annual_j_1_max__ = num_basis;
454: for (size_t j_1__ = 0; j_1__ < beta_annual_j_1_max__; ++j_1__) {
455: if (stan::math::is_uninitialized(beta_annual(j_1__))) {
456: std::stringstream msg__;
457: msg__ << “Undefined transformed parameter: beta_annual” << “(” << j_1__ << “)”;
458: stan::lang::rethrow_located(std::runtime_error(std::string("Error initializing variable beta_annual: ") + msg__.str()), current_statement_begin__, prog_reader__());
459: }
460: }
461: current_statement_begin__ = 41;
462: size_t beta_adj_j_1_max__ = K;
463: for (size_t j_1__ = 0; j_1__ < beta_adj_j_1_max__; ++j_1__) {
464: if (stan::math::is_uninitialized(beta_adj(j_1__))) {
465: std::stringstream msg__;
466: msg__ << “Undefined transformed parameter: beta_adj” << “(” << j_1__ << “)”;
467: stan::lang::rethrow_located(std::runtime_error(std::string("Error initializing variable beta_adj: ") + msg__.str()), current_statement_begin__, prog_reader__());
468: }
469: }
470: current_statement_begin__ = 43;
471: size_t annual_effects_gen_j_1_max__ = Ncol;
472: for (size_t j_1__ = 0; j_1__ < annual_effects_gen_j_1_max__; ++j_1__) {
473: if (stan::math::is_uninitialized(annual_effects_gen(j_1__))) {
474: std::stringstream msg__;
475: msg__ << “Undefined transformed parameter: annual_effects_gen” << “(” << j_1__ << “)”;
476: stan::lang::rethrow_located(std::runtime_error(std::string("Error initializing variable annual_effects_gen: ") + msg__.str()), current_statement_begin__, prog_reader__());
477: }
478: }
479: current_statement_begin__ = 45;
480: size_t overall_effects_gen_j_1_max__ = Ncol;
481: for (size_t j_1__ = 0; j_1__ < overall_effects_gen_j_1_max__; ++j_1__) {
482: if (stan::math::is_uninitialized(overall_effects_gen(j_1__))) {
483: std::stringstream msg__;

There should be more before and after this that has something like

error: ???
g++ ...

sorry for my late reply. I tried to fix myself by researching on the forum but had no luck.

Here are the complete error messages

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

Program source:
1:
2: // includes from the plugin
3: // [[Rcpp::plugins(cpp14)]]
4:
5: // user includes
6: #define STAN__SERVICES__COMMAND_HPP// Code generated by Stan version 2.19.1
7:
8: #include <stan/model/model_header.hpp>
9:
10: namespace modelc9d29db97fe_QUT_1comp_classical_overall_namespace {
11:
12: using std::istream;
13: using std::string;
14: using std::stringstream;
15: using std::vector;
16: using stan::io::dump;
17: using stan::math::lgamma;
18: using stan::model::prob_grad;
19: using namespace stan::math;
20:
21: static int current_statement_begin__;
22:
23: stan::io::program_reader prog_reader__() {
24: stan::io::program_reader reader;
25: reader.add_event(0, 0, “start”, “modelc9d29db97fe_QUT_1comp_classical_overall”);
26: reader.add_event(150, 148, “end”, “modelc9d29db97fe_QUT_1comp_classical_overall”);
27: return reader;
28: }
29:
30: class modelc9d29db97fe_QUT_1comp_classical_overall : public prob_grad {
31: private:
32: int N;
33: int K;
34: int D;
35: int Ncol;
36: std::vector kk;
37: vector_d dat_complete;
38: int num_basis;
39: matrix_d B_annual;
40: matrix_d K_TD;
41: public:
42: modelc9d29db97fe_QUT_1comp_classical_overall(stan::io::var_context& context__,
43: std::ostream* pstream__ = 0)
44: : prob_grad(0) {
45: ctor_body(context__, 0, pstream__);
46: }
47:
48: modelc9d29db97fe_QUT_1comp_classical_overall(stan::io::var_context& context__,
49: unsigned int random_seed__,
50: std::ostream* pstream__ = 0)
51: : prob_grad(0) {
52: ctor_body(context__, random_seed__, pstream__);
53: }
54:
55: void ctor_body(stan::io::var_context& context__,
56: unsigned int random_seed__,
57: std::ostream* pstream__) {
58: typedef double local_scalar_t__;
59:
60: boost::ecuyer1988 base_rng__ =
61: stan::services::util::create_rng(random_seed__, 0);
62: (void) base_rng__; // suppress unused var warning
63:
64: current_statement_begin__ = -1;
65:
66: static const char* function__ = “modelc9d29db97fe_QUT_1comp_classical_overall_namespace::modelc9d29db97fe_QUT_1comp_classical_overall”;
67: (void) function__; // dummy to suppress unused var warning
68: size_t pos__;
69: (void) pos__; // dummy to suppress unused var warning
70: std::vector vals_i__;
71: std::vector vals_r__;
72: local_scalar_t__ DUMMY_VAR__(std::numeric_limits::quiet_NaN());
73: (void) DUMMY_VAR__; // suppress unused var warning
74:
75: try {
76: // initialize data block variables from context__
77: current_statement_begin__ = 4;
78: context__.validate_dims(“data initialization”, “N”, “int”, context__.to_vec());
79: N = int(0);
80: vals_i__ = context__.vals_i(“N”);
81: pos__ = 0;
82: N = vals_i__[pos__++];
83: check_greater_or_equal(function__, “N”, N, 1);
84:
85: current_statement_begin__ = 6;
86: context__.validate_dims(“data initialization”, “K”, “int”, context__.to_vec());
87: K = int(0);
88: vals_i__ = context__.vals_i(“K”);
89: pos__ = 0;
90: K = vals_i__[pos__++];
91: check_greater_or_equal(function__, “K”, K, 1);
92:
93: current_statement_begin__ = 8;
94: context__.validate_dims(“data initialization”, “D”, “int”, context__.to_vec());
95: D = int(0);
96: vals_i__ = context__.vals_i(“D”);
97: pos__ = 0;
98: D = vals_i__[pos__++];
99: check_greater_or_equal(function__, “D”, D, 1);
100:
101: current_statement_begin__ = 10;
102: context__.validate_dims(“data initialization”, “Ncol”, “int”, context__.to_vec());
103: Ncol = int(0);
104: vals_i__ = context__.vals_i(“Ncol”);
105: pos__ = 0;
106: Ncol = vals_i__[pos__++];
107: check_greater_or_equal(function__, “Ncol”, Ncol, 1);
108:
109: current_statement_begin__ = 12;
110: validate_non_negative_index(“kk”, “N”, N);
111: context__.validate_dims(“data initialization”, “kk”, “int”, context__.to_vec(N));
112: kk = std::vector(N, int(0));
113: vals_i__ = context__.vals_i(“kk”);
114: pos__ = 0;
115: size_t kk_k_0_max__ = N;
116: for (size_t k_0__ = 0; k_0__ < kk_k_0_max__; ++k_0__) {
117: kk[k_0__] = vals_i__[pos__++];
118: }
119: size_t kk_i_0_max__ = N;
120: for (size_t i_0__ = 0; i_0__ < kk_i_0_max__; ++i_0__) {
121: check_greater_or_equal(function__, “kk[i_0__]”, kk[i_0__], 1);
122: check_less_or_equal(function__, “kk[i_0__]”, kk[i_0__], Ncol);
123: }
124:
125: current_statement_begin__ = 14;
126: validate_non_negative_index(“dat_complete”, “N”, N);
127: context__.validate_dims(“data initialization”, “dat_complete”, “vector_d”, context__.to_vec(N));
128: dat_complete = Eigen::Matrix<double, Eigen::Dynamic, 1>(N);
129: vals_r__ = context__.vals_r(“dat_complete”);
130: pos__ = 0;
131: size_t dat_complete_j_1_max__ = N;
132: for (size_t j_1__ = 0; j_1__ < dat_complete_j_1_max__; ++j_1__) {
133: dat_complete(j_1__) = vals_r__[pos__++];
134: }
135:
136: current_statement_begin__ = 16;
137: context__.validate_dims(“data initialization”, “num_basis”, “int”, context__.to_vec());
138: num_basis = int(0);
139: vals_i__ = context__.vals_i(“num_basis”);
140: pos__ = 0;
141: num_basis = vals_i__[pos__++];
142:
143: current_statement_begin__ = 18;
144: validate_non_negative_index(“B_annual”, “D”, D);
145: validate_non_negative_index(“B_annual”, “num_basis”, num_basis);
146: context__.validate_dims(“data initialization”, “B_annual”, “matrix_d”, context__.to_vec(D,num_basis));
147: B_annual = Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic>(D, num_basis);
148: vals_r__ = context__.vals_r(“B_annual”);
149: pos__ = 0;
150: size_t B_annual_j_2_max__ = num_basis;
151: size_t B_annual_j_1_max__ = D;
152: for (size_t j_2__ = 0; j_2__ < B_annual_j_2_max__; ++j_2__) {
153: for (size_t j_1__ = 0; j_1__ < B_annual_j_1_max__; ++j_1__) {
154: B_annual(j_1__, j_2__) = vals_r__[pos__++];
155: }
156: }
157:
158: current_statement_begin__ = 20;
159: validate_non_negative_index(“K_TD”, “K”, K);
160: validate_non_negative_index(“K_TD”, “K”, K);
161: context__.validate_dims(“data initialization”, “K_TD”, “matrix_d”, context__.to_vec(K,K));
162: K_TD = Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic>(K, K);
163: vals_r__ = context__.vals_r(“K_TD”);
164: pos__ = 0;
165: size_t K_TD_j_2_max__ = K;
166: size_t K_TD_j_1_max__ = K;
167: for (size_t j_2__ = 0; j_2__ < K_TD_j_2_max__; ++j_2__) {
168: for (size_t j_1__ = 0; j_1__ < K_TD_j_1_max__; ++j_1__) {
169: K_TD(j_1__, j_2__) = vals_r__[pos__++];
170: }
171: }
172:
173:
174: // initialize transformed data variables
175: // execute transformed data statements
176:
177: // validate transformed data
178:
179: // validate, set parameter ranges
180: num_params_r__ = 0U;
181: param_ranges_i__.clear();
182: current_statement_begin__ = 27;
183: validate_non_negative_index(“beta”, “K”, K);
184: num_params_r__ += K;
185: current_statement_begin__ = 29;
186: validate_non_negative_index(“beta_annual_raw”, “num_basis”, num_basis);
187: num_params_r__ += num_basis;
188: current_statement_begin__ = 31;
189: num_params_r__ += 1;
190: } catch (const std::exception& e) {
191: stan::lang::rethrow_located(e, current_statement_begin__, prog_reader__());
192: // Next line prevents compiler griping about no return
193: throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG **");
194: }
195: }
196:
197: ~modelc9d29db97fe_QUT_1comp_classical_overall() { }
198:
199:
200: void transform_inits(const stan::io::var_context& context__,
201: std::vector& params_i__,
202: std::vector& params_r__,
203: std::ostream
pstream__) const {
204: typedef double local_scalar_t__;
205: stan::io::writer writer__(params_r__, params_i__);
206: size_t pos__;
207: (void) pos__; // dummy call to supress warning
208: std::vector vals_r__;
209: std::vector vals_i__;
210:
211: current_statement_begin__ = 27;
212: if (!(context__.contains_r(“beta”)))
213: stan::lang::rethrow_located(std::runtime_error(std::string(“Variable beta missing”)), current_statement_begin__, prog_reader__());
214: vals_r__ = context__.vals_r(“beta”);
215: pos__ = 0U;
216: validate_non_negative_index(“beta”, “K”, K);
217: context__.validate_dims(“parameter initialization”, “beta”, “vector_d”, context__.to_vec(K));
218: Eigen::Matrix<double, Eigen::Dynamic, 1> beta(K);
219: size_t beta_j_1_max__ = K;
220: for (size_t j_1__ = 0; j_1__ < beta_j_1_max__; ++j_1__) {
221: beta(j_1__) = vals_r__[pos__++];
222: }

Followed by

223: try {
224: writer__.vector_unconstrain(beta);
225: } catch (const std::exception& e) {
226: stan::lang::rethrow_located(std::runtime_error(std::string("Error transforming variable beta: ") + e.what()), current_statement_begin__, prog_reader__());
227: }
228:
229: current_statement_begin__ = 29;
230: if (!(context__.contains_r(“beta_annual_raw”)))
231: stan::lang::rethrow_located(std::runtime_error(std::string(“Variable beta_annual_raw missing”)), current_statement_begin__, prog_reader__());
232: vals_r__ = context__.vals_r(“beta_annual_raw”);
233: pos__ = 0U;
234: validate_non_negative_index(“beta_annual_raw”, “num_basis”, num_basis);
235: context__.validate_dims(“parameter initialization”, “beta_annual_raw”, “vector_d”, context__.to_vec(num_basis));
236: Eigen::Matrix<double, Eigen::Dynamic, 1> beta_annual_raw(num_basis);
237: size_t beta_annual_raw_j_1_max__ = num_basis;
238: for (size_t j_1__ = 0; j_1__ < beta_annual_raw_j_1_max__; ++j_1__) {
239: beta_annual_raw(j_1__) = vals_r__[pos__++];
240: }
241: try {
242: writer__.vector_unconstrain(beta_annual_raw);
243: } catch (const std::exception& e) {
244: stan::lang::rethrow_located(std::runtime_error(std::string("Error transforming variable beta_annual_raw: ") + e.what()), current_statement_begin__, prog_reader__());
245: }
246:
247: current_statement_begin__ = 31;
248: if (!(context__.contains_r(“sigma”)))
249: stan::lang::rethrow_located(std::runtime_error(std::string(“Variable sigma missing”)), current_statement_begin__, prog_reader__());
250: vals_r__ = context__.vals_r(“sigma”);
251: pos__ = 0U;
252: context__.validate_dims(“parameter initialization”, “sigma”, “double”, context__.to_vec());
253: double sigma(0);
254: sigma = vals_r__[pos__++];
255: try {
256: writer__.scalar_lb_unconstrain(0, sigma);
257: } catch (const std::exception& e) {
258: stan::lang::rethrow_located(std::runtime_error(std::string("Error transforming variable sigma: ") + e.what()), current_statement_begin__, prog_reader__());
259: }
260:
261: params_r__ = writer__.data_r();
262: params_i__ = writer__.data_i();
263: }
264:
265: void transform_inits(const stan::io::var_context& context,
266: Eigen::Matrix<double, Eigen::Dynamic, 1>& params_r,
267: std::ostream* pstream__) const {
268: std::vector params_r_vec;
269: std::vector params_i_vec;
270: transform_inits(context, params_i_vec, params_r_vec, pstream__);
271: params_r.resize(params_r_vec.size());
272: for (int i = 0; i < params_r.size(); ++i)
273: params_r(i) = params_r_vec[i];
274: }
275:
276:
277: template <bool propto__, bool jacobian__, typename T__>
278: T__ log_prob(std::vector<T__>& params_r__,
279: std::vector& params_i__,
280: std::ostream* pstream__ = 0) const {
281:
282: typedef T__ local_scalar_t__;
283:
284: local_scalar_t__ DUMMY_VAR__(std::numeric_limits::quiet_NaN());
285: (void) DUMMY_VAR__; // dummy to suppress unused var warning
286:
287: T__ lp__(0.0);
288: stan::math::accumulator<T__> lp_accum__;
289: try {
290: stan::io::reader<local_scalar_t__> in__(params_r__, params_i__);
291:
292: // model parameters
293: current_statement_begin__ = 27;
294: Eigen::Matrix<local_scalar_t__, Eigen::Dynamic, 1> beta;
295: (void) beta; // dummy to suppress unused var warning
296: if (jacobian__)
297: beta = in__.vector_constrain(K, lp__);
298: else
299: beta = in__.vector_constrain(K);
300:
301: current_statement_begin__ = 29;
302: Eigen::Matrix<local_scalar_t__, Eigen::Dynamic, 1> beta_annual_raw;
303: (void) beta_annual_raw; // dummy to suppress unused var warning
304: if (jacobian__)
305: beta_annual_raw = in__.vector_constrain(num_basis, lp__);
306: else
307: beta_annual_raw = in__.vector_constrain(num_basis);
308:
309: current_statement_begin__ = 31;
310: local_scalar_t__ sigma;
311: (void) sigma; // dummy to suppress unused var warning
312: if (jacobian__)
313: sigma = in__.scalar_lb_constrain(0, lp__);
314: else
315: sigma = in__.scalar_lb_constrain(0);
316:
317: // transformed parameters
318: current_statement_begin__ = 37;
319: local_scalar_t__ alpha;
320: (void) alpha; // dummy to suppress unused var warning
321: stan::math::initialize(alpha, DUMMY_VAR__);
322: stan::math::fill(alpha, DUMMY_VAR__);
323:
324: current_statement_begin__ = 39;
325: validate_non_negative_index(“beta_annual”, “num_basis”, num_basis);
326: Eigen::Matrix<local_scalar_t__, Eigen::Dynamic, 1> beta_annual(num_basis);
327: stan::math::initialize(beta_annual, DUMMY_VAR__);
328: stan::math::fill(beta_annual, DUMMY_VAR__);
329:
330: current_statement_begin__ = 41;
331: validate_non_negative_index(“beta_adj”, “K”, K);
332: Eigen::Matrix<local_scalar_t__, Eigen::Dynamic, 1> beta_adj(K);
333: stan::math::initialize(beta_adj, DUMMY_VAR__);
334: stan::math::fill(beta_adj, DUMMY_VAR__);
335:
336: current_statement_begin__ = 43;
337: validate_non_negative_index(“annual_effects_gen”, “Ncol”, Ncol);
338: Eigen::Matrix<local_scalar_t__, Eigen::Dynamic, 1> annual_effects_gen(Ncol);
339: stan::math::initialize(annual_effects_gen, DUMMY_VAR__);
340: stan::math::fill(annual_effects_gen, DUMMY_VAR__);
341:
342: current_statement_begin__ = 45;
343: validate_non_negative_index(“overall_effects_gen”, “Ncol”, Ncol);
344: Eigen::Matrix<local_scalar_t__, Eigen::Dynamic, 1> overall_effects_gen(Ncol);
345: stan::math::initialize(overall_effects_gen, DUMMY_VAR__);
346: stan::math::fill(overall_effects_gen, DUMMY_VAR__);
347:
348: // transformed parameters block statements
349: current_statement_begin__ = 47;
350: stan::math::assign(beta_adj, subtract(beta, mean(beta)));
351: current_statement_begin__ = 49;
352: stan::math::assign(alpha, mean(beta));
353: current_statement_begin__ = 51;
354: stan::math::assign(beta_annual, multiply(beta_annual_raw, sigma));
355: current_statement_begin__ = 54;
356: for (int t = 1; t <= 17; ++t) {
357:
358: current_statement_begin__ = 55;
359: stan::model::assign(annual_effects_gen,
360: stan::model::cons_list(stan::model::index_min_max((1 + ((t - 1) * 8)), (8 * t)), stan::model::nil_index_list()),
361: rep_vector(get_base1(multiply(B_annual, beta_annual), t, “multiply(B_annual, beta_annual)”, 1), 8),
362: “assigning variable annual_effects_gen”);
363: }
364: current_statement_begin__ = 61;
365: for (int t = 18; t <= (D - 1); ++t) {
366:
367: current_statement_begin__ = 62;
368: stan::model::assign(annual_effects_gen,
369: stan::model::cons_list(stan::model::index_min_max((1 + ((t - 1) * 8)), (8 * t)), stan::model::nil_index_list()),
370: rep_vector(get_base1(multiply(B_annual, beta_annual), t, “multiply(B_annual, beta_annual)”, 1), 8),
371: “assigning variable annual_effects_gen”);
372: }
373: current_statement_begin__ = 66;
374: stan::model::assign(annual_effects_gen,
375: stan::model::cons_list(stan::model::index_min_max((1 + ((D - 1) * 8)), Ncol), stan::model::nil_index_list()),
376: rep_vector(get_base1(multiply(B_annual, beta_annual), D, “multiply(B_annual, beta_annual)”, 1), ((Ncol - (1 + ((D - 1) * 8))) + 1)),
377: “assigning variable annual_effects_gen”);
378: current_statement_begin__ = 73;
379: for (int t = 1; t <= K; ++t) {
380:
381: current_statement_begin__ = 74;
382: stan::model::assign(overall_effects_gen,
383: stan::model::cons_list(stan::model::index_uni(t), stan::model::nil_index_list()),
384: ((alpha + get_base1(beta_adj, t, “beta_adj”, 1)) + get_base1(annual_effects_gen, t, “annual_effects_gen”, 1)),
385: “assigning variable overall_effects_gen”);
386: }
387: current_statement_begin__ = 78;
388: for (int t = (K + 1); t <= (K * 2); ++t) {
389:
390: current_statement_begin__ = 79;
391: stan::model::assign(overall_effects_gen,
392: stan::model::cons_list(stan::model::index_uni(t), stan::model::nil_index_list()),
393: ((alpha + get_base1(beta_adj, (t - K), “beta_adj”, 1)) + get_base1(annual_effects_gen, t, “annual_effects_gen”, 1)),
394: “assigning variable overall_effects_gen”);
395: }
396: current_statement_begin__ = 83;
397: for (int t = ((2 * K) + 1); t <= 136; ++t) {
398:
399: current_statement_begin__ = 84;
400: stan::model::assign(overall_effects_gen,
401: stan::model::cons_list(stan::model::index_uni(t), stan::model::nil_index_list()),
402: ((alpha + get_base1(beta_adj, (t - (K * 2)), “beta_adj”, 1)) + get_base1(annual_effects_gen, t, “annual_effects_gen”, 1)),
403: “assigning variable overall_effects_gen”);
404: }
405: current_statement_begin__ = 90;
406: for (int t = 137; t <= (136 + K); ++t) {
407:
408: current_statement_begin__ = 91;
409: stan::model::assign(overall_effects_gen,
410: stan::model::cons_list(stan::model::index_uni(t), stan::model::nil_index_list()),
411: ((alpha + get_base1(beta_adj, (t - 136), “beta_adj”, 1)) + get_base1(annual_effects_gen, t, “annual_effects_gen”, 1)),
412: “assigning variable overall_effects_gen”);
413: }
414: current_statement_begin__ = 95;
415: for (int t = ((136 + K) + 1); t <= (136 + (K * 2)); ++t) {
416:
417: current_statement_begin__ = 96;
418: stan::model::assign(overall_effects_gen,
419: stan::model::cons_list(stan::model::index_uni(t), stan::model::nil_index_list()),
420: ((alpha + get_base1(beta_adj, ((t - K) - 136), “beta_adj”, 1)) + get_base1(annual_effects_gen, t, “annual_effects_gen”, 1)),
421: “assigning variable overall_effects_gen”);
422: }
423: current_statement_begin__ = 100;
424: for (int t = ((136 + (K * 2)) + 1); t <= (136 + (K * 3)); ++t) {
425:
426: current_statement_begin__ = 101;
427: stan::model::assign(overall_effects_gen,
428: stan::model::cons_list(stan::model::index_uni(t), stan::model::nil_index_list()),
429: ((alpha + get_base1(beta_adj, ((t - (2 * K)) - 136), “beta_adj”, 1)) + get_base1(annual_effects_gen, t, “annual_effects_gen”, 1)),
430: “assigning variable overall_effects_gen”);
431: }
432: current_statement_begin__ = 105;
433: for (int t = ((136 + (K * 3)) + 1); t <= Ncol; ++t) {
434:
435: current_statement_begin__ = 106;
436: stan::model::assign(overall_effects_gen,
437: stan::model::cons_list(stan::model::index_uni(t), stan::model::nil_index_list()),
438: ((alpha + get_base1(beta_adj, ((t - (3 * K)) - 136), “beta_adj”, 1)) + get_base1(annual_effects_gen, t, “annual_effects_gen”, 1)),
439: “assigning variable overall_effects_gen”);
440: }
441:
442: // validate transformed parameters
443: const char* function__ = “validate transformed params”;
444: (void) function__; // dummy to suppress unused var warning
445:
446: current_statement_begin__ = 37;
447: if (stan::math::is_uninitialized(alpha)) {
448: std::stringstream msg__;
449: msg__ << “Undefined transformed parameter: alpha”;
450: stan::lang::rethrow_located(std::runtime_error(std::string("Error initializing variable alpha: ") + msg__.str()), current_statement_begin__, prog_reader__());
451: }
452: current_statement_begin__ = 39;
453: size_t beta_annual_j_1_max__ = num_basis;
454: for (size_t j_1__ = 0; j_1__ < beta_annual_j_1_max__; ++j_1__) {
455: if (stan::math::is_uninitialized(beta_annual(j_1__))) {
456: std::stringstream msg__;
457: msg__ << “Undefined transformed parameter: beta_annual” << “(” << j_1__ << “)”;
458: stan::lang::rethrow_located(std::runtime_error(std::string("Error initializing variable beta_annual: ") + msg__.str()), current_statement_begin__, prog_reader__());
459: }
460: }
461: current_statement_begin__ = 41;
462: size_t beta_adj_j_1_max__ = K;
463: for (size_t j_1__ = 0; j_1__ < beta_adj_j_1_max__; ++j_1__) {
464: if (stan::math::is_uninitialized(beta_adj(j_1__))) {
465: std::stringstream msg__;
466: msg__ << “Undefined transformed parameter: beta_adj” << “(” << j_1__ << “)”;
467: stan::lang::rethrow_located(std::runtime_error(std::string("Error initializing variable beta_adj: ") + msg__.str()), current_statement_begin__, prog_reader__());
468: }
469: }
470: current_statement_begin__ = 43;
471: size_t annual_effects_gen_j_1_max__ = Ncol;
472: for (size_t j_1__ = 0; j_1__ < annual_effects_gen_j_1_max__; ++j_1__) {
473: if (stan::math::is_uninitialized(annual_effects_gen(j_1__))) {
474: std::stringstream msg__;
475: msg__ << “Undefined transformed parameter: annual_effects_gen” << “(” << j_1__ << “)”;
476: stan::lang::rethrow_located(std::runtime_error(std::string("Error initializing variable annual_effects_gen: ") + msg__.str()), current_statement_begin__, prog_reader__());
477: }
478: }
479: current_statement_begin__ = 45;
480: size_t overall_effects_gen_j_1_max__ = Ncol;
481: for (size_t j_1__ = 0; j_1__ < overall_effects_gen_j_1_max__; ++j_1__) {
482: if (stan::math::is_uninitialized(overall_effects_gen(j_1__))) {
483: std::stringstream msg__;
484: msg__ << “Undefined transformed parameter: overall_effects_gen” << “(” << j_1__ << “)”;
485: stan::lang::rethrow_located(std::runtime_error(std::string("Error initializing variable overall_effects_gen: “) + msg__.str()), current_statement_begin__, prog_reader__());
486: }
487: }
488:
489: // model body
490:
491: current_statement_begin__ = 117;
492: lp_accum__.add(normal_log<propto__>(beta_annual_raw, 0, 1));
493: current_statement_begin__ = 119;
494: lp_accum__.add(cauchy_log<propto__>(sigma, 0, 2.5));
495: current_statement_begin__ = 122;
496: lp_accum__.add(multi_normal_prec_log(beta_adj, rep_vector(0, K), multiply((1 / square(sigma)), K_TD)));
497: current_statement_begin__ = 128;
498: for (int n = 1; n <= N; ++n) {
499:
500: current_statement_begin__ = 130;
501: lp_accum__.add(normal_log(get_base1(dat_complete, n, “dat_complete”, 1), get_base1(overall_effects_gen, get_base1(kk, n, “kk”, 1), “overall_effects_gen”, 1), sigma));
502: }
503:
504: } catch (const std::exception& e) {
505: stan::lang::rethrow_located(e, current_statement_begin__, prog_reader__());
506: // Next line prevents compiler griping about no return
507: throw std::runtime_error(”*** IF YOU SEE THIS, PLEASE REPORT A BUG ");
508: }
509:
510: lp_accum__.add(lp__);
511: return lp_accum__.sum();
512:
513: } // log_prob()
514:
515: template <bool propto, bool jacobian, typename T_>
516: T_ log_prob(Eigen::Matrix<T_,Eigen::Dynamic,1>& params_r,
517: std::ostream
pstream = 0) const {
518: std::vector<T_> vec_params_r;
519: vec_params_r.reserve(params_r.size());
520: for (int i = 0; i < params_r.size(); ++i)
521: vec_params_r.push_back(params_r(i));
522: std::vector vec_params_i;
523: return log_prob<propto,jacobian,T_>(vec_params_r, vec_params_i, pstream);
524: }
525:
526:
527: void get_param_names(std::vectorstd::string& names__) const {
528: names__.resize(0);
529: names__.push_back(“beta”);
530: names__.push_back(“beta_annual_raw”);
531: names__.push_back(“sigma”);
532: names__.push_back(“alpha”);
533: names__.push_back(“beta_annual”);
534: names__.push_back(“beta_adj”);
535: names__.push_back(“annual_effects_gen”);
536: names__.push_back(“overall_effects_gen”);
537: names__.push_back(“log_lik_vec”);
538: }
539:
540:
541: void get_dims(std::vector<std::vector<size_t> >& dimss__) const {
542: dimss__.resize(0);
543: std::vector<size_t> dims__;
544: dims__.resize(0);
545: dims__.push_back(K);
546: dimss__.push_back(dims__);
547: dims__.resize(0);
548: dims__.push_back(num_basis);
549: dimss__.push_back(dims__);
550: dims__.resize(0);
551: dimss__.push_back(dims__);
552: dims__.resize(0);
553: dimss__.push_back(dims__);
554: dims__.resize(0);
555: dims__.push_back(num_basis);
556: dimss__.push_back(dims__);
557: dims__.resize(0);
558: dims__.push_back(K);
559: dimss__.push_back(dims__);
560: dims__.resize(0);
561: dims__.push_back(Ncol);
562: dimss__.push_back(dims__);
563: dims__.resize(0);
564: dims__.push_back(Ncol);
565: dimss__.push_back(dims__);
566: dims__.resize(0);
567: dims__.push_back(N);
568: dimss__.push_back(dims__);
569: }
570:
571: template
572: void write_array(RNG& base_rng__,
573: std::vector& params_r__,
574: std::vector& params_i__,
575: std::vector& vars__,
576: bool include_tparams__ = true,
577: bool include_gqs__ = true,
578: std::ostream
pstream__ = 0) const {
579: typedef double local_scalar_t__;
580:
581: vars__.resize(0);
582: stan::io::reader<local_scalar_t__> in__(params_r__, params_i__);
583: static const char
function__ = “modelc9d29db97fe_QUT_1comp_classical_overall_namespace::write_array”;
584: (void) function__; // dummy to suppress unused var warning
585:
586: // read-transform, write parameters
587: Eigen::Matrix<double, Eigen::Dynamic, 1> beta = in__.vector_constrain(K);
588: size_t beta_j_1_max__ = K;
589: for (size_t j_1__ = 0; j_1__ < beta_j_1_max__; ++j_1__) {
590: vars__.push_back(beta(j_1__));
591: }
592:
593: Eigen::Matrix<double, Eigen::Dynamic, 1> beta_annual_raw = in__.vector_constrain(num_basis);
594: size_t beta_annual_raw_j_1_max__ = num_basis;
595: for (size_t j_1__ = 0; j_1__ < beta_annual_raw_j_1_max__; ++j_1__) {
596: vars__.push_back(beta_annual_raw(j_1__));
597: }
598:
599: double sigma = in__.scalar_lb_constrain(0);
600: vars__.push_back(sigma);
601:
602: double lp__ = 0.0;
603: (void) lp__; // dummy to suppress unused var warning
604: stan::math::accumulator lp_accum__;
605:
606: local_scalar_t__ DUMMY_VAR__(std::numeric_limits::quiet_NaN());
607: (void) DUMMY_VAR__; // suppress unused var warning
608:
609: if (!include_tparams__ && !include_gqs__) return;
610:
611: try {
612: // declare and define transformed parameters
613: current_statement_begin__ = 37;
614: double alpha;
615: (void) alpha; // dummy to suppress unused var warning
616: stan::math::initialize(alpha, DUMMY_VAR__);
617: stan::math::fill(alpha, DUMMY_VAR__);
618:
619: current_statement_begin__ = 39;
620: validate_non_negative_index(“beta_annual”, “num_basis”, num_basis);
621: Eigen::Matrix<double, Eigen::Dynamic, 1> beta_annual(num_basis);
622: stan::math::initialize(beta_annual, DUMMY_VAR__);
623: stan::math::fill(beta_annual, DUMMY_VAR__);
624:
625: current_statement_begin__ = 41;
626: validate_non_negative_index(“beta_adj”, “K”, K);
627: Eigen::Matrix<double, Eigen::Dynamic, 1> beta_adj(K);
628: stan::math::initialize(beta_adj, DUMMY_VAR__);
629: stan::math::fill(beta_adj, DUMMY_VAR__);
630:
631: current_statement_begin__ = 43;
632: validate_non_negative_index(“annual_effects_gen”, “Ncol”, Ncol);
633: Eigen::Matrix<double, Eigen::Dynamic, 1> annual_effects_gen(Ncol);
634: stan::math::initialize(annual_effects_gen, DUMMY_VAR__);
635: stan::math::fill(annual_effects_gen, DUMMY_VAR__);
636:
637: current_statement_begin__ = 45;
638: validate_non_negative_index(“overall_effects_gen”, “Ncol”, Ncol);
639: Eigen::Matrix<double, Eigen::Dynamic, 1> overall_effects_gen(Ncol);
640: stan::math::initialize(overall_effects_gen, DUMMY_VAR__);
641: stan::math::fill(overall_effects_gen, DUMMY_VAR__);
642:
643: // do transformed parameters statements
644: current_statement_begin__ = 47;
645: stan::math::assign(beta_adj, subtract(beta, mean(beta)));
646: current_statement_begin__ = 49;
647: stan::math::assign(alpha, mean(beta));
648: current_statement_begin__ = 51;
649: stan::math::assign(beta_annual, multiply(beta_annual_raw, sigma));
650: current_statement_begin__ = 54;
651: for (int t = 1; t <= 17; ++t) {
652:
653: current_statement_begin__ = 55;
654: stan::model::assign(annual_effects_gen,
655: stan::model::cons_list(stan::model::index_min_max((1 + ((t - 1) * 8)), (8 * t)), stan::model::nil_index_list()),
656: rep_vector(get_base1(multiply(B_annual, beta_annual), t, “multiply(B_annual, beta_annual)”, 1), 8),
657: “assigning variable annual_effects_gen”);
658: }
659: current_statement_begin__ = 61;
660: for (int t = 18; t <= (D - 1); ++t) {
661:
662: current_statement_begin__ = 62;
663: stan::model::assign(annual_effects_gen,

Final part:

664: stan::model::cons_list(stan::model::index_min_max((1 + ((t - 1) * 8)), (8 * t)), stan::model::nil_index_list()),
665: rep_vector(get_base1(multiply(B_annual, beta_annual), t, “multiply(B_annual, beta_annual)”, 1), 8),
666: “assigning variable annual_effects_gen”);
667: }
668: current_statement_begin__ = 66;
669: stan::model::assign(annual_effects_gen,
670: stan::model::cons_list(stan::model::index_min_max((1 + ((D - 1) * 8)), Ncol), stan::model::nil_index_list()),
671: rep_vector(get_base1(multiply(B_annual, beta_annual), D, “multiply(B_annual, beta_annual)”, 1), ((Ncol - (1 + ((D - 1) * 8))) + 1)),
672: “assigning variable annual_effects_gen”);
673: current_statement_begin__ = 73;
674: for (int t = 1; t <= K; ++t) {
675:
676: current_statement_begin__ = 74;
677: stan::model::assign(overall_effects_gen,
678: stan::model::cons_list(stan::model::index_uni(t), stan::model::nil_index_list()),
679: ((alpha + get_base1(beta_adj, t, “beta_adj”, 1)) + get_base1(annual_effects_gen, t, “annual_effects_gen”, 1)),
680: “assigning variable overall_effects_gen”);
681: }
682: current_statement_begin__ = 78;
683: for (int t = (K + 1); t <= (K * 2); ++t) {
684:
685: current_statement_begin__ = 79;
686: stan::model::assign(overall_effects_gen,
687: stan::model::cons_list(stan::model::index_uni(t), stan::model::nil_index_list()),
688: ((alpha + get_base1(beta_adj, (t - K), “beta_adj”, 1)) + get_base1(annual_effects_gen, t, “annual_effects_gen”, 1)),
689: “assigning variable overall_effects_gen”);
690: }
691: current_statement_begin__ = 83;
692: for (int t = ((2 * K) + 1); t <= 136; ++t) {
693:
694: current_statement_begin__ = 84;
695: stan::model::assign(overall_effects_gen,
696: stan::model::cons_list(stan::model::index_uni(t), stan::model::nil_index_list()),
697: ((alpha + get_base1(beta_adj, (t - (K * 2)), “beta_adj”, 1)) + get_base1(annual_effects_gen, t, “annual_effects_gen”, 1)),
698: “assigning variable overall_effects_gen”);
699: }
700: current_statement_begin__ = 90;
701: for (int t = 137; t <= (136 + K); ++t) {
702:
703: current_statement_begin__ = 91;
704: stan::model::assign(overall_effects_gen,
705: stan::model::cons_list(stan::model::index_uni(t), stan::model::nil_index_list()),
706: ((alpha + get_base1(beta_adj, (t - 136), “beta_adj”, 1)) + get_base1(annual_effects_gen, t, “annual_effects_gen”, 1)),
707: “assigning variable overall_effects_gen”);
708: }
709: current_statement_begin__ = 95;
710: for (int t = ((136 + K) + 1); t <= (136 + (K * 2)); ++t) {
711:
712: current_statement_begin__ = 96;
713: stan::model::assign(overall_effects_gen,
714: stan::model::cons_list(stan::model::index_uni(t), stan::model::nil_index_list()),
715: ((alpha + get_base1(beta_adj, ((t - K) - 136), “beta_adj”, 1)) + get_base1(annual_effects_gen, t, “annual_effects_gen”, 1)),
716: “assigning variable overall_effects_gen”);
717: }
718: current_statement_begin__ = 100;
719: for (int t = ((136 + (K * 2)) + 1); t <= (136 + (K * 3)); ++t) {
720:
721: current_statement_begin__ = 101;
722: stan::model::assign(overall_effects_gen,
723: stan::model::cons_list(stan::model::index_uni(t), stan::model::nil_index_list()),
724: ((alpha + get_base1(beta_adj, ((t - (2 * K)) - 136), “beta_adj”, 1)) + get_base1(annual_effects_gen, t, “annual_effects_gen”, 1)),
725: “assigning variable overall_effects_gen”);
726: }
727: current_statement_begin__ = 105;
728: for (int t = ((136 + (K * 3)) + 1); t <= Ncol; ++t) {
729:
730: current_statement_begin__ = 106;
731: stan::model::assign(overall_effects_gen,
732: stan::model::cons_list(stan::model::index_uni(t), stan::model::nil_index_list()),
733: ((alpha + get_base1(beta_adj, ((t - (3 * K)) - 136), “beta_adj”, 1)) + get_base1(annual_effects_gen, t, “annual_effects_gen”, 1)),
734: “assigning variable overall_effects_gen”);
735: }
736:
737: if (!include_gqs__ && !include_tparams__) return;
738: // validate transformed parameters
739: const char* function__ = “validate transformed params”;
740: (void) function__; // dummy to suppress unused var warning
741:
742: // write transformed parameters
743: if (include_tparams__) {
744: vars__.push_back(alpha);
745: size_t beta_annual_j_1_max__ = num_basis;
746: for (size_t j_1__ = 0; j_1__ < beta_annual_j_1_max__; ++j_1__) {
747: vars__.push_back(beta_annual(j_1__));
748: }
749: size_t beta_adj_j_1_max__ = K;
750: for (size_t j_1__ = 0; j_1__ < beta_adj_j_1_max__; ++j_1__) {
751: vars__.push_back(beta_adj(j_1__));
752: }
753: size_t annual_effects_gen_j_1_max__ = Ncol;
754: for (size_t j_1__ = 0; j_1__ < annual_effects_gen_j_1_max__; ++j_1__) {
755: vars__.push_back(annual_effects_gen(j_1__));
756: }
757: size_t overall_effects_gen_j_1_max__ = Ncol;
758: for (size_t j_1__ = 0; j_1__ < overall_effects_gen_j_1_max__; ++j_1__) {
759: vars__.push_back(overall_effects_gen(j_1__));
760: }
761: }
762: if (!include_gqs__) return;
763: // declare and define generated quantities
764: current_statement_begin__ = 138;
765: validate_non_negative_index(“log_lik_vec”, “N”, N);
766: Eigen::Matrix<double, Eigen::Dynamic, 1> log_lik_vec(N);
767: stan::math::initialize(log_lik_vec, DUMMY_VAR__);
768: stan::math::fill(log_lik_vec, DUMMY_VAR__);
769:
770: // generated quantities statements
771: current_statement_begin__ = 140;
772: for (int n = 1; n <= N; ++n) {
773:
774: current_statement_begin__ = 142;
775: stan::model::assign(log_lik_vec,
776: stan::model::cons_list(stan::model::index_uni(n), stan::model::nil_index_list()),
777: normal_log(get_base1(dat_complete, n, “dat_complete”, 1), get_base1(overall_effects_gen, get_base1(kk, n, “kk”, 1), “overall_effects_gen”, 1), sigma),
778: “assigning variable log_lik_vec”);
779: }
780:
781: // validate, write generated quantities
782: current_statement_begin__ = 138;
783: size_t log_lik_vec_j_1_max__ = N;
784: for (size_t j_1__ = 0; j_1__ < log_lik_vec_j_1_max__; ++j_1__) {
785: vars__.push_back(log_lik_vec(j_1__));
786: }
787:
788: } catch (const std::exception& e) {
789: stan::lang::rethrow_located(e, current_statement_begin__, prog_reader__());
790: // Next line prevents compiler griping about no return
791: throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ");
792: }
793: }
794:
795: template
796: void write_array(RNG& base_rng,
797: Eigen::Matrix<double,Eigen::Dynamic,1>& params_r,
798: Eigen::Matrix<double,Eigen::Dynamic,1>& vars,
799: bool include_tparams = true,
800: bool include_gqs = true,
801: std::ostream
pstream = 0) const {
802: std::vector params_r_vec(params_r.size());
803: for (int i = 0; i < params_r.size(); ++i)
804: params_r_vec[i] = params_r(i);
805: std::vector vars_vec;
806: std::vector params_i_vec;
807: write_array(base_rng, params_r_vec, params_i_vec, vars_vec, include_tparams, include_gqs, pstream);
808: vars.resize(vars_vec.size());
809: for (int i = 0; i < vars.size(); ++i)
810: vars(i) = vars_vec[i];
811: }
812:
813: static std::string model_name() {
814: return “modelc9d29db97fe_QUT_1comp_classical_overall”;
815: }
816:
817:
818: void constrained_param_names(std::vectorstd::string& param_names__,
819: bool include_tparams__ = true,
820: bool include_gqs__ = true) const {
821: std::stringstream param_name_stream__;
822: size_t beta_j_1_max__ = K;
823: for (size_t j_1__ = 0; j_1__ < beta_j_1_max__; ++j_1__) {
824: param_name_stream__.str(std::string());
825: param_name_stream__ << “beta” << ‘.’ << j_1__ + 1;
826: param_names__.push_back(param_name_stream__.str());
827: }
828: size_t beta_annual_raw_j_1_max__ = num_basis;
829: for (size_t j_1__ = 0; j_1__ < beta_annual_raw_j_1_max__; ++j_1__) {
830: param_name_stream__.str(std::string());
831: param_name_stream__ << “beta_annual_raw” << ‘.’ << j_1__ + 1;
832: param_names__.push_back(param_name_stream__.str());
833: }
834: param_name_stream__.str(std::string());
835: param_name_stream__ << “sigma”;
836: param_names__.push_back(param_name_stream__.str());
837:
838: if (!include_gqs__ && !include_tparams__) return;
839:
840: if (include_tparams__) {
841: param_name_stream__.str(std::string());
842: param_name_stream__ << “alpha”;
843: param_names__.push_back(param_name_stream__.str());
844: size_t beta_annual_j_1_max__ = num_basis;
845: for (size_t j_1__ = 0; j_1__ < beta_annual_j_1_max__; ++j_1__) {
846: param_name_stream__.str(std::string());
847: param_name_stream__ << “beta_annual” << ‘.’ << j_1__ + 1;
848: param_names__.push_back(param_name_stream__.str());
849: }
850: size_t beta_adj_j_1_max__ = K;
851: for (size_t j_1__ = 0; j_1__ < beta_adj_j_1_max__; ++j_1__) {
852: param_name_stream__.str(std::string());
853: param_name_stream__ << “beta_adj” << ‘.’ << j_1__ + 1;
854: param_names__.push_back(param_name_stream__.str());
855: }
856: size_t annual_effects_gen_j_1_max__ = Ncol;
857: for (size_t j_1__ = 0; j_1__ < annual_effects_gen_j_1_max__; ++j_1__) {
858: param_name_stream__.str(std::string());
859: param_name_stream__ << “annual_effects_gen” << ‘.’ << j_1__ + 1;
860: param_names__.push_back(param_name_stream__.str());
861: }
862: size_t overall_effects_gen_j_1_max__ = Ncol;
863: for (size_t j_1__ = 0; j_1__ < overall_effects_gen_j_1_max__; ++j_1__) {
864: param_name_stream__.str(std::string());
865: param_name_stream__ << “overall_effects_gen” << ‘.’ << j_1__ + 1;
866: param_names__.push_back(param_name_stream__.str());
867: }
868: }
869:
870: if (!include_gqs__) return;
871: size_t log_lik_vec_j_1_max__ = N;
872: for (size_t j_1__ = 0; j_1__ < log_lik_vec_j_1_max__; ++j_1__) {
873: param_name_stream__.str(std::string());
874: param_name_stream__ << “log_lik_vec” << ‘.’ << j_1__ + 1;
875: param_names__.push_back(param_name_stream__.str());
876: }
877: }
878:
879:
880: void unconstrained_param_names(std::vectorstd::string& param_names__,
881: bool include_tparams__ = true,
882: bool include_gqs__ = true) const {
883: std::stringstream param_name_stream__;
884: size_t beta_j_1_max__ = K;
885: for (size_t j_1__ = 0; j_1__ < beta_j_1_max__; ++j_1__) {
886: param_name_stream__.str(std::string());
887: param_name_stream__ << “beta” << ‘.’ << j_1__ + 1;
888: param_names__.push_back(param_name_stream__.str());
889: }
890: size_t beta_annual_raw_j_1_max__ = num_basis;
891: for (size_t j_1__ = 0; j_1__ < beta_annual_raw_j_1_max__; ++j_1__) {
892: param_name_stream__.str(std::string());
893: param_name_stream__ << “beta_annual_raw” << ‘.’ << j_1__ + 1;
894: param_names__.push_back(param_name_stream__.str());
895: }
896: param_name_stream__.str(std::string());
897: param_name_stream__ << “sigma”;
898: param_names__.push_back(param_name_stream__.str());
899:
900: if (!include_gqs__ && !include_tparams__) return;
901:
902: if (include_tparams__) {
903: param_name_stream__.str(std::string());
904: param_name_stream__ << “alpha”;
905: param_names__.push_back(param_name_stream__.str());
906: size_t beta_annual_j_1_max__ = num_basis;
907: for (size_t j_1__ = 0; j_1__ < beta_annual_j_1_max__; ++j_1__) {
908: param_name_stream__.str(std::string());
909: param_name_stream__ << “beta_annual” << ‘.’ << j_1__ + 1;
910: param_names__.push_back(param_name_stream__.str());
911: }
912: size_t beta_adj_j_1_max__ = K;
913: for (size_t j_1__ = 0; j_1__ < beta_adj_j_1_max__; ++j_1__) {
914: param_name_stream__.str(std::string());
915: param_name_stream__ << “beta_adj” << ‘.’ << j_1__ + 1;
916: param_names__.push_back(param_name_stream__.str());
917: }
918: size_t annual_effects_gen_j_1_max__ = Ncol;
919: for (size_t j_1__ = 0; j_1__ < annual_effects_gen_j_1_max__; ++j_1__) {
920: param_name_stream__.str(std::string());
921: param_name_stream__ << “annual_effects_gen” << ‘.’ << j_1__ + 1;
922: param_names__.push_back(param_name_stream__.str());
923: }
924: size_t overall_effects_gen_j_1_max__ = Ncol;
925: for (size_t j_1__ = 0; j_1__ < overall_effects_gen_j_1_max__; ++j_1__) {
926: param_name_stream__.str(std::string());
927: param_name_stream__ << “overall_effects_gen” << ‘.’ << j_1__ + 1;
928: param_names__.push_back(param_name_stream__.str());
929: }
930: }
931:
932: if (!include_gqs__) return;
933: size_t log_lik_vec_j_1_max__ = N;
934: for (size_t j_1__ = 0; j_1__ < log_lik_vec_j_1_max__; ++j_1__) {
935: param_name_stream__.str(std::string());
936: param_name_stream__ << “log_lik_vec” << ‘.’ << j_1__ + 1;
937: param_names__.push_back(param_name_stream__.str());
938: }
939: }
940:
941: }; // model
942:
943: } // namespace
944:
945: typedef modelc9d29db97fe_QUT_1comp_classical_overall_namespace::modelc9d29db97fe_QUT_1comp_classical_overall stan_model;
946:
947: #include <rstan/rstaninc.hpp>
948: /

949: * Define Rcpp Module to expose stan_fit’s functions to R.
950: */
951: RCPP_MODULE(stan_fit4modelc9d29db97fe_QUT_1comp_classical_overall_mod){
952: Rcpp::class_<rstan::stan_fit<modelc9d29db97fe_QUT_1comp_classical_overall_namespace::modelc9d29db97fe_QUT_1comp_classical_overall,
953: boost::random::ecuyer1988> >(“stan_fit4modelc9d29db97fe_QUT_1comp_classical_overall”)
954: // .constructorRcpp::List()
955: .constructor<SEXP, SEXP, SEXP>()
956: // .constructor<SEXP, SEXP>()
957: .method(“call_sampler”,
958: &rstan::stan_fit<modelc9d29db97fe_QUT_1comp_classical_overall_namespace::modelc9d29db97fe_QUT_1comp_classical_overall, boost::random::ecuyer1988>::call_sampler)
959: .method(“param_names”,
960: &rstan::stan_fit<modelc9d29db97fe_QUT_1comp_classical_overall_namespace::modelc9d29db97fe_QUT_1comp_classical_overall, boost::random::ecuyer1988>::param_names)
961: .method(“param_names_oi”,
962: &rstan::stan_fit<modelc9d29db97fe_QUT_1comp_classical_overall_namespace::modelc9d29db97fe_QUT_1comp_classical_overall, boost::random::ecuyer1988>::param_names_oi)
963: .method(“param_fnames_oi”,
964: &rstan::stan_fit<modelc9d29db97fe_QUT_1comp_classical_overall_namespace::modelc9d29db97fe_QUT_1comp_classical_overall, boost::random::ecuyer1988>::param_fnames_oi)
965: .method(“param_dims”,
966: &rstan::stan_fit<modelc9d29db97fe_QUT_1comp_classical_overall_namespace::modelc9d29db97fe_QUT_1comp_classical_overall, boost::random::ecuyer1988>::param_dims)
967: .method(“param_dims_oi”,
968: &rstan::stan_fit<modelc9d29db97fe_QUT_1comp_classical_overall_namespace::modelc9d29db97fe_QUT_1comp_classical_overall, boost::random::ecuyer1988>::param_dims_oi)
969: .method(“update_param_oi”,
970: &rstan::stan_fit<modelc9d29db97fe_QUT_1comp_classical_overall_namespace::modelc9d29db97fe_QUT_1comp_classical_overall, boost::random::ecuyer1988>::update_param_oi)
971: .method(“param_oi_tidx”,
972: &rstan::stan_fit<modelc9d29db97fe_QUT_1comp_classical_overall_namespace::modelc9d29db97fe_QUT_1comp_classical_overall, boost::random::ecuyer1988>::param_oi_tidx)
973: .method(“grad_log_prob”,
974: &rstan::stan_fit<modelc9d29db97fe_QUT_1comp_classical_overall_namespace::modelc9d29db97fe_QUT_1comp_classical_overall, boost::random::ecuyer1988>::grad_log_prob)
975: .method(“log_prob”,
976: &rstan::stan_fit<modelc9d29db97fe_QUT_1comp_classical_overall_namespace::modelc9d29db97fe_QUT_1comp_classical_overall, boost::random::ecuyer1988>::log_prob)
977: .method(“unconstrain_pars”,
978: &rstan::stan_fit<modelc9d29db97fe_QUT_1comp_classical_overall_namespace::modelc9d29db97fe_QUT_1comp_classical_overall, boost::random::ecuyer1988>::unconstrain_pars)
979: .method(“constrain_pars”,
980: &rstan::stan_fit<modelc9d29db97fe_QUT_1comp_classical_overall_namespace::modelc9d29db97fe_QUT_1comp_classical_overall, boost::random::ecuyer1988>::constrain_pars)
981: .method(“num_pars_unconstrained”,
982: &rstan::stan_fit<modelc9d29db97fe_QUT_1comp_classical_overall_namespace::modelc9d29db97fe_QUT_1comp_classical_overall, boost::random::ecuyer1988>::num_pars_unconstrained)
983: .method(“unconstrained_param_names”,
984: &rstan::stan_fit<modelc9d29db97fe_QUT_1comp_classical_overall_namespace::modelc9d29db97fe_QUT_1comp_classical_overall, boost::random::ecuyer1988>::unconstrained_param_names)
985: .method(“constrained_param_names”,
986: &rstan::stan_fit<modelc9d29db97fe_QUT_1comp_classical_overall_namespace::modelc9d29db97fe_QUT_1comp_classical_overall, boost::random::ecuyer1988>::constrained_param_names)
987: .method(“standalone_gqs”,
988: &rstan::stan_fit<modelc9d29db97fe_QUT_1comp_classical_overall_namespace::modelc9d29db97fe_QUT_1comp_classical_overall, boost::random::ecuyer1988>::standalone_gqs)
989: ;
990: }
991:
992: // declarations
993: extern “C” {
994: SEXP filec9d68a5a106( ) ;
995: }
996:
997: // definition
998:
999: SEXP filec9d68a5a106( ){
1000: return Rcpp::wrap(“QUT_1comp_classical_overall”);
1001: }
1002:
1003:
Error in compileCode(f, code, language = language, verbose = verbose) :
Compilation ERROR, function(s)/method(s) not created! In file included from /apps/R/3.5.3/lib64/R/site-library/BH/include/boost/random/detail/integer_log2.hpp:19:0,
from /apps/R/3.5.3/lib64/R/site-library/BH/include/boost/random/detail/int_float_pair.hpp:26,
from /apps/R/3.5.3/lib64/R/site-library/BH/include/boost/random/exponential_distribution.hpp:27,
from /apps/R/3.5.3/lib64/R/site-library/BH/include/boost/random/gamma_distribution.hpp:25,
from /home/z5038974/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/stan/math/prim/mat/prob/dirichlet_rng.hpp:5,
from /home/z5038974/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/stan/math/prim/mat.hpp:292,
from /home/z5038974/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/stan/math/rev/mat.hpp:12,
from /home/z5038974/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/stan/math.hpp:4,

OK. Try

library(rstan)
example(stan_model, run.dontrun = TRUE)

but we need the part of the error message that actually says what the compiler error is, which will start with error:

I cannot seem to find theerror: part but I copied and paste the whole output produced by running the code above.

stn_md> stancode ← ‘data {real y_mean;} parameters {real y;} model {y ~ normal(y_mean,1);}’

stn_md> mod ← stan_model(model_code = stancode, verbose = TRUE)

TRANSLATING MODEL ‘16a540c6086086816528e4524def24d9’ FROM Stan CODE TO C++ CODE NOW.
successful in parsing the Stan model ‘16a540c6086086816528e4524def24d9’.
COMPILING THE C++ CODE FOR MODEL ‘16a540c6086086816528e4524def24d9’ NOW.
OS: x86_64, linux-gnu; rstan: 2.19.2; Rcpp: 1.0.1; inline: 0.3.15

setting environment variables:
PKG_LIBS = -L’/home/z5038974/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/lib/’ -lStanHeaders
PKG_CPPFLAGS = -I"/apps/R/3.5.3/lib64/R/site-library/Rcpp/include/" -I"/apps/R/3.5.3/lib64/R/site-library/RcppEigen/include/" -I"/apps/R/3.5.3/lib64/R/site-li brary/RcppEigen/include/unsupported" -I"/apps/R/3.5.3/lib64/R/site-library/BH/include" -I"/home/z5038974/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/sr c/" -I"/home/z5038974/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/" -I"/home/z5038974/R/x86_64-pc-linux-gnu-library/3.5/rstan/include" -DEIGEN_NO_DEBU G -DBOOST_DISABLE_ASSERTS
Program source :

1 :
2 : // includes from the plugin
3 : // [[Rcpp::plugins(cpp14)]]
4 :
5 : // user includes
6 : #define STAN__SERVICES__COMMAND_HPP// Code generated by Stan version 2.19.1
7 :
8 : #include <stan/model/model_header.hpp>
9 :
10 : namespace model41423ea27d3_16a540c6086086816528e4524def24d9_namespace {
11 :
12 : using std::istream;
13 : using std::string;
14 : using std::stringstream;
15 : using std::vector;
16 : using stan::io::dump;
17 : using stan::math::lgamma;
18 : using stan::model::prob_grad;
19 : using namespace stan::math;
20 :
21 : static int current_statement_begin__;
22 :
23 : stan::io::program_reader prog_reader__() {
24 : stan::io::program_reader reader;
25 : reader.add_event(0, 0, “start”, “model41423ea27d3_16a540c6086086816528e4524def24d9”);
26 : reader.add_event(3, 1, “end”, “model41423ea27d3_16a540c6086086816528e4524def24d9”);
27 : return reader;
28 : }
29 :
30 : class model41423ea27d3_16a540c6086086816528e4524def24d9 : public prob_grad {
31 : private:
32 : double y_mean;
33 : public:
34 : model41423ea27d3_16a540c6086086816528e4524def24d9(stan::io::var_context& context__,
35 : std::ostream* pstream__ = 0)
36 : : prob_grad(0) {
37 : ctor_body(context__, 0, pstream__);
38 : }
39 :
40 : model41423ea27d3_16a540c6086086816528e4524def24d9(stan::io::var_context& context__,
41 : unsigned int random_seed__,
42 : std::ostream* pstream__ = 0)
43 : : prob_grad(0) {
44 : ctor_body(context__, random_seed__, pstream__);
45 : }
46 :
47 : void ctor_body(stan::io::var_context& context__,
48 : unsigned int random_seed__,
49 : std::ostream* pstream__) {
50 : typedef double local_scalar_t__;
51 :
52 : boost::ecuyer1988 base_rng__ =
53 : stan::services::util::create_rng(random_seed__, 0);
54 : (void) base_rng__; // suppress unused var warning
55 :
56 : current_statement_begin__ = -1;
57 :
58 : static const char* function__ = “model41423ea27d3_16a540c6086086816528e4524def24d9_namespace::model41423ea27d3_16a540c6086086816528e4524def24d9”;
59 : (void) function__; // dummy to suppress unused var warning
60 : size_t pos__;
61 : (void) pos__; // dummy to suppress unused var warning
62 : std::vector vals_i__;
63 : std::vector vals_r__;
64 : local_scalar_t__ DUMMY_VAR__(std::numeric_limits::quiet_NaN());
65 : (void) DUMMY_VAR__; // suppress unused var warning
66 :
67 : try {
68 : // initialize data block variables from context__
69 : current_statement_begin__ = 1;
70 : context__.validate_dims(“data initialization”, “y_mean”, “double”, context__.to_vec());
71 : y_mean = double(0);
72 : vals_r__ = context__.vals_r(“y_mean”);
73 : pos__ = 0;
74 : y_mean = vals_r__[pos__++];
75 :
76 :
77 : // initialize transformed data variables
78 : // execute transformed data statements
79 :
80 : // validate transformed data
81 :
82 : // validate, set parameter ranges
83 : num_params_r__ = 0U;
84 : param_ranges_i__.clear();
85 : current_statement_begin__ = 1;
86 : num_params_r__ += 1;
87 : } catch (const std::exception& e) {
88 : stan::lang::rethrow_located(e, current_statement_begin__, prog_reader__());
89 : // Next line prevents compiler griping about no return
90 : throw std::runtime_error(“*** IF YOU SEE THIS, PLEASE REPORT A BUG ");
91 : }
92 : }
93 :
94 : ~model41423ea27d3_16a540c6086086816528e4524def24d9() { }
95 :
96 :
97 : void transform_inits(const stan::io::var_context& context__,
98 : std::vector& params_i__,
99 : std::vector& params_r__,
100 : std::ostream
pstream__) const {
101 : typedef double local_scalar_t__;
102 : stan::io::writer writer__(params_r__, params_i__);
103 : size_t pos__;
104 : (void) pos__; // dummy call to supress warning
105 : std::vector vals_r__;
106 : std::vector vals_i__;
107 :
108 : current_statement_begin__ = 1;
109 : if (!(context__.contains_r(“y”)))
110 : stan::lang::rethrow_located(std::runtime_error(std::string(“Variable y missing”)), current_statement_begin__, prog_reader__());
111 : vals_r__ = context__.vals_r(“y”);
112 : pos__ = 0U;
113 : context__.validate_dims(“parameter initialization”, “y”, “double”, context__.to_vec());
114 : double y(0);
115 : y = vals_r__[pos__++];
116 : try {
117 : writer__.scalar_unconstrain(y);
118 : } catch (const std::exception& e) {
119 : stan::lang::rethrow_located(std::runtime_error(std::string("Error transforming variable y: ") + e.what()), current_statement_begin__, prog_read er__());
120 : }
121 :
122 : params_r__ = writer__.data_r();
123 : params_i__ = writer__.data_i();
124 : }
125 :
126 : void transform_inits(const stan::io::var_context& context,
127 : Eigen::Matrix<double, Eigen::Dynamic, 1>& params_r,
128 : std::ostream
pstream__) const {
129 : std::vector params_r_vec;
130 : std::vector params_i_vec;
131 : transform_inits(context, params_i_vec, params_r_vec, pstream__);
132 : params_r.resize(params_r_vec.size());
133 : for (int i = 0; i < params_r.size(); ++i)
134 : params_r(i) = params_r_vec[i];
135 : }
136 :
137 :
138 : template <bool propto__, bool jacobian__, typename T__>
139 : T__ log_prob(std::vector<T__>& params_r__,
140 : std::vector& params_i__,
141 : std::ostream
pstream__ = 0) const {
142 :
143 : typedef T__ local_scalar_t__;
144 :
145 : local_scalar_t__ DUMMY_VAR__(std::numeric_limits::quiet_NaN());
146 : (void) DUMMY_VAR__; // dummy to suppress unused var warning
147 :
148 : T__ lp__(0.0);
149 : stan::math::accumulator<T__> lp_accum__;
150 : try {
151 : stan::io::reader<local_scalar_t__> in__(params_r__, params_i__);
152 :
153 : // model parameters
154 : current_statement_begin__ = 1;
155 : local_scalar_t__ y;
156 : (void) y; // dummy to suppress unused var warning
157 : if (jacobian__)
158 : y = in__.scalar_constrain(lp__);
159 : else
160 : y = in__.scalar_constrain();
161 :
162 : // model body
163 :
164 : current_statement_begin__ = 1;
165 : lp_accum__.add(normal_log<propto__>(y, y_mean, 1));
166 :
167 : } catch (const std::exception& e) {
168 : stan::lang::rethrow_located(e, current_statement_begin__, prog_reader__());
169 : // Next line prevents compiler griping about no return
170 : throw std::runtime_error(”*** IF YOU SEE THIS, PLEASE REPORT A BUG ");
171 : }
172 :
173 : lp_accum__.add(lp__);
174 : return lp_accum__.sum();
175 :
176 : } // log_prob()
177 :
178 : template <bool propto, bool jacobian, typename T_>
179 : T_ log_prob(Eigen::Matrix<T_,Eigen::Dynamic,1>& params_r,
180 : std::ostream
pstream = 0) const {
181 : std::vector<T_> vec_params_r;
182 : vec_params_r.reserve(params_r.size());
183 : for (int i = 0; i < params_r.size(); ++i)
184 : vec_params_r.push_back(params_r(i));
185 : std::vector vec_params_i;
186 : return log_prob<propto,jacobian,T_>(vec_params_r, vec_params_i, pstream);
187 : }
188 :
189 :
190 : void get_param_names(std::vectorstd::string& names__) const {
191 : names__.resize(0);
192 : names__.push_back(“y”);
193 : }
194 :
195 :
196 : void get_dims(std::vector<std::vector<size_t> >& dimss__) const {
197 : dimss__.resize(0);
198 : std::vector<size_t> dims__;
199 : dims__.resize(0);
200 : dimss__.push_back(dims__);
201 : }
202 :
203 : template
204 : void write_array(RNG& base_rng__,
205 : std::vector& params_r__,
206 : std::vector& params_i__,
207 : std::vector& vars__,
208 : bool include_tparams__ = true,
209 : bool include_gqs__ = true,
210 : std::ostream
pstream__ = 0) const {
211 : typedef double local_scalar_t__;
212 :
213 : vars__.resize(0);
214 : stan::io::reader<local_scalar_t__> in__(params_r__, params_i__);
215 : static const char
function__ = “model41423ea27d3_16a540c6086086816528e4524def24d9_namespace::write_array”;
216 : (void) function__; // dummy to suppress unused var warning
217 :
218 : // read-transform, write parameters
219 : double y = in__.scalar_constrain();
220 : vars__.push_back(y);
221 :
222 : double lp__ = 0.0;
223 : (void) lp__; // dummy to suppress unused var warning
224 : stan::math::accumulator lp_accum__;
225 :
226 : local_scalar_t__ DUMMY_VAR__(std::numeric_limits::quiet_NaN());
227 : (void) DUMMY_VAR__; // suppress unused var warning
228 :
229 : if (!include_tparams__ && !include_gqs__) return;
230 :
231 : try {
232 : if (!include_gqs__ && !include_tparams__) return;
233 : if (!include_gqs__) return;
234 : } catch (const std::exception& e) {
235 : stan::lang::rethrow_located(e, current_statement_begin__, prog_reader__());
236 : // Next line prevents compiler griping about no return
237 : throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ");
238 : }
239 : }
240 :
241 : template
242 : void write_array(RNG& base_rng,
243 : Eigen::Matrix<double,Eigen::Dynamic,1>& params_r,
244 : Eigen::Matrix<double,Eigen::Dynamic,1>& vars,
245 : bool include_tparams = true,
246 : bool include_gqs = true,
247 : std::ostream
pstream = 0) const {
248 : std::vector params_r_vec(params_r.size());
249 : for (int i = 0; i < params_r.size(); ++i)
250 : params_r_vec[i] = params_r(i);
251 : std::vector vars_vec;
252 : std::vector params_i_vec;
253 : write_array(base_rng, params_r_vec, params_i_vec, vars_vec, include_tparams, include_gqs, pstream);
254 : vars.resize(vars_vec.size());
255 : for (int i = 0; i < vars.size(); ++i)
256 : vars(i) = vars_vec[i];
257 : }
258 :
259 : static std::string model_name() {
260 : return “model41423ea27d3_16a540c6086086816528e4524def24d9”;
261 : }
262 :
263 :
264 : void constrained_param_names(std::vectorstd::string& param_names__,
265 : bool include_tparams__ = true,
266 : bool include_gqs__ = true) const {
267 : std::stringstream param_name_stream__;
268 : param_name_stream__.str(std::string());
269 : param_name_stream__ << “y”;
270 : param_names__.push_back(param_name_stream__.str());
271 :
272 : if (!include_gqs__ && !include_tparams__) return;
273 :
274 : if (include_tparams__) {
275 : }
276 :
277 : if (!include_gqs__) return;
278 : }
279 :
280 :
281 : void unconstrained_param_names(std::vectorstd::string& param_names__,
282 : bool include_tparams__ = true,
283 : bool include_gqs__ = true) const {
284 : std::stringstream param_name_stream__;
285 : param_name_stream__.str(std::string());
286 : param_name_stream__ << “y”;
287 : param_names__.push_back(param_name_stream__.str());
288 :
289 : if (!include_gqs__ && !include_tparams__) return;
290 :
291 : if (include_tparams__) {
292 : }
293 :
294 : if (!include_gqs__) return;
295 : }
296 :
297 : }; // model
298 :
299 : } // namespace
300 :
301 : typedef model41423ea27d3_16a540c6086086816528e4524def24d9_namespace::model41423ea27d3_16a540c6086086816528e4524def24d9 stan_model;
302 :
303 : #include <rstan/rstaninc.hpp>
304 : /

305 : * Define Rcpp Module to expose stan_fit’s functions to R.
306 : /
307 : RCPP_MODULE(stan_fit4model41423ea27d3_16a540c6086086816528e4524def24d9_mod){
308 : Rcpp::class_<rstan::stan_fit<model41423ea27d3_16a540c6086086816528e4524def24d9_namespace::model41423ea27d3_16a540c6086086816528e4524def24d9,
309 : boost::random::ecuyer1988> >(“stan_fit4model41423ea27d3_16a540c6086086816528e4524def24d9”)
310 : // .constructorRcpp::List()
311 : .constructor<SEXP, SEXP, SEXP>()
312 : // .constructor<SEXP, SEXP>()
313 : .method(“call_sampler”,
314 : &rstan::stan_fit<model41423ea27d3_16a540c6086086816528e4524def24d9_namespace::model41423ea27d3_16a540c6086086816528e4524def24d9, boost::random: :ecuyer1988>::call_sampler)
315 : .method(“param_names”,
316 : &rstan::stan_fit<model41423ea27d3_16a540c6086086816528e4524def24d9_namespace::model41423ea27d3_16a540c6086086816528e4524def24d9, boost::random: :ecuyer1988>::param_names)
317 : .method(“param_names_oi”,
318 : &rstan::stan_fit<model41423ea27d3_16a540c6086086816528e4524def24d9_namespace::model41423ea27d3_16a540c6086086816528e4524def24d9, boost::random: :ecuyer1988>::param_names_oi)
319 : .method(“param_fnames_oi”,
320 : &rstan::stan_fit<model41423ea27d3_16a540c6086086816528e4524def24d9_namespace::model41423ea27d3_16a540c6086086816528e4524def24d9, boost::random: :ecuyer1988>::param_fnames_oi)
321 : .method(“param_dims”,
322 : &rstan::stan_fit<model41423ea27d3_16a540c6086086816528e4524def24d9_namespace::model41423ea27d3_16a540c6086086816528e4524def24d9, boost::random: :ecuyer1988>::param_dims)
323 : .method(“param_dims_oi”,
324 : &rstan::stan_fit<model41423ea27d3_16a540c6086086816528e4524def24d9_namespace::model41423ea27d3_16a540c6086086816528e4524def24d9, boost::random: :ecuyer1988>::param_dims_oi)
325 : .method(“update_param_oi”,
326 : &rstan::stan_fit<model41423ea27d3_16a540c6086086816528e4524def24d9_namespace::model41423ea27d3_16a540c6086086816528e4524def24d9, boost::random: :ecuyer1988>::update_param_oi)
327 : .method(“param_oi_tidx”,
328 : &rstan::stan_fit<model41423ea27d3_16a540c6086086816528e4524def24d9_namespace::model41423ea27d3_16a540c6086086816528e4524def24d9, boost::random: :ecuyer1988>::param_oi_tidx)
329 : .method(“grad_log_prob”,
330 : &rstan::stan_fit<model41423ea27d3_16a540c6086086816528e4524def24d9_namespace::model41423ea27d3_16a540c6086086816528e4524def24d9, boost::random: :ecuyer1988>::grad_log_prob)
331 : .method(“log_prob”,
332 : &rstan::stan_fit<model41423ea27d3_16a540c6086086816528e4524def24d9_namespace::model41423ea27d3_16a540c6086086816528e4524def24d9, boost::random: :ecuyer1988>::log_prob)
333 : .method(“unconstrain_pars”,
334 : &rstan::stan_fit<model41423ea27d3_16a540c6086086816528e4524def24d9_namespace::model41423ea27d3_16a540c6086086816528e4524def24d9, boost::random: :ecuyer1988>::unconstrain_pars)
335 : .method(“constrain_pars”,
336 : &rstan::stan_fit<model41423ea27d3_16a540c6086086816528e4524def24d9_namespace::model41423ea27d3_16a540c6086086816528e4524def24d9, boost::random: :ecuyer1988>::constrain_pars)
337 : .method(“num_pars_unconstrained”,
338 : &rstan::stan_fit<model41423ea27d3_16a540c6086086816528e4524def24d9_namespace::model41423ea27d3_16a540c6086086816528e4524def24d9, boost::random: :ecuyer1988>::num_pars_unconstrained)
339 : .method(“unconstrained_param_names”,
340 : &rstan::stan_fit<model41423ea27d3_16a540c6086086816528e4524def24d9_namespace::model41423ea27d3_16a540c6086086816528e4524def24d9, boost::random: :ecuyer1988>::unconstrained_param_names)
341 : .method(“constrained_param_names”,
342 : &rstan::stan_fit<model41423ea27d3_16a540c6086086816528e4524def24d9_namespace::model41423ea27d3_16a540c6086086816528e4524def24d9, boost::random: :ecuyer1988>::constrained_param_names)
343 : .method(“standalone_gqs”,
344 : &rstan::stan_fit<model41423ea27d3_16a540c6086086816528e4524def24d9_namespace::model41423ea27d3_16a540c6086086816528e4524def24d9, boost::random: :ecuyer1988>::standalone_gqs)
345 : ;
346 : }
347 :
348 : // declarations
349 : extern “C” {
350 : SEXP file41422d7b341a( ) ;
351 : }
352 :
353 : // definition
354 :
355 : SEXP file41422d7b341a( ){
356 : return Rcpp::wrap(“16a540c6086086816528e4524def24d9”);
357 : }
358 :
359 :
Compilation argument:
/apps/R/3.5.3/lib64/R/bin/R CMD SHLIB file41422d7b341a.cpp 2> file41422d7b341a.cpp.err.txt
g++ -std=c++1y -I"/apps/R/3.5.3/lib64/R/include" -DNDEBUG -I"/apps/R/3.5.3/lib64/R/site-library/Rcpp/include/" -I"/apps/R/3.5.3/lib64/R/site-library/RcppEigen /include/" -I"/apps/R/3.5.3/lib64/R/site-library/RcppEigen/include/unsupported" -I"/apps/R/3.5.3/lib64/R/site-library/BH/include" -I"/home/z5038974/R/x86_64-pc- linux-gnu-library/3.5/StanHeaders/include/src/" -I"/home/z5038974/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/" -I"/home/z5038974/R/x86_64-pc-linux-gn u-library/3.5/rstan/include" -DEIGEN_NO_DEBUG -DBOOST_DISABLE_ASSERTS -I/usr/local/include -O3 -Wno-unused-variable -Wno-unused-function -Wno-macro-redefine d -fPIC -c file41422d7b341a.cpp -o file41422d7b341a.o
In file included from /apps/R/3.5.3/lib64/R/site-library/BH/include/boost/random/detail/integer_log2.hpp:19:0,
from /apps/R/3.5.3/lib64/R/site-library/BH/include/boost/random/detail/int_float_pair.hpp:26,
from /apps/R/3.5.3/lib64/R/site-library/BH/include/boost/random/exponential_distribution.hpp:27,
from /apps/R/3.5.3/lib64/R/site-library/BH/include/boost/random/gamma_distribution.hpp:25,
from /home/z5038974/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/stan/math/prim/mat/prob/dirichlet_rng.hpp:5,
from /home/z5038974/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/stan/math/prim/mat.hpp:292,
from /home/z5038974/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/stan/math/rev/mat.hpp:12,
from /home/z5038974/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/stan/math.hpp:4,
from /home/z5038974/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/model/model_header.hpp:4,
from file41422d7b341a.cpp:8:
/apps/R/3.5.3/lib64/R/site-library/BH/include/boost/pending/integer_log2.hpp:7:89: note: #pragma message: This header is deprecated. Use <boost/integer/integer_lo g2.hpp> instead.
BOOST_HEADER_DEPRECATED(“<boost/integer/integer_log2.hpp>”);
^
In file included from /home/z5038974/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/stan/math/rev/mat/fun/ordered_constrain.hpp:6:0,
from /home/z5038974/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/stan/math/rev/mat.hpp:41,
from /home/z5038974/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/stan/math.hpp:4,
from /home/z5038974/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/model/model_header.hpp:4,
from file41422d7b341a.cpp:8:
/home/z5038974/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/stan/math/rev/mat/functor/adj_jac_apply.hpp:31:32: error: ‘std::index_sequence’ has not been declared
std::index_sequence<I…> i) {
^
/home/z5038974/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/stan/math/rev/mat/functor/adj_jac_apply.hpp:31:46: error: expected ‘,’ or ‘…’ before ‘<’ to ken
std::index_sequence<I…> i) {
^
/home/z5038974/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/stan/math/rev/mat/functor/adj_jac_apply.hpp: In function ‘constexpr auto stan::math::internal ::apply(const F&, const Tuple&)’:
/home/z5038974/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/stan/math/rev/mat/functor/adj_jac_apply.hpp:49:27: error: ‘make_index_sequence’ is not a memb er of ‘std’
return apply_impl(f, t, std::make_index_sequence<std::tuple_size{}>{});
^
/home/z5038974/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/stan/math/rev/mat/functor/adj_jac_apply.hpp:49:27: note: suggested alternative:
In file included from /apps/R/3.5.3/lib64/R/site-library/BH/include/boost/fusion/container/vector/vector.hpp:28:0,
from /apps/R/3.5.3/lib64/R/site-library/BH/include/boost/fusion/container/vector/vector10.hpp:25,
from /apps/R/3.5.3/lib64/R/site-library/BH/include/boost/fusion/view/transform_view/transform_view.hpp:22,
from /apps/R/3.5.3/lib64/R/site-library/BH/include/boost/fusion/algorithm/transformation/transform.hpp:11,
from /apps/R/3.5.3/lib64/R/site-library/BH/include/boost/fusion/view/zip_view/detail/begin_impl.hpp:14,
from /apps/R/3.5.3/lib64/R/site-library/BH/include/boost/fusion/view/zip_view/zip_view.hpp:16,
from /apps/R/3.5.3/lib64/R/site-library/BH/include/boost/fusion/view/zip_view.hpp:12,
from /apps/R/3.5.3/lib64/R/site-library/BH/include/boost/fusion/include/zip_view.hpp:11,
from /apps/R/3.5.3/lib64/R/site-library/BH/include/boost/numeric/odeint/util/resize.hpp:26,
from /apps/R/3.5.3/lib64/R/site-library/BH/include/boost/numeric/odeint/util/state_wrapper.hpp:26,
from /apps/R/3.5.3/lib64/R/site-library/BH/include/boost/numeric/odeint/util/ublas_wrapper.hpp:33,
from /apps/R/3.5.3/lib64/R/site-library/BH/include/boost/numeric/odeint.hpp:25,
from /home/z5038974/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/stan/math/prim/arr/functor/integrate_ode_rk45.hpp:17,
from /home/z5038974/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/stan/math/prim/arr.hpp:46,
from /home/z5038974/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/stan/math/prim/mat.hpp:344,
from /home/z5038974/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/stan/math/rev/mat.hpp:12,
from /home/z5038974/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/stan/math.hpp:4,
from /home/z5038974/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/model/model_header.hpp:4,
from file41422d7b341a.cpp:8:
/apps/R/3.5.3/lib64/R/site-library/BH/include/boost/fusion/support/detail/index_sequence.hpp:59:12: note: ‘boost::fusion::detail::make_index_sequence’
struct make_index_sequence
^
In file included from /home/z5038974/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/stan/math/rev/mat/fun/ordered_constrain.hpp:6:0,
from /home/z5038974/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/stan/math/rev/mat.hpp:41,
from /home/z5038974/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/stan/math.hpp:4,
from /home/z5038974/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/stan/model/model_header.hpp:4,
from file41422d7b341a.cpp:8:
/home/z5038974/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/stan/math/rev/mat/functor/adj_jac_apply.hpp:49:77: error: expected primary-expression before ‘{’ token
return apply_impl(f, t, std::make_index_sequence<std::tuple_size{}>{});
^
/home/z5038974/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/stan/math/rev/mat/functor/adj_jac_apply.hpp:49:77: error: expected ‘)’ before ‘{’ token
/home/z5038974/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/stan/math/rev/mat/functor/adj_jac_apply.hpp: At global scope:
/home/z5038974/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/stan/math/rev/mat/functor/adj_jac_apply.hpp:151:9: error: expected type-specifier
= std::result_of_t<F(decltype(is_var_), decltype(value_of(Targs()))…)>;
^
/home/z5038974/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/stan/math/rev/mat/functor/adj_jac_apply.hpp:156:42: error: ‘FReturnType’ was not declared in this scope
std::array<int, internal::compute_dims::value> M_;
^
/home/z5038974/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/stan/math/rev/mat/functor/adj_jac_apply.hpp:156:53: error: template argument 1 is invalid
std::array<int, internal::compute_dims::value> M_;
^
/home/z5038974/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/stan/math/rev/mat/functor/adj_jac_apply.hpp:156:61: error: template argument 2 is invalid
std::array<int, internal::compute_dims::value> M_;
^
/home/z5038974/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/stan/math/rev/mat/functor/adj_jac_apply.hpp: In member function ‘std::vectorstan::math::var stan::math::adj_jac_vari<F, Targs>::build_return_varis_and_vars(const std::vector&)’:
/home/z5038974/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/stan/math/rev/mat/functor/adj_jac_apply.hpp:349:9: error: invalid types ‘int[int]’ for array subscript
M_[0] = val_y.size();
^
/home/z5038974/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/stan/math/rev/mat/functor/adj_jac_apply.hpp:350:32: error: invalid types ‘int[int]’ for array subscript
std::vector var_y(M_[0]);
^
/home/z5038974/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/stan/math/rev/mat/functor/adj_jac_apply.hpp: In member function ‘Eigen::Matrix<stan::math::va r, R, C> stan::math::adj_jac_vari<F, Targs>::build_return_varis_and_vars(const Eigen::Matrix<double, R, C>&)’:
/home/z5038974/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/stan/math/rev/mat/functor/adj_jac_apply.hpp:375:9: error: invalid types ‘int[int]’ for array subscript
M_[0] = val_y.rows();
^
/home/z5038974/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/stan/math/rev/mat/functor/adj_jac_apply.hpp:376:9: error: invalid types ‘int[int]’ for array subscript
M_[1] = val_y.cols();
^
/home/z5038974/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/stan/math/rev/mat/functor/adj_jac_apply.hpp:377:40: error: invalid types ‘int[int]’ for array subscript
Eigen::Matrix<var, R, C> var_y(M_[0], M_[1]);
^
/home/z5038974/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/stan/math/rev/mat/functor/adj_jac_apply.hpp:377:47: error: invalid types ‘int[int]’ for array subscript
Eigen::Matrix<var, R, C> var_y(M_[0], M_[1]);
^
/home/z5038974/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/stan/math/rev/mat/functor/adj_jac_apply.hpp: In member function ‘void stan::math::adj_jac_var i<F, Targs>::chain()’:
/home/z5038974/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/stan/math/rev/mat/functor/adj_jac_apply.hpp:530:5: error: ‘FReturnType’ was not declared in t his scope
FReturnType y_adj;
^
/home/z5038974/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/stan/math/rev/mat/functor/adj_jac_apply.hpp:530:17: error: expected ‘;’ before ‘y_adj’
FReturnType y_adj;
^
/home/z5038974/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/stan/math/rev/mat/functor/adj_jac_apply.hpp:532:38: error: ‘y_adj’ was not declared in this s cope
internal::build_y_adj(y_vi_, M_, y_adj);
^
/home/z5038974/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/stan/math/rev/mat/functor/adj_jac_apply.hpp:536:26: error: expansion pattern ‘auto&&’ contain s no argument packs
[this](auto&&… args) { this->accumulate_adjoints(args…); },
^
/home/z5038974/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/stan/math/rev/mat/functor/adj_jac_apply.hpp: In lambda function:
/home/z5038974/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/stan/math/rev/mat/functor/adj_jac_apply.hpp:536:60: error: ‘args’ was not declared in this sc ope
** [this](auto&&… args) { this->accumulate_adjoints(args…); },
*
** ^**
At global scope:
cc1plus: warning: unrecognized command line option “-Wno-macro-redefined” [enabled by default]
make: *** [file41422d7b341a.o] Error 1

Perhaps it is the last highlighted part that explains where the errors are?

Thanks for your help.

This is indicative of lack of the C++14 flags. What do you have in ~/.R/Makevars?

my current Makevars file states like this

XX14 = g++ -std=c++1y
CXX14FLAGS = -O3 -Wno-unused-variable -Wno-unused-function -Wno-macro-redefined
CXX14FLAGS += -fPIC

That should be CXX14 = g++ -std=c++1y rather than XX14.

yes it is. I failed to copy C previously.
CXX14 = g++ -std=c++1y
CXX14FLAGS = -O3 -Wno-unused-variable -Wno-unused-function -Wno-macro-redefined
CXX14FLAGS += -fPIC

I suspect you are trying to use a version of g++ that is less than 4.9.3, in which case the C++14 flags may be accepted but the functionality is not implemented. If so, then upgrade the compiler.

thanks for your reply. I am actually running on a remote cluster. I dont know exactly how to upgrade the compiler. could you please provide with some information that I can look into to fix it myself?

For RHEL, it is