# Error in compileCode

**URL:** <https://discourse.mc-stan.org/t/error-in-compilecode/9652>\
**Category:** RStan\
**Created:** [July 10, 2019, 2:31pm UTC](https://discourse.mc-stan.org/t/error-in-compilecode/9652 "2019-07-10T14:31:23Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jimams](https://avatars.discourse-cdn.com/v4/letter/j/3ec8ea/32.png) [@Jimams](https://discourse.mc-stan.org/u/Jimams)\
**Post date:** [July 10, 2019, 2:31pm UTC](https://discourse.mc-stan.org/t/error-in-compilecode/9652/1 "2019-07-10T14:31:23Z")

</div>

Hello,

I just starting using Rstan and I tried to run simple ODE models. I found an example for the Lotka-Volterra that run perfectly so I took the code and adjusted it to my own example of simple exponential growth. The code is as follows:

```
expon.stan=
  "functions {
  real dz_dt(real t,
                real[] z,
                real[] theta,
                real[] x_r,
                int[] x_i ){
  
    real V = z[1];
    real K = theta[1];
    real dV_dt = K*V;
    return dV_dt;
  }
}

data {
  int<lower = 0> N;
  real ts[N]; // Time points that were sampled
  real y_init[1];
  real<lower = 0> y[N,1];
}

parameters {
  real <lower=0> theta[1];
  real<lower=0> z_init[1];
  real<lower=0> sigma[1];
}

transformed parameters {
  real z[N, 1]
  = integrate_ode_bdf(dz_dt, z_init, 0, ts, theta,
                       rep_array(0.0, 0), rep_array(0, 0),
                       1e-5, 1e-3, 5e2);
}

model {
  theta[1] ~ lognormal(-2, 0.5);
  sigma ~ lognormal(-1, 1);
  z_init[1] ~ lognormal(-1.4, 0.5);
  y_init[1] ~ lognormal(log(z_init[1]), sigma[1]);
  y[, 1] ~ lognormal(log(z[, 1]), sigma[1]);
}

generated quantities {
  real y_init_rep[1];
  real y_rep[N, 1];

  y_init_rep[1] = lognormal_rng(log(z_init[1]), sigma[1]);
    for (n in 1:N)
      y_rep[n, 1] = lognormal_rng(log(z[n, 1]), sigma[1]);
}"

dat<-list(19,c(4,7,11,14,18,21,25,31,35,39,42,46,49,52,56,59,62,67,70),0.215,c(0.2484 ,0.2636, 0.3042 ,0.3678, 0.3767 ,0.3880 ,0.3937 ,0.4087, 0.4282, 0.4599 ,0.4730, 0.5415 ,0.5848, 0.6096, 0.6427, 0.6817 ,0.7308 ,0.7762 ,0.8077))

fit = stan(model_code=expon.stan, data = dat)

```

But i get the following error;

Error in compileCode(f, code, language = language, verbose = verbose) :  
Compilation ERROR, function(s)/method(s) not created! In file included from /home/kpwp689/R/x86\_64-pc-linux-gnu-library/3.5/RcppEigen/include/Eigen/Core:388:0,  
from /home/kpwp689/R/x86\_64-pc-linux-gnu-library/3.5/RcppEigen/include/Eigen/Dense:1,  
from /home/kpwp689/R/x86\_64-pc-linux-gnu-library/3.5/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp:4,  
from /home/kpwp689/R/x86\_64-pc-linux-gnu-library/3.5/StanHeaders/include/stan/math/rev/mat/fun/Eigen\_NumTraits.hpp:4,  
from /home/kpwp689/R/x86\_64-pc-linux-gnu-library/3.5/StanHeaders/include/stan/math/rev/core/matrix\_vari.hpp:4,  
from /home/kpwp689/R/x86\_64-pc-linux-gnu-library/3.5/StanHeaders/include/stan/math/rev/core.hpp:14,  
from /home/kpwp689/R/x86\_64-pc-linux-gnu-library/3.5/StanHeaders/include/stan/math/rev/mat.hpp:4,  
from /home/kpwp689/R/x86\_64-pc-linux-gnu-library/3.5/StanHeaders/include/stan/math.hpp:4,  
In addition: Warning message:  
In system(cmd, intern = !verbose) :  
running command ‘/opt/scp/software/mro/3.5.1-foss-2017a/lib64/R/bin/R CMD SHLIB filefd4a3eef7773.cpp 2\> filefd4a3eef7773.cpp.err.txt’ had status 1

---

<div class="post-metadata">

**Author:** ![bgoodri](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bgoodri/32/4451_2.png) [@bgoodri](https://discourse.mc-stan.org/u/bgoodri)\
**Post date:** [July 10, 2019, 2:49pm UTC](https://discourse.mc-stan.org/t/error-in-compilecode/9652/2 "2019-07-10T14:49:12Z")

</div>

In a clean R session, do

```
install.packages("rstan", dependencies = TRUE)
library(rstan)
example(stan_model, run.dontrun = TRUE)

```

and if there is still an error, tell us the line that has `error:` (with the colon) in it.

---

<div class="post-metadata">

**Author:** ![Jimams](https://avatars.discourse-cdn.com/v4/letter/j/3ec8ea/32.png) [@Jimams](https://discourse.mc-stan.org/u/Jimams)\
**Post date:** [July 10, 2019, 3:05pm UTC](https://discourse.mc-stan.org/t/error-in-compilecode/9652/3 "2019-07-10T15:05:56Z")

</div>

Thank you for the prompt reply. I followed the steps and the

`example(stan_model, run.dontrun = TRUE)`

runs smoothly. There was no error there but there is exactly the same error when I try to run my code.

---

<div class="post-metadata">

**Author:** ![bgoodri](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bgoodri/32/4451_2.png) [@bgoodri](https://discourse.mc-stan.org/u/bgoodri)\
**Post date:** [July 10, 2019, 4:28pm UTC](https://discourse.mc-stan.org/t/error-in-compilecode/9652/4 "2019-07-10T16:28:01Z")

</div>

Can you run your code with `verbose = TRUE` and paste the whole compiler error?

---

<div class="post-metadata">

**Author:** ![Jimams](https://avatars.discourse-cdn.com/v4/letter/j/3ec8ea/32.png) [@Jimams](https://discourse.mc-stan.org/u/Jimams)\
**Post date:** [July 11, 2019, 8:01am UTC](https://discourse.mc-stan.org/t/error-in-compilecode/9652/5 "2019-07-11T08:01:44Z")

</div>

I did and I get the same error text as before:

Error in compileCode(f, code, language = language, verbose = verbose) :  
Compilation ERROR, function(s)/method(s) not created! In file included from /home/kpwp689/R/x86\_64-pc-linux-gnu-library/3.5/RcppEigen/include/Eigen/Core:388:0,  
from /home/kpwp689/R/x86\_64-pc-linux-gnu-library/3.5/RcppEigen/include/Eigen/Dense:1,  
from /home/kpwp689/R/x86\_64-pc-linux-gnu-library/3.5/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp:4,  
from /home/kpwp689/R/x86\_64-pc-linux-gnu-library/3.5/StanHeaders/include/stan/math/rev/mat/fun/Eigen\_NumTraits.hpp:4,  
from /home/kpwp689/R/x86\_64-pc-linux-gnu-library/3.5/StanHeaders/include/stan/math/rev/core/matrix\_vari.hpp:4,  
from /home/kpwp689/R/x86\_64-pc-linux-gnu-library/3.5/StanHeaders/include/stan/math/rev/core.hpp:14,  
from /home/kpwp689/R/x86\_64-pc-linux-gnu-library/3.5/StanHeaders/include/stan/math/rev/mat.hpp:4,  
from /home/kpwp689/R/x86\_64-pc-linux-gnu-library/3.5/StanHeaders/include/stan/math.hpp:4,

---

<div class="post-metadata">

**Author:** ![bgoodri](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bgoodri/32/4451_2.png) [@bgoodri](https://discourse.mc-stan.org/u/bgoodri)\
**Post date:** [July 11, 2019, 4:51pm UTC](https://discourse.mc-stan.org/t/error-in-compilecode/9652/6 "2019-07-11T16:51:12Z")

</div>

That is not the whole message. The whole message is something like

```
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/ben/r-devel/library/StanHeaders/lib/' -lStanHeaders
PKG_CPPFLAGS = -I"/home/ben/r-devel/library/Rcpp/include/" -I"/home/ben/r-devel/library/RcppEigen/include/" -I"/home/ben/r-devel/library/RcppEigen/include/unsupported" -I"/home/ben/r-devel/library/BH/include" -I"/home/ben/r-devel/library/StanHeaders/include/src/" -I"/home/ben/r-devel/library/StanHeaders/include/" -I"/home/ben/r-devel/library/rstan/include" -DEIGEN_NO_DEBUG -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 modelc8b1bb6f8d0_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", "modelc8b1bb6f8d0_16a540c6086086816528e4524def24d9");
  26 : reader.add_event(3, 1, "end", "modelc8b1bb6f8d0_16a540c6086086816528e4524def24d9");
  27 : return reader;
  28 : }
  29 : 
  30 : class modelc8b1bb6f8d0_16a540c6086086816528e4524def24d9 : public prob_grad {
  31 : private:
  32 : double y_mean;
  33 : public:
  34 : modelc8b1bb6f8d0_16a540c6086086816528e4524def24d9(stan::io::var_context& context__,
  35 : std::ostream* pstream__ = 0)
  36 : : prob_grad(0) {
  37 : ctor_body(context __, 0, pstream__ );
  38 : }
  39 : 
  40 : modelc8b1bb6f8d0_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__ = "modelc8b1bb6f8d0_16a540c6086086816528e4524def24d9_namespace::modelc8b1bb6f8d0_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<int> vals_i__;
  63 : std::vector<double> vals_r__;
  64 : local_scalar_t __DUMMY_VAR__ (std::numeric_limits<double>::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 : ~modelc8b1bb6f8d0_16a540c6086086816528e4524def24d9() { }
  95 : 
  96 : 
  97 : void transform_inits(const stan::io::var_context& context__,
  98 : std::vector<int>& params_i__,
  99 : std::vector<double>& params_r__,
 100 : std::ostream* pstream__) const {
 101 : typedef double local_scalar_t__;
 102 : stan::io::writer<double> writer__(params_r__, params_i__);
 103 : size_t pos__;
 104 : (void) pos__; // dummy call to supress warning
 105 : std::vector<double> vals_r__;
 106 : std::vector<int> 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_reader__ ());
 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<double> params_r_vec;
 130 : std::vector<int> 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<int>& 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<double>::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<int> 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::vector<std::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 <typename RNG>
 204 : void write_array(RNG& base_rng__,
 205 : std::vector<double>& params_r__,
 206 : std::vector<int>& params_i__,
 207 : std::vector<double>& 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__ = "modelc8b1bb6f8d0_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<double> lp_accum__;
 225 : 
 226 : local_scalar_t __DUMMY_VAR__ (std::numeric_limits<double>::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 <typename RNG>
 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<double> 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<double> vars_vec;
 252 : std::vector<int> 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 "modelc8b1bb6f8d0_16a540c6086086816528e4524def24d9";
 261 : }
 262 : 
 263 : 
 264 : void constrained_param_names(std::vector<std::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::vector<std::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 modelc8b1bb6f8d0_16a540c6086086816528e4524def24d9_namespace::modelc8b1bb6f8d0_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_fit4modelc8b1bb6f8d0_16a540c6086086816528e4524def24d9_mod){
 308 : Rcpp::class_<rstan::stan_fit<modelc8b1bb6f8d0_16a540c6086086816528e4524def24d9_namespace::modelc8b1bb6f8d0_16a540c6086086816528e4524def24d9,
 309 : boost::random::ecuyer1988> >("stan_fit4modelc8b1bb6f8d0_16a540c6086086816528e4524def24d9")
 310 : // .constructor<Rcpp::List>()
 311 : .constructor<SEXP, SEXP, SEXP>()
 312 : // .constructor<SEXP, SEXP>()
 313 : .method("call_sampler",
 314 : &rstan::stan_fit<modelc8b1bb6f8d0_16a540c6086086816528e4524def24d9_namespace::modelc8b1bb6f8d0_16a540c6086086816528e4524def24d9, boost::random::ecuyer1988>::call_sampler)
 315 : .method("param_names",
 316 : &rstan::stan_fit<modelc8b1bb6f8d0_16a540c6086086816528e4524def24d9_namespace::modelc8b1bb6f8d0_16a540c6086086816528e4524def24d9, boost::random::ecuyer1988>::param_names)
 317 : .method("param_names_oi",
 318 : &rstan::stan_fit<modelc8b1bb6f8d0_16a540c6086086816528e4524def24d9_namespace::modelc8b1bb6f8d0_16a540c6086086816528e4524def24d9, boost::random::ecuyer1988>::param_names_oi)
 319 : .method("param_fnames_oi",
 320 : &rstan::stan_fit<modelc8b1bb6f8d0_16a540c6086086816528e4524def24d9_namespace::modelc8b1bb6f8d0_16a540c6086086816528e4524def24d9, boost::random::ecuyer1988>::param_fnames_oi)
 321 : .method("param_dims",
 322 : &rstan::stan_fit<modelc8b1bb6f8d0_16a540c6086086816528e4524def24d9_namespace::modelc8b1bb6f8d0_16a540c6086086816528e4524def24d9, boost::random::ecuyer1988>::param_dims)
 323 : .method("param_dims_oi",
 324 : &rstan::stan_fit<modelc8b1bb6f8d0_16a540c6086086816528e4524def24d9_namespace::modelc8b1bb6f8d0_16a540c6086086816528e4524def24d9, boost::random::ecuyer1988>::param_dims_oi)
 325 : .method("update_param_oi",
 326 : &rstan::stan_fit<modelc8b1bb6f8d0_16a540c6086086816528e4524def24d9_namespace::modelc8b1bb6f8d0_16a540c6086086816528e4524def24d9, boost::random::ecuyer1988>::update_param_oi)
 327 : .method("param_oi_tidx",
 328 : &rstan::stan_fit<modelc8b1bb6f8d0_16a540c6086086816528e4524def24d9_namespace::modelc8b1bb6f8d0_16a540c6086086816528e4524def24d9, boost::random::ecuyer1988>::param_oi_tidx)
 329 : .method("grad_log_prob",
 330 : &rstan::stan_fit<modelc8b1bb6f8d0_16a540c6086086816528e4524def24d9_namespace::modelc8b1bb6f8d0_16a540c6086086816528e4524def24d9, boost::random::ecuyer1988>::grad_log_prob)
 331 : .method("log_prob",
 332 : &rstan::stan_fit<modelc8b1bb6f8d0_16a540c6086086816528e4524def24d9_namespace::modelc8b1bb6f8d0_16a540c6086086816528e4524def24d9, boost::random::ecuyer1988>::log_prob)
 333 : .method("unconstrain_pars",
 334 : &rstan::stan_fit<modelc8b1bb6f8d0_16a540c6086086816528e4524def24d9_namespace::modelc8b1bb6f8d0_16a540c6086086816528e4524def24d9, boost::random::ecuyer1988>::unconstrain_pars)
 335 : .method("constrain_pars",
 336 : &rstan::stan_fit<modelc8b1bb6f8d0_16a540c6086086816528e4524def24d9_namespace::modelc8b1bb6f8d0_16a540c6086086816528e4524def24d9, boost::random::ecuyer1988>::constrain_pars)
 337 : .method("num_pars_unconstrained",
 338 : &rstan::stan_fit<modelc8b1bb6f8d0_16a540c6086086816528e4524def24d9_namespace::modelc8b1bb6f8d0_16a540c6086086816528e4524def24d9, boost::random::ecuyer1988>::num_pars_unconstrained)
 339 : .method("unconstrained_param_names",
 340 : &rstan::stan_fit<modelc8b1bb6f8d0_16a540c6086086816528e4524def24d9_namespace::modelc8b1bb6f8d0_16a540c6086086816528e4524def24d9, boost::random::ecuyer1988>::unconstrained_param_names)
 341 : .method("constrained_param_names",
 342 : &rstan::stan_fit<modelc8b1bb6f8d0_16a540c6086086816528e4524def24d9_namespace::modelc8b1bb6f8d0_16a540c6086086816528e4524def24d9, boost::random::ecuyer1988>::constrained_param_names)
 343 : .method("standalone_gqs",
 344 : &rstan::stan_fit<modelc8b1bb6f8d0_16a540c6086086816528e4524def24d9_namespace::modelc8b1bb6f8d0_16a540c6086086816528e4524def24d9, boost::random::ecuyer1988>::standalone_gqs)
 345 : ;
 346 : }
 347 : 
 348 : // declarations
 349 : extern "C" {
 350 : SEXP filec8b15afd9ad( ) ;
 351 : }
 352 : 
 353 : // definition
 354 : 
 355 : SEXP filec8b15afd9ad( ){
 356 : return Rcpp::wrap("16a540c6086086816528e4524def24d9");
 357 : }
 358 : 
 359 : 
Compilation argument:
 /home/ben/r-devel/bin/R CMD SHLIB filec8b15afd9ad.cpp 2> filec8b15afd9ad.cpp.err.txt 
g++ -Wno-ignored-attributes -std=gnu++14 -I"/home/ben/r-devel/include" -DNDEBUG -I"/home/ben/r-devel/library/Rcpp/include/" -I"/home/ben/r-devel/library/RcppEigen/include/" -I"/home/ben/r-devel/library/RcppEigen/include/unsupported" -I"/home/ben/r-devel/library/BH/include" -I"/home/ben/r-devel/library/StanHeaders/include/src/" -I"/home/ben/r-devel/library/StanHeaders/include/" -I"/home/ben/r-devel/library/rstan/include" -DEIGEN_NO_DEBUG -DBOOST_DISABLE_ASSERTS -I/usr/local/include -fpic -mtune=native -march=native -O3 -g0 -c filec8b15afd9ad.cpp -o filec8b15afd9ad.o

```

---

<div class="post-metadata">

**Author:** ![Jimams](https://avatars.discourse-cdn.com/v4/letter/j/3ec8ea/32.png) [@Jimams](https://discourse.mc-stan.org/u/Jimams)\
**Post date:** [July 15, 2019, 8:12am UTC](https://discourse.mc-stan.org/t/error-in-compilecode/9652/7 "2019-07-15T08:12:22Z")

</div>

Sorry for the late reply. I was away for the weekend. I am now including the whole compilation message:

```
TRANSLATING MODEL '102de305ede91408d5b21b0b0095339c' FROM Stan CODE TO C++ CODE NOW.
successful in parsing the Stan model '102de305ede91408d5b21b0b0095339c'.
COMPILING THE C++ CODE FOR MODEL '102de305ede91408d5b21b0b0095339c' NOW.
OS: x86_64, linux-gnu; rstan: 2.17.3; Rcpp: 1.0.1; inline: 0.3.14 
 >> setting environment variables: 
PKG_LIBS = -L'/home/kpwp689/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/lib' -lStanHeaders
PKG_CPPFLAGS = -I"/home/kpwp689/R/x86_64-pc-linux-gnu-library/3.5/Rcpp/include/" -I"/home/kpwp689/R/x86_64-pc-linux-gnu-library/3.5/RcppEigen/include/" -I"/home/kpwp689/R/x86_64-pc-linux-gnu-library/3.5/RcppEigen/include/unsupported" -I"/home/kpwp689/R/x86_64-pc-linux-gnu-library/3.5/rstan/include/boost_not_in_BH" -I"/opt/scp/software/mro/3.5.1-foss-2017a/lib64/R/site-library/BH/include" -I"/home/kpwp689/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/" -I"/home/kpwp689/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/" -I"/home/kpwp689/R/x86_64-pc-linux-gnu-library/3.5/rstan/include" -DEIGEN_NO_DEBUG -DBOOST_RESULT_OF_USE_TR1 -DBOOST_NO_DECLTYPE -DBOOST_DISABLE_ASSERTS -DBOOST_NO_CXX11_RVALUE_REFERENCES
 >> Program source :

   1 : 
   2 : // includes from the plugin
   3 : 
   4 : 
   5 : // user includes
   6 : #define STAN __SERVICES__ COMMAND_HPP// Code generated by Stan version 2.17.0
   7 : 
   8 : #include <stan/model/model_header.hpp>
   9 : 
  10 : namespace model5c082b6e424b_102de305ede91408d5b21b0b0095339c_namespace {
  11 : 
  12 : using std::istream;
  13 : using std::string;
  14 : using std::stringstream;
  15 : using std::vector;
  16 : using stan::io::dump;
  17 : using stan::math::lgamma;
  18 : using stan::model::prob_grad;
  19 : using namespace stan::math;
  20 : 
  21 : typedef Eigen::Matrix<double,Eigen::Dynamic,1> vector_d;
  22 : typedef Eigen::Matrix<double,1,Eigen::Dynamic> row_vector_d;
  23 : typedef Eigen::Matrix<double,Eigen::Dynamic,Eigen::Dynamic> matrix_d;
  24 : 
  25 : static int current_statement_begin__;
  26 : 
  27 : stan::io::program_reader prog_reader__() {
  28 : stan::io::program_reader reader;
  29 : reader.add_event(0, 0, "start", "model5c082b6e424b_102de305ede91408d5b21b0b0095339c");
  30 : reader.add_event(52, 52, "end", "model5c082b6e424b_102de305ede91408d5b21b0b0095339c");
  31 : return reader;
  32 : }
  33 : 
  34 : template <typename T0 __, typename T1__ , typename T2 __, typename T3__ >
  35 : typename boost::math::tools::promote_args<T0 __, T1__ , T2 __, T3__ >::type
  36 : dz_dt(const T0__& t,
  37 : const std::vector<T1__>& z,
  38 : const std::vector<T2__>& theta,
  39 : const std::vector<T3__>& x_r,
  40 : const std::vector<int>& x_i, std::ostream* pstream__) {
  41 : typedef typename boost::math::tools::promote_args<T0 __, T1__ , T2 __, T3__ >::type fun_scalar_t__;
  42 : typedef fun_scalar_t __fun_return_scalar_t__ ;
  43 : const static bool propto__ = true;
  44 : (void) propto__;
  45 : fun_scalar_t __DUMMY_VAR__ (std::numeric_limits<double>::quiet_NaN());
  46 : (void) DUMMY_VAR__; // suppress unused var warning
  47 : 
  48 : int current_statement_begin__ = -1;
  49 : try {
  50 : {
  51 : current_statement_begin__ = 8;
  52 : fun_scalar_t__ V;
  53 : (void) V; // dummy to suppress unused var warning
  54 : 
  55 : stan::math::initialize(V, std::numeric_limits<double>::quiet_NaN());
  56 : stan::math::fill(V,DUMMY_VAR__);
  57 : stan::math::assign(V,get_base1(z,1,"z",1));
  58 : current_statement_begin__ = 9;
  59 : fun_scalar_t__ K;
  60 : (void) K; // dummy to suppress unused var warning
  61 : 
  62 : stan::math::initialize(K, std::numeric_limits<double>::quiet_NaN());
  63 : stan::math::fill(K,DUMMY_VAR__);
  64 : stan::math::assign(K,get_base1(theta,1,"theta",1));
  65 : current_statement_begin__ = 11;
  66 : fun_scalar_t__ dV_dt;
  67 : (void) dV_dt; // dummy to suppress unused var warning
  68 : 
  69 : stan::math::initialize(dV_dt, std::numeric_limits<double>::quiet_NaN());
  70 : stan::math::fill(dV_dt,DUMMY_VAR__);
  71 : stan::math::assign(dV_dt,(K * V));
  72 : 
  73 : 
  74 : current_statement_begin__ = 13;
  75 : return stan::math::promote_scalar<fun_return_scalar_t__>(dV_dt);
  76 : }
  77 : } catch (const std::exception& e) {
  78 : stan::lang::rethrow_located(e, current_statement_begin __, prog_reader__ ());
  79 : // Next line prevents compiler griping about no return
  80 : throw std::runtime_error(" ***IF YOU SEE THIS, PLEASE REPORT A BUG***");
  81 : }
  82 : }
  83 : 
  84 : 
  85 : struct dz_dt_functor__ {
  86 : template <typename T0 __, typename T1__ , typename T2 __, typename T3__ >
  87 : typename boost::math::tools::promote_args<T0 __, T1__ , T2 __, T3__ >::type
  88 : operator()(const T0__& t,
  89 : const std::vector<T1__>& z,
  90 : const std::vector<T2__>& theta,
  91 : const std::vector<T3__>& x_r,
  92 : const std::vector<int>& x_i, std::ostream* pstream__) const {
  93 : return dz_dt(t, z, theta, x_r, x_i, pstream__);
  94 : }
  95 : };
  96 : 
  97 : class model5c082b6e424b_102de305ede91408d5b21b0b0095339c : public prob_grad {
  98 : private:
  99 : int N;
 100 : vector<double> ts;
 101 : vector<double> y_init;
 102 : vector<vector<double> > y;
 103 : public:
 104 : model5c082b6e424b_102de305ede91408d5b21b0b0095339c(stan::io::var_context& context__,
 105 : std::ostream* pstream__ = 0)
 106 : : prob_grad(0) {
 107 : ctor_body(context __, 0, pstream__ );
 108 : }
 109 : 
 110 : model5c082b6e424b_102de305ede91408d5b21b0b0095339c(stan::io::var_context& context__,
 111 : unsigned int random_seed__,
 112 : std::ostream* pstream__ = 0)
 113 : : prob_grad(0) {
 114 : ctor_body(context __, random_seed__ , pstream__);
 115 : }
 116 : 
 117 : void ctor_body(stan::io::var_context& context__,
 118 : unsigned int random_seed__,
 119 : std::ostream* pstream__) {
 120 : boost::ecuyer1988 base_rng__ =
 121 : stan::services::util::create_rng(random_seed__, 0);
 122 : (void) base_rng__; // suppress unused var warning
 123 : 
 124 : current_statement_begin__ = -1;
 125 : 
 126 : static const char* function__ = "model5c082b6e424b_102de305ede91408d5b21b0b0095339c_namespace::model5c082b6e424b_102de305ede91408d5b21b0b0095339c";
 127 : (void) function__; // dummy to suppress unused var warning
 128 : size_t pos__;
 129 : (void) pos__; // dummy to suppress unused var warning
 130 : std::vector<int> vals_i__;
 131 : std::vector<double> vals_r__;
 132 : double DUMMY_VAR__(std::numeric_limits<double>::quiet_NaN());
 133 : (void) DUMMY_VAR__; // suppress unused var warning
 134 : 
 135 : // initialize member variables
 136 : try {
 137 : current_statement_begin__ = 18;
 138 : context__.validate_dims("data initialization", "N", "int", context__.to_vec());
 139 : N = int(0);
 140 : vals_i __= context__.vals_i("N");
 141 : pos__ = 0;
 142 : N = vals_i__[pos__++];
 143 : current_statement_begin__ = 19;
 144 : validate_non_negative_index("ts", "N", N);
 145 : context__.validate_dims("data initialization", "ts", "double", context__.to_vec(N));
 146 : validate_non_negative_index("ts", "N", N);
 147 : ts = std::vector<double>(N,double(0));
 148 : vals_r __= context__.vals_r("ts");
 149 : pos__ = 0;
 150 : size_t ts_limit_0__ = N;
 151 : for (size_t i_0 __= 0; i_0__ < ts_limit_0 __; ++i_0__ ) {
 152 : ts[i_0__] = vals_r__[pos__++];
 153 : }
 154 : current_statement_begin__ = 20;
 155 : validate_non_negative_index("y_init", "1", 1);
 156 : context__.validate_dims("data initialization", "y_init", "double", context__.to_vec(1));
 157 : validate_non_negative_index("y_init", "1", 1);
 158 : y_init = std::vector<double>(1,double(0));
 159 : vals_r __= context__.vals_r("y_init");
 160 : pos__ = 0;
 161 : size_t y_init_limit_0__ = 1;
 162 : for (size_t i_0 __= 0; i_0__ < y_init_limit_0 __; ++i_0__ ) {
 163 : y_init[i_0__] = vals_r__[pos__++];
 164 : }
 165 : current_statement_begin__ = 21;
 166 : validate_non_negative_index("y", "N", N);
 167 : validate_non_negative_index("y", "1", 1);
 168 : context__.validate_dims("data initialization", "y", "double", context__.to_vec(N,1));
 169 : validate_non_negative_index("y", "N", N);
 170 : validate_non_negative_index("y", "1", 1);
 171 : y = std::vector<std::vector<double> >(N,std::vector<double>(1,double(0)));
 172 : vals_r __= context__.vals_r("y");
 173 : pos__ = 0;
 174 : size_t y_limit_1__ = 1;
 175 : for (size_t i_1 __= 0; i_1__ < y_limit_1 __; ++i_1__ ) {
 176 : size_t y_limit_0__ = N;
 177 : for (size_t i_0 __= 0; i_0__ < y_limit_0 __; ++i_0__ ) {
 178 : y[i_0__][i_1__] = vals_r__[pos__++];
 179 : }
 180 : }
 181 : 
 182 : // validate, data variables
 183 : current_statement_begin__ = 18;
 184 : check_greater_or_equal(function__,"N",N,0);
 185 : current_statement_begin__ = 19;
 186 : current_statement_begin__ = 20;
 187 : current_statement_begin__ = 21;
 188 : for (int k0 __= 0; k0__ < N; ++k0__) {
 189 : for (int k1 __= 0; k1__ < 1; ++k1__) {
 190 : check_greater_or_equal(function__,"y[k0__][k1__]",y[k0__][k1__],0);
 191 : }
 192 : }
 193 : // initialize data variables
 194 : 
 195 : 
 196 : // validate transformed data
 197 : 
 198 : // validate, set parameter ranges
 199 : num_params_r__ = 0U;
 200 : param_ranges_i__.clear();
 201 : current_statement_begin__ = 25;
 202 : validate_non_negative_index("theta", "1", 1);
 203 : num_params_r__ += 1;
 204 : current_statement_begin__ = 26;
 205 : validate_non_negative_index("z_init", "1", 1);
 206 : num_params_r__ += 1;
 207 : current_statement_begin__ = 27;
 208 : validate_non_negative_index("sigma", "1", 1);
 209 : num_params_r__ += 1;
 210 : } catch (const std::exception& e) {
 211 : stan::lang::rethrow_located(e, current_statement_begin __, prog_reader__ ());
 212 : // Next line prevents compiler griping about no return
 213 : throw std::runtime_error(" ***IF YOU SEE THIS, PLEASE REPORT A BUG***");
 214 : }
 215 : }
 216 : 
 217 : ~model5c082b6e424b_102de305ede91408d5b21b0b0095339c() { }
 218 : 
 219 : 
 220 : void transform_inits(const stan::io::var_context& context__,
 221 : std::vector<int>& params_i__,
 222 : std::vector<double>& params_r__,
 223 : std::ostream* pstream__) const {
 224 : stan::io::writer<double> writer__(params_r__,params_i__);
 225 : size_t pos__;
 226 : (void) pos__; // dummy call to supress warning
 227 : std::vector<double> vals_r__;
 228 : std::vector<int> vals_i__;
 229 : 
 230 : if (!(context__.contains_r("theta")))
 231 : throw std::runtime_error("variable theta missing");
 232 : vals_r __= context__.vals_r("theta");
 233 : pos__ = 0U;
 234 : validate_non_negative_index("theta", "1", 1);
 235 : context__.validate_dims("initialization", "theta", "double", context__.to_vec(1));
 236 : std::vector<double> theta(1,double(0));
 237 : for (int i0 __= 0U; i0__ < 1; ++i0__)
 238 : theta[i0__] = vals_r__[pos__++];
 239 : for (int i0 __= 0U; i0__ < 1; ++i0__)
 240 : try {
 241 : writer__.scalar_lb_unconstrain(0,theta[i0__]);
 242 : } catch (const std::exception& e) { 
 243 : throw std::runtime_error(std::string("Error transforming variable theta: ") + e.what());
 244 : }
 245 : 
 246 : if (!(context__.contains_r("z_init")))
 247 : throw std::runtime_error("variable z_init missing");
 248 : vals_r __= context__.vals_r("z_init");
 249 : pos__ = 0U;
 250 : validate_non_negative_index("z_init", "1", 1);
 251 : context__.validate_dims("initialization", "z_init", "double", context__.to_vec(1));
 252 : std::vector<double> z_init(1,double(0));
 253 : for (int i0 __= 0U; i0__ < 1; ++i0__)
 254 : z_init[i0__] = vals_r__[pos__++];
 255 : for (int i0 __= 0U; i0__ < 1; ++i0__)
 256 : try {
 257 : writer__.scalar_lb_unconstrain(0,z_init[i0__]);
 258 : } catch (const std::exception& e) { 
 259 : throw std::runtime_error(std::string("Error transforming variable z_init: ") + e.what());
 260 : }
 261 : 
 262 : if (!(context__.contains_r("sigma")))
 263 : throw std::runtime_error("variable sigma missing");
 264 : vals_r __= context__.vals_r("sigma");
 265 : pos__ = 0U;
 266 : validate_non_negative_index("sigma", "1", 1);
 267 : context__.validate_dims("initialization", "sigma", "double", context__.to_vec(1));
 268 : std::vector<double> sigma(1,double(0));
 269 : for (int i0 __= 0U; i0__ < 1; ++i0__)
 270 : sigma[i0__] = vals_r__[pos__++];
 271 : for (int i0 __= 0U; i0__ < 1; ++i0__)
 272 : try {
 273 : writer__.scalar_lb_unconstrain(0,sigma[i0__]);
 274 : } catch (const std::exception& e) { 
 275 : throw std::runtime_error(std::string("Error transforming variable sigma: ") + e.what());
 276 : }
 277 : 
 278 : params_r __= writer__.data_r();
 279 : params_i __= writer__.data_i();
 280 : }
 281 : 
 282 : void transform_inits(const stan::io::var_context& context,
 283 : Eigen::Matrix<double,Eigen::Dynamic,1>& params_r,
 284 : std::ostream* pstream__) const {
 285 : std::vector<double> params_r_vec;
 286 : std::vector<int> params_i_vec;
 287 : transform_inits(context, params_i_vec, params_r_vec, pstream__);
 288 : params_r.resize(params_r_vec.size());
 289 : for (int i = 0; i < params_r.size(); ++i)
 290 : params_r(i) = params_r_vec[i];
 291 : }
 292 : 
 293 : 
 294 : template <bool propto __, bool jacobian__ , typename T__>
 295 : T__log_prob(vector<T__>& params_r__,
 296 : vector<int>& params_i__,
 297 : std::ostream* pstream__ = 0) const {
 298 : 
 299 : T __DUMMY_VAR__ (std::numeric_limits<double>::quiet_NaN());
 300 : (void) DUMMY_VAR__; // suppress unused var warning
 301 : 
 302 : T __lp__ (0.0);
 303 : stan::math::accumulator<T __> lp_accum__ ;
 304 : 
 305 : try {
 306 : // model parameters
 307 : stan::io::reader<T __> in__ (params_r __,params_i__ );
 308 : 
 309 : vector<T__> theta;
 310 : size_t dim_theta_0__ = 1;
 311 : theta.reserve(dim_theta_0__);
 312 : for (size_t k_0 __= 0; k_0__ < dim_theta_0 __; ++k_0__ ) {
 313 : if (jacobian__)
 314 : theta.push_back(in__.scalar_lb_constrain(0,lp__));
 315 : else
 316 : theta.push_back(in__.scalar_lb_constrain(0));
 317 : }
 318 : 
 319 : vector<T__> z_init;
 320 : size_t dim_z_init_0__ = 1;
 321 : z_init.reserve(dim_z_init_0__);
 322 : for (size_t k_0 __= 0; k_0__ < dim_z_init_0 __; ++k_0__ ) {
 323 : if (jacobian__)
 324 : z_init.push_back(in__.scalar_lb_constrain(0,lp__));
 325 : else
 326 : z_init.push_back(in__.scalar_lb_constrain(0));
 327 : }
 328 : 
 329 : vector<T__> sigma;
 330 : size_t dim_sigma_0__ = 1;
 331 : sigma.reserve(dim_sigma_0__);
 332 : for (size_t k_0 __= 0; k_0__ < dim_sigma_0 __; ++k_0__ ) {
 333 : if (jacobian__)
 334 : sigma.push_back(in__.scalar_lb_constrain(0,lp__));
 335 : else
 336 : sigma.push_back(in__.scalar_lb_constrain(0));
 337 : }
 338 : 
 339 : 
 340 : // transformed parameters
 341 : current_statement_begin__ = 31;
 342 : validate_non_negative_index("z", "N", N);
 343 : validate_non_negative_index("z", "1", 1);
 344 : vector<vector<T__> > z(N, (vector<T__>(1)));
 345 : stan::math::initialize(z, DUMMY_VAR__);
 346 : stan::math::fill(z,DUMMY_VAR__);
 347 : stan::math::assign(z,integrate_ode_bdf(dz_dt_functor__(), z_init, 0, ts, theta, rep_array(0.0,0), rep_array(0,0), pstream__, 1.0000000000000001e-05, 0.001, 500.0));
 348 : 
 349 : 
 350 : 
 351 : // validate transformed parameters
 352 : for (int i0 __= 0; i0__ < N; ++i0__) {
 353 : for (int i1 __= 0; i1__ < 1; ++i1__) {
 354 : if (stan::math::is_uninitialized(z[i0__][i1__])) {
 355 : std::stringstream msg__;
 356 : msg__<< "Undefined transformed parameter: z" << '[' << i0__ << ']' << '[' << i1__ << ']';
 357 : throw std::runtime_error(msg__.str());
 358 : }
 359 : }
 360 : }
 361 : 
 362 : const char* function__ = "validate transformed params";
 363 : (void) function__; // dummy to suppress unused var warning
 364 : current_statement_begin__ = 31;
 365 : 

```

---

<div class="post-metadata">

**Author:** ![Jimams](https://avatars.discourse-cdn.com/v4/letter/j/3ec8ea/32.png) [@Jimams](https://discourse.mc-stan.org/u/Jimams)\
**Post date:** [July 15, 2019, 8:12am UTC](https://discourse.mc-stan.org/t/error-in-compilecode/9652/8 "2019-07-15T08:12:39Z")

</div>

```
 366 : // model body
 367 : 
 368 : current_statement_begin__ = 38;
 369 : lp_accum__.add(lognormal_log<propto__>(get_base1(theta,1,"theta",1), -(2), 0.5));
 370 : current_statement_begin__ = 39;
 371 : lp_accum__.add(lognormal_log<propto__>(sigma, -(1), 1));
 372 : current_statement_begin__ = 40;
 373 : lp_accum__.add(lognormal_log<propto__>(get_base1(z_init,1,"z_init",1), -(1.3999999999999999), 0.5));
 374 : current_statement_begin__ = 41;
 375 : lp_accum__.add(lognormal_log<propto__>(get_base1(y_init,1,"y_init",1), log(get_base1(z_init,1,"z_init",1)), get_base1(sigma,1,"sigma",1)));
 376 : current_statement_begin__ = 42;
 377 : lp_accum__.add(lognormal_log<propto__>(stan::model::rvalue(y, stan::model::cons_list(stan::model::index_omni(), stan::model::cons_list(stan::model::index_uni(1), stan::model::nil_index_list())), "y"), log(stan::model::rvalue(z, stan::model::cons_list(stan::model::index_omni(), stan::model::cons_list(stan::model::index_uni(1), stan::model::nil_index_list())), "z")), get_base1(sigma,1,"sigma",1)));
 378 : 
 379 : } catch (const std::exception& e) {
 380 : stan::lang::rethrow_located(e, current_statement_begin __, prog_reader__ ());
 381 : // Next line prevents compiler griping about no return
 382 : throw std::runtime_error(" ***IF YOU SEE THIS, PLEASE REPORT A BUG***");
 383 : }
 384 : 
 385 : lp_accum__.add(lp__);
 386 : return lp_accum__.sum();
 387 : 
 388 : } // log_prob()
 389 : 
 390 : template <bool propto, bool jacobian, typename T_>
 391 : T_ log_prob(Eigen::Matrix<T_,Eigen::Dynamic,1>& params_r,
 392 : std::ostream* pstream = 0) const {
 393 : std::vector<T_> vec_params_r;
 394 : vec_params_r.reserve(params_r.size());
 395 : for (int i = 0; i < params_r.size(); ++i)
 396 : vec_params_r.push_back(params_r(i));
 397 : std::vector<int> vec_params_i;
 398 : return log_prob<propto,jacobian,T_>(vec_params_r, vec_params_i, pstream);
 399 : }
 400 : 
 401 : 
 402 : void get_param_names(std::vector<std::string>& names__) const {
 403 : names__.resize(0);
 404 : names__.push_back("theta");
 405 : names__.push_back("z_init");
 406 : names__.push_back("sigma");
 407 : names__.push_back("z");
 408 : names__.push_back("y_init_rep");
 409 : names__.push_back("y_rep");
 410 : }
 411 : 
 412 : 
 413 : void get_dims(std::vector<std::vector<size_t> >& dimss__) const {
 414 : dimss__.resize(0);
 415 : std::vector<size_t> dims__;
 416 : dims__.resize(0);
 417 : dims__.push_back(1);
 418 : dimss__.push_back(dims__);
 419 : dims__.resize(0);
 420 : dims__.push_back(1);
 421 : dimss__.push_back(dims__);
 422 : dims__.resize(0);
 423 : dims__.push_back(1);
 424 : dimss__.push_back(dims__);
 425 : dims__.resize(0);
 426 : dims__.push_back(N);
 427 : dims__.push_back(1);
 428 : dimss__.push_back(dims__);
 429 : dims__.resize(0);
 430 : dims__.push_back(1);
 431 : dimss__.push_back(dims__);
 432 : dims__.resize(0);
 433 : dims__.push_back(N);
 434 : dims__.push_back(1);
 435 : dimss__.push_back(dims__);
 436 : }
 437 : 
 438 : template <typename RNG>
 439 : void write_array(RNG& base_rng__,
 440 : std::vector<double>& params_r__,
 441 : std::vector<int>& params_i__,
 442 : std::vector<double>& vars__,
 443 : bool include_tparams__ = true,
 444 : bool include_gqs__ = true,
 445 : std::ostream* pstream__ = 0) const {
 446 : vars__.resize(0);
 447 : stan::io::reader<double> in__(params_r__,params_i__);
 448 : static const char* function__ = "model5c082b6e424b_102de305ede91408d5b21b0b0095339c_namespace::write_array";
 449 : (void) function__; // dummy to suppress unused var warning
 450 : // read-transform, write parameters
 451 : vector<double> theta;
 452 : size_t dim_theta_0__ = 1;
 453 : for (size_t k_0 __= 0; k_0__ < dim_theta_0 __; ++k_0__ ) {
 454 : theta.push_back(in__.scalar_lb_constrain(0));
 455 : }
 456 : vector<double> z_init;
 457 : size_t dim_z_init_0__ = 1;
 458 : for (size_t k_0 __= 0; k_0__ < dim_z_init_0 __; ++k_0__ ) {
 459 : z_init.push_back(in__.scalar_lb_constrain(0));
 460 : }
 461 : vector<double> sigma;
 462 : size_t dim_sigma_0__ = 1;
 463 : for (size_t k_0 __= 0; k_0__ < dim_sigma_0 __; ++k_0__ ) {
 464 : sigma.push_back(in__.scalar_lb_constrain(0));
 465 : }
 466 : for (int k_0 __= 0; k_0__ < 1; ++k_0__) {
 467 : vars__.push_back(theta[k_0__]);
 468 : }
 469 : for (int k_0 __= 0; k_0__ < 1; ++k_0__) {
 470 : vars__.push_back(z_init[k_0__]);
 471 : }
 472 : for (int k_0 __= 0; k_0__ < 1; ++k_0__) {
 473 : vars__.push_back(sigma[k_0__]);
 474 : }
 475 : 
 476 : if (!include_tparams__) return;
 477 : // declare and define transformed parameters
 478 : double lp__ = 0.0;
 479 : (void) lp__; // dummy to suppress unused var warning
 480 : stan::math::accumulator<double> lp_accum__;
 481 : 
 482 : double DUMMY_VAR__(std::numeric_limits<double>::quiet_NaN());
 483 : (void) DUMMY_VAR__; // suppress unused var warning
 484 : 
 485 : try {
 486 : current_statement_begin__ = 31;
 487 : validate_non_negative_index("z", "N", N);
 488 : validate_non_negative_index("z", "1", 1);
 489 : vector<vector<double> > z(N, (vector<double>(1, 0.0)));
 490 : stan::math::initialize(z, std::numeric_limits<double>::quiet_NaN());
 491 : stan::math::fill(z,DUMMY_VAR__);
 492 : stan::math::assign(z,integrate_ode_bdf(dz_dt_functor__(), z_init, 0, ts, theta, rep_array(0.0,0), rep_array(0,0), pstream__, 1.0000000000000001e-05, 0.001, 500.0));
 493 : 
 494 : 
 495 : 
 496 : // validate transformed parameters
 497 : current_statement_begin__ = 31;
 498 : 
 499 : // write transformed parameters
 500 : for (int k_1 __= 0; k_1__ < 1; ++k_1__) {
 501 : for (int k_0 __= 0; k_0__ < N; ++k_0__) {
 502 : vars__.push_back(z[k_0__][k_1__]);
 503 : }
 504 : }
 505 : 
 506 : if (!include_gqs__) return;
 507 : // declare and define generated quantities
 508 : current_statement_begin__ = 46;
 509 : validate_non_negative_index("y_init_rep", "1", 1);
 510 : vector<double> y_init_rep(1, 0.0);
 511 : stan::math::initialize(y_init_rep, std::numeric_limits<double>::quiet_NaN());
 512 : stan::math::fill(y_init_rep,DUMMY_VAR__);
 513 : current_statement_begin__ = 47;
 514 : validate_non_negative_index("y_rep", "N", N);
 515 : validate_non_negative_index("y_rep", "1", 1);
 516 : vector<vector<double> > y_rep(N, (vector<double>(1, 0.0)));
 517 : stan::math::initialize(y_rep, std::numeric_limits<double>::quiet_NaN());
 518 : stan::math::fill(y_rep,DUMMY_VAR__);
 519 : 
 520 : 
 521 : current_statement_begin__ = 49;
 522 : stan::math::assign(get_base1_lhs(y_init_rep,1,"y_init_rep",1), lognormal_rng(log(get_base1(z_init,1,"z_init",1)),get_base1(sigma,1,"sigma",1), base_rng__));
 523 : current_statement_begin__ = 50;
 524 : for (int n = 1; n <= N; ++n) {
 525 : current_statement_begin__ = 51;
 526 : stan::math::assign(get_base1_lhs(get_base1_lhs(y_rep,n,"y_rep",1),1,"y_rep",2), lognormal_rng(log(get_base1(get_base1(z,n,"z",1),1,"z",2)),get_base1(sigma,1,"sigma",1), base_rng__));
 527 : }
 528 : 
 529 : // validate generated quantities
 530 : current_statement_begin__ = 46;
 531 : current_statement_begin__ = 47;
 532 : 
 533 : // write generated quantities
 534 : for (int k_0 __= 0; k_0__ < 1; ++k_0__) {
 535 : vars__.push_back(y_init_rep[k_0__]);
 536 : }
 537 : for (int k_1 __= 0; k_1__ < 1; ++k_1__) {
 538 : for (int k_0 __= 0; k_0__ < N; ++k_0__) {
 539 : vars__.push_back(y_rep[k_0__][k_1__]);
 540 : }
 541 : }
 542 : 
 543 : } catch (const std::exception& e) {
 544 : stan::lang::rethrow_located(e, current_statement_begin __, prog_reader__ ());
 545 : // Next line prevents compiler griping about no return
 546 : throw std::runtime_error(" ***IF YOU SEE THIS, PLEASE REPORT A BUG***");
 547 : }
 548 : }
 549 : 
 550 : template <typename RNG>
 551 : void write_array(RNG& base_rng,
 552 : Eigen::Matrix<double,Eigen::Dynamic,1>& params_r,
 553 : Eigen::Matrix<double,Eigen::Dynamic,1>& vars,
 554 : bool include_tparams = true,
 555 : bool include_gqs = true,
 556 : std::ostream* pstream = 0) const {
 557 : std::vector<double> params_r_vec(params_r.size());
 558 : for (int i = 0; i < params_r.size(); ++i)
 559 : params_r_vec[i] = params_r(i);
 560 : std::vector<double> vars_vec;
 561 : std::vector<int> params_i_vec;
 562 : write_array(base_rng,params_r_vec,params_i_vec,vars_vec,include_tparams,include_gqs,pstream);
 563 : vars.resize(vars_vec.size());
 564 : for (int i = 0; i < vars.size(); ++i)
 565 : vars(i) = vars_vec[i];
 566 : }
 567 : 
 568 : static std::string model_name() {
 569 : return "model5c082b6e424b_102de305ede91408d5b21b0b0095339c";
 570 : }
 571 : 
 572 : 
 573 : void constrained_param_names(std::vector<std::string>& param_names__,
 574 : bool include_tparams__ = true,
 575 : bool include_gqs__ = true) const {
 576 : std::stringstream param_name_stream__;
 577 : for (int k_0 __= 1; k_0__ <= 1; ++k_0__) {
 578 : param_name_stream__.str(std::string());
 579 : param_name_stream __<< "theta" << '.' << k_0__ ;
 580 : param_names__.push_back(param_name_stream__.str());
 581 : }
 582 : for (int k_0 __= 1; k_0__ <= 1; ++k_0__) {
 583 : param_name_stream__.str(std::string());
 584 : param_name_stream __<< "z_init" << '.' << k_0__ ;
 585 : param_names__.push_back(param_name_stream__.str());
 586 : }
 587 : for (int k_0 __= 1; k_0__ <= 1; ++k_0__) {
 588 : param_name_stream__.str(std::string());
 589 : param_name_stream __<< "sigma" << '.' << k_0__ ;
 590 : param_names__.push_back(param_name_stream__.str());
 591 : }
 592 : 
 593 : if (!include_gqs __&& !include_tparams__ ) return;
 594 : for (int k_1 __= 1; k_1__ <= 1; ++k_1__) {
 595 : for (int k_0 __= 1; k_0__ <= N; ++k_0__) {
 596 : param_name_stream__.str(std::string());
 597 : param_name_stream __<< "z" << '.' << k_0__ << '.' << k_1__;
 598 : param_names__.push_back(param_name_stream__.str());
 599 : }
 600 : }
 601 : 
 602 : if (!include_gqs__) return;
 603 : for (int k_0 __= 1; k_0__ <= 1; ++k_0__) {
 604 : param_name_stream__.str(std::string());
 605 : param_name_stream __<< "y_init_rep" << '.' << k_0__ ;
 606 : param_names__.push_back(param_name_stream__.str());
 607 : }
 608 : for (int k_1 __= 1; k_1__ <= 1; ++k_1__) {
 609 : for (int k_0 __= 1; k_0__ <= N; ++k_0__) {
 610 : param_name_stream__.str(std::string());
 611 : param_name_stream __<< "y_rep" << '.' << k_0__ << '.' << k_1__;
 612 : param_names__.push_back(param_name_stream__.str());
 613 : }
 614 : }
 615 : }
 616 : 
 617 : 
 618 : void unconstrained_param_names(std::vector<std::string>& param_names__,
 619 : bool include_tparams__ = true,
 620 : bool include_gqs__ = true) const {
 621 : std::stringstream param_name_stream__;
 622 : for (int k_0 __= 1; k_0__ <= 1; ++k_0__) {
 623 : param_name_stream__.str(std::string());
 624 : param_name_stream __<< "theta" << '.' << k_0__ ;
 625 : param_names__.push_back(param_name_stream__.str());
 626 : }
 627 : for (int k_0 __= 1; k_0__ <= 1; ++k_0__) {
 628 : param_name_stream__.str(std::string());
 629 : param_name_stream __<< "z_init" << '.' << k_0__ ;
 630 : param_names__.push_back(param_name_stream__.str());
 631 : }
 632 : for (int k_0 __= 1; k_0__ <= 1; ++k_0__) {
 633 : param_name_stream__.str(std::string());
 634 : param_name_stream __<< "sigma" << '.' << k_0__ ;
 635 : param_names__.push_back(param_name_stream__.str());
 636 : }
 637 : 
 638 : if (!include_gqs __&& !include_tparams__ ) return;
 639 : for (int k_1 __= 1; k_1__ <= 1; ++k_1__) {
 640 : for (int k_0 __= 1; k_0__ <= N; ++k_0__) {
 641 : param_name_stream__.str(std::string());
 642 : param_name_stream __<< "z" << '.' << k_0__ << '.' << k_1__;
 643 : param_names__.push_back(param_name_stream__.str());
 644 : }
 645 : }
 646 : 
 647 : if (!include_gqs__) return;
 648 : for (int k_0 __= 1; k_0__ <= 1; ++k_0__) {
 649 : param_name_stream__.str(std::string());
 650 : param_name_stream __<< "y_init_rep" << '.' << k_0__ ;
 651 : param_names__.push_back(param_name_stream__.str());
 652 : }
 653 : for (int k_1 __= 1; k_1__ <= 1; ++k_1__) {
 654 : for (int k_0 __= 1; k_0__ <= N; ++k_0__) {
 655 : param_name_stream__.str(std::string());
 656 : param_name_stream __<< "y_rep" << '.' << k_0__ << '.' << k_1__;
 657 : param_names__.push_back(param_name_stream__.str());
 658 : }
 659 : }
 660 : }
 661 : 
 662 : }; // model
 663 : 
 664 : }
 665 : 
 666 : typedef model5c082b6e424b_102de305ede91408d5b21b0b0095339c_namespace::model5c082b6e424b_102de305ede91408d5b21b0b0095339c stan_model;
 667 : 
 668 : #include <rstan/rstaninc.hpp>
 669 : /**
 670 : * Define Rcpp Module to expose stan_fit's functions to R.
 671 : */
 672 : RCPP_MODULE(stan_fit4model5c082b6e424b_102de305ede91408d5b21b0b0095339c_mod){
 673 : Rcpp::class_<rstan::stan_fit<model5c082b6e424b_102de305ede91408d5b21b0b0095339c_namespace::model5c082b6e424b_102de305ede91408d5b21b0b0095339c,
 674 : boost::random::ecuyer1988> >("stan_fit4model5c082b6e424b_102de305ede91408d5b21b0b0095339c")
 675 : // .constructor<Rcpp::List>()
 676 : .constructor<SEXP, SEXP, SEXP>()
 677 : // .constructor<SEXP, SEXP>()
 678 : .method("call_sampler",
 679 : &rstan::stan_fit<model5c082b6e424b_102de305ede91408d5b21b0b0095339c_namespace::model5c082b6e424b_102de305ede91408d5b21b0b0095339c, boost::random::ecuyer1988>::call_sampler)
 680 : .method("param_names",
 681 : &rstan::stan_fit<model5c082b6e424b_102de305ede91408d5b21b0b0095339c_namespace::model5c082b6e424b_102de305ede91408d5b21b0b0095339c, boost::random::ecuyer1988>::param_names)
 682 : .method("param_names_oi",
 683 : &rstan::stan_fit<model5c082b6e424b_102de305ede91408d5b21b0b0095339c_namespace::model5c082b6e424b_102de305ede91408d5b21b0b0095339c, boost::random::ecuyer1988>::param_names_oi)
 684 : .method("param_fnames_oi",
 685 : &rstan::stan_fit<model5c082b6e424b_102de305ede91408d5b21b0b0095339c_namespace::model5c082b6e424b_102de305ede91408d5b21b0b0095339c, boost::random::ecuyer1988>::param_fnames_oi)
 686 : .method("param_dims",
 687 : &rstan::stan_fit<model5c082b6e424b_102de305ede91408d5b21b0b0095339c_namespace::model5c082b6e424b_102de305ede91408d5b21b0b0095339c, boost::random::ecuyer1988>::param_dims)
 688 : .method("param_dims_oi",
 689 : &rstan::stan_fit<model5c082b6e424b_102de305ede91408d5b21b0b0095339c_namespace::model5c082b6e424b_102de305ede91408d5b21b0b0095339c, boost::random::ecuyer1988>::param_dims_oi)
 690 : .method("update_param_oi",
 691 : &rstan::stan_fit<model5c082b6e424b_102de305ede91408d5b21b0b0095339c_namespace::model5c082b6e424b_102de305ede91408d5b21b0b0095339c, boost::random::ecuyer1988>::update_param_oi)
 692 : .method("param_oi_tidx",
 693 : &rstan::stan_fit<model5c082b6e424b_102de305ede91408d5b21b0b0095339c_namespace::model5c082b6e424b_102de305ede91408d5b21b0b0095339c, boost::random::ecuyer1988>::param_oi_tidx)
 694 : .method("grad_log_prob",
 695 : &rstan::stan_fit<model5c082b6e424b_102de305ede91408d5b21b0b0095339c_namespace::model5c082b6e424b_102de305ede91408d5b21b0b0095339c, boost::random::ecuyer1988>::grad_log_prob)
 696 : .method("log_prob",
 697 : &rstan::stan_fit<model5c082b6e424b_102de305ede91408d5b21b0b0095339c_namespace::model5c082b6e424b_102de305ede91408d5b21b0b0095339c, boost::random::ecuyer1988>::log_prob)
 698 : .method("unconstrain_pars",
 699 : &rstan::stan_fit<model5c082b6e424b_102de305ede91408d5b21b0b0095339c_namespace::model5c082b6e424b_102de305ede91408d5b21b0b0095339c, boost::random::ecuyer1988>::unconstrain_pars)
 700 : .method("constrain_pars",
 701 : &rstan::stan_fit<model5c082b6e424b_102de305ede91408d5b21b0b0095339c_namespace::model5c082b6e424b_102de305ede91408d5b21b0b0095339c, boost::random::ecuyer1988>::constrain_pars)
 702 : .method("num_pars_unconstrained",
 703 : &rstan::stan_fit<model5c082b6e424b_102de305ede91408d5b21b0b0095339c_namespace::model5c082b6e424b_102de305ede91408d5b21b0b0095339c, boost::random::ecuyer1988>::num_pars_unconstrained)
 704 : .method("unconstrained_param_names",
 705 : &rstan::stan_fit<model5c082b6e424b_102de305ede91408d5b21b0b0095339c_namespace::model5c082b6e424b_102de305ede91408d5b21b0b0095339c, boost::random::ecuyer1988>::unconstrained_param_names)
 706 : .method("constrained_param_names",
 707 : &rstan::stan_fit<model5c082b6e424b_102de305ede91408d5b21b0b0095339c_namespace::model5c082b6e424b_102de305ede91408d5b21b0b0095339c, boost::random::ecuyer1988>::constrained_param_names)
 708 : ;
 709 : }
 710 : 
 711 : // declarations
 712 : extern "C" {
 713 : SEXP file5c08635880ea( ) ;
 714 : }
 715 : 
 716 : // definition
 717 : 
 718 : SEXP file5c08635880ea( ){
 719 : return Rcpp::wrap("102de305ede91408d5b21b0b0095339c");
 720 : }
 721 : 
 722 : 
Compilation argument:
 /opt/scp/software/mro/3.5.1-foss-2017a/lib64/R/bin/R CMD SHLIB file5c08635880ea.cpp 2> file5c08635880ea.cpp.err.txt 
g++ -I/opt/scp/software/mro/3.5.1-foss-2017a/lib64/R/include -DNDEBUG -I"/home/kpwp689/R/x86_64-pc-linux-gnu-library/3.5/Rcpp/include/" -I"/home/kpwp689/R/x86_64-pc-linux-gnu-library/3.5/RcppEigen/include/" -I"/home/kpwp689/R/x86_64-pc-linux-gnu-library/3.5/RcppEigen/include/unsupported" -I"/home/kpwp689/R/x86_64-pc-linux-gnu-library/3.5/rstan/include/boost_not_in_BH" -I"/opt/scp/software/mro/3.5.1-foss-2017a/lib64/R/site-library/BH/include" -I"/home/kpwp689/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/src/" -I"/home/kpwp689/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/" -I"/home/kpwp689/R/x86_64-pc-linux-gnu-library/3.5/rstan/include" -DEIGEN_NO_DEBUG -DBOOST_RESULT_OF_USE_TR1 -DBOOST_NO_DECLTYPE -DBOOST_DISABLE_ASSERTS -DBOOST_NO_CXX11_RVALUE_REFERENCES -DU_STATIC_IMPLEMENTATION -fpic -DU_STATIC_IMPLEMENTATION -O2 -g -c file5c08635880ea.cpp -o file5c08635880ea.o

```

---

<div class="post-metadata">

**Author:** ![Jimams](https://avatars.discourse-cdn.com/v4/letter/j/3ec8ea/32.png) [@Jimams](https://discourse.mc-stan.org/u/Jimams)\
**Post date:** [July 15, 2019, 8:14am UTC](https://discourse.mc-stan.org/t/error-in-compilecode/9652/9 "2019-07-15T08:14:23Z")

</div>

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

Program source:
  1: 
  2: // includes from the plugin
  3: 
  4: 
  5: // user includes
  6: #define STAN __SERVICES__ COMMAND_HPP// Code generated by Stan version 2.17.0
  7: 
  8: #include <stan/model/model_header.hpp>
  9: 
 10: namespace model5c082b6e424b_102de305ede91408d5b21b0b0095339c_namespace {
 11: 
 12: using std::istream;
 13: using std::string;
 14: using std::stringstream;
 15: using std::vector;
 16: using stan::io::dump;
 17: using stan::math::lgamma;
 18: using stan::model::prob_grad;
 19: using namespace stan::math;
 20: 
 21: typedef Eigen::Matrix<double,Eigen::Dynamic,1> vector_d;
 22: typedef Eigen::Matrix<double,1,Eigen::Dynamic> row_vector_d;
 23: typedef Eigen::Matrix<double,Eigen::Dynamic,Eigen::Dynamic> matrix_d;
 24: 
 25: static int current_statement_begin__;
 26: 
 27: stan::io::program_reader prog_reader__() {
 28: stan::io::program_reader reader;
 29: reader.add_event(0, 0, "start", "model5c082b6e424b_102de305ede91408d5b21b0b0095339c");
 30: reader.add_event(52, 52, "end", "model5c082b6e424b_102de305ede91408d5b21b0b0095339c");
 31: return reader;
 32: }
 33: 
 34: template <typename T0 __, typename T1__ , typename T2 __, typename T3__ >
 35: typename boost::math::tools::promote_args<T0 __, T1__ , T2 __, T3__ >::type
 36: dz_dt(const T0__& t,
 37: const std::vector<T1__>& z,
 38: const std::vector<T2__>& theta,
 39: const std::vector<T3__>& x_r,
 40: const std::vector<int>& x_i, std::ostream* pstream__) {
 41: typedef typename boost::math::tools::promote_args<T0 __, T1__ , T2 __, T3__ >::type fun_scalar_t__;
 42: typedef fun_scalar_t __fun_return_scalar_t__ ;
 43: const static bool propto__ = true;
 44: (void) propto__;
 45: fun_scalar_t __DUMMY_VAR__ (std::numeric_limits<double>::quiet_NaN());
 46: (void) DUMMY_VAR__; // suppress unused var warning
 47: 
 48: int current_statement_begin__ = -1;
 49: try {
 50: {
 51: current_statement_begin__ = 8;
 52: fun_scalar_t__ V;
 53: (void) V; // dummy to suppress unused var warning
 54: 
 55: stan::math::initialize(V, std::numeric_limits<double>::quiet_NaN());
 56: stan::math::fill(V,DUMMY_VAR__);
 57: stan::math::assign(V,get_base1(z,1,"z",1));
 58: current_statement_begin__ = 9;
 59: fun_scalar_t__ K;
 60: (void) K; // dummy to suppress unused var warning
 61: 
 62: stan::math::initialize(K, std::numeric_limits<double>::quiet_NaN());
 63: stan::math::fill(K,DUMMY_VAR__);
 64: stan::math::assign(K,get_base1(theta,1,"theta",1));
 65: current_statement_begin__ = 11;
 66: fun_scalar_t__ dV_dt;
 67: (void) dV_dt; // dummy to suppress unused var warning
 68: 
 69: stan::math::initialize(dV_dt, std::numeric_limits<double>::quiet_NaN());
 70: stan::math::fill(dV_dt,DUMMY_VAR__);
 71: stan::math::assign(dV_dt,(K * V));
 72: 
 73: 
 74: current_statement_begin__ = 13;
 75: return stan::math::promote_scalar<fun_return_scalar_t__>(dV_dt);
 76: }
 77: } catch (const std::exception& e) {
 78: stan::lang::rethrow_located(e, current_statement_begin __, prog_reader__ ());
 79: // Next line prevents compiler griping about no return
 80: throw std::runtime_error(" ***IF YOU SEE THIS, PLEASE REPORT A BUG***");
 81: }
 82: }
 83: 
 84: 
 85: struct dz_dt_functor__ {
 86: template <typename T0 __, typename T1__ , typename T2 __, typename T3__ >
 87: typename boost::math::tools::promote_args<T0 __, T1__ , T2 __, T3__ >::type
 88: operator()(const T0__& t,
 89: const std::vector<T1__>& z,
 90: const std::vector<T2__>& theta,
 91: const std::vector<T3__>& x_r,
 92: const std::vector<int>& x_i, std::ostream* pstream__) const {
 93: return dz_dt(t, z, theta, x_r, x_i, pstream__);
 94: }
 95: };
 96: 
 97: class model5c082b6e424b_102de305ede91408d5b21b0b0095339c : public prob_grad {
 98: private:
 99: int N;
100: vector<double> ts;
101: vector<double> y_init;
102: vector<vector<double> > y;
103: public:
104: model5c082b6e424b_102de305ede91408d5b21b0b0095339c(stan::io::var_context& context__,
105: std::ostream* pstream__ = 0)
106: : prob_grad(0) {
107: ctor_body(context __, 0, pstream__ );
108: }
109: 
110: model5c082b6e424b_102de305ede91408d5b21b0b0095339c(stan::io::var_context& context__,
111: unsigned int random_seed__,
112: std::ostream* pstream__ = 0)
113: : prob_grad(0) {
114: ctor_body(context __, random_seed__ , pstream__);
115: }
116: 
117: void ctor_body(stan::io::var_context& context__,
118: unsigned int random_seed__,
119: std::ostream* pstream__) {
120: boost::ecuyer1988 base_rng__ =
121: stan::services::util::create_rng(random_seed__, 0);
122: (void) base_rng__; // suppress unused var warning
123: 
124: current_statement_begin__ = -1;
125: 
126: static const char* function__ = "model5c082b6e424b_102de305ede91408d5b21b0b0095339c_namespace::model5c082b6e424b_102de305ede91408d5b21b0b0095339c";
127: (void) function__; // dummy to suppress unused var warning
128: size_t pos__;
129: (void) pos__; // dummy to suppress unused var warning
130: std::vector<int> vals_i__;
131: std::vector<double> vals_r__;
132: double DUMMY_VAR__(std::numeric_limits<double>::quiet_NaN());
133: (void) DUMMY_VAR__; // suppress unused var warning
134: 
135: // initialize member variables
136: try {
137: current_statement_begin__ = 18;
138: context__.validate_dims("data initialization", "N", "int", context__.to_vec());
139: N = int(0);
140: vals_i __= context__.vals_i("N");
141: pos__ = 0;
142: N = vals_i__[pos__++];
143: current_statement_begin__ = 19;
144: validate_non_negative_index("ts", "N", N);
145: context__.validate_dims("data initialization", "ts", "double", context__.to_vec(N));
146: validate_non_negative_index("ts", "N", N);
147: ts = std::vector<double>(N,double(0));
148: vals_r __= context__.vals_r("ts");
149: pos__ = 0;
150: size_t ts_limit_0__ = N;
151: for (size_t i_0 __= 0; i_0__ < ts_limit_0 __; ++i_0__ ) {
152: ts[i_0__] = vals_r__[pos__++];
153: }
154: current_statement_begin__ = 20;
155: validate_non_negative_index("y_init", "1", 1);
156: context__.validate_dims("data initialization", "y_init", "double", context__.to_vec(1));
157: validate_non_negative_index("y_init", "1", 1);
158: y_init = std::vector<double>(1,double(0));
159: vals_r __= context__.vals_r("y_init");
160: pos__ = 0;
161: size_t y_init_limit_0__ = 1;
162: for (size_t i_0 __= 0; i_0__ < y_init_limit_0 __; ++i_0__ ) {
163: y_init[i_0__] = vals_r__[pos__++];
164: }
165: current_statement_begin__ = 21;
166: validate_non_negative_index("y", "N", N);
167: validate_non_negative_index("y", "1", 1);
168: context__.validate_dims("data initialization", "y", "double", context__.to_vec(N,1));
169: validate_non_negative_index("y", "N", N);
170: validate_non_negative_index("y", "1", 1);
171: y = std::vector<std::vector<double> >(N,std::vector<double>(1,double(0)));
172: vals_r __= context__.vals_r("y");
173: pos__ = 0;
174: size_t y_limit_1__ = 1;
175: for (size_t i_1 __= 0; i_1__ < y_limit_1 __; ++i_1__ ) {
176: size_t y_limit_0__ = N;
177: for (size_t i_0 __= 0; i_0__ < y_limit_0 __; ++i_0__ ) {
178: y[i_0__][i_1__] = vals_r__[pos__++];
179: }
180: }
181: 
182: // validate, data variables
183: current_statement_begin__ = 18;
184: check_greater_or_equal(function__,"N",N,0);
185: current_statement_begin__ = 19;
186: current_statement_begin__ = 20;
187: current_statement_begin__ = 21;
188: for (int k0 __= 0; k0__ < N; ++k0__) {
189: for (int k1 __= 0; k1__ < 1; ++k1__) {
190: check_greater_or_equal(function__,"y[k0__][k1__]",y[k0__][k1__],0);
191: }
192: }
193: // initialize data variables
194: 
195: 
196: // validate transformed data
197: 
198: // validate, set parameter ranges
199: num_params_r__ = 0U;
200: param_ranges_i__.clear();
201: current_statement_begin__ = 25;
202: validate_non_negative_index("theta", "1", 1);
203: num_params_r__ += 1;
204: current_statement_begin__ = 26;
205: validate_non_negative_index("z_init", "1", 1);
206: num_params_r__ += 1;
207: current_statement_begin__ = 27;
208: validate_non_negative_index("sigma", "1", 1);
209: num_params_r__ += 1;
210: } catch (const std::exception& e) {
211: stan::lang::rethrow_located(e, current_statement_begin __, prog_reader__ ());
212: // Next line prevents compiler griping about no return
213: throw std::runtime_error(" ***IF YOU SEE THIS, PLEASE REPORT A BUG***");
214: }
215: }
216: 
217: ~model5c082b6e424b_102de305ede91408d5b21b0b0095339c() { }
218: 
219: 
220: void transform_inits(const stan::io::var_context& context__,
221: std::vector<int>& params_i__,
222: std::vector<double>& params_r__,
223: std::ostream* pstream__) const {
224: stan::io::writer<double> writer__(params_r__,params_i__);
225: size_t pos__;
226: (void) pos__; // dummy call to supress warning
227: std::vector<double> vals_r__;
228: std::vector<int> vals_i__;
229: 
230: if (!(context__.contains_r("theta")))
231: throw std::runtime_error("variable theta missing");
232: vals_r __= context__.vals_r("theta");
233: pos__ = 0U;
234: validate_non_negative_index("theta", "1", 1);
235: context__.validate_dims("initialization", "theta", "double", context__.to_vec(1));
236: std::vector<double> theta(1,double(0));
237: for (int i0 __= 0U; i0__ < 1; ++i0__)
238: theta[i0__] = vals_r__[pos__++];
239: for (int i0 __= 0U; i0__ < 1; ++i0__)
240: try {
241: writer__.scalar_lb_unconstrain(0,theta[i0__]);
242: } catch (const std::exception& e) { 
243: throw std::runtime_error(std::string("Error transforming variable theta: ") + e.what());
244: }
245: 
246: if (!(context__.contains_r("z_init")))
247: throw std::runtime_error("variable z_init missing");
248: vals_r __= context__.vals_r("z_init");
249: pos__ = 0U;
250: validate_non_negative_index("z_init", "1", 1);
251: context__.validate_dims("initialization", "z_init", "double", context__.to_vec(1));
252: std::vector<double> z_init(1,double(0));
253: for (int i0 __= 0U; i0__ < 1; ++i0__)
254: z_init[i0__] = vals_r__[pos__++];
255: for (int i0 __= 0U; i0__ < 1; ++i0__)
256: try {
257: writer__.scalar_lb_unconstrain(0,z_init[i0__]);
258: } catch (const std::exception& e) { 
259: throw std::runtime_error(std::string("Error transforming variable z_init: ") + e.what());
260: }
261: 
262: if (!(context__.contains_r("sigma")))
263: throw std::runtime_error("variable sigma missing");
264: vals_r __= context__.vals_r("sigma");
265: pos__ = 0U;
266: validate_non_negative_index("sigma", "1", 1);
267: context__.validate_dims("initialization", "sigma", "double", context__.to_vec(1));
268: std::vector<double> sigma(1,double(0));
269: for (int i0 __= 0U; i0__ < 1; ++i0__)
270: sigma[i0__] = vals_r__[pos__++];
271: for (int i0 __= 0U; i0__ < 1; ++i0__)
272: try {
273: writer__.scalar_lb_unconstrain(0,sigma[i0__]);
274: } catch (const std::exception& e) { 
275: throw std::runtime_error(std::string("Error transforming variable sigma: ") + e.what());
276: }
277: 
278: params_r __= writer__.data_r();
279: params_i __= writer__.data_i();
280: }
281: 
282: void transform_inits(const stan::io::var_context& context,
283: Eigen::Matrix<double,Eigen::Dynamic,1>& params_r,
284: std::ostream* pstream__) const {
285: std::vector<double> params_r_vec;
286: std::vector<int> params_i_vec;
287: transform_inits(context, params_i_vec, params_r_vec, pstream__);
288: params_r.resize(params_r_vec.size());
289: for (int i = 0; i < params_r.size(); ++i)
290: params_r(i) = params_r_vec[i];
291: }
292: 
293: 
294: template <bool propto __, bool jacobian__ , typename T__>
295: T__log_prob(vector<T__>& params_r__,
296: vector<int>& params_i__,
297: std::ostream* pstream__ = 0) const {
298: 
299: T __DUMMY_VAR__ (std::numeric_limits<double>::quiet_NaN());
300: (void) DUMMY_VAR__; // suppress unused var warning
301: 
302: T __lp__ (0.0);
303: stan::math::accumulator<T __> lp_accum__ ;
304: 
305: try {
306: // model parameters
307: stan::io::reader<T __> in__ (params_r __,params_i__ );
308: 
309: vector<T__> theta;
310: size_t dim_theta_0__ = 1;
311: theta.reserve(dim_theta_0__);
312: for (size_t k_0 __= 0; k_0__ < dim_theta_0 __; ++k_0__ ) {
313: if (jacobian__)
314: theta.push_back(in__.scalar_lb_constrain(0,lp__));
315: else
316: theta.push_back(in__.scalar_lb_constrain(0));
317: }
318: 
319: vector<T__> z_init;
320: size_t dim_z_init_0__ = 1;
321: z_init.reserve(dim_z_init_0__);
322: for (size_t k_0 __= 0; k_0__ < dim_z_init_0 __; ++k_0__ ) {
323: if (jacobian__)
324: z_init.push_back(in__.scalar_lb_constrain(0,lp__));
325: else
326: z_init.push_back(in__.scalar_lb_constrain(0));
327: }
328: 
329: vector<T__> sigma;
330: size_t dim_sigma_0__ = 1;
331: sigma.reserve(dim_sigma_0__);
332: for (size_t k_0 __= 0; k_0__ < dim_sigma_0 __; ++k_0__ ) {
333: if (jacobian__)
334: sigma.push_back(in__.scalar_lb_constrain(0,lp__));
335: else
336: sigma.push_back(in__.scalar_lb_constrain(0));
337: }
338: 
339: 
340: // transformed parameters
341: current_statement_begin__ = 31;
342: validate_non_negative_index("z", "N", N);
343: validate_non_negative_index("z", "1", 1);
344: vector<vector<T__> > z(N, (vector<T__>(1)));
345: stan::math::initialize(z, DUMMY_VAR__);
346: stan::math::fill(z,DUMMY_VAR__);
347: stan::math::assign(z,integrate_ode_bdf(dz_dt_functor__(), z_init, 0, ts, theta, rep_array(0.0,0), rep_array(0,0), pstream__, 1.0000000000000001e-05, 0.001, 500.0));
348: 
349: 
350: 
351: // validate transformed parameters
352: for (int i0 __= 0; i0__ < N; ++i0__) {
353: for (int i1 __= 0; i1__ < 1; ++i1__) {
354: if (stan::math::is_uninitialized(z[i0__][i1__])) {
355: std::stringstream msg__;
356: msg__<< "Undefined transformed parameter: z" << '[' << i0__ << ']' << '[' << i1__ << ']';
357: throw std::runtime_error(msg__.str());
358: }
359: }
360: }
361: 
362: const char* function__ = "validate transformed params";
363: (void) function__; // dummy to suppress unused var warning
364: current_statement_begin__ = 31;
365: 

```

---

<div class="post-metadata">

**Author:** ![Jimams](https://avatars.discourse-cdn.com/v4/letter/j/3ec8ea/32.png) [@Jimams](https://discourse.mc-stan.org/u/Jimams)\
**Post date:** [July 15, 2019, 8:14am UTC](https://discourse.mc-stan.org/t/error-in-compilecode/9652/10 "2019-07-15T08:14:32Z")

</div>

```
366: // model body
367: 
368: current_statement_begin__ = 38;
369: lp_accum__.add(lognormal_log<propto__>(get_base1(theta,1,"theta",1), -(2), 0.5));
370: current_statement_begin__ = 39;
371: lp_accum__.add(lognormal_log<propto__>(sigma, -(1), 1));
372: current_statement_begin__ = 40;
373: lp_accum__.add(lognormal_log<propto__>(get_base1(z_init,1,"z_init",1), -(1.3999999999999999), 0.5));
374: current_statement_begin__ = 41;
375: lp_accum__.add(lognormal_log<propto__>(get_base1(y_init,1,"y_init",1), log(get_base1(z_init,1,"z_init",1)), get_base1(sigma,1,"sigma",1)));
376: current_statement_begin__ = 42;
377: lp_accum__.add(lognormal_log<propto__>(stan::model::rvalue(y, stan::model::cons_list(stan::model::index_omni(), stan::model::cons_list(stan::model::index_uni(1), stan::model::nil_index_list())), "y"), log(stan::model::rvalue(z, stan::model::cons_list(stan::model::index_omni(), stan::model::cons_list(stan::model::index_uni(1), stan::model::nil_index_list())), "z")), get_base1(sigma,1,"sigma",1)));
378: 
379: } catch (const std::exception& e) {
380: stan::lang::rethrow_located(e, current_statement_begin __, prog_reader__ ());
381: // Next line prevents compiler griping about no return
382: throw std::runtime_error(" ***IF YOU SEE THIS, PLEASE REPORT A BUG***");
383: }
384: 
385: lp_accum__.add(lp__);
386: return lp_accum__.sum();
387: 
388: } // log_prob()
389: 
390: template <bool propto, bool jacobian, typename T_>
391: T_ log_prob(Eigen::Matrix<T_,Eigen::Dynamic,1>& params_r,
392: std::ostream* pstream = 0) const {
393: std::vector<T_> vec_params_r;
394: vec_params_r.reserve(params_r.size());
395: for (int i = 0; i < params_r.size(); ++i)
396: vec_params_r.push_back(params_r(i));
397: std::vector<int> vec_params_i;
398: return log_prob<propto,jacobian,T_>(vec_params_r, vec_params_i, pstream);
399: }
400: 
401: 
402: void get_param_names(std::vector<std::string>& names__) const {
403: names__.resize(0);
404: names__.push_back("theta");
405: names__.push_back("z_init");
406: names__.push_back("sigma");
407: names__.push_back("z");
408: names__.push_back("y_init_rep");
409: names__.push_back("y_rep");
410: }
411: 
412: 
413: void get_dims(std::vector<std::vector<size_t> >& dimss__) const {
414: dimss__.resize(0);
415: std::vector<size_t> dims__;
416: dims__.resize(0);
417: dims__.push_back(1);
418: dimss__.push_back(dims__);
419: dims__.resize(0);
420: dims__.push_back(1);
421: dimss__.push_back(dims__);
422: dims__.resize(0);
423: dims__.push_back(1);
424: dimss__.push_back(dims__);
425: dims__.resize(0);
426: dims__.push_back(N);
427: dims__.push_back(1);
428: dimss__.push_back(dims__);
429: dims__.resize(0);
430: dims__.push_back(1);
431: dimss__.push_back(dims__);
432: dims__.resize(0);
433: dims__.push_back(N);
434: dims__.push_back(1);
435: dimss__.push_back(dims__);
436: }
437: 
438: template <typename RNG>
439: void write_array(RNG& base_rng__,
440: std::vector<double>& params_r__,
441: std::vector<int>& params_i__,
442: std::vector<double>& vars__,
443: bool include_tparams__ = true,
444: bool include_gqs__ = true,
445: std::ostream* pstream__ = 0) const {
446: vars__.resize(0);
447: stan::io::reader<double> in__(params_r__,params_i__);
448: static const char* function__ = "model5c082b6e424b_102de305ede91408d5b21b0b0095339c_namespace::write_array";
449: (void) function__; // dummy to suppress unused var warning
450: // read-transform, write parameters
451: vector<double> theta;
452: size_t dim_theta_0__ = 1;
453: for (size_t k_0 __= 0; k_0__ < dim_theta_0 __; ++k_0__ ) {
454: theta.push_back(in__.scalar_lb_constrain(0));
455: }
456: vector<double> z_init;
457: size_t dim_z_init_0__ = 1;
458: for (size_t k_0 __= 0; k_0__ < dim_z_init_0 __; ++k_0__ ) {
459: z_init.push_back(in__.scalar_lb_constrain(0));
460: }
461: vector<double> sigma;
462: size_t dim_sigma_0__ = 1;
463: for (size_t k_0 __= 0; k_0__ < dim_sigma_0 __; ++k_0__ ) {
464: sigma.push_back(in__.scalar_lb_constrain(0));
465: }
466: for (int k_0 __= 0; k_0__ < 1; ++k_0__) {
467: vars__.push_back(theta[k_0__]);
468: }
469: for (int k_0 __= 0; k_0__ < 1; ++k_0__) {
470: vars__.push_back(z_init[k_0__]);
471: }
472: for (int k_0 __= 0; k_0__ < 1; ++k_0__) {
473: vars__.push_back(sigma[k_0__]);
474: }
475: 
476: if (!include_tparams__) return;
477: // declare and define transformed parameters
478: double lp__ = 0.0;
479: (void) lp__; // dummy to suppress unused var warning
480: stan::math::accumulator<double> lp_accum__;
481: 
482: double DUMMY_VAR__(std::numeric_limits<double>::quiet_NaN());
483: (void) DUMMY_VAR__; // suppress unused var warning
484: 
485: try {
486: current_statement_begin__ = 31;
487: validate_non_negative_index("z", "N", N);
488: validate_non_negative_index("z", "1", 1);
489: vector<vector<double> > z(N, (vector<double>(1, 0.0)));
490: stan::math::initialize(z, std::numeric_limits<double>::quiet_NaN());
491: stan::math::fill(z,DUMMY_VAR__);
492: stan::math::assign(z,integrate_ode_bdf(dz_dt_functor__(), z_init, 0, ts, theta, rep_array(0.0,0), rep_array(0,0), pstream__, 1.0000000000000001e-05, 0.001, 500.0));
493: 
494: 
495: 
496: // validate transformed parameters
497: current_statement_begin__ = 31;
498: 
499: // write transformed parameters
500: for (int k_1 __= 0; k_1__ < 1; ++k_1__) {
501: for (int k_0 __= 0; k_0__ < N; ++k_0__) {
502: vars__.push_back(z[k_0__][k_1__]);
503: }
504: }
505: 
506: if (!include_gqs__) return;
507: // declare and define generated quantities
508: current_statement_begin__ = 46;
509: validate_non_negative_index("y_init_rep", "1", 1);
510: vector<double> y_init_rep(1, 0.0);
511: stan::math::initialize(y_init_rep, std::numeric_limits<double>::quiet_NaN());
512: stan::math::fill(y_init_rep,DUMMY_VAR__);
513: current_statement_begin__ = 47;
514: validate_non_negative_index("y_rep", "N", N);
515: validate_non_negative_index("y_rep", "1", 1);
516: vector<vector<double> > y_rep(N, (vector<double>(1, 0.0)));
517: stan::math::initialize(y_rep, std::numeric_limits<double>::quiet_NaN());
518: stan::math::fill(y_rep,DUMMY_VAR__);
519: 
520: 
521: current_statement_begin__ = 49;
522: stan::math::assign(get_base1_lhs(y_init_rep,1,"y_init_rep",1), lognormal_rng(log(get_base1(z_init,1,"z_init",1)),get_base1(sigma,1,"sigma",1), base_rng__));
523: current_statement_begin__ = 50;
524: for (int n = 1; n <= N; ++n) {
525: current_statement_begin__ = 51;
526: stan::math::assign(get_base1_lhs(get_base1_lhs(y_rep,n,"y_rep",1),1,"y_rep",2), lognormal_rng(log(get_base1(get_base1(z,n,"z",1),1,"z",2)),get_base1(sigma,1,"sigma",1), base_rng__));
527: }
528: 
529: // validate generated quantities
530: current_statement_begin__ = 46;
531: current_statement_begin__ = 47;
532: 
533: // write generated quantities
534: for (int k_0 __= 0; k_0__ < 1; ++k_0__) {
535: vars__.push_back(y_init_rep[k_0__]);
536: }
537: for (int k_1 __= 0; k_1__ < 1; ++k_1__) {
538: for (int k_0 __= 0; k_0__ < N; ++k_0__) {
539: vars__.push_back(y_rep[k_0__][k_1__]);
540: }
541: }
542: 
543: } catch (const std::exception& e) {
544: stan::lang::rethrow_located(e, current_statement_begin __, prog_reader__ ());
545: // Next line prevents compiler griping about no return
546: throw std::runtime_error(" ***IF YOU SEE THIS, PLEASE REPORT A BUG***");
547: }
548: }
549: 
550: template <typename RNG>
551: void write_array(RNG& base_rng,
552: Eigen::Matrix<double,Eigen::Dynamic,1>& params_r,
553: Eigen::Matrix<double,Eigen::Dynamic,1>& vars,
554: bool include_tparams = true,
555: bool include_gqs = true,
556: std::ostream* pstream = 0) const {
557: std::vector<double> params_r_vec(params_r.size());
558: for (int i = 0; i < params_r.size(); ++i)
559: params_r_vec[i] = params_r(i);
560: std::vector<double> vars_vec;
561: std::vector<int> params_i_vec;
562: write_array(base_rng,params_r_vec,params_i_vec,vars_vec,include_tparams,include_gqs,pstream);
563: vars.resize(vars_vec.size());
564: for (int i = 0; i < vars.size(); ++i)
565: vars(i) = vars_vec[i];
566: }
567: 
568: static std::string model_name() {
569: return "model5c082b6e424b_102de305ede91408d5b21b0b0095339c";
570: }
571: 
572: 
573: void constrained_param_names(std::vector<std::string>& param_names__,
574: bool include_tparams__ = true,
575: bool include_gqs__ = true) const {
576: std::stringstream param_name_stream__;
577: for (int k_0 __= 1; k_0__ <= 1; ++k_0__) {
578: param_name_stream__.str(std::string());
579: param_name_stream __<< "theta" << '.' << k_0__ ;
580: param_names__.push_back(param_name_stream__.str());
581: }
582: for (int k_0 __= 1; k_0__ <= 1; ++k_0__) {
583: param_name_stream__.str(std::string());
584: param_name_stream __<< "z_init" << '.' << k_0__ ;
585: param_names__.push_back(param_name_stream__.str());
586: }
587: for (int k_0 __= 1; k_0__ <= 1; ++k_0__) {
588: param_name_stream__.str(std::string());
589: param_name_stream __<< "sigma" << '.' << k_0__ ;
590: param_names__.push_back(param_name_stream__.str());
591: }
592: 
593: if (!include_gqs __&& !include_tparams__ ) return;
594: for (int k_1 __= 1; k_1__ <= 1; ++k_1__) {
595: for (int k_0 __= 1; k_0__ <= N; ++k_0__) {
596: param_name_stream__.str(std::string());
597: param_name_stream __<< "z" << '.' << k_0__ << '.' << k_1__;
598: param_names__.push_back(param_name_stream__.str());
599: }
600: }
601: 
602: if (!include_gqs__) return;
603: for (int k_0 __= 1; k_0__ <= 1; ++k_0__) {
604: param_name_stream__.str(std::string());
605: param_name_stream __<< "y_init_rep" << '.' << k_0__ ;
606: param_names__.push_back(param_name_stream__.str());
607: }
608: for (int k_1 __= 1; k_1__ <= 1; ++k_1__) {
609: for (int k_0 __= 1; k_0__ <= N; ++k_0__) {
610: param_name_stream__.str(std::string());
611: param_name_stream __<< "y_rep" << '.' << k_0__ << '.' << k_1__;
612: param_names__.push_back(param_name_stream__.str());
613: }
614: }
615: }
616: 
617: 
618: void unconstrained_param_names(std::vector<std::string>& param_names__,
619: bool include_tparams__ = true,
620: bool include_gqs__ = true) const {
621: std::stringstream param_name_stream__;
622: for (int k_0 __= 1; k_0__ <= 1; ++k_0__) {
623: param_name_stream__.str(std::string());
624: param_name_stream __<< "theta" << '.' << k_0__ ;
625: param_names__.push_back(param_name_stream__.str());
626: }
627: for (int k_0 __= 1; k_0__ <= 1; ++k_0__) {
628: param_name_stream__.str(std::string());
629: param_name_stream __<< "z_init" << '.' << k_0__ ;
630: param_names__.push_back(param_name_stream__.str());
631: }
632: for (int k_0 __= 1; k_0__ <= 1; ++k_0__) {
633: param_name_stream__.str(std::string());
634: param_name_stream __<< "sigma" << '.' << k_0__ ;
635: param_names__.push_back(param_name_stream__.str());
636: }
637: 
638: if (!include_gqs __&& !include_tparams__ ) return;
639: for (int k_1 __= 1; k_1__ <= 1; ++k_1__) {
640: for (int k_0 __= 1; k_0__ <= N; ++k_0__) {
641: param_name_stream__.str(std::string());
642: param_name_stream __<< "z" << '.' << k_0__ << '.' << k_1__;
643: param_names__.push_back(param_name_stream__.str());
644: }
645: }
646: 
647: if (!include_gqs__) return;
648: for (int k_0 __= 1; k_0__ <= 1; ++k_0__) {
649: param_name_stream__.str(std::string());
650: param_name_stream __<< "y_init_rep" << '.' << k_0__ ;
651: param_names__.push_back(param_name_stream__.str());
652: }
653: for (int k_1 __= 1; k_1__ <= 1; ++k_1__) {
654: for (int k_0 __= 1; k_0__ <= N; ++k_0__) {
655: param_name_stream__.str(std::string());
656: param_name_stream __<< "y_rep" << '.' << k_0__ << '.' << k_1__;
657: param_names__.push_back(param_name_stream__.str());
658: }
659: }
660: }
661: 
662: }; // model
663: 
664: }
665: 
666: typedef model5c082b6e424b_102de305ede91408d5b21b0b0095339c_namespace::model5c082b6e424b_102de305ede91408d5b21b0b0095339c stan_model;
667: 
668: #include <rstan/rstaninc.hpp>
669: /**
670: * Define Rcpp Module to expose stan_fit's functions to R.
671: */
672: RCPP_MODULE(stan_fit4model5c082b6e424b_102de305ede91408d5b21b0b0095339c_mod){
673: Rcpp::class_<rstan::stan_fit<model5c082b6e424b_102de305ede91408d5b21b0b0095339c_namespace::model5c082b6e424b_102de305ede91408d5b21b0b0095339c,
674: boost::random::ecuyer1988> >("stan_fit4model5c082b6e424b_102de305ede91408d5b21b0b0095339c")
675: // .constructor<Rcpp::List>()
676: .constructor<SEXP, SEXP, SEXP>()
677: // .constructor<SEXP, SEXP>()
678: .method("call_sampler",
679: &rstan::stan_fit<model5c082b6e424b_102de305ede91408d5b21b0b0095339c_namespace::model5c082b6e424b_102de305ede91408d5b21b0b0095339c, boost::random::ecuyer1988>::call_sampler)
680: .method("param_names",
681: &rstan::stan_fit<model5c082b6e424b_102de305ede91408d5b21b0b0095339c_namespace::model5c082b6e424b_102de305ede91408d5b21b0b0095339c, boost::random::ecuyer1988>::param_names)
682: .method("param_names_oi",
683: &rstan::stan_fit<model5c082b6e424b_102de305ede91408d5b21b0b0095339c_namespace::model5c082b6e424b_102de305ede91408d5b21b0b0095339c, boost::random::ecuyer1988>::param_names_oi)
684: .method("param_fnames_oi",
685: &rstan::stan_fit<model5c082b6e424b_102de305ede91408d5b21b0b0095339c_namespace::model5c082b6e424b_102de305ede91408d5b21b0b0095339c, boost::random::ecuyer1988>::param_fnames_oi)
686: .method("param_dims",
687: &rstan::stan_fit<model5c082b6e424b_102de305ede91408d5b21b0b0095339c_namespace::model5c082b6e424b_102de305ede91408d5b21b0b0095339c, boost::random::ecuyer1988>::param_dims)
688: .method("param_dims_oi",
689: &rstan::stan_fit<model5c082b6e424b_102de305ede91408d5b21b0b0095339c_namespace::model5c082b6e424b_102de305ede91408d5b21b0b0095339c, boost::random::ecuyer1988>::param_dims_oi)
690: .method("update_param_oi",
691: &rstan::stan_fit<model5c082b6e424b_102de305ede91408d5b21b0b0095339c_namespace::model5c082b6e424b_102de305ede91408d5b21b0b0095339c, boost::random::ecuyer1988>::update_param_oi)
692: .method("param_oi_tidx",
693: &rstan::stan_fit<model5c082b6e424b_102de305ede91408d5b21b0b0095339c_namespace::model5c082b6e424b_102de305ede91408d5b21b0b0095339c, boost::random::ecuyer1988>::param_oi_tidx)
694: .method("grad_log_prob",
695: &rstan::stan_fit<model5c082b6e424b_102de305ede91408d5b21b0b0095339c_namespace::model5c082b6e424b_102de305ede91408d5b21b0b0095339c, boost::random::ecuyer1988>::grad_log_prob)
696: .method("log_prob",
697: &rstan::stan_fit<model5c082b6e424b_102de305ede91408d5b21b0b0095339c_namespace::model5c082b6e424b_102de305ede91408d5b21b0b0095339c, boost::random::ecuyer1988>::log_prob)
698: .method("unconstrain_pars",
699: &rstan::stan_fit<model5c082b6e424b_102de305ede91408d5b21b0b0095339c_namespace::model5c082b6e424b_102de305ede91408d5b21b0b0095339c, boost::random::ecuyer1988>::unconstrain_pars)
700: .method("constrain_pars",
701: &rstan::stan_fit<model5c082b6e424b_102de305ede91408d5b21b0b0095339c_namespace::model5c082b6e424b_102de305ede91408d5b21b0b0095339c, boost::random::ecuyer1988>::constrain_pars)
702: .method("num_pars_unconstrained",
703: &rstan::stan_fit<model5c082b6e424b_102de305ede91408d5b21b0b0095339c_namespace::model5c082b6e424b_102de305ede91408d5b21b0b0095339c, boost::random::ecuyer1988>::num_pars_unconstrained)
704: .method("unconstrained_param_names",
705: &rstan::stan_fit<model5c082b6e424b_102de305ede91408d5b21b0b0095339c_namespace::model5c082b6e424b_102de305ede91408d5b21b0b0095339c, boost::random::ecuyer1988>::unconstrained_param_names)
706: .method("constrained_param_names",
707: &rstan::stan_fit<model5c082b6e424b_102de305ede91408d5b21b0b0095339c_namespace::model5c082b6e424b_102de305ede91408d5b21b0b0095339c, boost::random::ecuyer1988>::constrained_param_names)
708: ;
709: }
710: 
711: // declarations
712: extern "C" {
713: SEXP file5c08635880ea( ) ;
714: }
715: 
716: // definition
717: 
718: SEXP file5c08635880ea( ){
719: return Rcpp::wrap("102de305ede91408d5b21b0b0095339c");
720: }
721: 
722: 
Error in compileCode(f, code, language = language, verbose = verbose) : 
  Compilation ERROR, function(s)/method(s) not created! In file included from /home/kpwp689/R/x86_64-pc-linux-gnu-library/3.5/RcppEigen/include/Eigen/Core:388:0,
                 from /home/kpwp689/R/x86_64-pc-linux-gnu-library/3.5/RcppEigen/include/Eigen/Dense:1,
                 from /home/kpwp689/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp:4,
                 from /home/kpwp689/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/stan/math/rev/mat/fun/Eigen_NumTraits.hpp:4,
                 from /home/kpwp689/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/stan/math/rev/core/matrix_vari.hpp:4,
                 from /home/kpwp689/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/stan/math/rev/core.hpp:14,
                 from /home/kpwp689/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/stan/math/rev/mat.hpp:4,
                 from /home/kpwp689/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/stan/math.hpp:4,

```

---

<div class="post-metadata">

**Author:** ![bgoodri](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bgoodri/32/4451_2.png) [@bgoodri](https://discourse.mc-stan.org/u/bgoodri)\
**Post date:** [July 15, 2019, 2:58pm UTC](https://discourse.mc-stan.org/t/error-in-compilecode/9652/11 "2019-07-15T14:58:03Z")

</div>

I would not be using RStan 2.17.3. That version was not even supposed to exist and is incompatible with the C++14 requirements nowdays. I would upgrade to 2.19.2 and try again. If it is not working do

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

```

and paste the whole output.

---

<div class="post-metadata">

**Author:** ![Jimams](https://avatars.discourse-cdn.com/v4/letter/j/3ec8ea/32.png) [@Jimams](https://discourse.mc-stan.org/u/Jimams)\
**Post date:** [July 15, 2019, 3:38pm UTC](https://discourse.mc-stan.org/t/error-in-compilecode/9652/12 "2019-07-15T15:38:10Z")

</div>

I try to automatically upgrade Rstan but it’s still the same version. How can I upgrade?

---

<div class="post-metadata">

**Author:** ![bgoodri](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bgoodri/32/4451_2.png) [@bgoodri](https://discourse.mc-stan.org/u/bgoodri)\
**Post date:** [July 16, 2019, 3:49am UTC](https://discourse.mc-stan.org/t/error-in-compilecode/9652/13 "2019-07-16T03:49:43Z")

</div>

```
remove.packages("rstan")
install.packages("rstan")

```

---

<div class="post-metadata">

**Author:** ![Jimams](https://avatars.discourse-cdn.com/v4/letter/j/3ec8ea/32.png) [@Jimams](https://discourse.mc-stan.org/u/Jimams)\
**Post date:** [July 16, 2019, 8:21am UTC](https://discourse.mc-stan.org/t/error-in-compilecode/9652/14 "2019-07-16T08:21:28Z")

</div>

I did that but I am afraid it installs the same version as before 2.17.3

---

<div class="post-metadata">

**Author:** ![bgoodri](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bgoodri/32/4451_2.png) [@bgoodri](https://discourse.mc-stan.org/u/bgoodri)\
**Post date:** [July 16, 2019, 1:59pm UTC](https://discourse.mc-stan.org/t/error-in-compilecode/9652/15 "2019-07-16T13:59:27Z")

</div>

What version of R are you using?

---

<div class="post-metadata">

**Author:** ![Jimams](https://avatars.discourse-cdn.com/v4/letter/j/3ec8ea/32.png) [@Jimams](https://discourse.mc-stan.org/u/Jimams)\
**Post date:** [July 16, 2019, 2:00pm UTC](https://discourse.mc-stan.org/t/error-in-compilecode/9652/16 "2019-07-16T14:00:05Z")

</div>

I am using 3.5.1

---

<div class="post-metadata">

**Author:** ![bgoodri](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bgoodri/32/4451_2.png) [@bgoodri](https://discourse.mc-stan.org/u/bgoodri)\
**Post date:** [July 16, 2019, 2:03pm UTC](https://discourse.mc-stan.org/t/error-in-compilecode/9652/17 "2019-07-16T14:03:44Z")

</div>

Try

```
install.packages("https://cran.r-project.org/src/contrib/rstan_2.19.2.tar.gz", repos = NULL)

```

---

<div class="post-metadata">

**Author:** ![Jimams](https://avatars.discourse-cdn.com/v4/letter/j/3ec8ea/32.png) [@Jimams](https://discourse.mc-stan.org/u/Jimams)\
**Post date:** [July 16, 2019, 2:04pm UTC](https://discourse.mc-stan.org/t/error-in-compilecode/9652/18 "2019-07-16T14:04:44Z")

</div>

I get this message:

- installing _source_ package ‘rstan’ …  
\*\* package ‘rstan’ successfully unpacked and MD5 sums checked  
\*\* libs  
Error: package ‘BH’ 1.66.0-1 was found, but \>= 1.69.0 is required by ‘rstan’
- removing ‘/home/user/R/x86\_64-pc-linux-gnu-library/3.5/rstan’
- restoring previous ‘/home/user/R/x86\_64-pc-linux-gnu-library/3.5/rstan’  
Warning in install.packages :  
installation of package ‘/tmp/Rtmpb2gdXu/downloaded\_packages/rstan\_2.19.2.tar.gz’ had non-zero exit status

---

<div class="post-metadata">

**Author:** ![bgoodri](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bgoodri/32/4451_2.png) [@bgoodri](https://discourse.mc-stan.org/u/bgoodri)\
**Post date:** [July 16, 2019, 3:19pm UTC](https://discourse.mc-stan.org/t/error-in-compilecode/9652/19 "2019-07-16T15:19:48Z")

</div>

You need to upgrade the BH package. If

```
install.packages("BH")

```

does not work then do.

```
install.packages("https://cran.r-project.org/src/contrib/BH_1.69.0-1.tar.gz", repos = NULL)

```

---

<div class="post-metadata">

**Author:** ![Jimams](https://avatars.discourse-cdn.com/v4/letter/j/3ec8ea/32.png) [@Jimams](https://discourse.mc-stan.org/u/Jimams)\
**Post date:** [July 16, 2019, 4:57pm UTC](https://discourse.mc-stan.org/t/error-in-compilecode/9652/20 "2019-07-16T16:57:11Z")

</div>

Only the second worked for me. Now apparently StanHeaders needs to be upgraded. What command can I use other than install.pachage(StanHeaders) that installs the old one?

[Next page](https://discourse.mc-stan.org/t/error-in-compilecode/9652.md?page=2)
