#ifndef MODELS_HPP
#define MODELS_HPP
#define STAN__SERVICES__COMMAND_HPP
#include <rstan/rstaninc.hpp>
#ifndef USE_STANC3
#define USE_STANC3
#endif
// Code generated by stanc v2.26.1-1-g67504470
#include <stan/model/model_header.hpp>
namespace model127c37207abc__namespace {
inline void validate_positive_index(const char* var_name, const char* expr,
                                    int val) {
  if (val < 1) {
    std::stringstream msg;
    msg << "Found dimension size less than one in simplex declaration"
        << "; variable=" << var_name << "; dimension size expression=" << expr
        << "; expression value=" << val;
    std::string msg_str(msg.str());
    throw std::invalid_argument(msg_str.c_str());
  }
}
inline void validate_unit_vector_index(const char* var_name, const char* expr,
                                       int val) {
  if (val <= 1) {
    std::stringstream msg;
    if (val == 1) {
      msg << "Found dimension size one in unit vector declaration."
          << " One-dimensional unit vector is discrete"
          << " but the target distribution must be continuous."
          << " variable=" << var_name << "; dimension size expression=" << expr;
    } else {
      msg << "Found dimension size less than one in unit vector declaration"
          << "; variable=" << var_name << "; dimension size expression=" << expr
          << "; expression value=" << val;
    }
    std::string msg_str(msg.str());
    throw std::invalid_argument(msg_str.c_str());
  }
}
using std::istream;
using std::string;
using std::stringstream;
using std::vector;
using std::pow;
using stan::io::dump;
using stan::math::lgamma;
using stan::model::model_base_crtp;
using stan::model::rvalue;
using stan::model::cons_list;
using stan::model::index_uni;
using stan::model::index_max;
using stan::model::index_min;
using stan::model::index_min_max;
using stan::model::index_multi;
using stan::model::index_omni;
using stan::model::nil_index_list;
using namespace stan::math;
using stan::math::pow; 
stan::math::profile_map profiles__;
static int current_statement__= 0;
static const std::vector<string> locations_array__ = {" (found before start of program)",
                                                      " (in 'string', line 46, column 2 to column 15)",
                                                      " (in 'string', line 47, column 2 to column 17)",
                                                      " (in 'string', line 48, column 2 to column 16)",
                                                      " (in 'string', line 51, column 2 to column 28)",
                                                      " (in 'string', line 52, column 2 to column 24)",
                                                      " (in 'string', line 55, column 2 to column 28)",
                                                      " (in 'string', line 56, column 2 to column 24)",
                                                      " (in 'string', line 57, column 2 to column 28)",
                                                      " (in 'string', line 58, column 2 to column 23)",
                                                      " (in 'string', line 59, column 2 to column 28)",
                                                      " (in 'string', line 60, column 2 to column 23)",
                                                      " (in 'string', line 64, column 2 to column 27)",
                                                      " (in 'string', line 66, column 2 to column 27)",
                                                      " (in 'string', line 67, column 2 to column 20)",
                                                      " (in 'string', line 68, column 2 to column 20)",
                                                      " (in 'string', line 69, column 2 to column 18)",
                                                      " (in 'string', line 71, column 2 to column 27)",
                                                      " (in 'string', line 73, column 2 to column 27)",
                                                      " (in 'string', line 74, column 2 to column 31)",
                                                      " (in 'string', line 75, column 2 to column 31)",
                                                      " (in 'string', line 76, column 2 to column 35)",
                                                      " (in 'string', line 77, column 2 to column 44)",
                                                      " (in 'string', line 78, column 2 to column 36)",
                                                      " (in 'string', line 79, column 2 to line 80, column 41)",
                                                      " (in 'string', line 81, column 2 to line 82, column 41)",
                                                      " (in 'string', line 83, column 2 to line 84, column 41)",
                                                      " (in 'string', line 85, column 2 to line 86, column 41)",
                                                      " (in 'string', line 108, column 2 to column 57)",
                                                      " (in 'string', line 92, column 11 to column 12)",
                                                      " (in 'string', line 92, column 4 to column 94)",
                                                      " (in 'string', line 95, column 6 to column 67)",
                                                      " (in 'string', line 93, column 19 to line 96, column 5)",
                                                      " (in 'string', line 93, column 4 to line 96, column 5)",
                                                      " (in 'string', line 97, column 4 to column 54)",
                                                      " (in 'string', line 90, column 19 to line 98, column 3)",
                                                      " (in 'string', line 90, column 2 to line 98, column 3)",
                                                      " (in 'string', line 100, column 2 to column 19)",
                                                      " (in 'string', line 101, column 2 to column 36)",
                                                      " (in 'string', line 102, column 2 to column 36)",
                                                      " (in 'string', line 103, column 2 to column 36)",
                                                      " (in 'string', line 104, column 2 to column 36)",
                                                      " (in 'string', line 5, column 2 to column 17)",
                                                      " (in 'string', line 6, column 8 to column 9)",
                                                      " (in 'string', line 6, column 2 to column 11)",
                                                      " (in 'string', line 7, column 2 to column 17)",
                                                      " (in 'string', line 8, column 9 to column 10)",
                                                      " (in 'string', line 8, column 12 to column 13)",
                                                      " (in 'string', line 8, column 2 to column 17)",
                                                      " (in 'string', line 10, column 2 to column 9)",
                                                      " (in 'string', line 11, column 9 to column 10)",
                                                      " (in 'string', line 11, column 12 to column 14)",
                                                      " (in 'string', line 11, column 2 to column 19)",
                                                      " (in 'string', line 13, column 2 to column 11)",
                                                      " (in 'string', line 14, column 14 to column 18)",
                                                      " (in 'string', line 14, column 2 to column 20)",
                                                      " (in 'string', line 16, column 9 to column 10)",
                                                      " (in 'string', line 16, column 12 to column 22)",
                                                      " (in 'string', line 16, column 2 to column 31)",
                                                      " (in 'string', line 18, column 2 to column 11)",
                                                      " (in 'string', line 19, column 14 to column 18)",
                                                      " (in 'string', line 19, column 2 to column 20)",
                                                      " (in 'string', line 21, column 9 to column 10)",
                                                      " (in 'string', line 21, column 12 to column 22)",
                                                      " (in 'string', line 21, column 2 to column 31)",
                                                      " (in 'string', line 23, column 2 to column 19)",
                                                      " (in 'string', line 24, column 2 to column 19)",
                                                      " (in 'string', line 25, column 19 to column 20)",
                                                      " (in 'string', line 25, column 2 to column 22)",
                                                      " (in 'string', line 27, column 9 to column 10)",
                                                      " (in 'string', line 27, column 2 to column 18)",
                                                      " (in 'string', line 29, column 2 to column 19)",
                                                      " (in 'string', line 30, column 2 to column 19)",
                                                      " (in 'string', line 31, column 19 to column 20)",
                                                      " (in 'string', line 31, column 2 to column 22)",
                                                      " (in 'string', line 33, column 9 to column 10)",
                                                      " (in 'string', line 33, column 2 to column 18)",
                                                      " (in 'string', line 34, column 2 to column 17)",
                                                      " (in 'string', line 37, column 2 to column 17)",
                                                      " (in 'string', line 38, column 9 to column 10)",
                                                      " (in 'string', line 38, column 12 to column 14)",
                                                      " (in 'string', line 38, column 2 to column 19)",
                                                      " (in 'string', line 39, column 9 to column 11)",
                                                      " (in 'string', line 39, column 2 to column 21)",
                                                      " (in 'string', line 41, column 4 to column 34)",
                                                      " (in 'string', line 42, column 4 to column 42)",
                                                      " (in 'string', line 40, column 17 to line 43, column 3)",
                                                      " (in 'string', line 40, column 2 to line 43, column 3)",
                                                      " (in 'string', line 46, column 9 to column 11)",
                                                      " (in 'string', line 48, column 9 to column 11)",
                                                      " (in 'string', line 51, column 9 to column 19)",
                                                      " (in 'string', line 55, column 9 to column 19)",
                                                      " (in 'string', line 57, column 18 to column 21)",
                                                      " (in 'string', line 58, column 18 to column 21)",
                                                      " (in 'string', line 58, column 9 to column 12)",
                                                      " (in 'string', line 59, column 18 to column 21)",
                                                      " (in 'string', line 60, column 18 to column 21)",
                                                      " (in 'string', line 60, column 9 to column 12)",
                                                      " (in 'string', line 64, column 9 to column 19)",
                                                      " (in 'string', line 66, column 9 to column 19)",
                                                      " (in 'string', line 67, column 9 to column 12)",
                                                      " (in 'string', line 68, column 9 to column 12)"};
class model127c37207abc_ final : public model_base_crtp<model127c37207abc_> {
private:
  int N;
  std::vector<int> Y;
  int K;
  Eigen::Matrix<double, -1, -1> X;
  int Ks;
  Eigen::Matrix<double, -1, -1> Xs;
  int nb_1;
  std::vector<int> knots_1;
  Eigen::Matrix<double, -1, -1> Zs_1_1;
  int nb_2;
  std::vector<int> knots_2;
  Eigen::Matrix<double, -1, -1> Zs_2_1;
  int N_1;
  int M_1;
  std::vector<int> J_1;
  Eigen::Matrix<double, -1, 1> Z_1_1;
  int N_2;
  int M_2;
  std::vector<int> J_2;
  Eigen::Matrix<double, -1, 1> Z_2_1;
  int prior_only;
  int Kc;
  Eigen::Matrix<double, -1, -1> Xc;
  Eigen::Matrix<double, -1, 1> means_X;
  int zs_1_1_1dim__;
  int zs_2_1_1dim__;
  int s_1_1_1dim__;
  int s_2_1_1dim__;
 
public:
  ~model127c37207abc_() { }
  
  inline std::string model_name() const final { return "model127c37207abc_"; }
  inline std::vector<std::string> model_compile_info() const noexcept {
    return std::vector<std::string>{"stanc_version = stanc3 v2.26.1-1-g67504470", "stancflags = "};
  }
  
  
  model127c37207abc_(stan::io::var_context& context__,
                     unsigned int random_seed__ = 0,
                     std::ostream* pstream__ = nullptr) : model_base_crtp(0) {
    using local_scalar_t__ = double ;
    boost::ecuyer1988 base_rng__ = 
        stan::services::util::create_rng(random_seed__, 0);
    (void) base_rng__;  // suppress unused var warning
    static const char* function__ = "model127c37207abc__namespace::model127c37207abc_";
    (void) function__;  // suppress unused var warning
    local_scalar_t__ DUMMY_VAR__(std::numeric_limits<double>::quiet_NaN());
    (void) DUMMY_VAR__;  // suppress unused var warning
    
    try {
      int pos__;
      pos__ = std::numeric_limits<int>::min();
      
      pos__ = 1;
      current_statement__ = 42;
      context__.validate_dims("data initialization","N","int",
          context__.to_vec());
      N = std::numeric_limits<int>::min();
      
      current_statement__ = 42;
      N = context__.vals_i("N")[(1 - 1)];
      current_statement__ = 42;
      current_statement__ = 42;
      check_greater_or_equal(function__, "N", N, 1);
      current_statement__ = 43;
      validate_non_negative_index("Y", "N", N);
      current_statement__ = 44;
      context__.validate_dims("data initialization","Y","int",
          context__.to_vec(N));
      Y = std::vector<int>(N, std::numeric_limits<int>::min());
      
      current_statement__ = 44;
      assign(Y, nil_index_list(), context__.vals_i("Y"),
        "assigning variable Y");
      current_statement__ = 45;
      context__.validate_dims("data initialization","K","int",
          context__.to_vec());
      K = std::numeric_limits<int>::min();
      
      current_statement__ = 45;
      K = context__.vals_i("K")[(1 - 1)];
      current_statement__ = 45;
      current_statement__ = 45;
      check_greater_or_equal(function__, "K", K, 1);
      current_statement__ = 46;
      validate_non_negative_index("X", "N", N);
      current_statement__ = 47;
      validate_non_negative_index("X", "K", K);
      current_statement__ = 48;
      context__.validate_dims("data initialization","X","double",
          context__.to_vec(N, K));
      X = Eigen::Matrix<double, -1, -1>(N, K);
      stan::math::fill(X, std::numeric_limits<double>::quiet_NaN());
      
      {
        std::vector<local_scalar_t__> X_flat__;
        current_statement__ = 48;
        assign(X_flat__, nil_index_list(), context__.vals_r("X"),
          "assigning variable X_flat__");
        current_statement__ = 48;
        pos__ = 1;
        current_statement__ = 48;
        for (int sym1__ = 1; sym1__ <= K; ++sym1__) {
          current_statement__ = 48;
          for (int sym2__ = 1; sym2__ <= N; ++sym2__) {
            current_statement__ = 48;
            assign(X,
              cons_list(index_uni(sym2__),
                cons_list(index_uni(sym1__), nil_index_list())),
              X_flat__[(pos__ - 1)], "assigning variable X");
            current_statement__ = 48;
            pos__ = (pos__ + 1);}}
      }
      current_statement__ = 49;
      context__.validate_dims("data initialization","Ks","int",
          context__.to_vec());
      Ks = std::numeric_limits<int>::min();
      
      current_statement__ = 49;
      Ks = context__.vals_i("Ks")[(1 - 1)];
      current_statement__ = 50;
      validate_non_negative_index("Xs", "N", N);
      current_statement__ = 51;
      validate_non_negative_index("Xs", "Ks", Ks);
      current_statement__ = 52;
      context__.validate_dims("data initialization","Xs","double",
          context__.to_vec(N, Ks));
      Xs = Eigen::Matrix<double, -1, -1>(N, Ks);
      stan::math::fill(Xs, std::numeric_limits<double>::quiet_NaN());
      
      {
        std::vector<local_scalar_t__> Xs_flat__;
        current_statement__ = 52;
        assign(Xs_flat__, nil_index_list(), context__.vals_r("Xs"),
          "assigning variable Xs_flat__");
        current_statement__ = 52;
        pos__ = 1;
        current_statement__ = 52;
        for (int sym1__ = 1; sym1__ <= Ks; ++sym1__) {
          current_statement__ = 52;
          for (int sym2__ = 1; sym2__ <= N; ++sym2__) {
            current_statement__ = 52;
            assign(Xs,
              cons_list(index_uni(sym2__),
                cons_list(index_uni(sym1__), nil_index_list())),
              Xs_flat__[(pos__ - 1)], "assigning variable Xs");
            current_statement__ = 52;
            pos__ = (pos__ + 1);}}
      }
      current_statement__ = 53;
      context__.validate_dims("data initialization","nb_1","int",
          context__.to_vec());
      nb_1 = std::numeric_limits<int>::min();
      
      current_statement__ = 53;
      nb_1 = context__.vals_i("nb_1")[(1 - 1)];
      current_statement__ = 54;
      validate_non_negative_index("knots_1", "nb_1", nb_1);
      current_statement__ = 55;
      context__.validate_dims("data initialization","knots_1","int",
          context__.to_vec(nb_1));
      knots_1 = std::vector<int>(nb_1, std::numeric_limits<int>::min());
      
      current_statement__ = 55;
      assign(knots_1, nil_index_list(), context__.vals_i("knots_1"),
        "assigning variable knots_1");
      current_statement__ = 56;
      validate_non_negative_index("Zs_1_1", "N", N);
      current_statement__ = 57;
      validate_non_negative_index("Zs_1_1", "knots_1[1]", knots_1[(1 - 1)]);
      current_statement__ = 58;
      context__.validate_dims("data initialization","Zs_1_1","double",
          context__.to_vec(N, knots_1[(1 - 1)]));
      Zs_1_1 = Eigen::Matrix<double, -1, -1>(N, knots_1[(1 - 1)]);
      stan::math::fill(Zs_1_1, std::numeric_limits<double>::quiet_NaN());
      
      {
        std::vector<local_scalar_t__> Zs_1_1_flat__;
        current_statement__ = 58;
        assign(Zs_1_1_flat__, nil_index_list(), context__.vals_r("Zs_1_1"),
          "assigning variable Zs_1_1_flat__");
        current_statement__ = 58;
        pos__ = 1;
        current_statement__ = 58;
        for (int sym1__ = 1; sym1__ <= knots_1[(1 - 1)]; ++sym1__) {
          current_statement__ = 58;
          for (int sym2__ = 1; sym2__ <= N; ++sym2__) {
            current_statement__ = 58;
            assign(Zs_1_1,
              cons_list(index_uni(sym2__),
                cons_list(index_uni(sym1__), nil_index_list())),
              Zs_1_1_flat__[(pos__ - 1)], "assigning variable Zs_1_1");
            current_statement__ = 58;
            pos__ = (pos__ + 1);}}
      }
      current_statement__ = 59;
      context__.validate_dims("data initialization","nb_2","int",
          context__.to_vec());
      nb_2 = std::numeric_limits<int>::min();
      
      current_statement__ = 59;
      nb_2 = context__.vals_i("nb_2")[(1 - 1)];
      current_statement__ = 60;
      validate_non_negative_index("knots_2", "nb_2", nb_2);
      current_statement__ = 61;
      context__.validate_dims("data initialization","knots_2","int",
          context__.to_vec(nb_2));
      knots_2 = std::vector<int>(nb_2, std::numeric_limits<int>::min());
      
      current_statement__ = 61;
      assign(knots_2, nil_index_list(), context__.vals_i("knots_2"),
        "assigning variable knots_2");
      current_statement__ = 62;
      validate_non_negative_index("Zs_2_1", "N", N);
      current_statement__ = 63;
      validate_non_negative_index("Zs_2_1", "knots_2[1]", knots_2[(1 - 1)]);
      current_statement__ = 64;
      context__.validate_dims("data initialization","Zs_2_1","double",
          context__.to_vec(N, knots_2[(1 - 1)]));
      Zs_2_1 = Eigen::Matrix<double, -1, -1>(N, knots_2[(1 - 1)]);
      stan::math::fill(Zs_2_1, std::numeric_limits<double>::quiet_NaN());
      
      {
        std::vector<local_scalar_t__> Zs_2_1_flat__;
        current_statement__ = 64;
        assign(Zs_2_1_flat__, nil_index_list(), context__.vals_r("Zs_2_1"),
          "assigning variable Zs_2_1_flat__");
        current_statement__ = 64;
        pos__ = 1;
        current_statement__ = 64;
        for (int sym1__ = 1; sym1__ <= knots_2[(1 - 1)]; ++sym1__) {
          current_statement__ = 64;
          for (int sym2__ = 1; sym2__ <= N; ++sym2__) {
            current_statement__ = 64;
            assign(Zs_2_1,
              cons_list(index_uni(sym2__),
                cons_list(index_uni(sym1__), nil_index_list())),
              Zs_2_1_flat__[(pos__ - 1)], "assigning variable Zs_2_1");
            current_statement__ = 64;
            pos__ = (pos__ + 1);}}
      }
      current_statement__ = 65;
      context__.validate_dims("data initialization","N_1","int",
          context__.to_vec());
      N_1 = std::numeric_limits<int>::min();
      
      current_statement__ = 65;
      N_1 = context__.vals_i("N_1")[(1 - 1)];
      current_statement__ = 65;
      current_statement__ = 65;
      check_greater_or_equal(function__, "N_1", N_1, 1);
      current_statement__ = 66;
      context__.validate_dims("data initialization","M_1","int",
          context__.to_vec());
      M_1 = std::numeric_limits<int>::min();
      
      current_statement__ = 66;
      M_1 = context__.vals_i("M_1")[(1 - 1)];
      current_statement__ = 66;
      current_statement__ = 66;
      check_greater_or_equal(function__, "M_1", M_1, 1);
      current_statement__ = 67;
      validate_non_negative_index("J_1", "N", N);
      current_statement__ = 68;
      context__.validate_dims("data initialization","J_1","int",
          context__.to_vec(N));
      J_1 = std::vector<int>(N, std::numeric_limits<int>::min());
      
      current_statement__ = 68;
      assign(J_1, nil_index_list(), context__.vals_i("J_1"),
        "assigning variable J_1");
      current_statement__ = 68;
      for (int sym1__ = 1; sym1__ <= N; ++sym1__) {
        current_statement__ = 68;
        current_statement__ = 68;
        check_greater_or_equal(function__, "J_1[sym1__]", J_1[(sym1__ - 1)],
                               1);}
      current_statement__ = 69;
      validate_non_negative_index("Z_1_1", "N", N);
      current_statement__ = 70;
      context__.validate_dims("data initialization","Z_1_1","double",
          context__.to_vec(N));
      Z_1_1 = Eigen::Matrix<double, -1, 1>(N);
      stan::math::fill(Z_1_1, std::numeric_limits<double>::quiet_NaN());
      
      {
        std::vector<local_scalar_t__> Z_1_1_flat__;
        current_statement__ = 70;
        assign(Z_1_1_flat__, nil_index_list(), context__.vals_r("Z_1_1"),
          "assigning variable Z_1_1_flat__");
        current_statement__ = 70;
        pos__ = 1;
        current_statement__ = 70;
        for (int sym1__ = 1; sym1__ <= N; ++sym1__) {
          current_statement__ = 70;
          assign(Z_1_1, cons_list(index_uni(sym1__), nil_index_list()),
            Z_1_1_flat__[(pos__ - 1)], "assigning variable Z_1_1");
          current_statement__ = 70;
          pos__ = (pos__ + 1);}
      }
      current_statement__ = 71;
      context__.validate_dims("data initialization","N_2","int",
          context__.to_vec());
      N_2 = std::numeric_limits<int>::min();
      
      current_statement__ = 71;
      N_2 = context__.vals_i("N_2")[(1 - 1)];
      current_statement__ = 71;
      current_statement__ = 71;
      check_greater_or_equal(function__, "N_2", N_2, 1);
      current_statement__ = 72;
      context__.validate_dims("data initialization","M_2","int",
          context__.to_vec());
      M_2 = std::numeric_limits<int>::min();
      
      current_statement__ = 72;
      M_2 = context__.vals_i("M_2")[(1 - 1)];
      current_statement__ = 72;
      current_statement__ = 72;
      check_greater_or_equal(function__, "M_2", M_2, 1);
      current_statement__ = 73;
      validate_non_negative_index("J_2", "N", N);
      current_statement__ = 74;
      context__.validate_dims("data initialization","J_2","int",
          context__.to_vec(N));
      J_2 = std::vector<int>(N, std::numeric_limits<int>::min());
      
      current_statement__ = 74;
      assign(J_2, nil_index_list(), context__.vals_i("J_2"),
        "assigning variable J_2");
      current_statement__ = 74;
      for (int sym1__ = 1; sym1__ <= N; ++sym1__) {
        current_statement__ = 74;
        current_statement__ = 74;
        check_greater_or_equal(function__, "J_2[sym1__]", J_2[(sym1__ - 1)],
                               1);}
      current_statement__ = 75;
      validate_non_negative_index("Z_2_1", "N", N);
      current_statement__ = 76;
      context__.validate_dims("data initialization","Z_2_1","double",
          context__.to_vec(N));
      Z_2_1 = Eigen::Matrix<double, -1, 1>(N);
      stan::math::fill(Z_2_1, std::numeric_limits<double>::quiet_NaN());
      
      {
        std::vector<local_scalar_t__> Z_2_1_flat__;
        current_statement__ = 76;
        assign(Z_2_1_flat__, nil_index_list(), context__.vals_r("Z_2_1"),
          "assigning variable Z_2_1_flat__");
        current_statement__ = 76;
        pos__ = 1;
        current_statement__ = 76;
        for (int sym1__ = 1; sym1__ <= N; ++sym1__) {
          current_statement__ = 76;
          assign(Z_2_1, cons_list(index_uni(sym1__), nil_index_list()),
            Z_2_1_flat__[(pos__ - 1)], "assigning variable Z_2_1");
          current_statement__ = 76;
          pos__ = (pos__ + 1);}
      }
      current_statement__ = 77;
      context__.validate_dims("data initialization","prior_only","int",
          context__.to_vec());
      prior_only = std::numeric_limits<int>::min();
      
      current_statement__ = 77;
      prior_only = context__.vals_i("prior_only")[(1 - 1)];
      current_statement__ = 78;
      Kc = std::numeric_limits<int>::min();
      
      current_statement__ = 78;
      Kc = (K - 1);
      current_statement__ = 79;
      validate_non_negative_index("Xc", "N", N);
      current_statement__ = 80;
      validate_non_negative_index("Xc", "Kc", Kc);
      current_statement__ = 81;
      Xc = Eigen::Matrix<double, -1, -1>(N, Kc);
      stan::math::fill(Xc, std::numeric_limits<double>::quiet_NaN());
      
      current_statement__ = 82;
      validate_non_negative_index("means_X", "Kc", Kc);
      current_statement__ = 83;
      means_X = Eigen::Matrix<double, -1, 1>(Kc);
      stan::math::fill(means_X, std::numeric_limits<double>::quiet_NaN());
      
      current_statement__ = 87;
      for (int i = 2; i <= K; ++i) {
        current_statement__ = 84;
        assign(means_X, cons_list(index_uni((i - 1)), nil_index_list()),
          mean(
            rvalue(X,
              cons_list(index_omni(),
                cons_list(index_uni(i), nil_index_list())), "X")),
          "assigning variable means_X");
        current_statement__ = 85;
        assign(Xc,
          cons_list(index_omni(),
            cons_list(index_uni((i - 1)), nil_index_list())),
          subtract(
            rvalue(X,
              cons_list(index_omni(),
                cons_list(index_uni(i), nil_index_list())), "X"),
            means_X[((i - 1) - 1)]), "assigning variable Xc");}
      current_statement__ = 88;
      validate_non_negative_index("b", "Kc", Kc);
      current_statement__ = 89;
      validate_non_negative_index("bs", "Ks", Ks);
      current_statement__ = 90;
      zs_1_1_1dim__ = std::numeric_limits<int>::min();
      
      current_statement__ = 90;
      zs_1_1_1dim__ = knots_1[(1 - 1)];
      current_statement__ = 90;
      validate_non_negative_index("zs_1_1", "knots_1[1]", zs_1_1_1dim__);
      current_statement__ = 91;
      zs_2_1_1dim__ = std::numeric_limits<int>::min();
      
      current_statement__ = 91;
      zs_2_1_1dim__ = knots_2[(1 - 1)];
      current_statement__ = 91;
      validate_non_negative_index("zs_2_1", "knots_2[1]", zs_2_1_1dim__);
      current_statement__ = 92;
      validate_non_negative_index("sd_1", "M_1", M_1);
      current_statement__ = 93;
      validate_non_negative_index("z_1", "M_1", M_1);
      current_statement__ = 94;
      validate_non_negative_index("z_1", "N_1", N_1);
      current_statement__ = 95;
      validate_non_negative_index("sd_2", "M_2", M_2);
      current_statement__ = 96;
      validate_non_negative_index("z_2", "M_2", M_2);
      current_statement__ = 97;
      validate_non_negative_index("z_2", "N_2", N_2);
      current_statement__ = 98;
      s_1_1_1dim__ = std::numeric_limits<int>::min();
      
      current_statement__ = 98;
      s_1_1_1dim__ = knots_1[(1 - 1)];
      current_statement__ = 98;
      validate_non_negative_index("s_1_1", "knots_1[1]", s_1_1_1dim__);
      current_statement__ = 99;
      s_2_1_1dim__ = std::numeric_limits<int>::min();
      
      current_statement__ = 99;
      s_2_1_1dim__ = knots_2[(1 - 1)];
      current_statement__ = 99;
      validate_non_negative_index("s_2_1", "knots_2[1]", s_2_1_1dim__);
      current_statement__ = 100;
      validate_non_negative_index("r_1_1", "N_1", N_1);
      current_statement__ = 101;
      validate_non_negative_index("r_2_1", "N_2", N_2);
    } catch (const std::exception& e) {
      stan::lang::rethrow_located(e, locations_array__[current_statement__]);
      // Next line prevents compiler griping about no return
      throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); 
    }
    num_params_r__ = 0U;
    
    try {
      num_params_r__ += Kc;
      num_params_r__ += 1;
      num_params_r__ += Ks;
      num_params_r__ += zs_1_1_1dim__;
      num_params_r__ += 1;
      num_params_r__ += zs_2_1_1dim__;
      num_params_r__ += 1;
      num_params_r__ += M_1;
      num_params_r__ += M_1 * N_1;
      num_params_r__ += M_2;
      num_params_r__ += M_2 * N_2;
    } catch (const std::exception& e) {
      stan::lang::rethrow_located(e, locations_array__[current_statement__]);
      // Next line prevents compiler griping about no return
      throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); 
    }
  }
  template <bool propto__, bool jacobian__, typename VecR, typename VecI, stan::require_vector_like_t<VecR>* = nullptr, stan::require_vector_like_vt<std::is_integral, VecI>* = nullptr>
  inline stan::scalar_type_t<VecR> log_prob_impl(VecR& params_r__,
                                                 VecI& params_i__,
                                                 std::ostream* pstream__ = nullptr) const {
    using T__ = stan::scalar_type_t<VecR>;
    using local_scalar_t__ = T__;
    T__ lp__(0.0);
    stan::math::accumulator<T__> lp_accum__;
    static const char* function__ = "model127c37207abc__namespace::log_prob";
(void) function__;  // suppress unused var warning
    stan::io::reader<local_scalar_t__> in__(params_r__, params_i__);
    local_scalar_t__ DUMMY_VAR__(std::numeric_limits<double>::quiet_NaN());
    (void) DUMMY_VAR__;  // suppress unused var warning
    
    try {
      Eigen::Matrix<local_scalar_t__, -1, 1> b;
      b = Eigen::Matrix<local_scalar_t__, -1, 1>(Kc);
      stan::math::fill(b, DUMMY_VAR__);
      
      current_statement__ = 1;
      b = in__.vector(Kc);
      local_scalar_t__ Intercept;
      Intercept = DUMMY_VAR__;
      
      current_statement__ = 2;
      Intercept = in__.scalar();
      Eigen::Matrix<local_scalar_t__, -1, 1> bs;
      bs = Eigen::Matrix<local_scalar_t__, -1, 1>(Ks);
      stan::math::fill(bs, DUMMY_VAR__);
      
      current_statement__ = 3;
      bs = in__.vector(Ks);
      Eigen::Matrix<local_scalar_t__, -1, 1> zs_1_1;
      zs_1_1 = Eigen::Matrix<local_scalar_t__, -1, 1>(zs_1_1_1dim__);
      stan::math::fill(zs_1_1, DUMMY_VAR__);
      
      current_statement__ = 4;
      zs_1_1 = in__.vector(zs_1_1_1dim__);
      local_scalar_t__ sds_1_1;
      sds_1_1 = DUMMY_VAR__;
      
      current_statement__ = 5;
      sds_1_1 = in__.scalar();
      current_statement__ = 5;
      if (jacobian__) {
        current_statement__ = 5;
        sds_1_1 = stan::math::lb_constrain(sds_1_1, 0, lp__);
      } else {
        current_statement__ = 5;
        sds_1_1 = stan::math::lb_constrain(sds_1_1, 0);
      }
      Eigen::Matrix<local_scalar_t__, -1, 1> zs_2_1;
      zs_2_1 = Eigen::Matrix<local_scalar_t__, -1, 1>(zs_2_1_1dim__);
      stan::math::fill(zs_2_1, DUMMY_VAR__);
      
      current_statement__ = 6;
      zs_2_1 = in__.vector(zs_2_1_1dim__);
      local_scalar_t__ sds_2_1;
      sds_2_1 = DUMMY_VAR__;
      
      current_statement__ = 7;
      sds_2_1 = in__.scalar();
      current_statement__ = 7;
      if (jacobian__) {
        current_statement__ = 7;
        sds_2_1 = stan::math::lb_constrain(sds_2_1, 0, lp__);
      } else {
        current_statement__ = 7;
        sds_2_1 = stan::math::lb_constrain(sds_2_1, 0);
      }
      Eigen::Matrix<local_scalar_t__, -1, 1> sd_1;
      sd_1 = Eigen::Matrix<local_scalar_t__, -1, 1>(M_1);
      stan::math::fill(sd_1, DUMMY_VAR__);
      
      current_statement__ = 8;
      sd_1 = in__.vector(M_1);
      current_statement__ = 8;
      for (int sym1__ = 1; sym1__ <= M_1; ++sym1__) {
        current_statement__ = 8;
        if (jacobian__) {
          current_statement__ = 8;
          assign(sd_1, cons_list(index_uni(sym1__), nil_index_list()),
            stan::math::lb_constrain(sd_1[(sym1__ - 1)], 0, lp__),
            "assigning variable sd_1");
        } else {
          current_statement__ = 8;
          assign(sd_1, cons_list(index_uni(sym1__), nil_index_list()),
            stan::math::lb_constrain(sd_1[(sym1__ - 1)], 0),
            "assigning variable sd_1");
        }}
      std::vector<Eigen::Matrix<local_scalar_t__, -1, 1>> z_1;
      z_1 = std::vector<Eigen::Matrix<local_scalar_t__, -1, 1>>(M_1, Eigen::Matrix<local_scalar_t__, -1, 1>(N_1));
      stan::math::fill(z_1, DUMMY_VAR__);
      
      current_statement__ = 9;
      for (int sym1__ = 1; sym1__ <= M_1; ++sym1__) {
        current_statement__ = 9;
        assign(z_1, cons_list(index_uni(sym1__), nil_index_list()),
          in__.vector(N_1), "assigning variable z_1");}
      Eigen::Matrix<local_scalar_t__, -1, 1> sd_2;
      sd_2 = Eigen::Matrix<local_scalar_t__, -1, 1>(M_2);
      stan::math::fill(sd_2, DUMMY_VAR__);
      
      current_statement__ = 10;
      sd_2 = in__.vector(M_2);
      current_statement__ = 10;
      for (int sym1__ = 1; sym1__ <= M_2; ++sym1__) {
        current_statement__ = 10;
        if (jacobian__) {
          current_statement__ = 10;
          assign(sd_2, cons_list(index_uni(sym1__), nil_index_list()),
            stan::math::lb_constrain(sd_2[(sym1__ - 1)], 0, lp__),
            "assigning variable sd_2");
        } else {
          current_statement__ = 10;
          assign(sd_2, cons_list(index_uni(sym1__), nil_index_list()),
            stan::math::lb_constrain(sd_2[(sym1__ - 1)], 0),
            "assigning variable sd_2");
        }}
      std::vector<Eigen::Matrix<local_scalar_t__, -1, 1>> z_2;
      z_2 = std::vector<Eigen::Matrix<local_scalar_t__, -1, 1>>(M_2, Eigen::Matrix<local_scalar_t__, -1, 1>(N_2));
      stan::math::fill(z_2, DUMMY_VAR__);
      
      current_statement__ = 11;
      for (int sym1__ = 1; sym1__ <= M_2; ++sym1__) {
        current_statement__ = 11;
        assign(z_2, cons_list(index_uni(sym1__), nil_index_list()),
          in__.vector(N_2), "assigning variable z_2");}
      Eigen::Matrix<local_scalar_t__, -1, 1> s_1_1;
      s_1_1 = Eigen::Matrix<local_scalar_t__, -1, 1>(s_1_1_1dim__);
      stan::math::fill(s_1_1, DUMMY_VAR__);
      
      Eigen::Matrix<local_scalar_t__, -1, 1> s_2_1;
      s_2_1 = Eigen::Matrix<local_scalar_t__, -1, 1>(s_2_1_1dim__);
      stan::math::fill(s_2_1, DUMMY_VAR__);
      
      Eigen::Matrix<local_scalar_t__, -1, 1> r_1_1;
      r_1_1 = Eigen::Matrix<local_scalar_t__, -1, 1>(N_1);
      stan::math::fill(r_1_1, DUMMY_VAR__);
      
      Eigen::Matrix<local_scalar_t__, -1, 1> r_2_1;
      r_2_1 = Eigen::Matrix<local_scalar_t__, -1, 1>(N_2);
      stan::math::fill(r_2_1, DUMMY_VAR__);
      
      local_scalar_t__ lprior;
      lprior = DUMMY_VAR__;
      
      current_statement__ = 16;
      lprior = 0;
      current_statement__ = 17;
      assign(s_1_1, nil_index_list(), multiply(sds_1_1, zs_1_1),
        "assigning variable s_1_1");
      current_statement__ = 18;
      assign(s_2_1, nil_index_list(), multiply(sds_2_1, zs_2_1),
        "assigning variable s_2_1");
      current_statement__ = 19;
      assign(r_1_1, nil_index_list(), multiply(sd_1[(1 - 1)], z_1[(1 - 1)]),
        "assigning variable r_1_1");
      current_statement__ = 20;
      assign(r_2_1, nil_index_list(), multiply(sd_2[(1 - 1)], z_2[(1 - 1)]),
        "assigning variable r_2_1");
      current_statement__ = 21;
      lprior = (lprior + normal_lpdf<false>(b, 0, 10));
      current_statement__ = 22;
      lprior = (lprior + logistic_lpdf<false>(Intercept, 0, 1));
      current_statement__ = 23;
      lprior = (lprior + normal_lpdf<false>(bs, 0, 10));
      current_statement__ = 24;
      lprior = (lprior +
                 (student_t_lpdf<false>(sds_1_1, 3, 0, 2.5) -
                   (1 * student_t_lccdf(0, 3, 0, 2.5))));
      current_statement__ = 25;
      lprior = (lprior +
                 (student_t_lpdf<false>(sds_2_1, 3, 0, 2.5) -
                   (1 * student_t_lccdf(0, 3, 0, 2.5))));
      current_statement__ = 26;
      lprior = (lprior +
                 (student_t_lpdf<false>(sd_1, 3, 0, 2.5) -
                   (1 * student_t_lccdf(0, 3, 0, 2.5))));
      current_statement__ = 27;
      lprior = (lprior +
                 (student_t_lpdf<false>(sd_2, 3, 0, 2.5) -
                   (1 * student_t_lccdf(0, 3, 0, 2.5))));
      {
        current_statement__ = 36;
        if (logical_negation(prior_only)) {
          current_statement__ = 29;
          validate_non_negative_index("mu", "N", N);
          Eigen::Matrix<local_scalar_t__, -1, 1> mu;
          mu = Eigen::Matrix<local_scalar_t__, -1, 1>(N);
          stan::math::fill(mu, DUMMY_VAR__);
          
          current_statement__ = 30;
          assign(mu, nil_index_list(),
            add(
              add(add(add(Intercept, rep_vector(0.0, N)), multiply(Xs, bs)),
                multiply(Zs_1_1, s_1_1)), multiply(Zs_2_1, s_2_1)),
            "assigning variable mu");
          current_statement__ = 33;
          for (int n = 1; n <= N; ++n) {
            current_statement__ = 31;
            assign(mu, cons_list(index_uni(n), nil_index_list()),
              (mu[(n - 1)] +
                ((r_1_1[(J_1[(n - 1)] - 1)] * Z_1_1[(n - 1)]) +
                  (r_2_1[(J_2[(n - 1)] - 1)] * Z_2_1[(n - 1)]))),
              "assigning variable mu");}
          current_statement__ = 34;
          lp_accum__.add(bernoulli_logit_glm_lpmf<false>(Y, Xc, mu, b));
        } 
        current_statement__ = 37;
        lp_accum__.add(lprior);
        current_statement__ = 38;
        lp_accum__.add(std_normal_lpdf<false>(zs_1_1));
        current_statement__ = 39;
        lp_accum__.add(std_normal_lpdf<false>(zs_2_1));
        current_statement__ = 40;
        lp_accum__.add(std_normal_lpdf<false>(z_1[(1 - 1)]));
        current_statement__ = 41;
        lp_accum__.add(std_normal_lpdf<false>(z_2[(1 - 1)]));
      }
    } catch (const std::exception& e) {
      stan::lang::rethrow_located(e, locations_array__[current_statement__]);
      // Next line prevents compiler griping about no return
      throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); 
    }
    lp_accum__.add(lp__);
    return lp_accum__.sum();
    } // log_prob_impl() 
    
  template <typename RNG, typename VecR, typename VecI, typename VecVar, stan::require_vector_like_vt<std::is_floating_point, VecR>* = nullptr, stan::require_vector_like_vt<std::is_integral, VecI>* = nullptr, stan::require_std_vector_vt<std::is_floating_point, VecVar>* = nullptr>
  inline void write_array_impl(RNG& base_rng__, VecR& params_r__,
                               VecI& params_i__, VecVar& vars__,
                               const bool emit_transformed_parameters__ = true,
                               const bool emit_generated_quantities__ = true,
                               std::ostream* pstream__ = nullptr) const {
    using local_scalar_t__ = double;
    vars__.resize(0);
    stan::io::reader<local_scalar_t__> in__(params_r__, params_i__);
    static const char* function__ = "model127c37207abc__namespace::write_array";
(void) function__;  // suppress unused var warning
    (void) function__;  // suppress unused var warning
    double lp__ = 0.0;
    (void) lp__;  // dummy to suppress unused var warning
    stan::math::accumulator<double> lp_accum__;
    local_scalar_t__ DUMMY_VAR__(std::numeric_limits<double>::quiet_NaN());
    (void) DUMMY_VAR__;  // suppress unused var warning
    
    try {
      Eigen::Matrix<double, -1, 1> b;
      b = Eigen::Matrix<double, -1, 1>(Kc);
      stan::math::fill(b, std::numeric_limits<double>::quiet_NaN());
      
      current_statement__ = 1;
      b = in__.vector(Kc);
      double Intercept;
      Intercept = std::numeric_limits<double>::quiet_NaN();
      
      current_statement__ = 2;
      Intercept = in__.scalar();
      Eigen::Matrix<double, -1, 1> bs;
      bs = Eigen::Matrix<double, -1, 1>(Ks);
      stan::math::fill(bs, std::numeric_limits<double>::quiet_NaN());
      
      current_statement__ = 3;
      bs = in__.vector(Ks);
      Eigen::Matrix<double, -1, 1> zs_1_1;
      zs_1_1 = Eigen::Matrix<double, -1, 1>(zs_1_1_1dim__);
      stan::math::fill(zs_1_1, std::numeric_limits<double>::quiet_NaN());
      
      current_statement__ = 4;
      zs_1_1 = in__.vector(zs_1_1_1dim__);
      double sds_1_1;
      sds_1_1 = std::numeric_limits<double>::quiet_NaN();
      
      current_statement__ = 5;
      sds_1_1 = in__.scalar();
      current_statement__ = 5;
      sds_1_1 = stan::math::lb_constrain(sds_1_1, 0);
      Eigen::Matrix<double, -1, 1> zs_2_1;
      zs_2_1 = Eigen::Matrix<double, -1, 1>(zs_2_1_1dim__);
      stan::math::fill(zs_2_1, std::numeric_limits<double>::quiet_NaN());
      
      current_statement__ = 6;
      zs_2_1 = in__.vector(zs_2_1_1dim__);
      double sds_2_1;
      sds_2_1 = std::numeric_limits<double>::quiet_NaN();
      
      current_statement__ = 7;
      sds_2_1 = in__.scalar();
      current_statement__ = 7;
      sds_2_1 = stan::math::lb_constrain(sds_2_1, 0);
      Eigen::Matrix<double, -1, 1> sd_1;
      sd_1 = Eigen::Matrix<double, -1, 1>(M_1);
      stan::math::fill(sd_1, std::numeric_limits<double>::quiet_NaN());
      
      current_statement__ = 8;
      sd_1 = in__.vector(M_1);
      current_statement__ = 8;
      for (int sym1__ = 1; sym1__ <= M_1; ++sym1__) {
        current_statement__ = 8;
        assign(sd_1, cons_list(index_uni(sym1__), nil_index_list()),
          stan::math::lb_constrain(sd_1[(sym1__ - 1)], 0),
          "assigning variable sd_1");}
      std::vector<Eigen::Matrix<double, -1, 1>> z_1;
      z_1 = std::vector<Eigen::Matrix<double, -1, 1>>(M_1, Eigen::Matrix<double, -1, 1>(N_1));
      stan::math::fill(z_1, std::numeric_limits<double>::quiet_NaN());
      
      current_statement__ = 9;
      for (int sym1__ = 1; sym1__ <= M_1; ++sym1__) {
        current_statement__ = 9;
        assign(z_1, cons_list(index_uni(sym1__), nil_index_list()),
          in__.vector(N_1), "assigning variable z_1");}
      Eigen::Matrix<double, -1, 1> sd_2;
      sd_2 = Eigen::Matrix<double, -1, 1>(M_2);
      stan::math::fill(sd_2, std::numeric_limits<double>::quiet_NaN());
      
      current_statement__ = 10;
      sd_2 = in__.vector(M_2);
      current_statement__ = 10;
      for (int sym1__ = 1; sym1__ <= M_2; ++sym1__) {
        current_statement__ = 10;
        assign(sd_2, cons_list(index_uni(sym1__), nil_index_list()),
          stan::math::lb_constrain(sd_2[(sym1__ - 1)], 0),
          "assigning variable sd_2");}
      std::vector<Eigen::Matrix<double, -1, 1>> z_2;
      z_2 = std::vector<Eigen::Matrix<double, -1, 1>>(M_2, Eigen::Matrix<double, -1, 1>(N_2));
      stan::math::fill(z_2, std::numeric_limits<double>::quiet_NaN());
      
      current_statement__ = 11;
      for (int sym1__ = 1; sym1__ <= M_2; ++sym1__) {
        current_statement__ = 11;
        assign(z_2, cons_list(index_uni(sym1__), nil_index_list()),
          in__.vector(N_2), "assigning variable z_2");}
      Eigen::Matrix<double, -1, 1> s_1_1;
      s_1_1 = Eigen::Matrix<double, -1, 1>(s_1_1_1dim__);
      stan::math::fill(s_1_1, std::numeric_limits<double>::quiet_NaN());
      
      Eigen::Matrix<double, -1, 1> s_2_1;
      s_2_1 = Eigen::Matrix<double, -1, 1>(s_2_1_1dim__);
      stan::math::fill(s_2_1, std::numeric_limits<double>::quiet_NaN());
      
      Eigen::Matrix<double, -1, 1> r_1_1;
      r_1_1 = Eigen::Matrix<double, -1, 1>(N_1);
      stan::math::fill(r_1_1, std::numeric_limits<double>::quiet_NaN());
      
      Eigen::Matrix<double, -1, 1> r_2_1;
      r_2_1 = Eigen::Matrix<double, -1, 1>(N_2);
      stan::math::fill(r_2_1, std::numeric_limits<double>::quiet_NaN());
      
      double lprior;
      lprior = std::numeric_limits<double>::quiet_NaN();
      
      for (int sym1__ = 1; sym1__ <= Kc; ++sym1__) {
        vars__.emplace_back(b[(sym1__ - 1)]);}
      vars__.emplace_back(Intercept);
      for (int sym1__ = 1; sym1__ <= Ks; ++sym1__) {
        vars__.emplace_back(bs[(sym1__ - 1)]);}
      for (int sym1__ = 1; sym1__ <= zs_1_1_1dim__; ++sym1__) {
        vars__.emplace_back(zs_1_1[(sym1__ - 1)]);}
      vars__.emplace_back(sds_1_1);
      for (int sym1__ = 1; sym1__ <= zs_2_1_1dim__; ++sym1__) {
        vars__.emplace_back(zs_2_1[(sym1__ - 1)]);}
      vars__.emplace_back(sds_2_1);
      for (int sym1__ = 1; sym1__ <= M_1; ++sym1__) {
        vars__.emplace_back(sd_1[(sym1__ - 1)]);}
      for (int sym1__ = 1; sym1__ <= N_1; ++sym1__) {
        for (int sym2__ = 1; sym2__ <= M_1; ++sym2__) {
          vars__.emplace_back(z_1[(sym2__ - 1)][(sym1__ - 1)]);}}
      for (int sym1__ = 1; sym1__ <= M_2; ++sym1__) {
        vars__.emplace_back(sd_2[(sym1__ - 1)]);}
      for (int sym1__ = 1; sym1__ <= N_2; ++sym1__) {
        for (int sym2__ = 1; sym2__ <= M_2; ++sym2__) {
          vars__.emplace_back(z_2[(sym2__ - 1)][(sym1__ - 1)]);}}
      if (logical_negation((primitive_value(emit_transformed_parameters__) ||
            primitive_value(emit_generated_quantities__)))) {
        return ;
      } 
      current_statement__ = 16;
      lprior = 0;
      current_statement__ = 17;
      assign(s_1_1, nil_index_list(), multiply(sds_1_1, zs_1_1),
        "assigning variable s_1_1");
      current_statement__ = 18;
      assign(s_2_1, nil_index_list(), multiply(sds_2_1, zs_2_1),
        "assigning variable s_2_1");
      current_statement__ = 19;
      assign(r_1_1, nil_index_list(), multiply(sd_1[(1 - 1)], z_1[(1 - 1)]),
        "assigning variable r_1_1");
      current_statement__ = 20;
      assign(r_2_1, nil_index_list(), multiply(sd_2[(1 - 1)], z_2[(1 - 1)]),
        "assigning variable r_2_1");
      current_statement__ = 21;
      lprior = (lprior + normal_lpdf<false>(b, 0, 10));
      current_statement__ = 22;
      lprior = (lprior + logistic_lpdf<false>(Intercept, 0, 1));
      current_statement__ = 23;
      lprior = (lprior + normal_lpdf<false>(bs, 0, 10));
      current_statement__ = 24;
      lprior = (lprior +
                 (student_t_lpdf<false>(sds_1_1, 3, 0, 2.5) -
                   (1 * student_t_lccdf(0, 3, 0, 2.5))));
      current_statement__ = 25;
      lprior = (lprior +
                 (student_t_lpdf<false>(sds_2_1, 3, 0, 2.5) -
                   (1 * student_t_lccdf(0, 3, 0, 2.5))));
      current_statement__ = 26;
      lprior = (lprior +
                 (student_t_lpdf<false>(sd_1, 3, 0, 2.5) -
                   (1 * student_t_lccdf(0, 3, 0, 2.5))));
      current_statement__ = 27;
      lprior = (lprior +
                 (student_t_lpdf<false>(sd_2, 3, 0, 2.5) -
                   (1 * student_t_lccdf(0, 3, 0, 2.5))));
      if (emit_transformed_parameters__) {
        for (int sym1__ = 1; sym1__ <= s_1_1_1dim__; ++sym1__) {
          vars__.emplace_back(s_1_1[(sym1__ - 1)]);}
        for (int sym1__ = 1; sym1__ <= s_2_1_1dim__; ++sym1__) {
          vars__.emplace_back(s_2_1[(sym1__ - 1)]);}
        for (int sym1__ = 1; sym1__ <= N_1; ++sym1__) {
          vars__.emplace_back(r_1_1[(sym1__ - 1)]);}
        for (int sym1__ = 1; sym1__ <= N_2; ++sym1__) {
          vars__.emplace_back(r_2_1[(sym1__ - 1)]);}
        vars__.emplace_back(lprior);
      } 
      if (logical_negation(emit_generated_quantities__)) {
        return ;
      } 
      double b_Intercept;
      b_Intercept = std::numeric_limits<double>::quiet_NaN();
      
      current_statement__ = 28;
      b_Intercept = (Intercept - dot_product(means_X, b));
      vars__.emplace_back(b_Intercept);
    } catch (const std::exception& e) {
      stan::lang::rethrow_located(e, locations_array__[current_statement__]);
      // Next line prevents compiler griping about no return
      throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); 
    }
    } // write_array_impl() 
    
  template <typename VecVar, typename VecI, stan::require_std_vector_t<VecVar>* = nullptr, stan::require_vector_like_vt<std::is_integral, VecI>* = nullptr>
  inline void transform_inits_impl(const stan::io::var_context& context__,
                                   VecI& params_i__, VecVar& vars__,
                                   std::ostream* pstream__ = nullptr) const {
    using local_scalar_t__ = double;
    vars__.clear();
    vars__.reserve(num_params_r__);
    
    try {
      int pos__;
      pos__ = std::numeric_limits<int>::min();
      
      pos__ = 1;
      Eigen::Matrix<double, -1, 1> b;
      b = Eigen::Matrix<double, -1, 1>(Kc);
      stan::math::fill(b, std::numeric_limits<double>::quiet_NaN());
      
      {
        std::vector<local_scalar_t__> b_flat__;
        current_statement__ = 1;
        assign(b_flat__, nil_index_list(), context__.vals_r("b"),
          "assigning variable b_flat__");
        current_statement__ = 1;
        pos__ = 1;
        current_statement__ = 1;
        for (int sym1__ = 1; sym1__ <= Kc; ++sym1__) {
          current_statement__ = 1;
          assign(b, cons_list(index_uni(sym1__), nil_index_list()),
            b_flat__[(pos__ - 1)], "assigning variable b");
          current_statement__ = 1;
          pos__ = (pos__ + 1);}
      }
      double Intercept;
      Intercept = std::numeric_limits<double>::quiet_NaN();
      
      current_statement__ = 2;
      Intercept = context__.vals_r("Intercept")[(1 - 1)];
      Eigen::Matrix<double, -1, 1> bs;
      bs = Eigen::Matrix<double, -1, 1>(Ks);
      stan::math::fill(bs, std::numeric_limits<double>::quiet_NaN());
      
      {
        std::vector<local_scalar_t__> bs_flat__;
        current_statement__ = 3;
        assign(bs_flat__, nil_index_list(), context__.vals_r("bs"),
          "assigning variable bs_flat__");
        current_statement__ = 3;
        pos__ = 1;
        current_statement__ = 3;
        for (int sym1__ = 1; sym1__ <= Ks; ++sym1__) {
          current_statement__ = 3;
          assign(bs, cons_list(index_uni(sym1__), nil_index_list()),
            bs_flat__[(pos__ - 1)], "assigning variable bs");
          current_statement__ = 3;
          pos__ = (pos__ + 1);}
      }
      Eigen::Matrix<double, -1, 1> zs_1_1;
      zs_1_1 = Eigen::Matrix<double, -1, 1>(zs_1_1_1dim__);
      stan::math::fill(zs_1_1, std::numeric_limits<double>::quiet_NaN());
      
      {
        std::vector<local_scalar_t__> zs_1_1_flat__;
        current_statement__ = 4;
        assign(zs_1_1_flat__, nil_index_list(), context__.vals_r("zs_1_1"),
          "assigning variable zs_1_1_flat__");
        current_statement__ = 4;
        pos__ = 1;
        current_statement__ = 4;
        for (int sym1__ = 1; sym1__ <= zs_1_1_1dim__; ++sym1__) {
          current_statement__ = 4;
          assign(zs_1_1, cons_list(index_uni(sym1__), nil_index_list()),
            zs_1_1_flat__[(pos__ - 1)], "assigning variable zs_1_1");
          current_statement__ = 4;
          pos__ = (pos__ + 1);}
      }
      double sds_1_1;
      sds_1_1 = std::numeric_limits<double>::quiet_NaN();
      
      current_statement__ = 5;
      sds_1_1 = context__.vals_r("sds_1_1")[(1 - 1)];
      double sds_1_1_free__;
      sds_1_1_free__ = std::numeric_limits<double>::quiet_NaN();
      
      current_statement__ = 5;
      sds_1_1_free__ = stan::math::lb_free(sds_1_1, 0);
      Eigen::Matrix<double, -1, 1> zs_2_1;
      zs_2_1 = Eigen::Matrix<double, -1, 1>(zs_2_1_1dim__);
      stan::math::fill(zs_2_1, std::numeric_limits<double>::quiet_NaN());
      
      {
        std::vector<local_scalar_t__> zs_2_1_flat__;
        current_statement__ = 6;
        assign(zs_2_1_flat__, nil_index_list(), context__.vals_r("zs_2_1"),
          "assigning variable zs_2_1_flat__");
        current_statement__ = 6;
        pos__ = 1;
        current_statement__ = 6;
        for (int sym1__ = 1; sym1__ <= zs_2_1_1dim__; ++sym1__) {
          current_statement__ = 6;
          assign(zs_2_1, cons_list(index_uni(sym1__), nil_index_list()),
            zs_2_1_flat__[(pos__ - 1)], "assigning variable zs_2_1");
          current_statement__ = 6;
          pos__ = (pos__ + 1);}
      }
      double sds_2_1;
      sds_2_1 = std::numeric_limits<double>::quiet_NaN();
      
      current_statement__ = 7;
      sds_2_1 = context__.vals_r("sds_2_1")[(1 - 1)];
      double sds_2_1_free__;
      sds_2_1_free__ = std::numeric_limits<double>::quiet_NaN();
      
      current_statement__ = 7;
      sds_2_1_free__ = stan::math::lb_free(sds_2_1, 0);
      Eigen::Matrix<double, -1, 1> sd_1;
      sd_1 = Eigen::Matrix<double, -1, 1>(M_1);
      stan::math::fill(sd_1, std::numeric_limits<double>::quiet_NaN());
      
      {
        std::vector<local_scalar_t__> sd_1_flat__;
        current_statement__ = 8;
        assign(sd_1_flat__, nil_index_list(), context__.vals_r("sd_1"),
          "assigning variable sd_1_flat__");
        current_statement__ = 8;
        pos__ = 1;
        current_statement__ = 8;
        for (int sym1__ = 1; sym1__ <= M_1; ++sym1__) {
          current_statement__ = 8;
          assign(sd_1, cons_list(index_uni(sym1__), nil_index_list()),
            sd_1_flat__[(pos__ - 1)], "assigning variable sd_1");
          current_statement__ = 8;
          pos__ = (pos__ + 1);}
      }
      Eigen::Matrix<double, -1, 1> sd_1_free__;
      sd_1_free__ = Eigen::Matrix<double, -1, 1>(M_1);
      stan::math::fill(sd_1_free__, std::numeric_limits<double>::quiet_NaN());
      
      current_statement__ = 8;
      for (int sym1__ = 1; sym1__ <= M_1; ++sym1__) {
        current_statement__ = 8;
        assign(sd_1_free__, cons_list(index_uni(sym1__), nil_index_list()),
          stan::math::lb_free(sd_1[(sym1__ - 1)], 0),
          "assigning variable sd_1_free__");}
      std::vector<Eigen::Matrix<double, -1, 1>> z_1;
      z_1 = std::vector<Eigen::Matrix<double, -1, 1>>(M_1, Eigen::Matrix<double, -1, 1>(N_1));
      stan::math::fill(z_1, std::numeric_limits<double>::quiet_NaN());
      
      {
        std::vector<local_scalar_t__> z_1_flat__;
        current_statement__ = 9;
        assign(z_1_flat__, nil_index_list(), context__.vals_r("z_1"),
          "assigning variable z_1_flat__");
        current_statement__ = 9;
        pos__ = 1;
        current_statement__ = 9;
        for (int sym1__ = 1; sym1__ <= N_1; ++sym1__) {
          current_statement__ = 9;
          for (int sym2__ = 1; sym2__ <= M_1; ++sym2__) {
            current_statement__ = 9;
            assign(z_1,
              cons_list(index_uni(sym2__),
                cons_list(index_uni(sym1__), nil_index_list())),
              z_1_flat__[(pos__ - 1)], "assigning variable z_1");
            current_statement__ = 9;
            pos__ = (pos__ + 1);}}
      }
      Eigen::Matrix<double, -1, 1> sd_2;
      sd_2 = Eigen::Matrix<double, -1, 1>(M_2);
      stan::math::fill(sd_2, std::numeric_limits<double>::quiet_NaN());
      
      {
        std::vector<local_scalar_t__> sd_2_flat__;
        current_statement__ = 10;
        assign(sd_2_flat__, nil_index_list(), context__.vals_r("sd_2"),
          "assigning variable sd_2_flat__");
        current_statement__ = 10;
        pos__ = 1;
        current_statement__ = 10;
        for (int sym1__ = 1; sym1__ <= M_2; ++sym1__) {
          current_statement__ = 10;
          assign(sd_2, cons_list(index_uni(sym1__), nil_index_list()),
            sd_2_flat__[(pos__ - 1)], "assigning variable sd_2");
          current_statement__ = 10;
          pos__ = (pos__ + 1);}
      }
      Eigen::Matrix<double, -1, 1> sd_2_free__;
      sd_2_free__ = Eigen::Matrix<double, -1, 1>(M_2);
      stan::math::fill(sd_2_free__, std::numeric_limits<double>::quiet_NaN());
      
      current_statement__ = 10;
      for (int sym1__ = 1; sym1__ <= M_2; ++sym1__) {
        current_statement__ = 10;
        assign(sd_2_free__, cons_list(index_uni(sym1__), nil_index_list()),
          stan::math::lb_free(sd_2[(sym1__ - 1)], 0),
          "assigning variable sd_2_free__");}
      std::vector<Eigen::Matrix<double, -1, 1>> z_2;
      z_2 = std::vector<Eigen::Matrix<double, -1, 1>>(M_2, Eigen::Matrix<double, -1, 1>(N_2));
      stan::math::fill(z_2, std::numeric_limits<double>::quiet_NaN());
      
      {
        std::vector<local_scalar_t__> z_2_flat__;
        current_statement__ = 11;
        assign(z_2_flat__, nil_index_list(), context__.vals_r("z_2"),
          "assigning variable z_2_flat__");
        current_statement__ = 11;
        pos__ = 1;
        current_statement__ = 11;
        for (int sym1__ = 1; sym1__ <= N_2; ++sym1__) {
          current_statement__ = 11;
          for (int sym2__ = 1; sym2__ <= M_2; ++sym2__) {
            current_statement__ = 11;
            assign(z_2,
              cons_list(index_uni(sym2__),
                cons_list(index_uni(sym1__), nil_index_list())),
              z_2_flat__[(pos__ - 1)], "assigning variable z_2");
            current_statement__ = 11;
            pos__ = (pos__ + 1);}}
      }
      for (int sym1__ = 1; sym1__ <= Kc; ++sym1__) {
        vars__.emplace_back(b[(sym1__ - 1)]);}
      vars__.emplace_back(Intercept);
      for (int sym1__ = 1; sym1__ <= Ks; ++sym1__) {
        vars__.emplace_back(bs[(sym1__ - 1)]);}
      for (int sym1__ = 1; sym1__ <= zs_1_1_1dim__; ++sym1__) {
        vars__.emplace_back(zs_1_1[(sym1__ - 1)]);}
      vars__.emplace_back(sds_1_1_free__);
      for (int sym1__ = 1; sym1__ <= zs_2_1_1dim__; ++sym1__) {
        vars__.emplace_back(zs_2_1[(sym1__ - 1)]);}
      vars__.emplace_back(sds_2_1_free__);
      for (int sym1__ = 1; sym1__ <= M_1; ++sym1__) {
        vars__.emplace_back(sd_1_free__[(sym1__ - 1)]);}
      for (int sym1__ = 1; sym1__ <= M_1; ++sym1__) {
        for (int sym2__ = 1; sym2__ <= N_1; ++sym2__) {
          vars__.emplace_back(z_1[(sym1__ - 1)][(sym2__ - 1)]);}}
      for (int sym1__ = 1; sym1__ <= M_2; ++sym1__) {
        vars__.emplace_back(sd_2_free__[(sym1__ - 1)]);}
      for (int sym1__ = 1; sym1__ <= M_2; ++sym1__) {
        for (int sym2__ = 1; sym2__ <= N_2; ++sym2__) {
          vars__.emplace_back(z_2[(sym1__ - 1)][(sym2__ - 1)]);}}
    } catch (const std::exception& e) {
      stan::lang::rethrow_located(e, locations_array__[current_statement__]);
      // Next line prevents compiler griping about no return
      throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); 
    }
    } // transform_inits_impl() 
    
  inline void get_param_names(std::vector<std::string>& names__) const {
    
    names__.clear();
    names__.emplace_back("b");
    names__.emplace_back("Intercept");
    names__.emplace_back("bs");
    names__.emplace_back("zs_1_1");
    names__.emplace_back("sds_1_1");
    names__.emplace_back("zs_2_1");
    names__.emplace_back("sds_2_1");
    names__.emplace_back("sd_1");
    names__.emplace_back("z_1");
    names__.emplace_back("sd_2");
    names__.emplace_back("z_2");
    names__.emplace_back("s_1_1");
    names__.emplace_back("s_2_1");
    names__.emplace_back("r_1_1");
    names__.emplace_back("r_2_1");
    names__.emplace_back("lprior");
    names__.emplace_back("b_Intercept");
    } // get_param_names() 
    
  inline void get_dims(std::vector<std::vector<size_t>>& dimss__) const {
    dimss__.clear();
    dimss__.emplace_back(std::vector<size_t>{static_cast<size_t>(Kc)});
    
    dimss__.emplace_back(std::vector<size_t>{});
    
    dimss__.emplace_back(std::vector<size_t>{static_cast<size_t>(Ks)});
    
    dimss__.emplace_back(std::vector<size_t>{
                                             static_cast<size_t>(zs_1_1_1dim__)
                                             });
    
    dimss__.emplace_back(std::vector<size_t>{});
    
    dimss__.emplace_back(std::vector<size_t>{
                                             static_cast<size_t>(zs_2_1_1dim__)
                                             });
    
    dimss__.emplace_back(std::vector<size_t>{});
    
    dimss__.emplace_back(std::vector<size_t>{static_cast<size_t>(M_1)});
    
    dimss__.emplace_back(std::vector<size_t>{static_cast<size_t>(M_1),
                                             static_cast<size_t>(N_1)});
    
    dimss__.emplace_back(std::vector<size_t>{static_cast<size_t>(M_2)});
    
    dimss__.emplace_back(std::vector<size_t>{static_cast<size_t>(M_2),
                                             static_cast<size_t>(N_2)});
    
    dimss__.emplace_back(std::vector<size_t>{
                                             static_cast<size_t>(s_1_1_1dim__)});
    
    dimss__.emplace_back(std::vector<size_t>{
                                             static_cast<size_t>(s_2_1_1dim__)});
    
    dimss__.emplace_back(std::vector<size_t>{static_cast<size_t>(N_1)});
    
    dimss__.emplace_back(std::vector<size_t>{static_cast<size_t>(N_2)});
    
    dimss__.emplace_back(std::vector<size_t>{});
    
    dimss__.emplace_back(std::vector<size_t>{});
    
    } // get_dims() 
    
  inline void constrained_param_names(
                                      std::vector<std::string>& param_names__,
                                      bool emit_transformed_parameters__ = true,
                                      bool emit_generated_quantities__ = true) const
    final {
    
    for (int sym1__ = 1; sym1__ <= Kc; ++sym1__) {
      {
        param_names__.emplace_back(std::string() + "b" + '.' + std::to_string(sym1__));
      }}
    param_names__.emplace_back(std::string() + "Intercept");
    for (int sym1__ = 1; sym1__ <= Ks; ++sym1__) {
      {
        param_names__.emplace_back(std::string() + "bs" + '.' + std::to_string(sym1__));
      }}
    for (int sym1__ = 1; sym1__ <= zs_1_1_1dim__; ++sym1__) {
      {
        param_names__.emplace_back(std::string() + "zs_1_1" + '.' + std::to_string(sym1__));
      }}
    param_names__.emplace_back(std::string() + "sds_1_1");
    for (int sym1__ = 1; sym1__ <= zs_2_1_1dim__; ++sym1__) {
      {
        param_names__.emplace_back(std::string() + "zs_2_1" + '.' + std::to_string(sym1__));
      }}
    param_names__.emplace_back(std::string() + "sds_2_1");
    for (int sym1__ = 1; sym1__ <= M_1; ++sym1__) {
      {
        param_names__.emplace_back(std::string() + "sd_1" + '.' + std::to_string(sym1__));
      }}
    for (int sym1__ = 1; sym1__ <= N_1; ++sym1__) {
      {
        for (int sym2__ = 1; sym2__ <= M_1; ++sym2__) {
          {
            param_names__.emplace_back(std::string() + "z_1" + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__));
          }}
      }}
    for (int sym1__ = 1; sym1__ <= M_2; ++sym1__) {
      {
        param_names__.emplace_back(std::string() + "sd_2" + '.' + std::to_string(sym1__));
      }}
    for (int sym1__ = 1; sym1__ <= N_2; ++sym1__) {
      {
        for (int sym2__ = 1; sym2__ <= M_2; ++sym2__) {
          {
            param_names__.emplace_back(std::string() + "z_2" + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__));
          }}
      }}
    if (emit_transformed_parameters__) {
      for (int sym1__ = 1; sym1__ <= s_1_1_1dim__; ++sym1__) {
        {
          param_names__.emplace_back(std::string() + "s_1_1" + '.' + std::to_string(sym1__));
        }}
      for (int sym1__ = 1; sym1__ <= s_2_1_1dim__; ++sym1__) {
        {
          param_names__.emplace_back(std::string() + "s_2_1" + '.' + std::to_string(sym1__));
        }}
      for (int sym1__ = 1; sym1__ <= N_1; ++sym1__) {
        {
          param_names__.emplace_back(std::string() + "r_1_1" + '.' + std::to_string(sym1__));
        }}
      for (int sym1__ = 1; sym1__ <= N_2; ++sym1__) {
        {
          param_names__.emplace_back(std::string() + "r_2_1" + '.' + std::to_string(sym1__));
        }}
      param_names__.emplace_back(std::string() + "lprior");
    }
    
    if (emit_generated_quantities__) {
      param_names__.emplace_back(std::string() + "b_Intercept");
    }
    
    } // constrained_param_names() 
    
  inline void unconstrained_param_names(
                                        std::vector<std::string>& param_names__,
                                        bool emit_transformed_parameters__ = true,
                                        bool emit_generated_quantities__ = true) const
    final {
    
    for (int sym1__ = 1; sym1__ <= Kc; ++sym1__) {
      {
        param_names__.emplace_back(std::string() + "b" + '.' + std::to_string(sym1__));
      }}
    param_names__.emplace_back(std::string() + "Intercept");
    for (int sym1__ = 1; sym1__ <= Ks; ++sym1__) {
      {
        param_names__.emplace_back(std::string() + "bs" + '.' + std::to_string(sym1__));
      }}
    for (int sym1__ = 1; sym1__ <= zs_1_1_1dim__; ++sym1__) {
      {
        param_names__.emplace_back(std::string() + "zs_1_1" + '.' + std::to_string(sym1__));
      }}
    param_names__.emplace_back(std::string() + "sds_1_1");
    for (int sym1__ = 1; sym1__ <= zs_2_1_1dim__; ++sym1__) {
      {
        param_names__.emplace_back(std::string() + "zs_2_1" + '.' + std::to_string(sym1__));
      }}
    param_names__.emplace_back(std::string() + "sds_2_1");
    for (int sym1__ = 1; sym1__ <= M_1; ++sym1__) {
      {
        param_names__.emplace_back(std::string() + "sd_1" + '.' + std::to_string(sym1__));
      }}
    for (int sym1__ = 1; sym1__ <= N_1; ++sym1__) {
      {
        for (int sym2__ = 1; sym2__ <= M_1; ++sym2__) {
          {
            param_names__.emplace_back(std::string() + "z_1" + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__));
          }}
      }}
    for (int sym1__ = 1; sym1__ <= M_2; ++sym1__) {
      {
        param_names__.emplace_back(std::string() + "sd_2" + '.' + std::to_string(sym1__));
      }}
    for (int sym1__ = 1; sym1__ <= N_2; ++sym1__) {
      {
        for (int sym2__ = 1; sym2__ <= M_2; ++sym2__) {
          {
            param_names__.emplace_back(std::string() + "z_2" + '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__));
          }}
      }}
    if (emit_transformed_parameters__) {
      for (int sym1__ = 1; sym1__ <= s_1_1_1dim__; ++sym1__) {
        {
          param_names__.emplace_back(std::string() + "s_1_1" + '.' + std::to_string(sym1__));
        }}
      for (int sym1__ = 1; sym1__ <= s_2_1_1dim__; ++sym1__) {
        {
          param_names__.emplace_back(std::string() + "s_2_1" + '.' + std::to_string(sym1__));
        }}
      for (int sym1__ = 1; sym1__ <= N_1; ++sym1__) {
        {
          param_names__.emplace_back(std::string() + "r_1_1" + '.' + std::to_string(sym1__));
        }}
      for (int sym1__ = 1; sym1__ <= N_2; ++sym1__) {
        {
          param_names__.emplace_back(std::string() + "r_2_1" + '.' + std::to_string(sym1__));
        }}
      param_names__.emplace_back(std::string() + "lprior");
    }
    
    if (emit_generated_quantities__) {
      param_names__.emplace_back(std::string() + "b_Intercept");
    }
    
    } // unconstrained_param_names() 
    
  inline std::string get_constrained_sizedtypes() const {
    stringstream s__;
    s__ << "[{\"name\":\"b\",\"type\":{\"name\":\"vector\",\"length\":" << Kc << "},\"block\":\"parameters\"},{\"name\":\"Intercept\",\"type\":{\"name\":\"real\"},\"block\":\"parameters\"},{\"name\":\"bs\",\"type\":{\"name\":\"vector\",\"length\":" << Ks << "},\"block\":\"parameters\"},{\"name\":\"zs_1_1\",\"type\":{\"name\":\"vector\",\"length\":" << zs_1_1_1dim__ << "},\"block\":\"parameters\"},{\"name\":\"sds_1_1\",\"type\":{\"name\":\"real\"},\"block\":\"parameters\"},{\"name\":\"zs_2_1\",\"type\":{\"name\":\"vector\",\"length\":" << zs_2_1_1dim__ << "},\"block\":\"parameters\"},{\"name\":\"sds_2_1\",\"type\":{\"name\":\"real\"},\"block\":\"parameters\"},{\"name\":\"sd_1\",\"type\":{\"name\":\"vector\",\"length\":" << M_1 << "},\"block\":\"parameters\"},{\"name\":\"z_1\",\"type\":{\"name\":\"array\",\"length\":" << M_1 << ",\"element_type\":{\"name\":\"vector\",\"length\":" << N_1 << "}},\"block\":\"parameters\"},{\"name\":\"sd_2\",\"type\":{\"name\":\"vector\",\"length\":" << M_2 << "},\"block\":\"parameters\"},{\"name\":\"z_2\",\"type\":{\"name\":\"array\",\"length\":" << M_2 << ",\"element_type\":{\"name\":\"vector\",\"length\":" << N_2 << "}},\"block\":\"parameters\"},{\"name\":\"s_1_1\",\"type\":{\"name\":\"vector\",\"length\":" << s_1_1_1dim__ << "},\"block\":\"transformed_parameters\"},{\"name\":\"s_2_1\",\"type\":{\"name\":\"vector\",\"length\":" << s_2_1_1dim__ << "},\"block\":\"transformed_parameters\"},{\"name\":\"r_1_1\",\"type\":{\"name\":\"vector\",\"length\":" << N_1 << "},\"block\":\"transformed_parameters\"},{\"name\":\"r_2_1\",\"type\":{\"name\":\"vector\",\"length\":" << N_2 << "},\"block\":\"transformed_parameters\"},{\"name\":\"lprior\",\"type\":{\"name\":\"real\"},\"block\":\"transformed_parameters\"},{\"name\":\"b_Intercept\",\"type\":{\"name\":\"real\"},\"block\":\"generated_quantities\"}]";
    return s__.str();
    } // get_constrained_sizedtypes() 
    
  inline std::string get_unconstrained_sizedtypes() const {
    stringstream s__;
    s__ << "[{\"name\":\"b\",\"type\":{\"name\":\"vector\",\"length\":" << Kc << "},\"block\":\"parameters\"},{\"name\":\"Intercept\",\"type\":{\"name\":\"real\"},\"block\":\"parameters\"},{\"name\":\"bs\",\"type\":{\"name\":\"vector\",\"length\":" << Ks << "},\"block\":\"parameters\"},{\"name\":\"zs_1_1\",\"type\":{\"name\":\"vector\",\"length\":" << zs_1_1_1dim__ << "},\"block\":\"parameters\"},{\"name\":\"sds_1_1\",\"type\":{\"name\":\"real\"},\"block\":\"parameters\"},{\"name\":\"zs_2_1\",\"type\":{\"name\":\"vector\",\"length\":" << zs_2_1_1dim__ << "},\"block\":\"parameters\"},{\"name\":\"sds_2_1\",\"type\":{\"name\":\"real\"},\"block\":\"parameters\"},{\"name\":\"sd_1\",\"type\":{\"name\":\"vector\",\"length\":" << M_1 << "},\"block\":\"parameters\"},{\"name\":\"z_1\",\"type\":{\"name\":\"array\",\"length\":" << M_1 << ",\"element_type\":{\"name\":\"vector\",\"length\":" << N_1 << "}},\"block\":\"parameters\"},{\"name\":\"sd_2\",\"type\":{\"name\":\"vector\",\"length\":" << M_2 << "},\"block\":\"parameters\"},{\"name\":\"z_2\",\"type\":{\"name\":\"array\",\"length\":" << M_2 << ",\"element_type\":{\"name\":\"vector\",\"length\":" << N_2 << "}},\"block\":\"parameters\"},{\"name\":\"s_1_1\",\"type\":{\"name\":\"vector\",\"length\":" << s_1_1_1dim__ << "},\"block\":\"transformed_parameters\"},{\"name\":\"s_2_1\",\"type\":{\"name\":\"vector\",\"length\":" << s_2_1_1dim__ << "},\"block\":\"transformed_parameters\"},{\"name\":\"r_1_1\",\"type\":{\"name\":\"vector\",\"length\":" << N_1 << "},\"block\":\"transformed_parameters\"},{\"name\":\"r_2_1\",\"type\":{\"name\":\"vector\",\"length\":" << N_2 << "},\"block\":\"transformed_parameters\"},{\"name\":\"lprior\",\"type\":{\"name\":\"real\"},\"block\":\"transformed_parameters\"},{\"name\":\"b_Intercept\",\"type\":{\"name\":\"real\"},\"block\":\"generated_quantities\"}]";
    return s__.str();
    } // get_unconstrained_sizedtypes() 
    
  
    // Begin method overload boilerplate
    template <typename RNG>
    inline void write_array(RNG& base_rng,
                            Eigen::Matrix<double,Eigen::Dynamic,1>& params_r,
                            Eigen::Matrix<double,Eigen::Dynamic,1>& vars,
                            const bool emit_transformed_parameters = true,
                            const bool emit_generated_quantities = true,
                            std::ostream* pstream = nullptr) const {
      std::vector<double> vars_vec(vars.size());
      std::vector<int> params_i;
      write_array_impl(base_rng, params_r, params_i, vars_vec,
          emit_transformed_parameters, emit_generated_quantities, pstream);
      vars.resize(vars_vec.size());
      for (int i = 0; i < vars.size(); ++i) {
        vars.coeffRef(i) = vars_vec[i];
      }
    }
    template <typename RNG>
    inline void write_array(RNG& base_rng, std::vector<double>& params_r,
                            std::vector<int>& params_i,
                            std::vector<double>& vars,
                            bool emit_transformed_parameters = true,
                            bool emit_generated_quantities = true,
                            std::ostream* pstream = nullptr) const {
      write_array_impl(base_rng, params_r, params_i, vars, emit_transformed_parameters, emit_generated_quantities, pstream);
    }
    template <bool propto__, bool jacobian__, typename T_>
    inline T_ log_prob(Eigen::Matrix<T_,Eigen::Dynamic,1>& params_r,
                       std::ostream* pstream = nullptr) const {
      Eigen::Matrix<int, -1, 1> params_i;
      return log_prob_impl<propto__, jacobian__>(params_r, params_i, pstream);
    }
    template <bool propto__, bool jacobian__, typename T__>
    inline T__ log_prob(std::vector<T__>& params_r,
                        std::vector<int>& params_i,
                        std::ostream* pstream = nullptr) const {
      return log_prob_impl<propto__, jacobian__>(params_r, params_i, pstream);
    }
  
    inline void transform_inits(const stan::io::var_context& context,
                         Eigen::Matrix<double, Eigen::Dynamic, 1>& params_r,
                         std::ostream* pstream = nullptr) const final {
      std::vector<double> params_r_vec(params_r.size());
      std::vector<int> params_i;
      transform_inits_impl(context, params_i, params_r_vec, pstream);
      params_r.resize(params_r_vec.size());
      for (int i = 0; i < params_r.size(); ++i) {
        params_r.coeffRef(i) = params_r_vec[i];
      }
    }
    inline void transform_inits(const stan::io::var_context& context,
                                std::vector<int>& params_i,
                                std::vector<double>& vars,
                                std::ostream* pstream = nullptr) const final {
      transform_inits_impl(context, params_i, vars, pstream);
    }        
};
}
using stan_model = model127c37207abc__namespace::model127c37207abc_;
#ifndef USING_R
// Boilerplate
stan::model::model_base& new_model(
        stan::io::var_context& data_context,
        unsigned int seed,
        std::ostream* msg_stream) {
  stan_model* m = new stan_model(data_context, seed, msg_stream);
  return *m;
}
stan::math::profile_map& get_stan_profile_data() {
  return model127c37207abc__namespace::profiles__;
}
#endif
#endif