Running ‘testthat.R’ [195s/312s]
Running the tests in ‘tests/testthat.R’ failed.
Complete output:
  > library(testthat)
  > library(dgo)
  Loading required package: dgodata
  Loading required package: rstan
  Loading required package: ggplot2
  Loading required package: StanHeaders
  rstan (Version 2.17.2, GitRev: 2e1f913d3ca3)
  For execution on a local, multicore CPU with excess RAM we recommend calling
  options(mc.cores = parallel::detectCores()).
  To avoid recompilation of unchanged Stan programs, we recommend calling
  rstan_options(auto_write = TRUE)
  > 
  > # https://stackoverflow.com/questions/12410694/rbundler-build-error-cannot-open-file-startup-rs-no-such-file-or-directory#27994299
  > Sys.setenv("R_TESTS" = "")
  > test_check("dgo")
  In file included from /tmp/RtmpgFaap4/RLIBS_7078477768c2/BH/include/boost/config.hpp:39:0,
                   from /tmp/RtmpgFaap4/RLIBS_7078477768c2/BH/include/boost/math/tools/config.hpp:13,
                   from /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/core/var.hpp:7,
                   from /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/core/gevv_vvv_vari.hpp:5,
                   from /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/core.hpp:12,
                   from /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat.hpp:4,
                   from /home/ripley/R/Lib32/StanHeaders/include/stan/math.hpp:4,
                   from /home/ripley/R/Lib32/StanHeaders/include/src/stan/model/model_header.hpp:4,
                   from file439375b94caa.cpp:8:
  /tmp/RtmpgFaap4/RLIBS_7078477768c2/BH/include/boost/config/compiler/gcc.hpp:186:0: warning: "BOOST_NO_CXX11_RVALUE_REFERENCES" redefined
   #  define BOOST_NO_CXX11_RVALUE_REFERENCES
   ^
  <command-line>:0:0: note: this is the location of the previous definition
  In file included from /usr/include/sys/ucontext.h:20:0,
                   from /usr/include/sys/signal.h:231,
                   from /usr/include/sys/procset.h:23,
                   from /usr/include/sys/wait.h:25,
                   from /usr/include/stdlib.h:21,
                   from /opt/csw/include/c++/5.2.0/cstdlib:72,
                   from /home/ripley/R/Lib32/StanHeaders/include/stan/math/memory/stack_alloc.hpp:8,
                   from /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/core/autodiffstackstorage.hpp:4,
                   from /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/core.hpp:4,
                   from /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat.hpp:4,
                   from /home/ripley/R/Lib32/StanHeaders/include/stan/math.hpp:4,
                   from /home/ripley/R/Lib32/StanHeaders/include/src/stan/model/model_header.hpp:4,
                   from file439375b94caa.cpp:8:
  /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat/functor/algebra_system.hpp:97:24: error: expected nested-name-specifier before numeric constant
       template <typename FS, typename F, typename T0, typename T1>
                          ^
  /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat/functor/algebra_system.hpp:97:24: error: expected ‘>’ before numeric constant
  /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat/functor/algebra_system.hpp:100:7: error: expected unqualified-id before numeric constant
         FS fs_;
         ^
  In file included from /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat/functor/algebra_solver.hpp:4:0,
                   from /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat.hpp:55,
                   from /home/ripley/R/Lib32/StanHeaders/include/stan/math.hpp:4,
                   from /home/ripley/R/Lib32/StanHeaders/include/src/stan/model/model_header.hpp:4,
                   from file439375b94caa.cpp:8:
  /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat/functor/algebra_system.hpp:106:28: error: ISO C++ forbids declaration of ‘parameter’ with no type [-fpermissive]
         hybrj_functor_solver(const FS& fs,
                              ^
  In file included from /usr/include/sys/ucontext.h:20:0,
                   from /usr/include/sys/signal.h:231,
                   from /usr/include/sys/procset.h:23,
                   from /usr/include/sys/wait.h:25,
                   from /usr/include/stdlib.h:21,
                   from /opt/csw/include/c++/5.2.0/cstdlib:72,
                   from /home/ripley/R/Lib32/StanHeaders/include/stan/math/memory/stack_alloc.hpp:8,
                   from /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/core/autodiffstackstorage.hpp:4,
                   from /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/core.hpp:4,
                   from /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat.hpp:4,
                   from /home/ripley/R/Lib32/StanHeaders/include/stan/math.hpp:4,
                   from /home/ripley/R/Lib32/StanHeaders/include/src/stan/model/model_header.hpp:4,
                   from file439375b94caa.cpp:8:
  /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat/functor/algebra_system.hpp:106:34: error: expected ‘,’ or ‘...’ before numeric constant
         hybrj_functor_solver(const FS& fs,
                                    ^
  In file included from /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat/functor/algebra_solver.hpp:4:0,
                   from /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat.hpp:55,
                   from /home/ripley/R/Lib32/StanHeaders/include/stan/math.hpp:4,
                   from /home/ripley/R/Lib32/StanHeaders/include/src/stan/model/model_header.hpp:4,
                   from file439375b94caa.cpp:8:
  /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat/functor/algebra_system.hpp: In constructor ‘stan::math::hybrj_functor_solver<<anonymous> >::hybrj_functor_solver(int)’:
  /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat/functor/algebra_system.hpp:113:11: error: class ‘stan::math::hybrj_functor_solver<<anonymous> >’ does not have any field named ‘fs_’
           : fs_(f, x, y, dat, dat_int, msgs),
             ^
  /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat/functor/algebra_system.hpp:113:15: error: ‘f’ was not declared in this scope
           : fs_(f, x, y, dat, dat_int, msgs),
                 ^
  /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat/functor/algebra_system.hpp:113:18: error: ‘x’ was not declared in this scope
           : fs_(f, x, y, dat, dat_int, msgs),
                    ^
  /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat/functor/algebra_system.hpp:113:21: error: ‘y’ was not declared in this scope
           : fs_(f, x, y, dat, dat_int, msgs),
                       ^
  /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat/functor/algebra_system.hpp:113:24: error: ‘dat’ was not declared in this scope
           : fs_(f, x, y, dat, dat_int, msgs),
                          ^
  /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat/functor/algebra_system.hpp:113:29: error: ‘dat_int’ was not declared in this scope
           : fs_(f, x, y, dat, dat_int, msgs),
                               ^
  /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat/functor/algebra_system.hpp:113:38: error: ‘msgs’ was not declared in this scope
           : fs_(f, x, y, dat, dat_int, msgs),
                                        ^
  /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat/functor/algebra_system.hpp: In member function ‘int stan::math::hybrj_functor_solver<<anonymous> >::operator()(const VectorXd&, Eigen::VectorXd&)’:
  /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat/functor/algebra_system.hpp:124:18: error: ‘fs_’ was not declared in this scope
           jacobian(fs_, iv, fvec, J_);
                    ^
  /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat/functor/algebra_system.hpp: In member function ‘Eigen::MatrixXd stan::math::hybrj_functor_solver<<anonymous> >::get_jacobian(const VectorXd&)’:
  /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat/functor/algebra_system.hpp:147:18: error: ‘fs_’ was not declared in this scope
           jacobian(fs_, iv, fvec, J_);
                    ^
  /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat/functor/algebra_system.hpp: In member function ‘Eigen::VectorXd stan::math::hybrj_functor_solver<<anonymous> >::get_value(const VectorXd&) const’:
  /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat/functor/algebra_system.hpp:158:22: error: there are no arguments to ‘fs_’ that depend on a template parameter, so a declaration of ‘fs_’ must be available [-fpermissive]
           return fs_(iv);
                        ^
  /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat/functor/algebra_system.hpp:158:22: note: (if you use ‘-fpermissive’, G++ will accept your code, but allowing the use of an undeclared name is deprecated)
  In file included from /usr/include/sys/ucontext.h:20:0,
                   from /usr/include/sys/signal.h:231,
                   from /usr/include/sys/procset.h:23,
                   from /usr/include/sys/wait.h:25,
                   from /usr/include/stdlib.h:21,
                   from /opt/csw/include/c++/5.2.0/cstdlib:72,
                   from /home/ripley/R/Lib32/StanHeaders/include/stan/math/memory/stack_alloc.hpp:8,
                   from /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/core/autodiffstackstorage.hpp:4,
                   from /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/core.hpp:4,
                   from /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat.hpp:4,
                   from /home/ripley/R/Lib32/StanHeaders/include/stan/math.hpp:4,
                   from /home/ripley/R/Lib32/StanHeaders/include/src/stan/model/model_header.hpp:4,
                   from file439375b94caa.cpp:8:
  /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat/functor/algebra_solver.hpp: At global scope:
  /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat/functor/algebra_solver.hpp:26:24: error: expected nested-name-specifier before numeric constant
       template <typename FS, typename F, typename T, typename FX>
                          ^
  /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat/functor/algebra_solver.hpp:26:24: error: expected ‘>’ before numeric constant
  In file included from /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat.hpp:55:0,
                   from /home/ripley/R/Lib32/StanHeaders/include/stan/math.hpp:4,
                   from /home/ripley/R/Lib32/StanHeaders/include/src/stan/model/model_header.hpp:4,
                   from file439375b94caa.cpp:8:
  /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat/functor/algebra_solver.hpp:39:27: error: ISO C++ forbids declaration of ‘parameter’ with no type [-fpermissive]
         algebra_solver_vari(const FS& fs,
                             ^
  In file included from /usr/include/sys/ucontext.h:20:0,
                   from /usr/include/sys/signal.h:231,
                   from /usr/include/sys/procset.h:23,
                   from /usr/include/sys/wait.h:25,
                   from /usr/include/stdlib.h:21,
                   from /opt/csw/include/c++/5.2.0/cstdlib:72,
                   from /home/ripley/R/Lib32/StanHeaders/include/stan/math/memory/stack_alloc.hpp:8,
                   from /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/core/autodiffstackstorage.hpp:4,
                   from /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/core.hpp:4,
                   from /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat.hpp:4,
                   from /home/ripley/R/Lib32/StanHeaders/include/stan/math.hpp:4,
                   from /home/ripley/R/Lib32/StanHeaders/include/src/stan/model/model_header.hpp:4,
                   from file439375b94caa.cpp:8:
  /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat/functor/algebra_solver.hpp:39:33: error: expected ‘,’ or ‘...’ before numeric constant
         algebra_solver_vari(const FS& fs,
                                   ^
  In file included from /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat.hpp:55:0,
                   from /home/ripley/R/Lib32/StanHeaders/include/stan/math.hpp:4,
                   from /home/ripley/R/Lib32/StanHeaders/include/src/stan/model/model_header.hpp:4,
                   from file439375b94caa.cpp:8:
  /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat/functor/algebra_solver.hpp: In constructor ‘stan::math::algebra_solver_vari<<anonymous> >::algebra_solver_vari(int)’:
  /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat/functor/algebra_solver.hpp:48:27: error: there are no arguments to ‘theta_dbl’ that depend on a template parameter, so a declaration of ‘theta_dbl’ must be available [-fpermissive]
           : vari(theta_dbl(0)),
                             ^
  /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat/functor/algebra_solver.hpp:49:59: error: ‘y’ was not declared in this scope
             y_(ChainableStack::memalloc_.alloc_array<vari*>(y.size())),
                                                             ^
  /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat/functor/algebra_solver.hpp:51:19: error: ‘x’ was not declared in this scope
             x_size_(x.size()),
                     ^
  /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat/functor/algebra_solver.hpp:62:43: error: there are no arguments to ‘theta_dbl’ that depend on a template parameter, so a declaration of ‘theta_dbl’ must be available [-fpermissive]
             theta_[i] = new vari(theta_dbl(i), false);
                                             ^
  /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat/functor/algebra_solver.hpp:66:42: error: ‘F’ was not declared in this scope
           typedef hybrj_functor_solver<FS, F, double, double> f_y;
                                            ^
  /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat/functor/algebra_solver.hpp:66:59: error: wrong number of template arguments (4, should be 1)
           typedef hybrj_functor_solver<FS, F, double, double> f_y;
                                                             ^
  In file included from /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat/functor/algebra_solver.hpp:4:0,
                   from /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat.hpp:55,
                   from /home/ripley/R/Lib32/StanHeaders/include/stan/math.hpp:4,
                   from /home/ripley/R/Lib32/StanHeaders/include/src/stan/model/model_header.hpp:4,
                   from file439375b94caa.cpp:8:
  /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat/functor/algebra_system.hpp:98:12: note: provided for ‘template<int <anonymous> > struct stan::math::hybrj_functor_solver’
       struct hybrj_functor_solver : nlo_functor<double> {
              ^
  In file included from /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat.hpp:55:0,
                   from /home/ripley/R/Lib32/StanHeaders/include/stan/math.hpp:4,
                   from /home/ripley/R/Lib32/StanHeaders/include/src/stan/model/model_header.hpp:4,
                   from file439375b94caa.cpp:8:
  /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat/functor/algebra_solver.hpp:68:28: error: ‘fx’ was not declared in this scope
             = - mdivide_left(fx.get_jacobian(theta_dbl),
                              ^
  /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat/functor/algebra_solver.hpp:68:44: error: ‘theta_dbl’ was not declared in this scope
             = - mdivide_left(fx.get_jacobian(theta_dbl),
                                              ^
  /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat/functor/algebra_solver.hpp:69:32: error: ‘fs’ was not declared in this scope
                              f_y(fs, f, theta_dbl, value_of(y),
                                  ^
  /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat/functor/algebra_solver.hpp:69:36: error: ‘f’ was not declared in this scope
                              f_y(fs, f, theta_dbl, value_of(y),
                                      ^
  /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat/functor/algebra_solver.hpp:70:32: error: ‘dat’ was not declared in this scope
                                  dat, dat_int, msgs).get_jacobian(value_of(y)));
                                  ^
  /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat/functor/algebra_solver.hpp:70:37: error: ‘dat_int’ was not declared in this scope
                                  dat, dat_int, msgs).get_jacobian(value_of(y)));
                                       ^
  /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat/functor/algebra_solver.hpp:70:46: error: ‘msgs’ was not declared in this scope
                                  dat, dat_int, msgs).get_jacobian(value_of(y)));
                                                ^
  /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat/functor/algebra_solver.hpp:70:52: error: request for member ‘get_jacobian’ in ‘f_y(<expression error>, <expression error>, theta_dbl, <expression error>, <expression error>, <expression error>, <expression error>)’, which is of non-class type ‘f_y {aka int}’
                                  dat, dat_int, msgs).get_jacobian(value_of(y)));
                                                      ^
  In file included from /usr/include/sys/ucontext.h:20:0,
                   from /usr/include/sys/signal.h:231,
                   from /usr/include/sys/procset.h:23,
                   from /usr/include/sys/wait.h:25,
                   from /usr/include/stdlib.h:21,
                   from /opt/csw/include/c++/5.2.0/cstdlib:72,
                   from /home/ripley/R/Lib32/StanHeaders/include/stan/math/memory/stack_alloc.hpp:8,
                   from /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/core/autodiffstackstorage.hpp:4,
                   from /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/core.hpp:4,
                   from /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat.hpp:4,
                   from /home/ripley/R/Lib32/StanHeaders/include/stan/math.hpp:4,
                   from /home/ripley/R/Lib32/StanHeaders/include/src/stan/model/model_header.hpp:4,
                   from file439375b94caa.cpp:8:
  /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat/functor/algebra_solver.hpp: In function ‘Eigen::VectorXd stan::math::algebra_solver(const F&, const VectorXd&, const VectorXd&, const std::vector<double>&, const std::vector<int>&, std::ostream*, double, double, long int)’:
  /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat/functor/algebra_solver.hpp:160:55: error: expected unqualified-id before numeric constant
         typedef system_functor<F, double, double, true> FS;
                                                         ^
  In file included from /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat.hpp:55:0,
                   from /home/ripley/R/Lib32/StanHeaders/include/stan/math.hpp:4,
                   from /home/ripley/R/Lib32/StanHeaders/include/src/stan/model/model_header.hpp:4,
                   from file439375b94caa.cpp:8:
  /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat/functor/algebra_solver.hpp:161:57: error: wrong number of template arguments (4, should be 1)
         typedef hybrj_functor_solver<FS, F, double, double> FX;
                                                           ^
  In file included from /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat/functor/algebra_solver.hpp:4:0,
                   from /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat.hpp:55,
                   from /home/ripley/R/Lib32/StanHeaders/include/stan/math.hpp:4,
                   from /home/ripley/R/Lib32/StanHeaders/include/src/stan/model/model_header.hpp:4,
                   from file439375b94caa.cpp:8:
  /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat/functor/algebra_system.hpp:98:12: note: provided for ‘template<int <anonymous> > struct stan::math::hybrj_functor_solver’
       struct hybrj_functor_solver : nlo_functor<double> {
              ^
  In file included from /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat.hpp:55:0,
                   from /home/ripley/R/Lib32/StanHeaders/include/stan/math.hpp:4,
                   from /home/ripley/R/Lib32/StanHeaders/include/src/stan/model/model_header.hpp:4,
                   from file439375b94caa.cpp:8:
  /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat/functor/algebra_solver.hpp:162:16: error: expression cannot be used as a function
         FX fx(FS(), f, x, y, dat, dat_int, msgs);
                  ^
  /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat/functor/algebra_solver.hpp:162:46: error: expression list treated as compound expression in initializer [-fpermissive]
         FX fx(FS(), f, x, y, dat, dat_int, msgs);
                                                ^
  /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat/functor/algebra_solver.hpp:168:31: error: request for member ‘get_value’ in ‘fx’, which is of non-class type ‘FX {aka int}’
                              fx.get_value(x),
                                 ^
  /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat/functor/algebra_solver.hpp:186:31: error: request for member ‘get_value’ in ‘fx’, which is of non-class type ‘FX {aka int}’
         double system_norm = fx.get_value(theta_dbl).stableNorm();
                                 ^
  In file included from /usr/include/sys/ucontext.h:20:0,
                   from /usr/include/sys/signal.h:231,
                   from /usr/include/sys/procset.h:23,
                   from /usr/include/sys/wait.h:25,
                   from /usr/include/stdlib.h:21,
                   from /opt/csw/include/c++/5.2.0/cstdlib:72,
                   from /home/ripley/R/Lib32/StanHeaders/include/stan/math/memory/stack_alloc.hpp:8,
                   from /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/core/autodiffstackstorage.hpp:4,
                   from /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/core.hpp:4,
                   from /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat.hpp:4,
                   from /home/ripley/R/Lib32/StanHeaders/include/stan/math.hpp:4,
                   from /home/ripley/R/Lib32/StanHeaders/include/src/stan/model/model_header.hpp:4,
                   from file439375b94caa.cpp:8:
  /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat/functor/algebra_solver.hpp: In function ‘Eigen::Matrix<RhsScalar, -1, 1> stan::math::algebra_solver(const F&, const VectorXd&, const Eigen::Matrix<RhsScalar, -1, 1>&, const std::vector<double>&, const std::vector<int>&, std::ostream*, double, double, long int)’:
  /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat/functor/algebra_solver.hpp:265:55: error: expected unqualified-id before numeric constant
         typedef system_functor<F, double, double, true> FS;
                                                         ^
  In file included from /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat.hpp:55:0,
                   from /home/ripley/R/Lib32/StanHeaders/include/stan/math.hpp:4,
                   from /home/ripley/R/Lib32/StanHeaders/include/src/stan/model/model_header.hpp:4,
                   from file439375b94caa.cpp:8:
  /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat/functor/algebra_solver.hpp:266:57: error: wrong number of template arguments (4, should be 1)
         typedef hybrj_functor_solver<FS, F, double, double> FX;
                                                           ^
  In file included from /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat/functor/algebra_solver.hpp:4:0,
                   from /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat.hpp:55,
                   from /home/ripley/R/Lib32/StanHeaders/include/stan/math.hpp:4,
                   from /home/ripley/R/Lib32/StanHeaders/include/src/stan/model/model_header.hpp:4,
                   from file439375b94caa.cpp:8:
  /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat/functor/algebra_system.hpp:98:12: note: provided for ‘template<int <anonymous> > struct stan::math::hybrj_functor_solver’
       struct hybrj_functor_solver : nlo_functor<double> {
              ^
  In file included from /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat.hpp:55:0,
                   from /home/ripley/R/Lib32/StanHeaders/include/stan/math.hpp:4,
                   from /home/ripley/R/Lib32/StanHeaders/include/src/stan/model/model_header.hpp:4,
                   from file439375b94caa.cpp:8:
  /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat/functor/algebra_solver.hpp:267:16: error: expression cannot be used as a function
         FX fx(FS(), f, x, value_of(y), dat, dat_int, msgs);
                  ^
  /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat/functor/algebra_solver.hpp:267:56: error: expression list treated as compound expression in initializer [-fpermissive]
         FX fx(FS(), f, x, value_of(y), dat, dat_int, msgs);
                                                          ^
  /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat/functor/algebra_solver.hpp:270:40: error: wrong number of template arguments (4, should be 1)
         algebra_solver_vari<FY, F,  T, FX>* vi0
                                          ^
  /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat/functor/algebra_solver.hpp:27:12: note: provided for ‘template<int <anonymous> > struct stan::math::algebra_solver_vari’
       struct algebra_solver_vari : public vari {
              ^
  /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat/functor/algebra_solver.hpp:271:47: error: wrong number of template arguments (4, should be 1)
           = new algebra_solver_vari<FY, F, T, FX>(FY(), f, x, y, dat, dat_int,
                                                 ^
  /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat/functor/algebra_solver.hpp:27:12: note: provided for ‘template<int <anonymous> > struct stan::math::algebra_solver_vari’
       struct algebra_solver_vari : public vari {
              ^
  /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat/functor/algebra_solver.hpp:274:27: error: request for member ‘theta_’ in ‘vi0->’, which is of non-class type ‘int’
         theta(0) = var(vi0->theta_[0]);
                             ^
  /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat/functor/algebra_solver.hpp:276:29: error: request for member ‘theta_’ in ‘vi0->’, which is of non-class type ‘int’
           theta(i) = var(vi0->theta_[i]);
                               ^
  make: Fatal error: Command failed for target `file439375b94caa.o'
  Current working directory /tmp/RtmpWWayYH
  
  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 model439319d3ba2_2017_01_04_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", "model439319d3ba2_2017_01_04");
   30:     reader.add_event(232, 232, "end", "model439319d3ba2_2017_01_04");
   31:     return reader;
   32: }
   33: 
   34: class model439319d3ba2_2017_01_04 : public prob_grad {
   35: private:
   36:     int G;
   37:     int G_hier;
   38:     int Q;
   39:     int T;
   40:     int N;
   41:     int N_observed;
   42:     int S;
   43:     int P;
   44:     int H;
   45:     int Hprior;
   46:     int D;
   47:     int constant_item;
   48:     int separate_t;
   49:     int hierarchical_model;
   50:     double delta_tbar_prior_mean;
   51:     double delta_tbar_prior_sd;
   52:     double innov_sd_delta_scale;
   53:     double innov_sd_theta_scale;
   54:     vector<int> n_vec;
   55:     vector<int> s_vec;
   56:     vector<int> observed;
   57:     vector<vector<vector<int> > > NNl2;
   58:     vector<vector<vector<int> > > SSl2;
   59:     matrix_d XX;
   60:     vector<matrix_d> WT;
   61:     vector<matrix_d> ZZ;
   62:     vector<matrix_d> ZZ_prior;
   63:     matrix_d l2_only;
   64: public:
   65:     model439319d3ba2_2017_01_04(stan::io::var_context& context__,
   66:         std::ostream* pstream__ = 0)
   67:         : prob_grad(0) {
   68:         ctor_body(context__, 0, pstream__);
   69:     }
   70: 
   71:     model439319d3ba2_2017_01_04(stan::io::var_context& context__,
   72:         unsigned int random_seed__,
   73:         std::ostream* pstream__ = 0)
   74:         : prob_grad(0) {
   75:         ctor_body(context__, random_seed__, pstream__);
   76:     }
   77: 
   78:     void ctor_body(stan::io::var_context& context__,
   79:                    unsigned int random_seed__,
   80:                    std::ostream* pstream__) {
   81:         boost::ecuyer1988 base_rng__ =
   82:           stan::services::util::create_rng(random_seed__, 0);
   83:         (void) base_rng__;  // suppress unused var warning
   84: 
   85:         current_statement_begin__ = -1;
   86: 
   87:         static const char* function__ = "model439319d3ba2_2017_01_04_namespace::model439319d3ba2_2017_01_04";
   88:         (void) function__;  // dummy to suppress unused var warning
   89:         size_t pos__;
   90:         (void) pos__;  // dummy to suppress unused var warning
   91:         std::vector<int> vals_i__;
   92:         std::vector<double> vals_r__;
   93:         double DUMMY_VAR__(std::numeric_limits<double>::quiet_NaN());
   94:         (void) DUMMY_VAR__;  // suppress unused var warning
   95: 
   96:         // initialize member variables
   97:         try {
   98:             current_statement_begin__ = 2;
   99:             context__.validate_dims("data initialization", "G", "int", context__.to_vec());
  100:             G = int(0);
  101:             vals_i__ = context__.vals_i("G");
  102:             pos__ = 0;
  103:             G = vals_i__[pos__++];
  104:             current_statement_begin__ = 3;
  105:             context__.validate_dims("data initialization", "G_hier", "int", context__.to_vec());
  106:             G_hier = int(0);
  107:             vals_i__ = context__.vals_i("G_hier");
  108:             pos__ = 0;
  109:             G_hier = vals_i__[pos__++];
  110:             current_statement_begin__ = 4;
  111:             context__.validate_dims("data initialization", "Q", "int", context__.to_vec());
  112:             Q = int(0);
  113:             vals_i__ = context__.vals_i("Q");
  114:             pos__ = 0;
  115:             Q = vals_i__[pos__++];
  116:             current_statement_begin__ = 5;
  117:             context__.validate_dims("data initialization", "T", "int", context__.to_vec());
  118:             T = int(0);
  119:             vals_i__ = context__.vals_i("T");
  120:             pos__ = 0;
  121:             T = vals_i__[pos__++];
  122:             current_statement_begin__ = 6;
  123:             context__.validate_dims("data initialization", "N", "int", context__.to_vec());
  124:             N = int(0);
  125:             vals_i__ = context__.vals_i("N");
  126:             pos__ = 0;
  127:             N = vals_i__[pos__++];
  128:             current_statement_begin__ = 7;
  129:             context__.validate_dims("data initialization", "N_observed", "int", context__.to_vec());
  130:             N_observed = int(0);
  131:             vals_i__ = context__.vals_i("N_observed");
  132:             pos__ = 0;
  133:             N_observed = vals_i__[pos__++];
  134:             current_statement_begin__ = 8;
  135:             context__.validate_dims("data initialization", "S", "int", context__.to_vec());
  136:             S = int(0);
  137:             vals_i__ = context__.vals_i("S");
  138:             pos__ = 0;
  139:             S = vals_i__[pos__++];
  140:             current_statement_begin__ = 9;
  141:             context__.validate_dims("data initialization", "P", "int", context__.to_vec());
  142:             P = int(0);
  143:             vals_i__ = context__.vals_i("P");
  144:             pos__ = 0;
  145:             P = vals_i__[pos__++];
  146:             current_statement_begin__ = 10;
  147:             context__.validate_dims("data initialization", "H", "int", context__.to_vec());
  148:             H = int(0);
  149:             vals_i__ = context__.vals_i("H");
  150:             pos__ = 0;
  151:             H = vals_i__[pos__++];
  152:             current_statement_begin__ = 11;
  153:             context__.validate_dims("data initialization", "Hprior", "int", context__.to_vec());
  154:             Hprior = int(0);
  155:             vals_i__ = context__.vals_i("Hprior");
  156:             pos__ = 0;
  157:             Hprior = vals_i__[pos__++];
  158:             current_statement_begin__ = 12;
  159:             context__.validate_dims("data initialization", "D", "int", context__.to_vec());
  160:             D = int(0);
  161:             vals_i__ = context__.vals_i("D");
  162:             pos__ = 0;
  163:             D = vals_i__[pos__++];
  164:             current_statement_begin__ = 13;
  165:             context__.validate_dims("data initialization", "constant_item", "int", context__.to_vec());
  166:             constant_item = int(0);
  167:             vals_i__ = context__.vals_i("constant_item");
  168:             pos__ = 0;
  169:             constant_item = vals_i__[pos__++];
  170:             current_statement_begin__ = 14;
  171:             context__.validate_dims("data initialization", "separate_t", "int", context__.to_vec());
  172:             separate_t = int(0);
  173:             vals_i__ = context__.vals_i("separate_t");
  174:             pos__ = 0;
  175:             separate_t = vals_i__[pos__++];
  176:             current_statement_begin__ = 15;
  177:             context__.validate_dims("data initialization", "hierarchical_model", "int", context__.to_vec());
  178:             hierarchical_model = int(0);
  179:             vals_i__ = context__.vals_i("hierarchical_model");
  180:             pos__ = 0;
  181:             hierarchical_model = vals_i__[pos__++];
  182:             current_statement_begin__ = 16;
  183:             context__.validate_dims("data initialization", "delta_tbar_prior_mean", "double", context__.to_vec());
  184:             delta_tbar_prior_mean = double(0);
  185:             vals_r__ = context__.vals_r("delta_tbar_prior_mean");
  186:             pos__ = 0;
  187:             delta_tbar_prior_mean = vals_r__[pos__++];
  188:             current_statement_begin__ = 17;
  189:             context__.validate_dims("data initialization", "delta_tbar_prior_sd", "double", context__.to_vec());
  190:             delta_tbar_prior_sd = double(0);
  191:             vals_r__ = context__.vals_r("delta_tbar_prior_sd");
  192:             pos__ = 0;
  193:             delta_tbar_prior_sd = vals_r__[pos__++];
  194:             current_statement_begin__ = 18;
  195:             context__.validate_dims("data initialization", "innov_sd_delta_scale", "double", context__.to_vec());
  196:             innov_sd_delta_scale = double(0);
  197:             vals_r__ = context__.vals_r("innov_sd_delta_scale");
  198:             pos__ = 0;
  199:             innov_sd_delta_scale = vals_r__[pos__++];
  200:             current_statement_begin__ = 19;
  201:             context__.validate_dims("data initialization", "innov_sd_theta_scale", "double", context__.to_vec());
  202:             innov_sd_theta_scale = double(0);
  203:             vals_r__ = context__.vals_r("innov_sd_theta_scale");
  204:             pos__ = 0;
  205:             innov_sd_theta_scale = vals_r__[pos__++];
  206:             current_statement_begin__ = 20;
  207:             validate_non_negative_index("n_vec", "N", N);
  208:             context__.validate_dims("data initialization", "n_vec", "int", context__.to_vec(N));
  209:             validate_non_negative_index("n_vec", "N", N);
  210:             n_vec = std::vector<int>(N,int(0));
  211:             vals_i__ = context__.vals_i("n_vec");
  212:             pos__ = 0;
  213:             size_t n_vec_limit_0__ = N;
  214:             for (size_t i_0__ = 0; i_0__ < n_vec_limit_0__; ++i_0__) {
  215:                 n_vec[i_0__] = vals_i__[pos__++];
  216:             }
  217:             current_statement_begin__ = 21;
  218:             validate_non_negative_index("s_vec", "N", N);
  219:             context__.validate_dims("data initialization", "s_vec", "int", context__.to_vec(N));
  220:             validate_non_negative_index("s_vec", "N", N);
  221:             s_vec = std::vector<int>(N,int(0));
  222:             vals_i__ = context__.vals_i("s_vec");
  223:             pos__ = 0;
  224:             size_t s_vec_limit_0__ = N;
  225:             for (size_t i_0__ = 0; i_0__ < s_vec_limit_0__; ++i_0__) {
  226:                 s_vec[i_0__] = vals_i__[pos__++];
  227:             }
  228:             current_statement_begin__ = 22;
  229:             validate_non_negative_index("observed", "N_observed", N_observed);
  230:             context__.validate_dims("data initialization", "observed", "int", context__.to_vec(N_observed));
  231:             validate_non_negative_index("observed", "N_observed", N_observed);
  232:             observed = std::vector<int>(N_observed,int(0));
  233:             vals_i__ = context__.vals_i("observed");
  234:             pos__ = 0;
  235:             size_t observed_limit_0__ = N_observed;
  236:             for (size_t i_0__ = 0; i_0__ < observed_limit_0__; ++i_0__) {
  237:                 observed[i_0__] = vals_i__[pos__++];
  238:             }
  239:             current_statement_begin__ = 23;
  240:             validate_non_negative_index("NNl2", "T", T);
  241:             validate_non_negative_index("NNl2", "Q", Q);
  242:             validate_non_negative_index("NNl2", "G_hier", G_hier);
  243:             context__.validate_dims("data initialization", "NNl2", "int", context__.to_vec(T,Q,G_hier));
  244:             validate_non_negative_index("NNl2", "T", T);
  245:             validate_non_negative_index("NNl2", "Q", Q);
  246:             validate_non_negative_index("NNl2", "G_hier", G_hier);
  247:             NNl2 = std::vector<std::vector<std::vector<int> > >(T,std::vector<std::vector<int> >(Q,std::vector<int>(G_hier,int(0))));
  248:             vals_i__ = context__.vals_i("NNl2");
  249:             pos__ = 0;
  250:             size_t NNl2_limit_2__ = G_hier;
  251:             for (size_t i_2__ = 0; i_2__ < NNl2_limit_2__; ++i_2__) {
  252:                 size_t NNl2_limit_1__ = Q;
  253:                 for (size_t i_1__ = 0; i_1__ < NNl2_limit_1__; ++i_1__) {
  254:                     size_t NNl2_limit_0__ = T;
  255:                     for (size_t i_0__ = 0; i_0__ < NNl2_limit_0__; ++i_0__) {
  256:                         NNl2[i_0__][i_1__][i_2__] = vals_i__[pos__++];
  257:                     }
  258:                 }
  259:             }
  260:             current_statement_begin__ = 24;
  261:             validate_non_negative_index("SSl2", "T", T);
  262:             validate_non_negative_index("SSl2", "Q", Q);
  263:             validate_non_negative_index("SSl2", "G_hier", G_hier);
  264:             context__.validate_dims("data initialization", "SSl2", "int", context__.to_vec(T,Q,G_hier));
  265:             validate_non_negative_index("SSl2", "T", T);
  266:             validate_non_negative_index("SSl2", "Q", Q);
  267:             validate_non_negative_index("SSl2", "G_hier", G_hier);
  268:             SSl2 = std::vector<std::vector<std::vector<int> > >(T,std::vector<std::vector<int> >(Q,std::vector<int>(G_hier,int(0))));
  269:             vals_i__ = context__.vals_i("SSl2");
  270:             pos__ = 0;
  271:             size_t SSl2_limit_2__ = G_hier;
  272:             for (size_t i_2__ = 0; i_2__ < SSl2_limit_2__; ++i_2__) {
  273:                 size_t SSl2_limit_1__ = Q;
  274:                 for (size_t i_1__ = 0; i_1__ < SSl2_limit_1__; ++i_1__) {
  275:                     size_t SSl2_limit_0__ = T;
  276:                     for (size_t i_0__ = 0; i_0__ < SSl2_limit_0__; ++i_0__) {
  277:                         SSl2[i_0__][i_1__][i_2__] = vals_i__[pos__++];
  278:                     }
  279:                 }
  280:             }
  281:             current_statement_begin__ = 25;
  282:             validate_non_negative_index("XX", "G", G);
  283:             validate_non_negative_index("XX", "P", P);
  284:             context__.validate_dims("data initialization", "XX", "matrix_d", context__.to_vec(G,P));
  285:             validate_non_negative_index("XX", "G", G);
  286:             validate_non_negative_index("XX", "P", P);
  287:             XX = matrix_d(static_cast<Eigen::VectorXd::Index>(G),static_cast<Eigen::VectorXd::Index>(P));
  288:             vals_r__ = context__.vals_r("XX");
  289:             pos__ = 0;
  290:             size_t XX_m_mat_lim__ = G;
  291:             size_t XX_n_mat_lim__ = P;
  292:             for (size_t n_mat__ = 0; n_mat__ < XX_n_mat_lim__; ++n_mat__) {
  293:                 for (size_t m_mat__ = 0; m_mat__ < XX_m_mat_lim__; ++m_mat__) {
  294:                     XX(m_mat__,n_mat__) = vals_r__[pos__++];
  295:                 }
  296:             }
  297:             current_statement_begin__ = 26;
  298:             validate_non_negative_index("WT", "T", T);
  299:             validate_non_negative_index("WT", "G_hier", G_hier);
  300:             validate_non_negative_index("WT", "G", G);
  301:             context__.validate_dims("data initialization", "WT", "matrix_d", context__.to_vec(T,G_hier,G));
  302:             validate_non_negative_index("WT", "T", T);
  303:             validate_non_negative_index("WT", "G_hier", G_hier);
  304:             validate_non_negative_index("WT", "G", G);
  305:             WT = std::vector<matrix_d>(T,matrix_d(static_cast<Eigen::VectorXd::Index>(G_hier),static_cast<Eigen::VectorXd::Index>(G)));
  306:             vals_r__ = context__.vals_r("WT");
  307:             pos__ = 0;
  308:             size_t WT_m_mat_lim__ = G_hier;
  309:             size_t WT_n_mat_lim__ = G;
  310:             for (size_t n_mat__ = 0; n_mat__ < WT_n_mat_lim__; ++n_mat__) {
  311:                 for (size_t m_mat__ = 0; m_mat__ < WT_m_mat_lim__; ++m_mat__) {
  312:                     size_t WT_limit_0__ = T;
  313:                     for (size_t i_0__ = 0; i_0__ < WT_limit_0__; ++i_0__) {
  314:                         WT[i_0__](m_mat__,n_mat__) = vals_r__[pos__++];
  315:             }
  316:                 }
  317:             }
  318:             current_statement_begin__ = 27;
  319:             validate_non_negative_index("ZZ", "T", T);
  320:             validate_non_negative_index("ZZ", "P", P);
  321:             validate_non_negative_index("ZZ", "H", H);
  322:             context__.validate_dims("data initialization", "ZZ", "matrix_d", context__.to_vec(T,P,H));
  323:             validate_non_negative_index("ZZ", "T", T);
  324:             validate_non_negative_index("ZZ", "P", P);
  325:             validate_non_negative_index("ZZ", "H", H);
  326:             ZZ = std::vector<matrix_d>(T,matrix_d(static_cast<Eigen::VectorXd::Index>(P),static_cast<Eigen::VectorXd::Index>(H)));
  327:             vals_r__ = context__.vals_r("ZZ");
  328:             pos__ = 0;
  329:             size_t ZZ_m_mat_lim__ = P;
  330:             size_t ZZ_n_mat_lim__ = H;
  331:             for (size_t n_mat__ = 0; n_mat__ < ZZ_n_mat_lim__; ++n_mat__) {
  332:                 for (size_t m_mat__ = 0; m_mat__ < ZZ_m_mat_lim__; ++m_mat__) {
  333:                     size_t ZZ_limit_0__ = T;
  334:                     for (size_t i_0__ = 0; i_0__ < ZZ_limit_0__; ++i_0__) {
  335:                         ZZ[i_0__](m_mat__,n_mat__) = vals_r__[pos__++];
  336:             }
  337:                 }
  338:             }
  339:             current_statement_begin__ = 28;
  340:             validate_non_negative_index("ZZ_prior", "T", T);
  341:             validate_non_negative_index("ZZ_prior", "P", P);
  342:             validate_non_negative_index("ZZ_prior", "Hprior", Hprior);
  343:             context__.validate_dims("data initialization", "ZZ_prior", "matrix_d", context__.to_vec(T,P,Hprior));
  344:             validate_non_negative_index("ZZ_prior", "T", T);
  345:             validate_non_negative_index("ZZ_prior", "P", P);
  346:             validate_non_negative_index("ZZ_prior", "Hprior", Hprior);
  347:             ZZ_prior = std::vector<matrix_d>(T,matrix_d(static_cast<Eigen::VectorXd::Index>(P),static_cast<Eigen::VectorXd::Index>(Hprior)));
  348:             vals_r__ = context__.vals_r("ZZ_prior");
  349:             pos__ = 0;
  350:             size_t ZZ_prior_m_mat_lim__ = P;
  351:             size_t ZZ_prior_n_mat_lim__ = Hprior;
  352:             for (size_t n_mat__ = 0; n_mat__ < ZZ_prior_n_mat_lim__; ++n_mat__) {
  353:                 for (size_t m_mat__ = 0; m_mat__ < ZZ_prior_m_mat_lim__; ++m_mat__) {
  354:                     size_t ZZ_prior_limit_0__ = T;
  355:                     for (size_t i_0__ = 0; i_0__ < ZZ_prior_limit_0__; ++i_0__) {
  356:                         ZZ_prior[i_0__](m_mat__,n_mat__) = vals_r__[pos__++];
  357:             }
  358:                 }
  359:             }
  360:             current_statement_begin__ = 29;
  361:             validate_non_negative_index("l2_only", "T", T);
  362:             validate_non_negative_index("l2_only", "Q", Q);
  363:             context__.validate_dims("data initialization", "l2_only", "matrix_d", context__.to_vec(T,Q));
  364:             validate_non_negative_index("l2_only", "T", T);
  365:             validate_non_negative_index("l2_only", "Q", Q);
  366:             l2_only = matrix_d(static_cast<Eigen::VectorXd::Index>(T),static_cast<Eigen::VectorXd::Index>(Q));
  367:             vals_r__ = context__.vals_r("l2_only");
  368:             pos__ = 0;
  369:             size_t l2_only_m_mat_lim__ = T;
  370:             size_t l2_only_n_mat_lim__ = Q;
  371:             for (size_t n_mat__ = 0; n_mat__ < l2_only_n_mat_lim__; ++n_mat__) {
  372:                 for (size_t m_mat__ = 0; m_mat__ < l2_only_m_mat_lim__; ++m_mat__) {
  373:                     l2_only(m_mat__,n_mat__) = vals_r__[pos__++];
  374:                 }
  375:             }
  376: 
  377:             // validate, data variables
  378:             current_statement_begin__ = 2;
  379:             check_greater_or_equal(function__,"G",G,1);
  380:             current_statement_begin__ = 3;
  381:             check_greater_or_equal(function__,"G_hier",G_hier,1);
  382:             current_statement_begin__ = 4;
  383:             check_greater_or_equal(function__,"Q",Q,1);
  384:             current_statement_begin__ = 5;
  385:             check_greater_or_equal(function__,"T",T,1);
  386:             current_statement_begin__ = 6;
  387:             check_greater_or_equal(function__,"N",N,1);
  388:             current_statement_begin__ = 7;
  389:             check_greater_or_equal(function__,"N_observed",N_observed,1);
  390:             current_statement_begin__ = 8;
  391:             check_greater_or_equal(function__,"S",S,1);
  392:             current_statement_begin__ = 9;
  393:             check_greater_or_equal(function__,"P",P,1);
  394:             current_statement_begin__ = 10;
  395:             check_greater_or_equal(function__,"H",H,1);
  396:             current_statement_begin__ = 11;
  397:             check_greater_or_equal(function__,"Hprior",Hprior,1);
  398:             current_statement_begin__ = 12;
  399:             check_greater_or_equal(function__,"D",D,1);
  400:             current_statement_begin__ = 13;
  401:             check_greater_or_equal(function__,"constant_item",constant_item,0);
  402:             check_less_or_equal(function__,"constant_item",constant_item,1);
  403:             current_statement_begin__ = 14;
  404:             check_greater_or_equal(function__,"separate_t",separate_t,0);
  405:             check_less_or_equal(function__,"separate_t",separate_t,1);
  406:             current_statement_begin__ = 15;
  407:             check_greater_or_equal(function__,"hierarchical_model",hierarchical_model,0);
  408:             check_less_or_equal(function__,"hierarchical_model",hierarchical_model,1);
  409:             current_statement_begin__ = 16;
  410:             current_statement_begin__ = 17;
  411:             check_greater_or_equal(function__,"delta_tbar_prior_sd",delta_tbar_prior_sd,0);
  412:             current_statement_begin__ = 18;
  413:             check_greater_or_equal(function__,"innov_sd_delta_scale",innov_sd_delta_scale,0);
  414:             current_statement_begin__ = 19;
  415:             check_greater_or_equal(function__,"innov_sd_theta_scale",innov_sd_theta_scale,0);
  416:             current_statement_begin__ = 20;
  417:             for (int k0__ = 0; k0__ < N; ++k0__) {
  418:                 check_greater_or_equal(function__,"n_vec[k0__]",n_vec[k0__],0);
  419:             }
  420:             current_statement_begin__ = 21;
  421:             for (int k0__ = 0; k0__ < N; ++k0__) {
  422:                 check_greater_or_equal(function__,"s_vec[k0__]",s_vec[k0__],0);
  423:             }
  424:             current_statement_begin__ = 22;
  425:             current_statement_begin__ = 23;
  426:             current_statement_begin__ = 24;
  427:             current_statement_begin__ = 25;
  428:             check_greater_or_equal(function__,"XX",XX,0);
  429:             check_less_or_equal(function__,"XX",XX,1);
  430:             current_statement_begin__ = 26;
  431:             for (int k0__ = 0; k0__ < T; ++k0__) {
  432:                 check_greater_or_equal(function__,"WT[k0__]",WT[k0__],0);
  433:                 check_less_or_equal(function__,"WT[k0__]",WT[k0__],1);
  434:             }
  435:             current_statement_begin__ = 27;
  436:             current_statement_begin__ = 28;
  437:             current_statement_begin__ = 29;
  438:             check_greater_or_equal(function__,"l2_only",l2_only,0);
  439:             check_less_or_equal(function__,"l2_only",l2_only,1);
  440:             // initialize data variables
  441: 
  442: 
  443:             // validate transformed data
  444: 
  445:             // validate, set parameter ranges
  446:             num_params_r__ = 0U;
  447:             param_ranges_i__.clear();
  448:             current_statement_begin__ = 36;
  449:             validate_non_negative_index("diff_raw", "Q", Q);
  450:             validate_non_negative_index("diff_raw", "D", D);
  451:             num_params_r__ += Q * D;
  452:             current_statement_begin__ = 37;
  453:             validate_non_negative_index("disc_raw", "Q", Q);
  454:             num_params_r__ += Q;
  455:             current_statement_begin__ = 38;
  456:             validate_non_negative_index("xi", "T", T);
  457:             num_params_r__ += T;
  458:             current_statement_begin__ = 39;
  459:             validate_non_negative_index("gamma_raw", "P", P);
  460:             validate_non_negative_index("gamma_raw", "T", T);
  461:             num_params_r__ += P * T;
  462:             current_statement_begin__ = 40;
  463:             validate_non_negative_index("delta_gamma", "T", T);
  464:             num_params_r__ += T;
  465:             current_statement_begin__ = 41;
  466:             validate_non_negative_index("nu_geo", "H", H);
  467:             validate_non_negative_index("nu_geo", "T", T);
  468:             num_params_r__ += H * T;
  469:             current_statement_begin__ = 42;
  470:             validate_non_negative_index("nu_geo_prior", "Hprior", Hprior);
  471:             num_params_r__ += Hprior;
  472:             current_statement_begin__ = 43;
  473:             validate_non_negative_index("delta_tbar", "T", T);
  474:             num_params_r__ += T;
  475:             current_statement_begin__ = 44;
  476:             validate_non_negative_index("theta_bar_raw", "G", G);
  477:             validate_non_negative_index("theta_bar_raw", "T", T);
  478:             num_params_r__ += G * T;
  479:             current_statement_begin__ = 45;
  480:             validate_non_negative_index("sd_theta_bar", "T", T);
  481:             num_params_r__ += T;
  482:             current_statement_begin__ = 46;
  483:             validate_non_negative_index("sd_theta", "T", T);
  484:             num_params_r__ += T;
  485:             current_statement_begin__ = 47;
  486:             ++num_params_r__;
  487:             current_statement_begin__ = 48;
  488:             ++num_params_r__;
  489:             current_statement_begin__ = 49;
  490:             ++num_params_r__;
  491:             current_statement_begin__ = 50;
  492:             ++num_params_r__;
  493:             current_statement_begin__ = 51;
  494:             ++num_params_r__;
  495:         } catch (const std::exception& e) {
  496:             stan::lang::rethrow_located(e, current_statement_begin__, prog_reader__());
  497:             // Next line prevents compiler griping about no return
  498:             throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***");
  499:         }
  500:     }
  501: 
  502:     ~model439319d3ba2_2017_01_04() { }
  503: 
  504: 
  505:     void transform_inits(const stan::io::var_context& context__,
  506:                          std::vector<int>& params_i__,
  507:                          std::vector<double>& params_r__,
  508:                          std::ostream* pstream__) const {
  509:         stan::io::writer<double> writer__(params_r__,params_i__);
  510:         size_t pos__;
  511:         (void) pos__; // dummy call to supress warning
  512:         std::vector<double> vals_r__;
  513:         std::vector<int> vals_i__;
  514: 
  515:         if (!(context__.contains_r("diff_raw")))
  516:             throw std::runtime_error("variable diff_raw missing");
  517:         vals_r__ = context__.vals_r("diff_raw");
  518:         pos__ = 0U;
  519:         validate_non_negative_index("diff_raw", "D", D);
  520:         validate_non_negative_index("diff_raw", "Q", Q);
  521:         context__.validate_dims("initialization", "diff_raw", "vector_d", context__.to_vec(D,Q));
  522:         std::vector<vector_d> diff_raw(D,vector_d(static_cast<Eigen::VectorXd::Index>(Q)));
  523:         for (int j1__ = 0U; j1__ < Q; ++j1__)
  524:             for (int i0__ = 0U; i0__ < D; ++i0__)
  525:                 diff_raw[i0__](j1__) = vals_r__[pos__++];
  526:         for (int i0__ = 0U; i0__ < D; ++i0__)
  527:             try {
  528:             writer__.vector_unconstrain(diff_raw[i0__]);
  529:         } catch (const std::exception& e) { 
  530:             throw std::runtime_error(std::string("Error transforming variable diff_raw: ") + e.what());
  531:         }
  532: 
  533:         if (!(context__.contains_r("disc_raw")))
  534:             throw std::runtime_error("variable disc_raw missing");
  535:         vals_r__ = context__.vals_r("disc_raw");
  536:         pos__ = 0U;
  537:         validate_non_negative_index("disc_raw", "Q", Q);
  538:         context__.validate_dims("initialization", "disc_raw", "vector_d", context__.to_vec(Q));
  539:         vector_d disc_raw(static_cast<Eigen::VectorXd::Index>(Q));
  540:         for (int j1__ = 0U; j1__ < Q; ++j1__)
  541:             disc_raw(j1__) = vals_r__[pos__++];
  542:         try {
  543:             writer__.vector_lb_unconstrain(0,disc_raw);
  544:         } catch (const std::exception& e) { 
  545:             throw std::runtime_error(std::string("Error transforming variable disc_raw: ") + e.what());
  546:         }
  547: 
  548:         if (!(context__.contains_r("xi")))
  549:             throw std::runtime_error("variable xi missing");
  550:         vals_r__ = context__.vals_r("xi");
  551:         pos__ = 0U;
  552:         validate_non_negative_index("xi", "T", T);
  553:         context__.validate_dims("initialization", "xi", "vector_d", context__.to_vec(T));
  554:         vector_d xi(static_cast<Eigen::VectorXd::Index>(T));
  555:         for (int j1__ = 0U; j1__ < T; ++j1__)
  556:             xi(j1__) = vals_r__[pos__++];
  557:         try {
  558:             writer__.vector_unconstrain(xi);
  559:         } catch (const std::exception& e) { 
  560:             throw std::runtime_error(std::string("Error transforming variable xi: ") + e.what());
  561:         }
  562: 
  563:         if (!(context__.contains_r("gamma_raw")))
  564:             throw std::runtime_error("variable gamma_raw missing");
  565:         vals_r__ = context__.vals_r("gamma_raw");
  566:         pos__ = 0U;
  567:         validate_non_negative_index("gamma_raw", "T", T);
  568:         validate_non_negative_index("gamma_raw", "P", P);
  569:         context__.validate_dims("initialization", "gamma_raw", "vector_d", context__.to_vec(T,P));
  570:         std::vector<vector_d> gamma_raw(T,vector_d(static_cast<Eigen::VectorXd::Index>(P)));
  571:         for (int j1__ = 0U; j1__ < P; ++j1__)
  572:             for (int i0__ = 0U; i0__ < T; ++i0__)
  573:                 gamma_raw[i0__](j1__) = vals_r__[pos__++];
  574:         for (int i0__ = 0U; i0__ < T; ++i0__)
  575:             try {
  576:             writer__.vector_unconstrain(gamma_raw[i0__]);
  577:         } catch (const std::exception& e) { 
  578:             throw std::runtime_error(std::string("Error transforming variable gamma_raw: ") + e.what());
  579:         }
  580: 
  581:         if (!(context__.contains_r("delta_gamma")))
  582:             throw std::runtime_error("variable delta_gamma missing");
  583:         vals_r__ = context__.vals_r("delta_gamma");
  584:         pos__ = 0U;
  585:         validate_non_negative_index("delta_gamma", "T", T);
  586:         context__.validate_dims("initialization", "delta_gamma", "vector_d", context__.to_vec(T));
  587:         vector_d delta_gamma(static_cast<Eigen::VectorXd::Index>(T));
  588:         for (int j1__ = 0U; j1__ < T; ++j1__)
  589:             delta_gamma(j1__) = vals_r__[pos__++];
  590:         try {
  591:             writer__.vector_unconstrain(delta_gamma);
  592:         } catch (const std::exception& e) { 
  593:             throw std::runtime_error(std::string("Error transforming variable delta_gamma: ") + e.what());
  594:         }
  595: 
  596:         if (!(context__.contains_r("nu_geo")))
  597:             throw std::runtime_error("variable nu_geo missing");
  598:         vals_r__ = context__.vals_r("nu_geo");
  599:         pos__ = 0U;
  600:         validate_non_negative_index("nu_geo", "T", T);
  601:         validate_non_negative_index("nu_geo", "H", H);
  602:         context__.validate_dims("initialization", "nu_geo", "vector_d", context__.to_vec(T,H));
  603:         std::vector<vector_d> nu_geo(T,vector_d(static_cast<Eigen::VectorXd::Index>(H)));
  604:         for (int j1__ = 0U; j1__ < H; ++j1__)
  605:             for (int i0__ = 0U; i0__ < T; ++i0__)
  606:                 nu_geo[i0__](j1__) = vals_r__[pos__++];
  607:         for (int i0__ = 0U; i0__ < T; ++i0__)
  608:             try {
  609:             writer__.vector_unconstrain(nu_geo[i0__]);
  610:         } catch (const std::exception& e) { 
  611:             throw std::runtime_error(std::string("Error transforming variable nu_geo: ") + e.what());
  612:         }
  613: 
  614:         if (!(context__.contains_r("nu_geo_prior")))
  615:             throw std::runtime_error("variable nu_geo_prior missing");
  616:         vals_r__ = context__.vals_r("nu_geo_prior");
  617:         pos__ = 0U;
  618:         validate_non_negative_index("nu_geo_prior", "Hprior", Hprior);
  619:         context__.validate_dims("initialization", "nu_geo_prior", "vector_d", context__.to_vec(Hprior));
  620:         vector_d nu_geo_prior(static_cast<Eigen::VectorXd::Index>(Hprior));
  621:         for (int j1__ = 0U; j1__ < Hprior; ++j1__)
  622:             nu_geo_prior(j1__) = vals_r__[pos__++];
  623:         try {
  624:             writer__.vector_unconstrain(nu_geo_prior);
  625:         } catch (const std::exception& e) { 
  626:             throw std::runtime_error(std::string("Error transforming variable nu_geo_prior: ") + e.what());
  627:         }
  628: 
  629:         if (!(context__.contains_r("delta_tbar")))
  630:             throw std::runtime_error("variable delta_tbar missing");
  631:         vals_r__ = context__.vals_r("delta_tbar");
  632:         pos__ = 0U;
  633:         validate_non_negative_index("delta_tbar", "T", T);
  634:         context__.validate_dims("initialization", "delta_tbar", "vector_d", context__.to_vec(T));
  635:         vector_d delta_tbar(static_cast<Eigen::VectorXd::Index>(T));
  636:         for (int j1__ = 0U; j1__ < T; ++j1__)
  637:             delta_tbar(j1__) = vals_r__[pos__++];
  638:         try {
  639:             writer__.vector_unconstrain(delta_tbar);
  640:         } catch (const std::exception& e) { 
  641:             throw std::runtime_error(std::string("Error transforming variable delta_tbar: ") + e.what());
  642:         }
  643: 
  644:         if (!(context__.contains_r("theta_bar_raw")))
  645:             throw std::runtime_error("variable theta_bar_raw missing");
  646:         vals_r__ = context__.vals_r("theta_bar_raw");
  647:         pos__ = 0U;
  648:         validate_non_negative_index("theta_bar_raw", "T", T);
  649:         validate_non_negative_index("theta_bar_raw", "G", G);
  650:         context__.validate_dims("initialization", "theta_bar_raw", "vector_d", context__.to_vec(T,G));
  651:         std::vector<vector_d> theta_bar_raw(T,vector_d(static_cast<Eigen::VectorXd::Index>(G)));
  652:         for (int j1__ = 0U; j1__ < G; ++j1__)
  653:             for (int i0__ = 0U; i0__ < T; ++i0__)
  654:                 theta_bar_raw[i0__](j1__) = vals_r__[pos__++];
  655:         for (int i0__ = 0U; i0__ < T; ++i0__)
  656:             try {
  657:             writer__.vector_unconstrain(theta_bar_raw[i0__]);
  658:         } catch (const std::exception& e) { 
  659:             throw std::runtime_error(std::string("Error transforming variable theta_bar_raw: ") + e.what());
  660:         }
  661: 
  662:         if (!(context__.contains_r("sd_theta_bar")))
  663:             throw std::runtime_error("variable sd_theta_bar missing");
  664:         vals_r__ = context__.vals_r("sd_theta_bar");
  665:         pos__ = 0U;
  666:         validate_non_negative_index("sd_theta_bar", "T", T);
  667:         context__.validate_dims("initialization", "sd_theta_bar", "vector_d", context__.to_vec(T));
  668:         vector_d sd_theta_bar(static_cast<Eigen::VectorXd::Index>(T));
  669:         for (int j1__ = 0U; j1__ < T; ++j1__)
  670:             sd_theta_bar(j1__) = vals_r__[pos__++];
  671:         try {
  672:             writer__.vector_lb_unconstrain(0,sd_theta_bar);
  673:         } catch (const std::exception& e) { 
  674:             throw std::runtime_error(std::string("Error transforming variable sd_theta_bar: ") + e.what());
  675:         }
  676: 
  677:         if (!(context__.contains_r("sd_theta")))
  678:             throw std::runtime_error("variable sd_theta missing");
  679:         vals_r__ = context__.vals_r("sd_theta");
  680:         pos__ = 0U;
  681:         validate_non_negative_index("sd_theta", "T", T);
  682:         context__.validate_dims("initialization", "sd_theta", "vector_d", context__.to_vec(T));
  683:         vector_d sd_theta(static_cast<Eigen::VectorXd::Index>(T));
  684:         for (int j1__ = 0U; j1__ < T; ++j1__)
  685:             sd_theta(j1__) = vals_r__[pos__++];
  686:         try {
  687:             writer__.vector_lb_unconstrain(0,sd_theta);
  688:         } catch (const std::exception& e) { 
  689:             throw std::runtime_error(std::string("Error transforming variable sd_theta: ") + e.what());
  690:         }
  691: 
  692:         if (!(context__.contains_r("sd_gamma_geo")))
  693:             throw std::runtime_error("variable sd_gamma_geo missing");
  694:         vals_r__ = context__.vals_r("sd_gamma_geo");
  695:         pos__ = 0U;
  696:         context__.validate_dims("initialization", "sd_gamma_geo", "double", context__.to_vec());
  697:         double sd_gamma_geo(0);
  698:         sd_gamma_geo = vals_r__[pos__++];
  699:         try {
  700:             writer__.scalar_lb_unconstrain(0,sd_gamma_geo);
  701:         } catch (const std::exception& e) { 
  702:             throw std::runtime_error(std::string("Error transforming variable sd_gamma_geo: ") + e.what());
  703:         }
  704: 
  705:         if (!(context__.contains_r("sd_gamma_demo")))
  706:             throw std::runtime_error("variable sd_gamma_demo missing");
  707:         vals_r__ = context__.vals_r("sd_gamma_demo");
  708:         pos__ = 0U;
  709:         context__.validate_dims("initialization", "sd_gamma_demo", "double", context__.to_vec());
  710:         double sd_gamma_demo(0);
  711:         sd_gamma_demo = vals_r__[pos__++];
  712:         try {
  713:             writer__.scalar_lb_unconstrain(0,sd_gamma_demo);
  714:         } catch (const std::exception& e) { 
  715:             throw std::runtime_error(std::string("Error transforming variable sd_gamma_demo: ") + e.what());
  716:         }
  717: 
  718:         if (!(context__.contains_r("sd_innov_delta")))
  719:             throw std::runtime_error("variable sd_innov_delta missing");
  720:         vals_r__ = context__.vals_r("sd_innov_delta");
  721:         pos__ = 0U;
  722:         context__.validate_dims("initialization", "sd_innov_delta", "double", context__.to_vec());
  723:         double sd_innov_delta(0);
  724:         sd_innov_delta = vals_r__[pos__++];
  725:         try {
  726:             writer__.scalar_lb_unconstrain(0,sd_innov_delta);
  727:         } catch (const std::exception& e) { 
  728:             throw std::runtime_error(std::string("Error transforming variable sd_innov_delta: ") + e.what());
  729:         }
  730: 
  731:         if (!(context__.contains_r("sd_innov_logsd")))
  732:             throw std::runtime_error("variable sd_innov_logsd missing");
  733:         vals_r__ = context__.vals_r("sd_innov_logsd");
  734:         pos__ = 0U;
  735:         context__.validate_dims("initialization", "sd_innov_logsd", "double", context__.to_vec());
  736:         double sd_innov_logsd(0);
  737:         sd_innov_logsd = vals_r__[pos__++];
  738:         try {
  739:             writer__.scalar_lb_unconstrain(0,sd_innov_logsd);
  740:         } catch (const std::exception& e) { 
  741:             throw std::runtime_error(std::string("Error transforming variable sd_innov_logsd: ") + e.what());
  742:         }
  743: 
  744:         if (!(context__.contains_r("sd_innov_gamma")))
  745:             throw std::runtime_error("variable sd_innov_gamma missing");
  746:         vals_r__ = context__.vals_r("sd_innov_gamma");
  747:         pos__ = 0U;
  748:         context__.validate_dims("initialization", "sd_innov_gamma", "double", context__.to_vec());
  749:         double sd_innov_gamma(0);
  750:         sd_innov_gamma = vals_r__[pos__++];
  751:         try {
  752:             writer__.scalar_lb_unconstrain(0,sd_innov_gamma);
  753:         } catch (const std::exception& e) { 
  754:             throw std::runtime_error(std::string("Error transforming variable sd_innov_gamma: ") + e.what());
  755:         }
  756: 
  757:         params_r__ = writer__.data_r();
  758:         params_i__ = writer__.data_i();
  759:     }
  760: 
  761:     void transform_inits(const stan::io::var_context& context,
  762:                          Eigen::Matrix<double,Eigen::Dynamic,1>& params_r,
  763:                          std::ostream* pstream__) const {
  764:       std::vector<double> params_r_vec;
  765:       std::vector<int> params_i_vec;
  766:       transform_inits(context, params_i_vec, params_r_vec, pstream__);
  767:       params_r.resize(params_r_vec.size());
  768:       for (int i = 0; i < params_r.size(); ++i)
  769:         params_r(i) = params_r_vec[i];
  770:     }
  771: 
  772: 
  773:     template <bool propto__, bool jacobian__, typename T__>
  774:     T__ log_prob(vector<T__>& params_r__,
  775:                  vector<int>& params_i__,
  776:                  std::ostream* pstream__ = 0) const {
  777: 
  778:         T__ DUMMY_VAR__(std::numeric_limits<double>::quiet_NaN());
  779:         (void) DUMMY_VAR__;  // suppress unused var warning
  780: 
  781:         T__ lp__(0.0);
  782:         stan::math::accumulator<T__> lp_accum__;
  783: 
  784:         try {
  785:             // model parameters
  786:             stan::io::reader<T__> in__(params_r__,params_i__);
  787: 
  788:             vector<Eigen::Matrix<T__,Eigen::Dynamic,1> > diff_raw;
  789:             size_t dim_diff_raw_0__ = D;
  790:             diff_raw.reserve(dim_diff_raw_0__);
  791:             for (size_t k_0__ = 0; k_0__ < dim_diff_raw_0__; ++k_0__) {
  792:                 if (jacobian__)
  793:                     diff_raw.push_back(in__.vector_constrain(Q,lp__));
  794:                 else
  795:                     diff_raw.push_back(in__.vector_constrain(Q));
  796:             }
  797: 
  798:             Eigen::Matrix<T__,Eigen::Dynamic,1>  disc_raw;
  799:             (void) disc_raw;  // dummy to suppress unused var warning
  800:             if (jacobian__)
  801:                 disc_raw = in__.vector_lb_constrain(0,Q,lp__);
  802:             else
  803:                 disc_raw = in__.vector_lb_constrain(0,Q);
  804: 
  805:             Eigen::Matrix<T__,Eigen::Dynamic,1>  xi;
  806:             (void) xi;  // dummy to suppress unused var warning
  807:             if (jacobian__)
  808:                 xi = in__.vector_constrain(T,lp__);
  809:             else
  810:                 xi = in__.vector_constrain(T);
  811: 
  812:             vector<Eigen::Matrix<T__,Eigen::Dynamic,1> > gamma_raw;
  813:             size_t dim_gamma_raw_0__ = T;
  814:             gamma_raw.reserve(dim_gamma_raw_0__);
  815:             for (size_t k_0__ = 0; k_0__ < dim_gamma_raw_0__; ++k_0__) {
  816:                 if (jacobian__)
  817:                     gamma_raw.push_back(in__.vector_constrain(P,lp__));
  818:                 else
  819:                     gamma_raw.push_back(in__.vector_constrain(P));
  820:             }
  821: 
  822:             Eigen::Matrix<T__,Eigen::Dynamic,1>  delta_gamma;
  823:             (void) delta_gamma;  // dummy to suppress unused var warning
  824:             if (jacobian__)
  825:                 delta_gamma = in__.vector_constrain(T,lp__);
  826:             else
  827:                 delta_gamma = in__.vector_constrain(T);
  828: 
  829:             vector<Eigen::Matrix<T__,Eigen::Dynamic,1> > nu_geo;
  830:             size_t dim_nu_geo_0__ = T;
  831:             nu_geo.reserve(dim_nu_geo_0__);
  832:             for (size_t k_0__ = 0; k_0__ < dim_nu_geo_0__; ++k_0__) {
  833:                 if (jacobian__)
  834:                     nu_geo.push_back(in__.vector_constrain(H,lp__));
  835:                 else
  836:                     nu_geo.push_back(in__.vector_constrain(H));
  837:             }
  838: 
  839:             Eigen::Matrix<T__,Eigen::Dynamic,1>  nu_geo_prior;
  840:             (void) nu_geo_prior;  // dummy to suppress unused var warning
  841:             if (jacobian__)
  842:                 nu_geo_prior = in__.vector_constrain(Hprior,lp__);
  843:             else
  844:                 nu_geo_prior = in__.vector_constrain(Hprior);
  845: 
  846:             Eigen::Matrix<T__,Eigen::Dynamic,1>  delta_tbar;
  847:             (void) delta_tbar;  // dummy to suppress unused var warning
  848:             if (jacobian__)
  849:                 delta_tbar = in__.vector_constrain(T,lp__);
  850:             else
  851:                 delta_tbar = in__.vector_constrain(T);
  852: 
  853:             vector<Eigen::Matrix<T__,Eigen::Dynamic,1> > theta_bar_raw;
  854:             size_t dim_theta_bar_raw_0__ = T;
  855:             theta_bar_raw.reserve(dim_theta_bar_raw_0__);
  856:             for (size_t k_0__ = 0; k_0__ < dim_theta_bar_raw_0__; ++k_0__) {
  857:                 if (jacobian__)
  858:                     theta_bar_raw.push_back(in__.vector_constrain(G,lp__));
  859:                 else
  860:                     theta_bar_raw.push_back(in__.vector_constrain(G));
  861:             }
  862: 
  863:             Eigen::Matrix<T__,Eigen::Dynamic,1>  sd_theta_bar;
  864:             (void) sd_theta_bar;  // dummy to suppress unused var warning
  865:             if (jacobian__)
  866:                 sd_theta_bar = in__.vector_lb_constrain(0,T,lp__);
  867:             else
  868:                 sd_theta_bar = in__.vector_lb_constrain(0,T);
  869: 
  870:             Eigen::Matrix<T__,Eigen::Dynamic,1>  sd_theta;
  871:             (void) sd_theta;  // dummy to suppress unused var warning
  872:             if (jacobian__)
  873:                 sd_theta = in__.vector_lb_constrain(0,T,lp__);
  874:             else
  875:                 sd_theta = in__.vector_lb_constrain(0,T);
  876: 
  877:             T__ sd_gamma_geo;
  878:             (void) sd_gamma_geo;  // dummy to suppress unused var warning
  879:             if (jacobian__)
  880:                 sd_gamma_geo = in__.scalar_lb_constrain(0,lp__);
  881:             else
  882:                 sd_gamma_geo = in__.scalar_lb_constrain(0);
  883: 
  884:             T__ sd_gamma_demo;
  885:             (void) sd_gamma_demo;  // dummy to suppress unused var warning
  886:             if (jacobian__)
  887:                 sd_gamma_demo = in__.scalar_lb_constrain(0,lp__);
  888:             else
  889:                 sd_gamma_demo = in__.scalar_lb_constrain(0);
  890: 
  891:             T__ sd_innov_delta;
  892:             (void) sd_innov_delta;  // dummy to suppress unused var warning
  893:             if (jacobian__)
  894:                 sd_innov_delta = in__.scalar_lb_constrain(0,lp__);
  895:             else
  896:                 sd_innov_delta = in__.scalar_lb_constrain(0);
  897: 
  898:             T__ sd_innov_logsd;
  899:             (void) sd_innov_logsd;  // dummy to suppress unused var warning
  900:             if (jacobian__)
  901:                 sd_innov_logsd = in__.scalar_lb_constrain(0,lp__);
  902:             else
  903:                 sd_innov_logsd = in__.scalar_lb_constrain(0);
  904: 
  905:             T__ sd_innov_gamma;
  906:             (void) sd_innov_gamma;  // dummy to suppress unused var warning
  907:             if (jacobian__)
  908:                 sd_innov_gamma = in__.scalar_lb_constrain(0,lp__);
  909:             else
  910:                 sd_innov_gamma = in__.scalar_lb_constrain(0);
  911: 
  912: 
  913:             // transformed parameters
  914:             current_statement_begin__ = 55;
  915:             validate_non_negative_index("theta_bar", "G", G);
  916:             validate_non_negative_index("theta_bar", "T", T);
  917:             vector<Eigen::Matrix<T__,Eigen::Dynamic,1> > theta_bar(T, (Eigen::Matrix<T__,Eigen::Dynamic,1> (static_cast<Eigen::VectorXd::Index>(G))));
  918:             stan::math::initialize(theta_bar, DUMMY_VAR__);
  919:             stan::math::fill(theta_bar,DUMMY_VAR__);
  920:             current_statement_begin__ = 56;
  921:             validate_non_negative_index("diff", "Q", Q);
  922:             validate_non_negative_index("diff", "D", D);
  923:             vector<Eigen::Matrix<T__,Eigen::Dynamic,1> > diff(D, (Eigen::Matrix<T__,Eigen::Dynamic,1> (static_cast<Eigen::VectorXd::Index>(Q))));
  924:             stan::math::initialize(diff, DUMMY_VAR__);
  925:             stan::math::fill(diff,DUMMY_VAR__);
  926:             current_statement_begin__ = 57;
  927:             validate_non_negative_index("kappa", "Q", Q);
  928:             validate_non_negative_index("kappa", "D", D);
  929:             vector<Eigen::Matrix<T__,Eigen::Dynamic,1> > kappa(D, (Eigen::Matrix<T__,Eigen::Dynamic,1> (static_cast<Eigen::VectorXd::Index>(Q))));
  930:             stan::math::initialize(kappa, DUMMY_VAR__);
  931:             stan::math::fill(kappa,DUMMY_VAR__);
  932:             current_statement_begin__ = 58;
  933:             validate_non_negative_index("disc", "Q", Q);
  934:             Eigen::Matrix<T__,Eigen::Dynamic,1>  disc(static_cast<Eigen::VectorXd::Index>(Q));
  935:             (void) disc;  // dummy to suppress unused var warning
  936: 
  937:             stan::math::initialize(disc, DUMMY_VAR__);
  938:             stan::math::fill(disc,DUMMY_VAR__);
  939:             current_statement_begin__ = 59;
  940:             validate_non_negative_index("sd_item", "Q", Q);
  941:             Eigen::Matrix<T__,Eigen::Dynamic,1>  sd_item(static_cast<Eigen::VectorXd::Index>(Q));
  942:             (void) sd_item;  // dummy to suppress unused var warning
  943: 
  944:             stan::math::initialize(sd_item, DUMMY_VAR__);
  945:             stan::math::fill(sd_item,DUMMY_VAR__);
  946:             current_statement_begin__ = 60;
  947:             validate_non_negative_index("var_item", "Q", Q);
  948:             Eigen::Matrix<T__,Eigen::Dynamic,1>  var_item(static_cast<Eigen::VectorXd::Index>(Q));
  949:             (void) var_item;  // dummy to suppress unused var warning
  950: 
  951:             stan::math::initialize(var_item, DUMMY_VAR__);
  952:             stan::math::fill(var_item,DUMMY_VAR__);
  953:             current_statement_begin__ = 61;
  954:             validate_non_negative_index("var_theta", "T", T);
  955:             Eigen::Matrix<T__,Eigen::Dynamic,1>  var_theta(static_cast<Eigen::VectorXd::Index>(T));
  956:             (void) var_theta;  // dummy to suppress unused var warning
  957: 
  958:             stan::math::initialize(var_theta, DUMMY_VAR__);
  959:             stan::math::fill(var_theta,DUMMY_VAR__);
  960:             current_statement_begin__ = 63;
  961:             validate_non_negative_index("gamma", "P", P);
  962:             validate_non_negative_index("gamma", "T", T);
  963:             vector<Eigen::Matrix<T__,Eigen::Dynamic,1> > gamma(T, (Eigen::Matrix<T__,Eigen::Dynamic,1> (static_cast<Eigen::VectorXd::Index>(P))));
  964:             stan::math::initialize(gamma, DUMMY_VAR__);
  965:             stan::math::fill(gamma,DUMMY_VAR__);
  966:             current_statement_begin__ = 64;
  967:             validate_non_negative_index("mu_theta_bar", "G", G);
  968:             validate_non_negative_index("mu_theta_bar", "T", T);
  969:             vector<Eigen::Matrix<T__,Eigen::Dynamic,1> > mu_theta_bar(T, (Eigen::Matrix<T__,Eigen::Dynamic,1> (static_cast<Eigen::VectorXd::Index>(G))));
  970:             stan::math::initialize(mu_theta_bar, DUMMY_VAR__);
  971:             stan::math::fill(mu_theta_bar,DUMMY_VAR__);
  972:             current_statement_begin__ = 65;
  973:             validate_non_negative_index("mu_gamma", "P", P);
  974:             validate_non_negative_index("mu_gamma", "T", T);
  975:             vector<Eigen::Matrix<T__,Eigen::Dynamic,1> > mu_gamma(T, (Eigen::Matrix<T__,Eigen::Dynamic,1> (static_cast<Eigen::VectorXd::Index>(P))));
  976:             stan::math::initialize(mu_gamma, DUMMY_VAR__);
  977:             stan::math::fill(mu_gamma,DUMMY_VAR__);
  978:             current_statement_begin__ = 66;
  979:             validate_non_negative_index("z", "G", G);
  980:             validate_non_negative_index("z", "T", T);
  981:             validate_non_negative_index("z", "Q", Q);
  982:             vector<vector<Eigen::Matrix<T__,Eigen::Dynamic,1> > > z(T, (vector<Eigen::Matrix<T__,Eigen::Dynamic,1> >(Q, (Eigen::Matrix<T__,Eigen::Dynamic,1> (static_cast<Eigen::VectorXd::Index>(G))))));
  983:             stan::math::initialize(z, DUMMY_VAR__);
  984:             stan::math::fill(z,DUMMY_VAR__);
  985:             current_statement_begin__ = 67;
  986:             validate_non_negative_index("prob", "T", T);
  987:             validate_non_negative_index("prob", "Q", Q);
  988:             validate_non_negative_index("prob", "G", G);
  989:             vector<vector<vector<T__> > > prob(T, (vector<vector<T__> >(Q, (vector<T__>(G)))));
  990:             stan::math::initialize(prob, DUMMY_VAR__);
  991:             stan::math::fill(prob,DUMMY_VAR__);
  992: 
  993: 
  994:             current_statement_begin__ = 69;
  995:             stan::math::assign(disc, multiply(disc_raw,pow(exp(sum(log(disc_raw))),-(inv(Q)))));
  996:             current_statement_begin__ = 70;
  997:             for (int q = 1; q <= Q; ++q) {
  998: 
  999:                 current_statement_begin__ = 71;
  1000:                 stan::math::assign(get_base1_lhs(sd_item,q,"sd_item",1), inv(get_base1(disc,q,"disc",1)));
  1001:             }
  1002:             current_statement_begin__ = 73;
  1003:             for (int d = 1; d <= D; ++d) {
  1004: 
  1005:                 current_statement_begin__ = 75;
  1006:                 stan::math::assign(get_base1_lhs(diff,d,"diff",1), subtract(get_base1(diff_raw,d,"diff_raw",1),mean(get_base1(diff_raw,1,"diff_raw",1))));
  1007:                 current_statement_begin__ = 76;
  1008:                 stan::math::assign(get_base1_lhs(kappa,d,"kappa",1), elt_divide(get_base1(diff,d,"diff",1),disc));
  1009:             }
  1010:             current_statement_begin__ = 78;
  1011:             stan::math::assign(var_item, elt_multiply(sd_item,sd_item));
  1012:             current_statement_begin__ = 79;
  1013:             stan::math::assign(var_theta, elt_multiply(sd_theta,sd_theta));
  1014:             current_statement_begin__ = 80;
  1015:             for (int t = 1; t <= T; ++t) {
  1016: 
  1017:                 current_statement_begin__ = 81;
  1018:                 if (as_bool((primitive_value(logical_eq(t,1)) || primitive_value(logical_eq(separate_t,1))))) {
  1019: 
  1020:                     current_statement_begin__ = 82;
  1021:                     stan::math::assign(get_base1_lhs(mu_gamma,t,"mu_gamma",1), multiply(get_base1(ZZ_prior,t,"ZZ_prior",1),nu_geo_prior));
  1022:                     current_statement_begin__ = 83;
  1023:                     for (int p = 1; p <= P; ++p) {
  1024: 
  1025:                         current_statement_begin__ = 84;
  1026:                         if (as_bool(logical_lte(p,S))) {
  1027: 
  1028:                             current_statement_begin__ = 85;
  1029:                             stan::math::assign(get_base1_lhs(get_base1_lhs(gamma,t,"gamma",1),p,"gamma",2), (get_base1(get_base1(mu_gamma,t,"mu_gamma",1),p,"mu_gamma",2) + (sd_gamma_geo * get_base1(get_base1(gamma_raw,t,"gamma_raw",1),p,"gamma_raw",2))));
  1030:                         }
  1031:                         current_statement_begin__ = 87;
  1032:                         if (as_bool(logical_gt(p,S))) {
  1033: 
  1034:                             current_statement_begin__ = 88;
  1035:                             stan::math::assign(get_base1_lhs(get_base1_lhs(gamma,t,"gamma",1),p,"gamma",2), (get_base1(get_base1(mu_gamma,t,"mu_gamma",1),p,"mu_gamma",2) + (sd_gamma_demo * get_base1(get_base1(gamma_raw,t,"gamma_raw",1),p,"gamma_raw",2))));
  1036:                         }
  1037:                     }
  1038:                     current_statement_begin__ = 91;
  1039:                     stan::math::assign(get_base1_lhs(mu_theta_bar,t,"mu_theta_bar",1), add(get_base1(xi,t,"xi",1),multiply(XX,get_base1(gamma,t,"gamma",1))));
  1040:                 }
  1041:                 current_statement_begin__ = 94;
  1042:                 if (as_bool((primitive_value(logical_gt(t,1)) && primitive_value(logical_eq(separate_t,0))))) {
  1043: 
  1044:                     current_statement_begin__ = 95;
  1045:                     if (as_bool(logical_eq(t,2))) {
  1046: 
  1047:                         current_statement_begin__ = 103;
  1048:                         stan::math::assign(get_base1_lhs(mu_gamma,t,"mu_gamma",1), multiply(get_base1(ZZ_prior,t,"ZZ_prior",1),nu_geo_prior));
  1049:                         current_statement_begin__ = 104;
  1050:                         for (int p = 1; p <= P; ++p) {
  1051: 
  1052:                             current_statement_begin__ = 105;
  1053:                             if (as_bool(logical_lte(p,S))) {
  1054: 
  1055:                                 current_statement_begin__ = 106;
  1056:                                 stan::math::assign(get_base1_lhs(get_base1_lhs(gamma,t,"gamma",1),p,"gamma",2), (get_base1(get_base1(mu_gamma,t,"mu_gamma",1),p,"mu_gamma",2) + (sd_gamma_geo * get_base1(get_base1(gamma_raw,t,"gamma_raw",1),p,"gamma_raw",2))));
  1057:                             }
  1058:                             current_statement_begin__ = 108;
  1059:                             if (as_bool(logical_gt(p,S))) {
  1060: 
  1061:                                 current_statement_begin__ = 109;
  1062:                                 stan::math::assign(get_base1_lhs(get_base1_lhs(gamma,t,"gamma",1),p,"gamma",2), (get_base1(get_base1(mu_gamma,t,"mu_gamma",1),p,"mu_gamma",2) + (sd_gamma_demo * get_base1(get_base1(gamma_raw,t,"gamma_raw",1),p,"gamma_raw",2))));
  1063:                             }
  1064:                         }
  1065:                     } else {
  1066: 
  1067:                         current_statement_begin__ = 115;
  1068:                         for (int p = 1; p <= P; ++p) {
  1069: 
  1070:                             current_statement_begin__ = 116;
  1071:                             if (as_bool(logical_lte(p,S))) {
  1072: 
  1073:                                 current_statement_begin__ = 117;
  1074:                                 stan::math::assign(get_base1_lhs(get_base1_lhs(mu_gamma,t,"mu_gamma",1),p,"mu_gamma",2), ((get_base1(get_base1(gamma,(t - 1),"gamma",1),p,"gamma",2) * get_base1(delta_gamma,t,"delta_gamma",1)) + multiply(get_base1(get_base1(ZZ,t,"ZZ",1),p,"ZZ",2),get_base1(nu_geo,t,"nu_geo",1))));
  1075:                             }
  1076:                             current_statement_begin__ = 119;
  1077:                             if (as_bool(logical_gt(p,S))) {
  1078: 
  1079:                                 current_statement_begin__ = 120;
  1080:                                 stan::math::assign(get_base1_lhs(get_base1_lhs(mu_gamma,t,"mu_gamma",1),p,"mu_gamma",2), get_base1(get_base1(gamma,(t - 1),"gamma",1),p,"gamma",2));
  1081:                             }
  1082:                         }
  1083:                         current_statement_begin__ = 123;
  1084:                         stan::math::assign(get_base1_lhs(gamma,t,"gamma",1), add(get_base1(mu_gamma,t,"mu_gamma",1),multiply(sd_innov_gamma,get_base1(gamma_raw,t,"gamma_raw",1))));
  1085:                     }
  1086:                     current_statement_begin__ = 125;
  1087:                     stan::math::assign(get_base1_lhs(mu_theta_bar,t,"mu_theta_bar",1), add(add(get_base1(xi,t,"xi",1),multiply(XX,get_base1(gamma,t,"gamma",1))),multiply(get_base1(theta_bar,(t - 1),"theta_bar",1),get_base1(delta_tbar,t,"delta_tbar",1))));
  1088:                 }
  1089:                 current_statement_begin__ = 129;
  1090:                 if (as_bool(logical_eq(hierarchical_model,1))) {
  1091: 
  1092:                     current_statement_begin__ = 130;
  1093:                     stan::math::assign(get_base1_lhs(theta_bar,t,"theta_bar",1), add(get_base1(mu_theta_bar,t,"mu_theta_bar",1),multiply(get_base1(sd_theta_bar,t,"sd_theta_bar",1),get_base1(theta_bar_raw,t,"theta_bar_raw",1))));
  1094:                 }
  1095:                 current_statement_begin__ = 132;
  1096:                 if (as_bool(logical_eq(hierarchical_model,0))) {
  1097: 
  1098:                     current_statement_begin__ = 133;
  1099:                     stan::math::assign(get_base1_lhs(theta_bar,t,"theta_bar",1), multiply(get_base1(sd_theta_bar,t,"sd_theta_bar",1),get_base1(theta_bar_raw,t,"theta_bar_raw",1)));
  1100:                 }
  1101:                 current_statement_begin__ = 135;
  1102:                 for (int q = 1; q <= Q; ++q) {
  1103:                     {
  1104:                     current_statement_begin__ = 136;
  1105:                     T__ sd_tq;
  1106:                     (void) sd_tq;  // dummy to suppress unused var warning
  1107: 
  1108:                     stan::math::initialize(sd_tq, DUMMY_VAR__);
  1109:                     stan::math::fill(sd_tq,DUMMY_VAR__);
  1110: 
  1111: 
  1112:                     current_statement_begin__ = 137;
  1113:                     stan::math::assign(sd_tq, sqrt((get_base1(var_theta,t,"var_theta",1) + get_base1(var_item,q,"var_item",1))));
  1114:                     current_statement_begin__ = 139;
  1115:                     if (as_bool(logical_eq(constant_item,0))) {
  1116: 
  1117:                         current_statement_begin__ = 140;
  1118:                         stan::math::assign(get_base1_lhs(get_base1_lhs(z,t,"z",1),q,"z",2), divide(subtract(get_base1(theta_bar,t,"theta_bar",1),get_base1(get_base1(kappa,t,"kappa",1),q,"kappa",2)),sd_tq));
  1119:                     }
  1120:                     current_statement_begin__ = 142;
  1121:                     if (as_bool(logical_eq(constant_item,1))) {
  1122: 
  1123:                         current_statement_begin__ = 143;
  1124:                         stan::math::assign(get_base1_lhs(get_base1_lhs(z,t,"z",1),q,"z",2), divide(subtract(get_base1(theta_bar,t,"theta_bar",1),get_base1(get_base1(kappa,1,"kappa",1),q,"kappa",2)),sd_tq));
  1125:                     }
  1126:                     current_statement_begin__ = 145;
  1127:                     for (int g = 1; g <= G; ++g) {
  1128: 
  1129:                         current_statement_begin__ = 146;
  1130:                         if (as_bool(logical_eq(Q,1))) {
  1131: 
  1132:                             current_statement_begin__ = 148;
  1133:                             stan::math::assign(get_base1_lhs(get_base1_lhs(get_base1_lhs(prob,t,"prob",1),q,"prob",2),g,"prob",3), Phi_approx(get_base1(get_base1(theta_bar,t,"theta_bar",1),g,"theta_bar",2)));
  1134:                         }
  1135:                         current_statement_begin__ = 150;
  1136:                         if (as_bool(logical_gt(Q,1))) {
  1137: 
  1138:                             current_statement_begin__ = 152;
  1139:                             stan::math::assign(get_base1_lhs(get_base1_lhs(get_base1_lhs(prob,t,"prob",1),q,"prob",2),g,"prob",3), Phi_approx(get_base1(get_base1(get_base1(z,t,"z",1),q,"z",2),g,"z",3)));
  1140:                         }
  1141:                     }
  1142:                     }
  1143:                 }
  1144:             }
  1145: 
  1146:             // validate transformed parameters
  1147:             for (int i0__ = 0; i0__ < T; ++i0__) {
  1148:                 for (int i1__ = 0; i1__ < G; ++i1__) {
  1149:                     if (stan::math::is_uninitialized(theta_bar[i0__](i1__))) {
  1150:                         std::stringstream msg__;
  1151:                         msg__ << "Undefined transformed parameter: theta_bar" << '[' << i0__ << ']' << '[' << i1__ << ']';
  1152:                         throw std::runtime_error(msg__.str());
  1153:                     }
  1154:                 }
  1155:             }
  1156:             for (int i0__ = 0; i0__ < D; ++i0__) {
  1157:                 for (int i1__ = 0; i1__ < Q; ++i1__) {
  1158:                     if (stan::math::is_uninitialized(diff[i0__](i1__))) {
  1159:                         std::stringstream msg__;
  1160:                         msg__ << "Undefined transformed parameter: diff" << '[' << i0__ << ']' << '[' << i1__ << ']';
  1161:                         throw std::runtime_error(msg__.str());
  1162:                     }
  1163:                 }
  1164:             }
  1165:             for (int i0__ = 0; i0__ < D; ++i0__) {
  1166:                 for (int i1__ = 0; i1__ < Q; ++i1__) {
  1167:                     if (stan::math::is_uninitialized(kappa[i0__](i1__))) {
  1168:                         std::stringstream msg__;
  1169:                         msg__ << "Undefined transformed parameter: kappa" << '[' << i0__ << ']' << '[' << i1__ << ']';
  1170:                         throw std::runtime_error(msg__.str());
  1171:                     }
  1172:                 }
  1173:             }
  1174:             for (int i0__ = 0; i0__ < Q; ++i0__) {
  1175:                 if (stan::math::is_uninitialized(disc(i0__))) {
  1176:                     std::stringstream msg__;
  1177:                     msg__ << "Undefined transformed parameter: disc" << '[' << i0__ << ']';
  1178:                     throw std::runtime_error(msg__.str());
  1179:                 }
  1180:             }
  1181:             for (int i0__ = 0; i0__ < Q; ++i0__) {
  1182:                 if (stan::math::is_uninitialized(sd_item(i0__))) {
  1183:                     std::stringstream msg__;
  1184:                     msg__ << "Undefined transformed parameter: sd_item" << '[' << i0__ << ']';
  1185:                     throw std::runtime_error(msg__.str());
  1186:                 }
  1187:             }
  1188:             for (int i0__ = 0; i0__ < Q; ++i0__) {
  1189:                 if (stan::math::is_uninitialized(var_item(i0__))) {
  1190:                     std::stringstream msg__;
  1191:                     msg__ << "Undefined transformed parameter: var_item" << '[' << i0__ << ']';
  1192:                     throw std::runtime_error(msg__.str());
  1193:                 }
  1194:             }
  1195:             for (int i0__ = 0; i0__ < T; ++i0__) {
  1196:                 if (stan::math::is_uninitialized(var_theta(i0__))) {
  1197:                     std::stringstream msg__;
  1198:                     msg__ << "Undefined transformed parameter: var_theta" << '[' << i0__ << ']';
  1199:                     throw std::runtime_error(msg__.str());
  1200:                 }
  1201:             }
  1202:             for (int i0__ = 0; i0__ < T; ++i0__) {
  1203:                 for (int i1__ = 0; i1__ < P; ++i1__) {
  1204:                     if (stan::math::is_uninitialized(gamma[i0__](i1__))) {
  1205:                         std::stringstream msg__;
  1206:                         msg__ << "Undefined transformed parameter: gamma" << '[' << i0__ << ']' << '[' << i1__ << ']';
  1207:                         throw std::runtime_error(msg__.str());
  1208:                     }
  1209:                 }
  1210:             }
  1211:             for (int i0__ = 0; i0__ < T; ++i0__) {
  1212:                 for (int i1__ = 0; i1__ < G; ++i1__) {
  1213:                     if (stan::math::is_uninitialized(mu_theta_bar[i0__](i1__))) {
  1214:                         std::stringstream msg__;
  1215:                         msg__ << "Undefined transformed parameter: mu_theta_bar" << '[' << i0__ << ']' << '[' << i1__ << ']';
  1216:                         throw std::runtime_error(msg__.str());
  1217:                     }
  1218:                 }
  1219:             }
  1220:             for (int i0__ = 0; i0__ < T; ++i0__) {
  1221:                 for (int i1__ = 0; i1__ < P; ++i1__) {
  1222:                     if (stan::math::is_uninitialized(mu_gamma[i0__](i1__))) {
  1223:                         std::stringstream msg__;
  1224:                         msg__ << "Undefined transformed parameter: mu_gamma" << '[' << i0__ << ']' << '[' << i1__ << ']';
  1225:                         throw std::runtime_error(msg__.str());
  1226:                     }
  1227:                 }
  1228:             }
  1229:             for (int i0__ = 0; i0__ < T; ++i0__) {
  1230:                 for (int i1__ = 0; i1__ < Q; ++i1__) {
  1231:                     for (int i2__ = 0; i2__ < G; ++i2__) {
  1232:                         if (stan::math::is_uninitialized(z[i0__][i1__](i2__))) {
  1233:                             std::stringstream msg__;
  1234:                             msg__ << "Undefined transformed parameter: z" << '[' << i0__ << ']' << '[' << i1__ << ']' << '[' << i2__ << ']';
  1235:                             throw std::runtime_error(msg__.str());
  1236:                         }
  1237:                     }
  1238:                 }
  1239:             }
  1240:             for (int i0__ = 0; i0__ < T; ++i0__) {
  1241:                 for (int i1__ = 0; i1__ < Q; ++i1__) {
  1242:                     for (int i2__ = 0; i2__ < G; ++i2__) {
  1243:                         if (stan::math::is_uninitialized(prob[i0__][i1__][i2__])) {
  1244:                             std::stringstream msg__;
  1245:                             msg__ << "Undefined transformed parameter: prob" << '[' << i0__ << ']' << '[' << i1__ << ']' << '[' << i2__ << ']';
  1246:                             throw std::runtime_error(msg__.str());
  1247:                         }
  1248:                     }
  1249:                 }
  1250:             }
  1251: 
  1252:             const char* function__ = "validate transformed params";
  1253:             (void) function__;  // dummy to suppress unused var warning
  1254:             current_statement_begin__ = 55;
  1255:             current_statement_begin__ = 56;
  1256:             current_statement_begin__ = 57;
  1257:             current_statement_begin__ = 58;
  1258:             check_greater_or_equal(function__,"disc",disc,0);
  1259:             current_statement_begin__ = 59;
  1260:             check_greater_or_equal(function__,"sd_item",sd_item,0);
  1261:             current_statement_begin__ = 60;
  1262:             check_greater_or_equal(function__,"var_item",var_item,0);
  1263:             current_statement_begin__ = 61;
  1264:             check_greater_or_equal(function__,"var_theta",var_theta,0);
  1265:             current_statement_begin__ = 63;
  1266:             current_statement_begin__ = 64;
  1267:             current_statement_begin__ = 65;
  1268:             current_statement_begin__ = 66;
  1269:             current_statement_begin__ = 67;
  1270:             for (int k0__ = 0; k0__ < T; ++k0__) {
  1271:                 for (int k1__ = 0; k1__ < Q; ++k1__) {
  1272:                     for (int k2__ = 0; k2__ < G; ++k2__) {
  1273:                         check_greater_or_equal(function__,"prob[k0__][k1__][k2__]",prob[k0__][k1__][k2__],0);
  1274:                         check_less_or_equal(function__,"prob[k0__][k1__][k2__]",prob[k0__][k1__][k2__],1);
  1275:                     }
  1276:                 }
  1277:             }
  1278: 
  1279:             // model body
  1280:             {
  1281:             current_statement_begin__ = 161;
  1282:             validate_non_negative_index("prob_vec", "N", N);
  1283:             vector<T__> prob_vec(N);
  1284:             stan::math::initialize(prob_vec, DUMMY_VAR__);
  1285:             stan::math::fill(prob_vec,DUMMY_VAR__);
  1286:             current_statement_begin__ = 162;
  1287:             int pos(0);
  1288:             (void) pos;  // dummy to suppress unused var warning
  1289: 
  1290:             stan::math::fill(pos, std::numeric_limits<int>::min());
  1291: 
  1292: 
  1293:             current_statement_begin__ = 163;
  1294:             stan::math::assign(pos, 0);
  1295:             current_statement_begin__ = 166;
  1296:             if (as_bool(logical_eq(constant_item,1))) {
  1297: 
  1298:                 current_statement_begin__ = 167;
  1299:                 lp_accum__.add(normal_log<propto__>(get_base1(diff_raw,1,"diff_raw",1), 0, 1));
  1300:             }
  1301:             current_statement_begin__ = 169;
  1302:             lp_accum__.add(lognormal_log<propto__>(disc_raw, 0, 1));
  1303:             current_statement_begin__ = 170;
  1304:             lp_accum__.add(cauchy_log<propto__>(sd_gamma_geo, 0, 2.5));
  1305:             current_statement_begin__ = 171;
  1306:             lp_accum__.add(cauchy_log<propto__>(sd_gamma_demo, 0, 2.5));
  1307:             current_statement_begin__ = 172;
  1308:             lp_accum__.add(cauchy_log<propto__>(sd_innov_delta, 0, innov_sd_delta_scale));
  1309:             current_statement_begin__ = 173;
  1310:             lp_accum__.add(cauchy_log<propto__>(sd_innov_gamma, 0, 2.5));
  1311:             current_statement_begin__ = 174;
  1312:             lp_accum__.add(cauchy_log<propto__>(sd_innov_logsd, 0, innov_sd_theta_scale));
  1313:             current_statement_begin__ = 176;
  1314:             for (int t = 1; t <= T; ++t) {
  1315: 
  1316:                 current_statement_begin__ = 177;
  1317:                 lp_accum__.add(normal_log<propto__>(get_base1(gamma_raw,t,"gamma_raw",1), 0, 1));
  1318:                 current_statement_begin__ = 178;
  1319:                 lp_accum__.add(normal_log<propto__>(get_base1(theta_bar_raw,t,"theta_bar_raw",1), 0, 1));
  1320:                 current_statement_begin__ = 179;
  1321:                 if (as_bool(logical_eq(t,1))) {
  1322: 
  1323:                     current_statement_begin__ = 180;
  1324:                     if (as_bool(logical_eq(constant_item,0))) {
  1325: 
  1326:                         current_statement_begin__ = 181;
  1327:                         lp_accum__.add(normal_log<propto__>(get_base1(diff_raw,t,"diff_raw",1), 0, 1));
  1328:                     }
  1329:                     current_statement_begin__ = 184;
  1330:                     lp_accum__.add(cauchy_log<propto__>(get_base1(sd_theta_bar,t,"sd_theta_bar",1), 0, 2.5));
  1331:                     current_statement_begin__ = 185;
  1332:                     lp_accum__.add(cauchy_log<propto__>(get_base1(sd_theta,t,"sd_theta",1), 0, 2.5));
  1333:                     current_statement_begin__ = 186;
  1334:                     lp_accum__.add(normal_log<propto__>(get_base1(nu_geo,t,"nu_geo",1), 0, 10));
  1335:                     current_statement_begin__ = 187;
  1336:                     lp_accum__.add(normal_log<propto__>(nu_geo_prior, 0, 10));
  1337:                     current_statement_begin__ = 188;
  1338:                     lp_accum__.add(normal_log<propto__>(get_base1(delta_gamma,t,"delta_gamma",1), 0.5, 0.5));
  1339:                     current_statement_begin__ = 189;
  1340:                     lp_accum__.add(normal_log<propto__>(get_base1(delta_tbar,t,"delta_tbar",1), delta_tbar_prior_mean, delta_tbar_prior_sd));
  1341:                     current_statement_begin__ = 190;
  1342:                     lp_accum__.add(normal_log<propto__>(get_base1(xi,t,"xi",1), 0, 10));
  1343:                 }
  1344:                 current_statement_begin__ = 192;
  1345:                 if (as_bool(logical_gt(t,1))) {
  1346: 
  1347:                     current_statement_begin__ = 196;
  1348:                     if (as_bool(logical_eq(constant_item,0))) {
  1349: 
  1350:                         current_statement_begin__ = 197;
  1351:                         lp_accum__.add(normal_log<propto__>(get_base1(diff_raw,t,"diff_raw",1), get_base1(diff_raw,(t - 1),"diff_raw",1), sd_innov_gamma));
  1352:                     }
  1353:                     current_statement_begin__ = 201;
  1354:                     lp_accum__.add(normal_log<propto__>(get_base1(delta_gamma,t,"delta_gamma",1), get_base1(delta_gamma,(t - 1),"delta_gamma",1), sd_innov_delta));
  1355:                     current_statement_begin__ = 202;
  1356:                     lp_accum__.add(normal_log<propto__>(get_base1(nu_geo,t,"nu_geo",1), get_base1(nu_geo,(t - 1),"nu_geo",1), sd_innov_delta));
  1357:                     current_statement_begin__ = 203;
  1358:                     lp_accum__.add(normal_log<propto__>(get_base1(delta_tbar,t,"delta_tbar",1), get_base1(delta_tbar,(t - 1),"delta_tbar",1), sd_innov_delta));
  1359:                     current_statement_begin__ = 204;
  1360:                     lp_accum__.add(lognormal_log<propto__>(get_base1(sd_theta_bar,t,"sd_theta_bar",1), log(get_base1(sd_theta_bar,(t - 1),"sd_theta_bar",1)), sd_innov_logsd));
  1361:                     current_statement_begin__ = 205;
  1362:                     lp_accum__.add(lognormal_log<propto__>(get_base1(sd_theta,t,"sd_theta",1), log(get_base1(sd_theta,(t - 1),"sd_theta",1)), sd_innov_logsd));
  1363:                     current_statement_begin__ = 206;
  1364:                     if (as_bool((primitive_value(logical_eq(separate_t,0)) && primitive_value(logical_gt(t,2))))) {
  1365: 
  1366:                         current_statement_begin__ = 207;
  1367:                         lp_accum__.add(normal_log<propto__>(get_base1(xi,t,"xi",1), get_base1(xi,(t - 1),"xi",1), sd_innov_gamma));
  1368:                     }
  1369:                     current_statement_begin__ = 209;
  1370:                     if (as_bool((primitive_value(logical_eq(separate_t,1)) || primitive_value(logical_eq(t,2))))) {
  1371: 
  1372:                         current_statement_begin__ = 210;
  1373:                         lp_accum__.add(normal_log<propto__>(get_base1(xi,t,"xi",1), 0, 10));
  1374:                     }
  1375:                 }
  1376:                 current_statement_begin__ = 214;
  1377:                 for (int q = 1; q <= Q; ++q) {
  1378: 
  1379:                     current_statement_begin__ = 215;
  1380:                     for (int g = 1; g <= G; ++g) {
  1381: 
  1382:                         current_statement_begin__ = 216;
  1383:                         stan::math::assign(pos, (pos + 1));
  1384:                         current_statement_begin__ = 217;
  1385:                         stan::math::assign(get_base1_lhs(prob_vec,pos,"prob_vec",1), get_base1(get_base1(get_base1(prob,t,"prob",1),q,"prob",2),g,"prob",3));
  1386:                     }
  1387:                 }
  1388:             }
  1389:             current_statement_begin__ = 224;
  1390:             lp_accum__.add(binomial_log<propto__>(stan::model::rvalue(s_vec, stan::model::cons_list(stan::model::index_multi(observed), stan::model::nil_index_list()), "s_vec"), stan::model::rvalue(n_vec, stan::model::cons_list(stan::model::index_multi(observed), stan::model::nil_index_list()), "n_vec"), stan::model::rvalue(prob_vec, stan::model::cons_list(stan::model::index_multi(observed), stan::model::nil_index_list()), "prob_vec")));
  1391:             }
  1392: 
  1393:         } catch (const std::exception& e) {
  1394:             stan::lang::rethrow_located(e, current_statement_begin__, prog_reader__());
  1395:             // Next line prevents compiler griping about no return
  1396:             throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***");
  1397:         }
  1398: 
  1399:         lp_accum__.add(lp__);
  1400:         return lp_accum__.sum();
  1401: 
  1402:     } // log_prob()
  1403: 
  1404:     template <bool propto, bool jacobian, typename T_>
  1405:     T_ log_prob(Eigen::Matrix<T_,Eigen::Dynamic,1>& params_r,
  1406:                std::ostream* pstream = 0) const {
  1407:       std::vector<T_> vec_params_r;
  1408:       vec_params_r.reserve(params_r.size());
  1409:       for (int i = 0; i < params_r.size(); ++i)
  1410:         vec_params_r.push_back(params_r(i));
  1411:       std::vector<int> vec_params_i;
  1412:       return log_prob<propto,jacobian,T_>(vec_params_r, vec_params_i, pstream);
  1413:     }
  1414: 
  1415: 
  1416:     void get_param_names(std::vector<std::string>& names__) const {
  1417:         names__.resize(0);
  1418:         names__.push_back("diff_raw");
  1419:         names__.push_back("disc_raw");
  1420:         names__.push_back("xi");
  1421:         names__.push_back("gamma_raw");
  1422:         names__.push_back("delta_gamma");
  1423:         names__.push_back("nu_geo");
  1424:         names__.push_back("nu_geo_prior");
  1425:         names__.push_back("delta_tbar");
  1426:         names__.push_back("theta_bar_raw");
  1427:         names__.push_back("sd_theta_bar");
  1428:         names__.push_back("sd_theta");
  1429:         names__.push_back("sd_gamma_geo");
  1430:         names__.push_back("sd_gamma_demo");
  1431:         names__.push_back("sd_innov_delta");
  1432:         names__.push_back("sd_innov_logsd");
  1433:         names__.push_back("sd_innov_gamma");
  1434:         names__.push_back("theta_bar");
  1435:         names__.push_back("diff");
  1436:         names__.push_back("kappa");
  1437:         names__.push_back("disc");
  1438:         names__.push_back("sd_item");
  1439:         names__.push_back("var_item");
  1440:         names__.push_back("var_theta");
  1441:         names__.push_back("gamma");
  1442:         names__.push_back("mu_theta_bar");
  1443:         names__.push_back("mu_gamma");
  1444:         names__.push_back("z");
  1445:         names__.push_back("prob");
  1446:         names__.push_back("sd_total");
  1447:     }
  1448: 
  1449: 
  1450:     void get_dims(std::vector<std::vector<size_t> >& dimss__) const {
  1451:         dimss__.resize(0);
  1452:         std::vector<size_t> dims__;
  1453:         dims__.resize(0);
  1454:         dims__.push_back(D);
  1455:         dims__.push_back(Q);
  1456:         dimss__.push_back(dims__);
  1457:         dims__.resize(0);
  1458:         dims__.push_back(Q);
  1459:         dimss__.push_back(dims__);
  1460:         dims__.resize(0);
  1461:         dims__.push_back(T);
  1462:         dimss__.push_back(dims__);
  1463:         dims__.resize(0);
  1464:         dims__.push_back(T);
  1465:         dims__.push_back(P);
  1466:         dimss__.push_back(dims__);
  1467:         dims__.resize(0);
  1468:         dims__.push_back(T);
  1469:         dimss__.push_back(dims__);
  1470:         dims__.resize(0);
  1471:         dims__.push_back(T);
  1472:         dims__.push_back(H);
  1473:         dimss__.push_back(dims__);
  1474:         dims__.resize(0);
  1475:         dims__.push_back(Hprior);
  1476:         dimss__.push_back(dims__);
  1477:         dims__.resize(0);
  1478:         dims__.push_back(T);
  1479:         dimss__.push_back(dims__);
  1480:         dims__.resize(0);
  1481:         dims__.push_back(T);
  1482:         dims__.push_back(G);
  1483:         dimss__.push_back(dims__);
  1484:         dims__.resize(0);
  1485:         dims__.push_back(T);
  1486:         dimss__.push_back(dims__);
  1487:         dims__.resize(0);
  1488:         dims__.push_back(T);
  1489:         dimss__.push_back(dims__);
  1490:         dims__.resize(0);
  1491:         dimss__.push_back(dims__);
  1492:         dims__.resize(0);
  1493:         dimss__.push_back(dims__);
  1494:         dims__.resize(0);
  1495:         dimss__.push_back(dims__);
  1496:         dims__.resize(0);
  1497:         dimss__.push_back(dims__);
  1498:         dims__.resize(0);
  1499:         dimss__.push_back(dims__);
  1500:         dims__.resize(0);
  1501:         dims__.push_back(T);
  1502:         dims__.push_back(G);
  1503:         dimss__.push_back(dims__);
  1504:         dims__.resize(0);
  1505:         dims__.push_back(D);
  1506:         dims__.push_back(Q);
  1507:         dimss__.push_back(dims__);
  1508:         dims__.resize(0);
  1509:         dims__.push_back(D);
  1510:         dims__.push_back(Q);
  1511:         dimss__.push_back(dims__);
  1512:         dims__.resize(0);
  1513:         dims__.push_back(Q);
  1514:         dimss__.push_back(dims__);
  1515:         dims__.resize(0);
  1516:         dims__.push_back(Q);
  1517:         dimss__.push_back(dims__);
  1518:         dims__.resize(0);
  1519:         dims__.push_back(Q);
  1520:         dimss__.push_back(dims__);
  1521:         dims__.resize(0);
  1522:         dims__.push_back(T);
  1523:         dimss__.push_back(dims__);
  1524:         dims__.resize(0);
  1525:         dims__.push_back(T);
  1526:         dims__.push_back(P);
  1527:         dimss__.push_back(dims__);
  1528:         dims__.resize(0);
  1529:         dims__.push_back(T);
  1530:         dims__.push_back(G);
  1531:         dimss__.push_back(dims__);
  1532:         dims__.resize(0);
  1533:         dims__.push_back(T);
  1534:         dims__.push_back(P);
  1535:         dimss__.push_back(dims__);
  1536:         dims__.resize(0);
  1537:         dims__.push_back(T);
  1538:         dims__.push_back(Q);
  1539:         dims__.push_back(G);
  1540:         dimss__.push_back(dims__);
  1541:         dims__.resize(0);
  1542:         dims__.push_back(T);
  1543:         dims__.push_back(Q);
  1544:         dims__.push_back(G);
  1545:         dimss__.push_back(dims__);
  1546:         dims__.resize(0);
  1547:         dims__.push_back(T);
  1548:         dimss__.push_back(dims__);
  1549:     }
  1550: 
  1551:     template <typename RNG>
  1552:     void write_array(RNG& base_rng__,
  1553:                      std::vector<double>& params_r__,
  1554:                      std::vector<int>& params_i__,
  1555:                      std::vector<double>& vars__,
  1556:                      bool include_tparams__ = true,
  1557:                      bool include_gqs__ = true,
  1558:                      std::ostream* pstream__ = 0) const {
  1559:         vars__.resize(0);
  1560:         stan::io::reader<double> in__(params_r__,params_i__);
  1561:         static const char* function__ = "model439319d3ba2_2017_01_04_namespace::write_array";
  1562:         (void) function__;  // dummy to suppress unused var warning
  1563:         // read-transform, write parameters
  1564:         vector<vector_d> diff_raw;
  1565:         size_t dim_diff_raw_0__ = D;
  1566:         for (size_t k_0__ = 0; k_0__ < dim_diff_raw_0__; ++k_0__) {
  1567:             diff_raw.push_back(in__.vector_constrain(Q));
  1568:         }
  1569:         vector_d disc_raw = in__.vector_lb_constrain(0,Q);
  1570:         vector_d xi = in__.vector_constrain(T);
  1571:         vector<vector_d> gamma_raw;
  1572:         size_t dim_gamma_raw_0__ = T;
  1573:         for (size_t k_0__ = 0; k_0__ < dim_gamma_raw_0__; ++k_0__) {
  1574:             gamma_raw.push_back(in__.vector_constrain(P));
  1575:         }
  1576:         vector_d delta_gamma = in__.vector_constrain(T);
  1577:         vector<vector_d> nu_geo;
  1578:         size_t dim_nu_geo_0__ = T;
  1579:         for (size_t k_0__ = 0; k_0__ < dim_nu_geo_0__; ++k_0__) {
  1580:             nu_geo.push_back(in__.vector_constrain(H));
  1581:         }
  1582:         vector_d nu_geo_prior = in__.vector_constrain(Hprior);
  1583:         vector_d delta_tbar = in__.vector_constrain(T);
  1584:         vector<vector_d> theta_bar_raw;
  1585:         size_t dim_theta_bar_raw_0__ = T;
  1586:         for (size_t k_0__ = 0; k_0__ < dim_theta_bar_raw_0__; ++k_0__) {
  1587:             theta_bar_raw.push_back(in__.vector_constrain(G));
  1588:         }
  1589:         vector_d sd_theta_bar = in__.vector_lb_constrain(0,T);
  1590:         vector_d sd_theta = in__.vector_lb_constrain(0,T);
  1591:         double sd_gamma_geo = in__.scalar_lb_constrain(0);
  1592:         double sd_gamma_demo = in__.scalar_lb_constrain(0);
  1593:         double sd_innov_delta = in__.scalar_lb_constrain(0);
  1594:         double sd_innov_logsd = in__.scalar_lb_constrain(0);
  1595:         double sd_innov_gamma = in__.scalar_lb_constrain(0);
  1596:             for (int k_1__ = 0; k_1__ < Q; ++k_1__) {
  1597:                 for (int k_0__ = 0; k_0__ < D; ++k_0__) {
  1598:                 vars__.push_back(diff_raw[k_0__][k_1__]);
  1599:                 }
  1600:             }
  1601:             for (int k_0__ = 0; k_0__ < Q; ++k_0__) {
  1602:             vars__.push_back(disc_raw[k_0__]);
  1603:             }
  1604:             for (int k_0__ = 0; k_0__ < T; ++k_0__) {
  1605:             vars__.push_back(xi[k_0__]);
  1606:             }
  1607:             for (int k_1__ = 0; k_1__ < P; ++k_1__) {
  1608:                 for (int k_0__ = 0; k_0__ < T; ++k_0__) {
  1609:                 vars__.push_back(gamma_raw[k_0__][k_1__]);
  1610:                 }
  1611:             }
  1612:             for (int k_0__ = 0; k_0__ < T; ++k_0__) {
  1613:             vars__.push_back(delta_gamma[k_0__]);
  1614:             }
  1615:             for (int k_1__ = 0; k_1__ < H; ++k_1__) {
  1616:                 for (int k_0__ = 0; k_0__ < T; ++k_0__) {
  1617:                 vars__.push_back(nu_geo[k_0__][k_1__]);
  1618:                 }
  1619:             }
  1620:             for (int k_0__ = 0; k_0__ < Hprior; ++k_0__) {
  1621:             vars__.push_back(nu_geo_prior[k_0__]);
  1622:             }
  1623:             for (int k_0__ = 0; k_0__ < T; ++k_0__) {
  1624:             vars__.push_back(delta_tbar[k_0__]);
  1625:             }
  1626:             for (int k_1__ = 0; k_1__ < G; ++k_1__) {
  1627:                 for (int k_0__ = 0; k_0__ < T; ++k_0__) {
  1628:                 vars__.push_back(theta_bar_raw[k_0__][k_1__]);
  1629:                 }
  1630:             }
  1631:             for (int k_0__ = 0; k_0__ < T; ++k_0__) {
  1632:             vars__.push_back(sd_theta_bar[k_0__]);
  1633:             }
  1634:             for (int k_0__ = 0; k_0__ < T; ++k_0__) {
  1635:             vars__.push_back(sd_theta[k_0__]);
  1636:             }
  1637:         vars__.push_back(sd_gamma_geo);
  1638:         vars__.push_back(sd_gamma_demo);
  1639:         vars__.push_back(sd_innov_delta);
  1640:         vars__.push_back(sd_innov_logsd);
  1641:         vars__.push_back(sd_innov_gamma);
  1642: 
  1643:         if (!include_tparams__) return;
  1644:         // declare and define transformed parameters
  1645:         double lp__ = 0.0;
  1646:         (void) lp__;  // dummy to suppress unused var warning
  1647:         stan::math::accumulator<double> lp_accum__;
  1648: 
  1649:         double DUMMY_VAR__(std::numeric_limits<double>::quiet_NaN());
  1650:         (void) DUMMY_VAR__;  // suppress unused var warning
  1651: 
  1652:         try {
  1653:             current_statement_begin__ = 55;
  1654:             validate_non_negative_index("theta_bar", "G", G);
  1655:             validate_non_negative_index("theta_bar", "T", T);
  1656:             vector<vector_d> theta_bar(T, (vector_d(static_cast<Eigen::VectorXd::Index>(G))));
  1657:             stan::math::initialize(theta_bar, std::numeric_limits<double>::quiet_NaN());
  1658:             stan::math::fill(theta_bar,DUMMY_VAR__);
  1659:             current_statement_begin__ = 56;
  1660:             validate_non_negative_index("diff", "Q", Q);
  1661:             validate_non_negative_index("diff", "D", D);
  1662:             vector<vector_d> diff(D, (vector_d(static_cast<Eigen::VectorXd::Index>(Q))));
  1663:             stan::math::initialize(diff, std::numeric_limits<double>::quiet_NaN());
  1664:             stan::math::fill(diff,DUMMY_VAR__);
  1665:             current_statement_begin__ = 57;
  1666:             validate_non_negative_index("kappa", "Q", Q);
  1667:             validate_non_negative_index("kappa", "D", D);
  1668:             vector<vector_d> kappa(D, (vector_d(static_cast<Eigen::VectorXd::Index>(Q))));
  1669:             stan::math::initialize(kappa, std::numeric_limits<double>::quiet_NaN());
  1670:             stan::math::fill(kappa,DUMMY_VAR__);
  1671:             current_statement_begin__ = 58;
  1672:             validate_non_negative_index("disc", "Q", Q);
  1673:             vector_d disc(static_cast<Eigen::VectorXd::Index>(Q));
  1674:             (void) disc;  // dummy to suppress unused var warning
  1675: 
  1676:             stan::math::initialize(disc, std::numeric_limits<double>::quiet_NaN());
  1677:             stan::math::fill(disc,DUMMY_VAR__);
  1678:             current_statement_begin__ = 59;
  1679:             validate_non_negative_index("sd_item", "Q", Q);
  1680:             vector_d sd_item(static_cast<Eigen::VectorXd::Index>(Q));
  1681:             (void) sd_item;  // dummy to suppress unused var warning
  1682: 
  1683:             stan::math::initialize(sd_item, std::numeric_limits<double>::quiet_NaN());
  1684:             stan::math::fill(sd_item,DUMMY_VAR__);
  1685:             current_statement_begin__ = 60;
  1686:             validate_non_negative_index("var_item", "Q", Q);
  1687:             vector_d var_item(static_cast<Eigen::VectorXd::Index>(Q));
  1688:             (void) var_item;  // dummy to suppress unused var warning
  1689: 
  1690:             stan::math::initialize(var_item, std::numeric_limits<double>::quiet_NaN());
  1691:             stan::math::fill(var_item,DUMMY_VAR__);
  1692:             current_statement_begin__ = 61;
  1693:             validate_non_negative_index("var_theta", "T", T);
  1694:             vector_d var_theta(static_cast<Eigen::VectorXd::Index>(T));
  1695:             (void) var_theta;  // dummy to suppress unused var warning
  1696: 
  1697:             stan::math::initialize(var_theta, std::numeric_limits<double>::quiet_NaN());
  1698:             stan::math::fill(var_theta,DUMMY_VAR__);
  1699:             current_statement_begin__ = 63;
  1700:             validate_non_negative_index("gamma", "P", P);
  1701:             validate_non_negative_index("gamma", "T", T);
  1702:             vector<vector_d> gamma(T, (vector_d(static_cast<Eigen::VectorXd::Index>(P))));
  1703:             stan::math::initialize(gamma, std::numeric_limits<double>::quiet_NaN());
  1704:             stan::math::fill(gamma,DUMMY_VAR__);
  1705:             current_statement_begin__ = 64;
  1706:             validate_non_negative_index("mu_theta_bar", "G", G);
  1707:             validate_non_negative_index("mu_theta_bar", "T", T);
  1708:             vector<vector_d> mu_theta_bar(T, (vector_d(static_cast<Eigen::VectorXd::Index>(G))));
  1709:             stan::math::initialize(mu_theta_bar, std::numeric_limits<double>::quiet_NaN());
  1710:             stan::math::fill(mu_theta_bar,DUMMY_VAR__);
  1711:             current_statement_begin__ = 65;
  1712:             validate_non_negative_index("mu_gamma", "P", P);
  1713:             validate_non_negative_index("mu_gamma", "T", T);
  1714:             vector<vector_d> mu_gamma(T, (vector_d(static_cast<Eigen::VectorXd::Index>(P))));
  1715:             stan::math::initialize(mu_gamma, std::numeric_limits<double>::quiet_NaN());
  1716:             stan::math::fill(mu_gamma,DUMMY_VAR__);
  1717:             current_statement_begin__ = 66;
  1718:             validate_non_negative_index("z", "G", G);
  1719:             validate_non_negative_index("z", "T", T);
  1720:             validate_non_negative_index("z", "Q", Q);
  1721:             vector<vector<vector_d> > z(T, (vector<vector_d>(Q, (vector_d(static_cast<Eigen::VectorXd::Index>(G))))));
  1722:             stan::math::initialize(z, std::numeric_limits<double>::quiet_NaN());
  1723:             stan::math::fill(z,DUMMY_VAR__);
  1724:             current_statement_begin__ = 67;
  1725:             validate_non_negative_index("prob", "T", T);
  1726:             validate_non_negative_index("prob", "Q", Q);
  1727:             validate_non_negative_index("prob", "G", G);
  1728:             vector<vector<vector<double> > > prob(T, (vector<vector<double> >(Q, (vector<double>(G, 0.0)))));
  1729:             stan::math::initialize(prob, std::numeric_limits<double>::quiet_NaN());
  1730:             stan::math::fill(prob,DUMMY_VAR__);
  1731: 
  1732: 
  1733:             current_statement_begin__ = 69;
  1734:             stan::math::assign(disc, multiply(disc_raw,pow(exp(sum(log(disc_raw))),-(inv(Q)))));
  1735:             current_statement_begin__ = 70;
  1736:             for (int q = 1; q <= Q; ++q) {
  1737: 
  1738:                 current_statement_begin__ = 71;
  1739:                 stan::math::assign(get_base1_lhs(sd_item,q,"sd_item",1), inv(get_base1(disc,q,"disc",1)));
  1740:             }
  1741:             current_statement_begin__ = 73;
  1742:             for (int d = 1; d <= D; ++d) {
  1743: 
  1744:                 current_statement_begin__ = 75;
  1745:                 stan::math::assign(get_base1_lhs(diff,d,"diff",1), subtract(get_base1(diff_raw,d,"diff_raw",1),mean(get_base1(diff_raw,1,"diff_raw",1))));
  1746:                 current_statement_begin__ = 76;
  1747:                 stan::math::assign(get_base1_lhs(kappa,d,"kappa",1), elt_divide(get_base1(diff,d,"diff",1),disc));
  1748:             }
  1749:             current_statement_begin__ = 78;
  1750:             stan::math::assign(var_item, elt_multiply(sd_item,sd_item));
  1751:             current_statement_begin__ = 79;
  1752:             stan::math::assign(var_theta, elt_multiply(sd_theta,sd_theta));
  1753:             current_statement_begin__ = 80;
  1754:             for (int t = 1; t <= T; ++t) {
  1755: 
  1756:                 current_statement_begin__ = 81;
  1757:                 if (as_bool((primitive_value(logical_eq(t,1)) || primitive_value(logical_eq(separate_t,1))))) {
  1758: 
  1759:                     current_statement_begin__ = 82;
  1760:                     stan::math::assign(get_base1_lhs(mu_gamma,t,"mu_gamma",1), multiply(get_base1(ZZ_prior,t,"ZZ_prior",1),nu_geo_prior));
  1761:                     current_statement_begin__ = 83;
  1762:                     for (int p = 1; p <= P; ++p) {
  1763: 
  1764:                         current_statement_begin__ = 84;
  1765:                         if (as_bool(logical_lte(p,S))) {
  1766: 
  1767:                             current_statement_begin__ = 85;
  1768:                             stan::math::assign(get_base1_lhs(get_base1_lhs(gamma,t,"gamma",1),p,"gamma",2), (get_base1(get_base1(mu_gamma,t,"mu_gamma",1),p,"mu_gamma",2) + (sd_gamma_geo * get_base1(get_base1(gamma_raw,t,"gamma_raw",1),p,"gamma_raw",2))));
  1769:                         }
  1770:                         current_statement_begin__ = 87;
  1771:                         if (as_bool(logical_gt(p,S))) {
  1772: 
  1773:                             current_statement_begin__ = 88;
  1774:                             stan::math::assign(get_base1_lhs(get_base1_lhs(gamma,t,"gamma",1),p,"gamma",2), (get_base1(get_base1(mu_gamma,t,"mu_gamma",1),p,"mu_gamma",2) + (sd_gamma_demo * get_base1(get_base1(gamma_raw,t,"gamma_raw",1),p,"gamma_raw",2))));
  1775:                         }
  1776:                     }
  1777:                     current_statement_begin__ = 91;
  1778:                     stan::math::assign(get_base1_lhs(mu_theta_bar,t,"mu_theta_bar",1), add(get_base1(xi,t,"xi",1),multiply(XX,get_base1(gamma,t,"gamma",1))));
  1779:                 }
  1780:                 current_statement_begin__ = 94;
  1781:                 if (as_bool((primitive_value(logical_gt(t,1)) && primitive_value(logical_eq(separate_t,0))))) {
  1782: 
  1783:                     current_statement_begin__ = 95;
  1784:                     if (as_bool(logical_eq(t,2))) {
  1785: 
  1786:                         current_statement_begin__ = 103;
  1787:                         stan::math::assign(get_base1_lhs(mu_gamma,t,"mu_gamma",1), multiply(get_base1(ZZ_prior,t,"ZZ_prior",1),nu_geo_prior));
  1788:                         current_statement_begin__ = 104;
  1789:                         for (int p = 1; p <= P; ++p) {
  1790: 
  1791:                             current_statement_begin__ = 105;
  1792:                             if (as_bool(logical_lte(p,S))) {
  1793: 
  1794:                                 current_statement_begin__ = 106;
  1795:                                 stan::math::assign(get_base1_lhs(get_base1_lhs(gamma,t,"gamma",1),p,"gamma",2), (get_base1(get_base1(mu_gamma,t,"mu_gamma",1),p,"mu_gamma",2) + (sd_gamma_geo * get_base1(get_base1(gamma_raw,t,"gamma_raw",1),p,"gamma_raw",2))));
  1796:                             }
  1797:                             current_statement_begin__ = 108;
  1798:                             if (as_bool(logical_gt(p,S))) {
  1799: 
  1800:                                 current_statement_begin__ = 109;
  1801:                                 stan::math::assign(get_base1_lhs(get_base1_lhs(gamma,t,"gamma",1),p,"gamma",2), (get_base1(get_base1(mu_gamma,t,"mu_gamma",1),p,"mu_gamma",2) + (sd_gamma_demo * get_base1(get_base1(gamma_raw,t,"gamma_raw",1),p,"gamma_raw",2))));
  1802:                             }
  1803:                         }
  1804:                     } else {
  1805: 
  1806:                         current_statement_begin__ = 115;
  1807:                         for (int p = 1; p <= P; ++p) {
  1808: 
  1809:                             current_statement_begin__ = 116;
  1810:                             if (as_bool(logical_lte(p,S))) {
  1811: 
  1812:                                 current_statement_begin__ = 117;
  1813:                                 stan::math::assign(get_base1_lhs(get_base1_lhs(mu_gamma,t,"mu_gamma",1),p,"mu_gamma",2), ((get_base1(get_base1(gamma,(t - 1),"gamma",1),p,"gamma",2) * get_base1(delta_gamma,t,"delta_gamma",1)) + multiply(get_base1(get_base1(ZZ,t,"ZZ",1),p,"ZZ",2),get_base1(nu_geo,t,"nu_geo",1))));
  1814:                             }
  1815:                             current_statement_begin__ = 119;
  1816:                             if (as_bool(logical_gt(p,S))) {
  1817: 
  1818:                                 current_statement_begin__ = 120;
  1819:                                 stan::math::assign(get_base1_lhs(get_base1_lhs(mu_gamma,t,"mu_gamma",1),p,"mu_gamma",2), get_base1(get_base1(gamma,(t - 1),"gamma",1),p,"gamma",2));
  1820:                             }
  1821:                         }
  1822:                         current_statement_begin__ = 123;
  1823:                         stan::math::assign(get_base1_lhs(gamma,t,"gamma",1), add(get_base1(mu_gamma,t,"mu_gamma",1),multiply(sd_innov_gamma,get_base1(gamma_raw,t,"gamma_raw",1))));
  1824:                     }
  1825:                     current_statement_begin__ = 125;
  1826:                     stan::math::assign(get_base1_lhs(mu_theta_bar,t,"mu_theta_bar",1), add(add(get_base1(xi,t,"xi",1),multiply(XX,get_base1(gamma,t,"gamma",1))),multiply(get_base1(theta_bar,(t - 1),"theta_bar",1),get_base1(delta_tbar,t,"delta_tbar",1))));
  1827:                 }
  1828:                 current_statement_begin__ = 129;
  1829:                 if (as_bool(logical_eq(hierarchical_model,1))) {
  1830: 
  1831:                     current_statement_begin__ = 130;
  1832:                     stan::math::assign(get_base1_lhs(theta_bar,t,"theta_bar",1), add(get_base1(mu_theta_bar,t,"mu_theta_bar",1),multiply(get_base1(sd_theta_bar,t,"sd_theta_bar",1),get_base1(theta_bar_raw,t,"theta_bar_raw",1))));
  1833:                 }
  1834:                 current_statement_begin__ = 132;
  1835:                 if (as_bool(logical_eq(hierarchical_model,0))) {
  1836: 
  1837:                     current_statement_begin__ = 133;
  1838:                     stan::math::assign(get_base1_lhs(theta_bar,t,"theta_bar",1), multiply(get_base1(sd_theta_bar,t,"sd_theta_bar",1),get_base1(theta_bar_raw,t,"theta_bar_raw",1)));
  1839:                 }
  1840:                 current_statement_begin__ = 135;
  1841:                 for (int q = 1; q <= Q; ++q) {
  1842:                     {
  1843:                     current_statement_begin__ = 136;
  1844:                     double sd_tq(0.0);
  1845:                     (void) sd_tq;  // dummy to suppress unused var warning
  1846: 
  1847:                     stan::math::initialize(sd_tq, std::numeric_limits<double>::quiet_NaN());
  1848:                     stan::math::fill(sd_tq,DUMMY_VAR__);
  1849: 
  1850: 
  1851:                     current_statement_begin__ = 137;
  1852:                     stan::math::assign(sd_tq, sqrt((get_base1(var_theta,t,"var_theta",1) + get_base1(var_item,q,"var_item",1))));
  1853:                     current_statement_begin__ = 139;
  1854:                     if (as_bool(logical_eq(constant_item,0))) {
  1855: 
  1856:                         current_statement_begin__ = 140;
  1857:                         stan::math::assign(get_base1_lhs(get_base1_lhs(z,t,"z",1),q,"z",2), divide(subtract(get_base1(theta_bar,t,"theta_bar",1),get_base1(get_base1(kappa,t,"kappa",1),q,"kappa",2)),sd_tq));
  1858:                     }
  1859:                     current_statement_begin__ = 142;
  1860:                     if (as_bool(logical_eq(constant_item,1))) {
  1861: 
  1862:                         current_statement_begin__ = 143;
  1863:                         stan::math::assign(get_base1_lhs(get_base1_lhs(z,t,"z",1),q,"z",2), divide(subtract(get_base1(theta_bar,t,"theta_bar",1),get_base1(get_base1(kappa,1,"kappa",1),q,"kappa",2)),sd_tq));
  1864:                     }
  1865:                     current_statement_begin__ = 145;
  1866:                     for (int g = 1; g <= G; ++g) {
  1867: 
  1868:                         current_statement_begin__ = 146;
  1869:                         if (as_bool(logical_eq(Q,1))) {
  1870: 
  1871:                             current_statement_begin__ = 148;
  1872:                             stan::math::assign(get_base1_lhs(get_base1_lhs(get_base1_lhs(prob,t,"prob",1),q,"prob",2),g,"prob",3), Phi_approx(get_base1(get_base1(theta_bar,t,"theta_bar",1),g,"theta_bar",2)));
  1873:                         }
  1874:                         current_statement_begin__ = 150;
  1875:                         if (as_bool(logical_gt(Q,1))) {
  1876: 
  1877:                             current_statement_begin__ = 152;
  1878:                             stan::math::assign(get_base1_lhs(get_base1_lhs(get_base1_lhs(prob,t,"prob",1),q,"prob",2),g,"prob",3), Phi_approx(get_base1(get_base1(get_base1(z,t,"z",1),q,"z",2),g,"z",3)));
  1879:                         }
  1880:                     }
  1881:                     }
  1882:                 }
  1883:             }
  1884: 
  1885:             // validate transformed parameters
  1886:             current_statement_begin__ = 55;
  1887:             current_statement_begin__ = 56;
  1888:             current_statement_begin__ = 57;
  1889:             current_statement_begin__ = 58;
  1890:             check_greater_or_equal(function__,"disc",disc,0);
  1891:             current_statement_begin__ = 59;
  1892:             check_greater_or_equal(function__,"sd_item",sd_item,0);
  1893:             current_statement_begin__ = 60;
  1894:             check_greater_or_equal(function__,"var_item",var_item,0);
  1895:             current_statement_begin__ = 61;
  1896:             check_greater_or_equal(function__,"var_theta",var_theta,0);
  1897:             current_statement_begin__ = 63;
  1898:             current_statement_begin__ = 64;
  1899:             current_statement_begin__ = 65;
  1900:             current_statement_begin__ = 66;
  1901:             current_statement_begin__ = 67;
  1902:             for (int k0__ = 0; k0__ < T; ++k0__) {
  1903:                 for (int k1__ = 0; k1__ < Q; ++k1__) {
  1904:                     for (int k2__ = 0; k2__ < G; ++k2__) {
  1905:                         check_greater_or_equal(function__,"prob[k0__][k1__][k2__]",prob[k0__][k1__][k2__],0);
  1906:                         check_less_or_equal(function__,"prob[k0__][k1__][k2__]",prob[k0__][k1__][k2__],1);
  1907:                     }
  1908:                 }
  1909:             }
  1910: 
  1911:             // write transformed parameters
  1912:             for (int k_1__ = 0; k_1__ < G; ++k_1__) {
  1913:                 for (int k_0__ = 0; k_0__ < T; ++k_0__) {
  1914:                 vars__.push_back(theta_bar[k_0__][k_1__]);
  1915:                 }
  1916:             }
  1917:             for (int k_1__ = 0; k_1__ < Q; ++k_1__) {
  1918:                 for (int k_0__ = 0; k_0__ < D; ++k_0__) {
  1919:                 vars__.push_back(diff[k_0__][k_1__]);
  1920:                 }
  1921:             }
  1922:             for (int k_1__ = 0; k_1__ < Q; ++k_1__) {
  1923:                 for (int k_0__ = 0; k_0__ < D; ++k_0__) {
  1924:                 vars__.push_back(kappa[k_0__][k_1__]);
  1925:                 }
  1926:             }
  1927:             for (int k_0__ = 0; k_0__ < Q; ++k_0__) {
  1928:             vars__.push_back(disc[k_0__]);
  1929:             }
  1930:             for (int k_0__ = 0; k_0__ < Q; ++k_0__) {
  1931:             vars__.push_back(sd_item[k_0__]);
  1932:             }
  1933:             for (int k_0__ = 0; k_0__ < Q; ++k_0__) {
  1934:             vars__.push_back(var_item[k_0__]);
  1935:             }
  1936:             for (int k_0__ = 0; k_0__ < T; ++k_0__) {
  1937:             vars__.push_back(var_theta[k_0__]);
  1938:             }
  1939:             for (int k_1__ = 0; k_1__ < P; ++k_1__) {
  1940:                 for (int k_0__ = 0; k_0__ < T; ++k_0__) {
  1941:                 vars__.push_back(gamma[k_0__][k_1__]);
  1942:                 }
  1943:             }
  1944:             for (int k_1__ = 0; k_1__ < G; ++k_1__) {
  1945:                 for (int k_0__ = 0; k_0__ < T; ++k_0__) {
  1946:                 vars__.push_back(mu_theta_bar[k_0__][k_1__]);
  1947:                 }
  1948:             }
  1949:             for (int k_1__ = 0; k_1__ < P; ++k_1__) {
  1950:                 for (int k_0__ = 0; k_0__ < T; ++k_0__) {
  1951:                 vars__.push_back(mu_gamma[k_0__][k_1__]);
  1952:                 }
  1953:             }
  1954:             for (int k_2__ = 0; k_2__ < G; ++k_2__) {
  1955:                 for (int k_1__ = 0; k_1__ < Q; ++k_1__) {
  1956:                     for (int k_0__ = 0; k_0__ < T; ++k_0__) {
  1957:                     vars__.push_back(z[k_0__][k_1__][k_2__]);
  1958:                     }
  1959:                 }
  1960:             }
  1961:             for (int k_2__ = 0; k_2__ < G; ++k_2__) {
  1962:                 for (int k_1__ = 0; k_1__ < Q; ++k_1__) {
  1963:                     for (int k_0__ = 0; k_0__ < T; ++k_0__) {
  1964:                     vars__.push_back(prob[k_0__][k_1__][k_2__]);
  1965:                     }
  1966:                 }
  1967:             }
  1968: 
  1969:             if (!include_gqs__) return;
  1970:             // declare and define generated quantities
  1971:             current_statement_begin__ = 228;
  1972:             validate_non_negative_index("sd_total", "T", T);
  1973:             vector_d sd_total(static_cast<Eigen::VectorXd::Index>(T));
  1974:             (void) sd_total;  // dummy to suppress unused var warning
  1975: 
  1976:             stan::math::initialize(sd_total, std::numeric_limits<double>::quiet_NaN());
  1977:             stan::math::fill(sd_total,DUMMY_VAR__);
  1978: 
  1979: 
  1980:             current_statement_begin__ = 229;
  1981:             for (int t = 1; t <= T; ++t) {
  1982: 
  1983:                 current_statement_begin__ = 230;
  1984:                 stan::math::assign(get_base1_lhs(sd_total,t,"sd_total",1), sqrt((variance(get_base1(theta_bar,t,"theta_bar",1)) + square(get_base1(sd_theta,t,"sd_theta",1)))));
  1985:             }
  1986: 
  1987:             // validate generated quantities
  1988:             current_statement_begin__ = 228;
  1989:             check_greater_or_equal(function__,"sd_total",sd_total,0);
  1990: 
  1991:             // write generated quantities
  1992:             for (int k_0__ = 0; k_0__ < T; ++k_0__) {
  1993:             vars__.push_back(sd_total[k_0__]);
  1994:             }
  1995: 
  1996:         } catch (const std::exception& e) {
  1997:             stan::lang::rethrow_located(e, current_statement_begin__, prog_reader__());
  1998:             // Next line prevents compiler griping about no return
  1999:             throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***");
  2000:         }
  2001:     }
  2002: 
  2003:     template <typename RNG>
  2004:     void write_array(RNG& base_rng,
  2005:                      Eigen::Matrix<double,Eigen::Dynamic,1>& params_r,
  2006:                      Eigen::Matrix<double,Eigen::Dynamic,1>& vars,
  2007:                      bool include_tparams = true,
  2008:                      bool include_gqs = true,
  2009:                      std::ostream* pstream = 0) const {
  2010:       std::vector<double> params_r_vec(params_r.size());
  2011:       for (int i = 0; i < params_r.size(); ++i)
  2012:         params_r_vec[i] = params_r(i);
  2013:       std::vector<double> vars_vec;
  2014:       std::vector<int> params_i_vec;
  2015:       write_array(base_rng,params_r_vec,params_i_vec,vars_vec,include_tparams,include_gqs,pstream);
  2016:       vars.resize(vars_vec.size());
  2017:       for (int i = 0; i < vars.size(); ++i)
  2018:         vars(i) = vars_vec[i];
  2019:     }
  2020: 
  2021:     static std::string model_name() {
  2022:         return "model439319d3ba2_2017_01_04";
  2023:     }
  2024: 
  2025: 
  2026:     void constrained_param_names(std::vector<std::string>& param_names__,
  2027:                                  bool include_tparams__ = true,
  2028:                                  bool include_gqs__ = true) const {
  2029:         std::stringstream param_name_stream__;
  2030:         for (int k_1__ = 1; k_1__ <= Q; ++k_1__) {
  2031:             for (int k_0__ = 1; k_0__ <= D; ++k_0__) {
  2032:                 param_name_stream__.str(std::string());
  2033:                 param_name_stream__ << "diff_raw" << '.' << k_0__ << '.' << k_1__;
  2034:                 param_names__.push_back(param_name_stream__.str());
  2035:             }
  2036:         }
  2037:         for (int k_0__ = 1; k_0__ <= Q; ++k_0__) {
  2038:             param_name_stream__.str(std::string());
  2039:             param_name_stream__ << "disc_raw" << '.' << k_0__;
  2040:             param_names__.push_back(param_name_stream__.str());
  2041:         }
  2042:         for (int k_0__ = 1; k_0__ <= T; ++k_0__) {
  2043:             param_name_stream__.str(std::string());
  2044:             param_name_stream__ << "xi" << '.' << k_0__;
  2045:             param_names__.push_back(param_name_stream__.str());
  2046:         }
  2047:         for (int k_1__ = 1; k_1__ <= P; ++k_1__) {
  2048:             for (int k_0__ = 1; k_0__ <= T; ++k_0__) {
  2049:                 param_name_stream__.str(std::string());
  2050:                 param_name_stream__ << "gamma_raw" << '.' << k_0__ << '.' << k_1__;
  2051:                 param_names__.push_back(param_name_stream__.str());
  2052:             }
  2053:         }
  2054:         for (int k_0__ = 1; k_0__ <= T; ++k_0__) {
  2055:             param_name_stream__.str(std::string());
  2056:             param_name_stream__ << "delta_gamma" << '.' << k_0__;
  2057:             param_names__.push_back(param_name_stream__.str());
  2058:         }
  2059:         for (int k_1__ = 1; k_1__ <= H; ++k_1__) {
  2060:             for (int k_0__ = 1; k_0__ <= T; ++k_0__) {
  2061:                 param_name_stream__.str(std::string());
  2062:                 param_name_stream__ << "nu_geo" << '.' << k_0__ << '.' << k_1__;
  2063:                 param_names__.push_back(param_name_stream__.str());
  2064:             }
  2065:         }
  2066:         for (int k_0__ = 1; k_0__ <= Hprior; ++k_0__) {
  2067:             param_name_stream__.str(std::string());
  2068:             param_name_stream__ << "nu_geo_prior" << '.' << k_0__;
  2069:             param_names__.push_back(param_name_stream__.str());
  2070:         }
  2071:         for (int k_0__ = 1; k_0__ <= T; ++k_0__) {
  2072:             param_name_stream__.str(std::string());
  2073:             param_name_stream__ << "delta_tbar" << '.' << k_0__;
  2074:             param_names__.push_back(param_name_stream__.str());
  2075:         }
  2076:         for (int k_1__ = 1; k_1__ <= G; ++k_1__) {
  2077:             for (int k_0__ = 1; k_0__ <= T; ++k_0__) {
  2078:                 param_name_stream__.str(std::string());
  2079:                 param_name_stream__ << "theta_bar_raw" << '.' << k_0__ << '.' << k_1__;
  2080:                 param_names__.push_back(param_name_stream__.str());
  2081:             }
  2082:         }
  2083:         for (int k_0__ = 1; k_0__ <= T; ++k_0__) {
  2084:             param_name_stream__.str(std::string());
  2085:             param_name_stream__ << "sd_theta_bar" << '.' << k_0__;
  2086:             param_names__.push_back(param_name_stream__.str());
  2087:         }
  2088:         for (int k_0__ = 1; k_0__ <= T; ++k_0__) {
  2089:             param_name_stream__.str(std::string());
  2090:             param_name_stream__ << "sd_theta" << '.' << k_0__;
  2091:             param_names__.push_back(param_name_stream__.str());
  2092:         }
  2093:         param_name_stream__.str(std::string());
  2094:         param_name_stream__ << "sd_gamma_geo";
  2095:         param_names__.push_back(param_name_stream__.str());
  2096:         param_name_stream__.str(std::string());
  2097:         param_name_stream__ << "sd_gamma_demo";
  2098:         param_names__.push_back(param_name_stream__.str());
  2099:         param_name_stream__.str(std::string());
  2100:         param_name_stream__ << "sd_innov_delta";
  2101:         param_names__.push_back(param_name_stream__.str());
  2102:         param_name_stream__.str(std::string());
  2103:         param_name_stream__ << "sd_innov_logsd";
  2104:         param_names__.push_back(param_name_stream__.str());
  2105:         param_name_stream__.str(std::string());
  2106:         param_name_stream__ << "sd_innov_gamma";
  2107:         param_names__.push_back(param_name_stream__.str());
  2108: 
  2109:         if (!include_gqs__ && !include_tparams__) return;
  2110:         for (int k_1__ = 1; k_1__ <= G; ++k_1__) {
  2111:             for (int k_0__ = 1; k_0__ <= T; ++k_0__) {
  2112:                 param_name_stream__.str(std::string());
  2113:                 param_name_stream__ << "theta_bar" << '.' << k_0__ << '.' << k_1__;
  2114:                 param_names__.push_back(param_name_stream__.str());
  2115:             }
  2116:         }
  2117:         for (int k_1__ = 1; k_1__ <= Q; ++k_1__) {
  2118:             for (int k_0__ = 1; k_0__ <= D; ++k_0__) {
  2119:                 param_name_stream__.str(std::string());
  2120:                 param_name_stream__ << "diff" << '.' << k_0__ << '.' << k_1__;
  2121:                 param_names__.push_back(param_name_stream__.str());
  2122:             }
  2123:         }
  2124:         for (int k_1__ = 1; k_1__ <= Q; ++k_1__) {
  2125:             for (int k_0__ = 1; k_0__ <= D; ++k_0__) {
  2126:                 param_name_stream__.str(std::string());
  2127:                 param_name_stream__ << "kappa" << '.' << k_0__ << '.' << k_1__;
  2128:                 param_names__.push_back(param_name_stream__.str());
  2129:             }
  2130:         }
  2131:         for (int k_0__ = 1; k_0__ <= Q; ++k_0__) {
  2132:             param_name_stream__.str(std::string());
  2133:             param_name_stream__ << "disc" << '.' << k_0__;
  2134:             param_names__.push_back(param_name_stream__.str());
  2135:         }
  2136:         for (int k_0__ = 1; k_0__ <= Q; ++k_0__) {
  2137:             param_name_stream__.str(std::string());
  2138:             param_name_stream__ << "sd_item" << '.' << k_0__;
  2139:             param_names__.push_back(param_name_stream__.str());
  2140:         }
  2141:         for (int k_0__ = 1; k_0__ <= Q; ++k_0__) {
  2142:             param_name_stream__.str(std::string());
  2143:             param_name_stream__ << "var_item" << '.' << k_0__;
  2144:             param_names__.push_back(param_name_stream__.str());
  2145:         }
  2146:         for (int k_0__ = 1; k_0__ <= T; ++k_0__) {
  2147:             param_name_stream__.str(std::string());
  2148:             param_name_stream__ << "var_theta" << '.' << k_0__;
  2149:             param_names__.push_back(param_name_stream__.str());
  2150:         }
  2151:         for (int k_1__ = 1; k_1__ <= P; ++k_1__) {
  2152:             for (int k_0__ = 1; k_0__ <= T; ++k_0__) {
  2153:                 param_name_stream__.str(std::string());
  2154:                 param_name_stream__ << "gamma" << '.' << k_0__ << '.' << k_1__;
  2155:                 param_names__.push_back(param_name_stream__.str());
  2156:             }
  2157:         }
  2158:         for (int k_1__ = 1; k_1__ <= G; ++k_1__) {
  2159:             for (int k_0__ = 1; k_0__ <= T; ++k_0__) {
  2160:                 param_name_stream__.str(std::string());
  2161:                 param_name_stream__ << "mu_theta_bar" << '.' << k_0__ << '.' << k_1__;
  2162:                 param_names__.push_back(param_name_stream__.str());
  2163:             }
  2164:         }
  2165:         for (int k_1__ = 1; k_1__ <= P; ++k_1__) {
  2166:             for (int k_0__ = 1; k_0__ <= T; ++k_0__) {
  2167:                 param_name_stream__.str(std::string());
  2168:                 param_name_stream__ << "mu_gamma" << '.' << k_0__ << '.' << k_1__;
  2169:                 param_names__.push_back(param_name_stream__.str());
  2170:             }
  2171:         }
  2172:         for (int k_2__ = 1; k_2__ <= G; ++k_2__) {
  2173:             for (int k_1__ = 1; k_1__ <= Q; ++k_1__) {
  2174:                 for (int k_0__ = 1; k_0__ <= T; ++k_0__) {
  2175:                     param_name_stream__.str(std::string());
  2176:                     param_name_stream__ << "z" << '.' << k_0__ << '.' << k_1__ << '.' << k_2__;
  2177:                     param_names__.push_back(param_name_stream__.str());
  2178:                 }
  2179:             }
  2180:         }
  2181:         for (int k_2__ = 1; k_2__ <= G; ++k_2__) {
  2182:             for (int k_1__ = 1; k_1__ <= Q; ++k_1__) {
  2183:                 for (int k_0__ = 1; k_0__ <= T; ++k_0__) {
  2184:                     param_name_stream__.str(std::string());
  2185:                     param_name_stream__ << "prob" << '.' << k_0__ << '.' << k_1__ << '.' << k_2__;
  2186:                     param_names__.push_back(param_name_stream__.str());
  2187:                 }
  2188:             }
  2189:         }
  2190: 
  2191:         if (!include_gqs__) return;
  2192:         for (int k_0__ = 1; k_0__ <= T; ++k_0__) {
  2193:             param_name_stream__.str(std::string());
  2194:             param_name_stream__ << "sd_total" << '.' << k_0__;
  2195:             param_names__.push_back(param_name_stream__.str());
  2196:         }
  2197:     }
  2198: 
  2199: 
  2200:     void unconstrained_param_names(std::vector<std::string>& param_names__,
  2201:                                    bool include_tparams__ = true,
  2202:                                    bool include_gqs__ = true) const {
  2203:         std::stringstream param_name_stream__;
  2204:         for (int k_1__ = 1; k_1__ <= Q; ++k_1__) {
  2205:             for (int k_0__ = 1; k_0__ <= D; ++k_0__) {
  2206:                 param_name_stream__.str(std::string());
  2207:                 param_name_stream__ << "diff_raw" << '.' << k_0__ << '.' << k_1__;
  2208:                 param_names__.push_back(param_name_stream__.str());
  2209:             }
  2210:         }
  2211:         for (int k_0__ = 1; k_0__ <= Q; ++k_0__) {
  2212:             param_name_stream__.str(std::string());
  2213:             param_name_stream__ << "disc_raw" << '.' << k_0__;
  2214:             param_names__.push_back(param_name_stream__.str());
  2215:         }
  2216:         for (int k_0__ = 1; k_0__ <= T; ++k_0__) {
  2217:             param_name_stream__.str(std::string());
  2218:             param_name_stream__ << "xi" << '.' << k_0__;
  2219:             param_names__.push_back(param_name_stream__.str());
  2220:         }
  2221:         for (int k_1__ = 1; k_1__ <= P; ++k_1__) {
  2222:             for (int k_0__ = 1; k_0__ <= T; ++k_0__) {
  2223:                 param_name_stream__.str(std::string());
  2224:                 param_name_stream__ << "gamma_raw" << '.' << k_0__ << '.' << k_1__;
  2225:                 param_names__.push_back(param_name_stream__.str());
  2226:             }
  2227:         }
  2228:         for (int k_0__ = 1; k_0__ <= T; ++k_0__) {
  2229:             param_name_stream__.str(std::string());
  2230:             param_name_stream__ << "delta_gamma" << '.' << k_0__;
  2231:             param_names__.push_back(param_name_stream__.str());
  2232:         }
  2233:         for (int k_1__ = 1; k_1__ <= H; ++k_1__) {
  2234:             for (int k_0__ = 1; k_0__ <= T; ++k_0__) {
  2235:                 param_name_stream__.str(std::string());
  2236:                 param_name_stream__ << "nu_geo" << '.' << k_0__ << '.' << k_1__;
  2237:                 param_names__.push_back(param_name_stream__.str());
  2238:             }
  2239:         }
  2240:         for (int k_0__ = 1; k_0__ <= Hprior; ++k_0__) {
  2241:             param_name_stream__.str(std::string());
  2242:             param_name_stream__ << "nu_geo_prior" << '.' << k_0__;
  2243:             param_names__.push_back(param_name_stream__.str());
  2244:         }
  2245:         for (int k_0__ = 1; k_0__ <= T; ++k_0__) {
  2246:             param_name_stream__.str(std::string());
  2247:             param_name_stream__ << "delta_tbar" << '.' << k_0__;
  2248:             param_names__.push_back(param_name_stream__.str());
  2249:         }
  2250:         for (int k_1__ = 1; k_1__ <= G; ++k_1__) {
  2251:             for (int k_0__ = 1; k_0__ <= T; ++k_0__) {
  2252:                 param_name_stream__.str(std::string());
  2253:                 param_name_stream__ << "theta_bar_raw" << '.' << k_0__ << '.' << k_1__;
  2254:                 param_names__.push_back(param_name_stream__.str());
  2255:             }
  2256:         }
  2257:         for (int k_0__ = 1; k_0__ <= T; ++k_0__) {
  2258:             param_name_stream__.str(std::string());
  2259:             param_name_stream__ << "sd_theta_bar" << '.' << k_0__;
  2260:             param_names__.push_back(param_name_stream__.str());
  2261:         }
  2262:         for (int k_0__ = 1; k_0__ <= T; ++k_0__) {
  2263:             param_name_stream__.str(std::string());
  2264:             param_name_stream__ << "sd_theta" << '.' << k_0__;
  2265:             param_names__.push_back(param_name_stream__.str());
  2266:         }
  2267:         param_name_stream__.str(std::string());
  2268:         param_name_stream__ << "sd_gamma_geo";
  2269:         param_names__.push_back(param_name_stream__.str());
  2270:         param_name_stream__.str(std::string());
  2271:         param_name_stream__ << "sd_gamma_demo";
  2272:         param_names__.push_back(param_name_stream__.str());
  2273:         param_name_stream__.str(std::string());
  2274:         param_name_stream__ << "sd_innov_delta";
  2275:         param_names__.push_back(param_name_stream__.str());
  2276:         param_name_stream__.str(std::string());
  2277:         param_name_stream__ << "sd_innov_logsd";
  2278:         param_names__.push_back(param_name_stream__.str());
  2279:         param_name_stream__.str(std::string());
  2280:         param_name_stream__ << "sd_innov_gamma";
  2281:         param_names__.push_back(param_name_stream__.str());
  2282: 
  2283:         if (!include_gqs__ && !include_tparams__) return;
  2284:         for (int k_1__ = 1; k_1__ <= G; ++k_1__) {
  2285:             for (int k_0__ = 1; k_0__ <= T; ++k_0__) {
  2286:                 param_name_stream__.str(std::string());
  2287:                 param_name_stream__ << "theta_bar" << '.' << k_0__ << '.' << k_1__;
  2288:                 param_names__.push_back(param_name_stream__.str());
  2289:             }
  2290:         }
  2291:         for (int k_1__ = 1; k_1__ <= Q; ++k_1__) {
  2292:             for (int k_0__ = 1; k_0__ <= D; ++k_0__) {
  2293:                 param_name_stream__.str(std::string());
  2294:                 param_name_stream__ << "diff" << '.' << k_0__ << '.' << k_1__;
  2295:                 param_names__.push_back(param_name_stream__.str());
  2296:             }
  2297:         }
  2298:         for (int k_1__ = 1; k_1__ <= Q; ++k_1__) {
  2299:             for (int k_0__ = 1; k_0__ <= D; ++k_0__) {
  2300:                 param_name_stream__.str(std::string());
  2301:                 param_name_stream__ << "kappa" << '.' << k_0__ << '.' << k_1__;
  2302:                 param_names__.push_back(param_name_stream__.str());
  2303:             }
  2304:         }
  2305:         for (int k_0__ = 1; k_0__ <= Q; ++k_0__) {
  2306:             param_name_stream__.str(std::string());
  2307:             param_name_stream__ << "disc" << '.' << k_0__;
  2308:             param_names__.push_back(param_name_stream__.str());
  2309:         }
  2310:         for (int k_0__ = 1; k_0__ <= Q; ++k_0__) {
  2311:             param_name_stream__.str(std::string());
  2312:             param_name_stream__ << "sd_item" << '.' << k_0__;
  2313:             param_names__.push_back(param_name_stream__.str());
  2314:         }
  2315:         for (int k_0__ = 1; k_0__ <= Q; ++k_0__) {
  2316:             param_name_stream__.str(std::string());
  2317:             param_name_stream__ << "var_item" << '.' << k_0__;
  2318:             param_names__.push_back(param_name_stream__.str());
  2319:         }
  2320:         for (int k_0__ = 1; k_0__ <= T; ++k_0__) {
  2321:             param_name_stream__.str(std::string());
  2322:             param_name_stream__ << "var_theta" << '.' << k_0__;
  2323:             param_names__.push_back(param_name_stream__.str());
  2324:         }
  2325:         for (int k_1__ = 1; k_1__ <= P; ++k_1__) {
  2326:             for (int k_0__ = 1; k_0__ <= T; ++k_0__) {
  2327:                 param_name_stream__.str(std::string());
  2328:                 param_name_stream__ << "gamma" << '.' << k_0__ << '.' << k_1__;
  2329:                 param_names__.push_back(param_name_stream__.str());
  2330:             }
  2331:         }
  2332:         for (int k_1__ = 1; k_1__ <= G; ++k_1__) {
  2333:             for (int k_0__ = 1; k_0__ <= T; ++k_0__) {
  2334:                 param_name_stream__.str(std::string());
  2335:                 param_name_stream__ << "mu_theta_bar" << '.' << k_0__ << '.' << k_1__;
  2336:                 param_names__.push_back(param_name_stream__.str());
  2337:             }
  2338:         }
  2339:         for (int k_1__ = 1; k_1__ <= P; ++k_1__) {
  2340:             for (int k_0__ = 1; k_0__ <= T; ++k_0__) {
  2341:                 param_name_stream__.str(std::string());
  2342:                 param_name_stream__ << "mu_gamma" << '.' << k_0__ << '.' << k_1__;
  2343:                 param_names__.push_back(param_name_stream__.str());
  2344:             }
  2345:         }
  2346:         for (int k_2__ = 1; k_2__ <= G; ++k_2__) {
  2347:             for (int k_1__ = 1; k_1__ <= Q; ++k_1__) {
  2348:                 for (int k_0__ = 1; k_0__ <= T; ++k_0__) {
  2349:                     param_name_stream__.str(std::string());
  2350:                     param_name_stream__ << "z" << '.' << k_0__ << '.' << k_1__ << '.' << k_2__;
  2351:                     param_names__.push_back(param_name_stream__.str());
  2352:                 }
  2353:             }
  2354:         }
  2355:         for (int k_2__ = 1; k_2__ <= G; ++k_2__) {
  2356:             for (int k_1__ = 1; k_1__ <= Q; ++k_1__) {
  2357:                 for (int k_0__ = 1; k_0__ <= T; ++k_0__) {
  2358:                     param_name_stream__.str(std::string());
  2359:                     param_name_stream__ << "prob" << '.' << k_0__ << '.' << k_1__ << '.' << k_2__;
  2360:                     param_names__.push_back(param_name_stream__.str());
  2361:                 }
  2362:             }
  2363:         }
  2364: 
  2365:         if (!include_gqs__) return;
  2366:         for (int k_0__ = 1; k_0__ <= T; ++k_0__) {
  2367:             param_name_stream__.str(std::string());
  2368:             param_name_stream__ << "sd_total" << '.' << k_0__;
  2369:             param_names__.push_back(param_name_stream__.str());
  2370:         }
  2371:     }
  2372: 
  2373: }; // model
  2374: 
  2375: }
  2376: 
  2377: typedef model439319d3ba2_2017_01_04_namespace::model439319d3ba2_2017_01_04 stan_model;
  2378: 
  2379: #include <rstan/rstaninc.hpp>
  2380: /**
  2381:  * Define Rcpp Module to expose stan_fit's functions to R.
  2382:  */
  2383: RCPP_MODULE(stan_fit4model439319d3ba2_2017_01_04_mod){
  2384:   Rcpp::class_<rstan::stan_fit<model439319d3ba2_2017_01_04_namespace::model439319d3ba2_2017_01_04,
  2385:                boost::random::ecuyer1988> >("stan_fit4model439319d3ba2_2017_01_04")
  2386:     // .constructor<Rcpp::List>()
  2387:     .constructor<SEXP, SEXP, SEXP>()
  2388:     // .constructor<SEXP, SEXP>()
  2389:     .method("call_sampler",
  2390:             &rstan::stan_fit<model439319d3ba2_2017_01_04_namespace::model439319d3ba2_2017_01_04, boost::random::ecuyer1988>::call_sampler)
  2391:     .method("param_names",
  2392:             &rstan::stan_fit<model439319d3ba2_2017_01_04_namespace::model439319d3ba2_2017_01_04, boost::random::ecuyer1988>::param_names)
  2393:     .method("param_names_oi",
  2394:             &rstan::stan_fit<model439319d3ba2_2017_01_04_namespace::model439319d3ba2_2017_01_04, boost::random::ecuyer1988>::param_names_oi)
  2395:     .method("param_fnames_oi",
  2396:             &rstan::stan_fit<model439319d3ba2_2017_01_04_namespace::model439319d3ba2_2017_01_04, boost::random::ecuyer1988>::param_fnames_oi)
  2397:     .method("param_dims",
  2398:             &rstan::stan_fit<model439319d3ba2_2017_01_04_namespace::model439319d3ba2_2017_01_04, boost::random::ecuyer1988>::param_dims)
  2399:     .method("param_dims_oi",
  2400:             &rstan::stan_fit<model439319d3ba2_2017_01_04_namespace::model439319d3ba2_2017_01_04, boost::random::ecuyer1988>::param_dims_oi)
  2401:     .method("update_param_oi",
  2402:             &rstan::stan_fit<model439319d3ba2_2017_01_04_namespace::model439319d3ba2_2017_01_04, boost::random::ecuyer1988>::update_param_oi)
  2403:     .method("param_oi_tidx",
  2404:             &rstan::stan_fit<model439319d3ba2_2017_01_04_namespace::model439319d3ba2_2017_01_04, boost::random::ecuyer1988>::param_oi_tidx)
  2405:     .method("grad_log_prob",
  2406:             &rstan::stan_fit<model439319d3ba2_2017_01_04_namespace::model439319d3ba2_2017_01_04, boost::random::ecuyer1988>::grad_log_prob)
  2407:     .method("log_prob",
  2408:             &rstan::stan_fit<model439319d3ba2_2017_01_04_namespace::model439319d3ba2_2017_01_04, boost::random::ecuyer1988>::log_prob)
  2409:     .method("unconstrain_pars",
  2410:             &rstan::stan_fit<model439319d3ba2_2017_01_04_namespace::model439319d3ba2_2017_01_04, boost::random::ecuyer1988>::unconstrain_pars)
  2411:     .method("constrain_pars",
  2412:             &rstan::stan_fit<model439319d3ba2_2017_01_04_namespace::model439319d3ba2_2017_01_04, boost::random::ecuyer1988>::constrain_pars)
  2413:     .method("num_pars_unconstrained",
  2414:             &rstan::stan_fit<model439319d3ba2_2017_01_04_namespace::model439319d3ba2_2017_01_04, boost::random::ecuyer1988>::num_pars_unconstrained)
  2415:     .method("unconstrained_param_names",
  2416:             &rstan::stan_fit<model439319d3ba2_2017_01_04_namespace::model439319d3ba2_2017_01_04, boost::random::ecuyer1988>::unconstrained_param_names)
  2417:     .method("constrained_param_names",
  2418:             &rstan::stan_fit<model439319d3ba2_2017_01_04_namespace::model439319d3ba2_2017_01_04, boost::random::ecuyer1988>::constrained_param_names)
  2419:     ;
  2420: }
  2421: 
  2422: // declarations
  2423: extern "C" {
  2424: SEXP file439375b94caa( ) ;
  2425: }
  2426: 
  2427: // definition
  2428: 
  2429: SEXP file439375b94caa(  ){
  2430:  return Rcpp::wrap("2017_01_04");
  2431: }
  2432: 
  2433: 
  ── 1. Error: (unknown) (@test-dgirt.r#1)  ──────────────────────────────────────
  Compilation ERROR, function(s)/method(s) not created! In file included from /tmp/RtmpgFaap4/RLIBS_7078477768c2/BH/include/boost/config.hpp:39:0,
                   from /tmp/RtmpgFaap4/RLIBS_7078477768c2/BH/include/boost/math/tools/config.hpp:13,
                   from /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/core/var.hpp:7,
                   from /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/core/gevv_vvv_vari.hpp:5,
                   from /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/core.hpp:12,
                   from /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat.hpp:4,
                   from /home/ripley/R/Lib32/StanHeaders/include/stan/math.hpp:4,
                   from /home/ripley/R/Lib32/StanHeaders/include/src/stan/model/model_header.hpp:4,
                   from file439375b94caa.cpp:8:
  /tmp/RtmpgFaap4/RLIBS_7078477768c2/BH/include/boost/config/compiler/gcc.hpp:186:0: warning: "BOOST_NO_CXX11_RVALUE_REFERENCES" redefined
   #  define BOOST_NO_CXX11_RVALUE_REFERENCES
   ^
  <command-line>:0:0: note: this is the location of the previous definition
  In file included from /usr/include/sys/ucontext.h:20:0,
                   from /usr/include/sys/signal.h:231,
                   from /usr/include/sys/procset.h:23,
                   from /usr/include/sys/wait.h:25,
                   from /usr/include/stdlib.h:21,
                   from /opt/csw/include/c++/5.2.0/cstdlib:72,
                   from /home/ripley/R/Lib32/StanHeaders/include/stan/math/memory/stack_alloc.hpp:8,
                   from /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/core/autodiffstackstorage.hpp:4,
                   from /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/core.hpp:4,
                   from /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat.hpp:4,
                   from /home/ripley/R/Lib32/StanHeaders/include/stan/math.hpp:4,
                   from /home/ripley/R/Lib32/StanHeaders/include/src/stan/model/model_header.hpp:4,
                   from file439375b94caa.cpp:8:
  /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat/functor/algebra_system.hpp:97:24: error: expected nested-name-specifier before numeric constant
       template <typename FS, typename F, typename T0, typename T1>
                          ^
  /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat/functor/algebra_system.hpp:97:24: error: expected ‘>’ before numeric constant
  /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat/functor/algebra_system.hpp:100:7: error: expected unqualified-id before numeric constant
         FS fs_;
         ^
  In file included from /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat/functor/algebra_solver.hpp:4:0,
                   from /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat.hpp:55,
                   from /home/ripley/R/Lib32/StanHeaders/include/stan/math.hpp:4,
                   from /home/ripley/R/Lib32/StanHeaders/include/src/stan/model/model_header.hpp:4,
                   from file439375b94caa.cpp:8:
  /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat/functor/algebra_system.hpp:106:28: error: ISO C++ forbids declaration of ‘parameter’ with no type [-fpermissive]
         hybrj_functor_solver(const FS& fs,
                              ^
  In file included from /usr/include/sys/ucontext.h:20:0,
                   from /usr/include/sys/signal.h:231,
                   from /usr/include/sys/procset.h:23,
                   from /usr/include/sys/wait.h:25,
                   from /usr/include/stdlib.h:21,
                   from /opt/csw/include/c++/5.2.0/cstdlib:72,
                   from /home/ripley/R/Lib32/StanHeaders/include/stan/math/memory/stack_alloc.hpp:8,
                   from /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/core/autodiffstackstorage.hpp:4,
                   from /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/core.hpp:4,
                   from /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat.hpp:4,
                   from /home/ripley/R/Lib32/StanHeaders/include/stan/math.hpp:4,
                   from /home/ripley/R/Lib32/StanHeaders/include/src/stan/model/model_header.hpp:4,
                   from file439375b94caa.cpp:8:
  /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat/functor/algebra_system.hpp:106:34: error: expected ‘,’ or ‘...’ before numeric constant
         hybrj_functor_solver(const FS& fs,
                                    ^
  In file included from /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat/functor/algebra_solver.hpp:4:0,
                   from /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat.hpp:55,
                   from /home/ripley/R/Lib32/StanHeaders/include/stan/math.hpp:4,
                   from /home/ripley/R/Lib32/StanHeaders/include/src/stan/model/model_header.hpp:4,
                   from file439375b94caa.cpp:8:
  /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat/functor/algebra_system.hpp: In constructor ‘stan::math::hybrj_functor_solver<<anonymous> >::hybrj_functor_solver(int)’:
  /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat/functor/algebra_system.hpp:113:11: error: class ‘stan::math::hybrj_functor_solver<<anonymous> >’ does not have any field named ‘fs_’
           : fs_(f, x, y, dat, dat_int, msgs),
             ^
  /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat/functor/algebra_system.hpp:113:15: error: ‘f’ was not declared in this scope
           : fs_(f, x, y, dat, dat_int, msgs),
                 ^
  /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat/functor/algebra_system.hpp:113:18: error: ‘x’ was not declared in this scope
           : fs_(f, x, y, dat, dat_int, msgs),
                    ^
  /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat/functor/algebra_system.hpp:113:21: error: ‘y’ was not declared in this scope
           : fs_(f, x, y, dat, dat_int, msgs),
                       ^
  /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat/functor/algebra_system.hpp:113:24: error: ‘dat’ was not declared in this scope
           : fs_(f, x, y, dat, dat_int, msgs),
                          ^
  /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat/functor/algebra_system.hpp:113:29: error: ‘dat_int’ was not declared in this scope
           : fs_(f, x, y, dat, dat_int, msgs),
                               ^
  /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat/functor/algebra_system.hpp:113:38: error: ‘msgs’ was not declared in this scope
           : fs_(f, x, y, dat, dat_int, msgs),
                                        ^
  /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat/functor/algebra_system.hpp: In member function ‘int stan::math::hybrj_functor_solver<<anonymous> >::operator()(const VectorXd&, Eigen::VectorXd&)’:
  /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat/functor/algebra_system.hpp:124:18: error: ‘fs_’ was not declared in this scope
           jacobian(fs_, iv, fvec, J_);
                    ^
  /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat/functor/algebra_system.hpp: In member function ‘Eigen::MatrixXd stan::math::hybrj_functor_solver<<anonymous> >::get_jacobian(const VectorXd&)’:
  /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat/functor/algebra_system.hpp:147:18: error: ‘fs_’ was not declared in this scope
           jacobian(fs_, iv, fvec, J_);
                    ^
  /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat/functor/algebra_system.hpp: In member function ‘Eigen::VectorXd stan::math::hybrj_functor_solver<<anonymous> >::get_value(const VectorXd&) const’:
  /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat/functor/algebra_system.hpp:158:22: error: there are no arguments to ‘fs_’ that depend on a template parameter, so a declaration of ‘fs_’ must be available [-fpermissive]
           return fs_(iv);
                        ^
  /home/ripley/R/Lib32/StanHeaders/include/stan/math/rev/mat/functor/algebra_system.hpp:158:22: note: (if you use ‘-fpermissive’, G++ will accept your code, but allowing the use of an undeclared name is deprecated)
  In file included from /usr/include/sys/ucontext.h:20:0,
                   from /usr/i
  1: suppressWarnings(dgirt(toy_dgirt_in, iter = 1, chains = 1)) at testthat/test-dgirt.r:1
  2: withCallingHandlers(expr, warning = function(w) invokeRestart("muffleWarning"))
  3: dgirt(toy_dgirt_in, iter = 1, chains = 1)
  4: fit_dgo_model(model_output = "dgirt_fit", shaped_data = shaped_data, ..., separate_t = separate_t, 
         delta_tbar_prior_mean = delta_tbar_prior_mean, delta_tbar_prior_sd = delta_tbar_prior_sd, 
         innov_sd_delta_scale = delta_tbar_prior_sd, innov_sd_theta_scale = innov_sd_theta_scale, 
         version = version, hierarchical_model = hierarchical_model, model = model)
  5: rstan::stan_model(stanc_ret = stanc_ret)
  6: cxxfunctionplus(signature(), body = paste(" return Rcpp::wrap(\"", model_name, "\");", 
         sep = ""), includes = inc, plugin = "rstan", save_dso = save_dso | auto_write, 
         module_name = paste("stan_fit4", model_cppname, "_mod", sep = ""), verbose = verbose)
  7: cxxfunction(sig = sig, body = body, plugin = plugin, includes = includes, settings = settings, 
         ..., verbose = verbose)
  8: compileCode(f, code, language = language, verbose = verbose)
  9: stop(paste("Compilation ERROR, function(s)/method(s) not created!", paste(errmsg, 
         collapse = "\n")))
  
  ══ testthat results  ═══════════════════════════════════════════════════════════
  OK: 373 SKIPPED: 1 FAILED: 1
  1. Error: (unknown) (@test-dgirt.r#1) 
  
  Error: testthat unit tests failed
  Execution halted