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__;