// Generated by rstantools.  Do not edit by hand.

/*
    rstanarm is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    rstanarm is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with rstanarm.  If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef MODELS_HPP
#define MODELS_HPP
#define STAN__SERVICES__COMMAND_HPP
#ifndef USE_STANC3
#define USE_STANC3
#endif
#include <rstan/rstaninc.hpp>
// Code generated by stanc v2.32.2
#include <stan/model/model_header.hpp>
namespace model_binomial_namespace {
using stan::model::model_base_crtp;
using namespace stan::math;
stan::math::profile_map profiles__;
static constexpr std::array<const char*, 573> locations_array__ =
  {" (found before start of program)",
  " (in 'binomial', line 511, column 2 to column 81)",
  " (in 'binomial', line 514, column 2 to column 56)",
  " (in 'binomial', line 515, column 2 to column 33)",
  " (in 'binomial', line 516, column 2 to column 73)",
  " (in 'binomial', line 517, column 2 to column 33)",
  " (in 'binomial', line 518, column 2 to column 37)",
  " (in 'binomial', line 519, column 2 to column 35)",
  " (in 'binomial', line 520, column 2 to column 67)",
  " (in 'binomial', line 521, column 2 to column 55)",
  " (in 'binomial', line 522, column 2 to column 16)",
  " (in 'binomial', line 523, column 2 to column 22)",
  " (in 'binomial', line 524, column 2 to column 39)",
  " (in 'binomial', line 525, column 2 to column 42)",
  " (in 'binomial', line 526, column 2 to column 25)",
  " (in 'binomial', line 531, column 2 to column 17)",
  " (in 'binomial', line 532, column 2 to column 31)",
  " (in 'binomial', line 533, column 2 to column 60)",
  " (in 'binomial', line 534, column 2 to column 14)",
  " (in 'binomial', line 535, column 2 to column 30)",
  " (in 'binomial', line 693, column 2 to column 61)",
  " (in 'binomial', line 694, column 2 to column 34)",
  " (in 'binomial', line 558, column 4 to column 18)",
  " (in 'binomial', line 560, column 6 to column 30)",
  " (in 'binomial', line 561, column 6 to column 17)",
  " (in 'binomial', line 563, column 8 to column 33)",
  " (in 'binomial', line 564, column 8 to column 19)",
  " (in 'binomial', line 562, column 34 to line 565, column 7)",
  " (in 'binomial', line 562, column 6 to line 565, column 7)",
  " (in 'binomial', line 566, column 6 to column 49)",
  " (in 'binomial', line 567, column 6 to column 31)",
  " (in 'binomial', line 559, column 19 to line 568, column 5)",
  " (in 'binomial', line 559, column 4 to line 568, column 5)",
  " (in 'binomial', line 557, column 28 to line 569, column 3)",
  " (in 'binomial', line 557, column 7 to line 569, column 3)",
  " (in 'binomial', line 556, column 4 to column 87)",
  " (in 'binomial', line 555, column 7 to line 569, column 3)",
  " (in 'binomial', line 554, column 4 to column 66)",
  " (in 'binomial', line 553, column 7 to line 569, column 3)",
  " (in 'binomial', line 548, column 4 to column 43)",
  " (in 'binomial', line 551, column 9 to column 79)",
  " (in 'binomial', line 550, column 6 to column 78)",
  " (in 'binomial', line 549, column 4 to line 551, column 79)",
  " (in 'binomial', line 547, column 28 to line 552, column 3)",
  " (in 'binomial', line 547, column 7 to line 569, column 3)",
  " (in 'binomial', line 542, column 4 to column 43)",
  " (in 'binomial', line 545, column 9 to column 75)",
  " (in 'binomial', line 544, column 6 to column 74)",
  " (in 'binomial', line 543, column 4 to line 545, column 75)",
  " (in 'binomial', line 541, column 28 to line 546, column 3)",
  " (in 'binomial', line 541, column 7 to line 569, column 3)",
  " (in 'binomial', line 539, column 4 to column 75)",
  " (in 'binomial', line 538, column 43 to line 540, column 3)",
  " (in 'binomial', line 538, column 28 to line 540, column 3)",
  " (in 'binomial', line 538, column 7 to line 569, column 3)",
  " (in 'binomial', line 537, column 28 to column 70)",
  " (in 'binomial', line 537, column 7 to line 569, column 3)",
  " (in 'binomial', line 536, column 28 to column 42)",
  " (in 'binomial', line 536, column 2 to line 569, column 3)",
  " (in 'binomial', line 572, column 4 to column 80)",
  " (in 'binomial', line 573, column 38 to column 55)",
  " (in 'binomial', line 573, column 4 to column 55)",
  " (in 'binomial', line 574, column 4 to column 57)",
  " (in 'binomial', line 571, column 16 to line 575, column 3)",
  " (in 'binomial', line 571, column 2 to line 575, column 3)",
  " (in 'binomial', line 589, column 6 to column 78)",
  " (in 'binomial', line 590, column 6 to column 37)",
  " (in 'binomial', line 588, column 11 to line 591, column 5)",
  " (in 'binomial', line 578, column 6 to column 20)",
  " (in 'binomial', line 579, column 6 to column 29)",
  " (in 'binomial', line 584, column 10 to column 37)",
  " (in 'binomial', line 585, column 10 to column 57)",
  " (in 'binomial', line 586, column 10 to column 26)",
  " (in 'binomial', line 583, column 25 to line 587, column 9)",
  " (in 'binomial', line 583, column 8 to line 587, column 9)",
  " (in 'binomial', line 581, column 8 to column 29)",
  " (in 'binomial', line 580, column 6 to line 587, column 9)",
  " (in 'binomial', line 577, column 27 to line 588, column 5)",
  " (in 'binomial', line 577, column 4 to line 591, column 5)",
  " (in 'binomial', line 576, column 13 to line 592, column 3)",
  " (in 'binomial', line 576, column 2 to line 592, column 3)",
  " (in 'binomial', line 699, column 6 to column 26)",
  " (in 'binomial', line 697, column 6 to column 52)",
  " (in 'binomial', line 696, column 4 to line 699, column 26)",
  " (in 'binomial', line 695, column 26 to line 700, column 3)",
  " (in 'binomial', line 695, column 2 to line 700, column 3)",
  " (in 'binomial', line 702, column 11 to column 12)",
  " (in 'binomial', line 702, column 4 to column 17)",
  " (in 'binomial', line 704, column 9 to column 10)",
  " (in 'binomial', line 704, column 2 to column 16)",
  " (in 'binomial', line 709, column 7 to column 32)",
  " (in 'binomial', line 707, column 9 to column 66)",
  " (in 'binomial', line 706, column 17 to column 35)",
  " (in 'binomial', line 706, column 4 to line 707, column 66)",
  " (in 'binomial', line 705, column 13 to line 708, column 3)",
  " (in 'binomial', line 705, column 2 to line 709, column 32)",
  " (in 'binomial', line 710, column 23 to column 38)",
  " (in 'binomial', line 710, column 2 to column 38)",
  " (in 'binomial', line 711, column 16 to column 39)",
  " (in 'binomial', line 711, column 2 to column 39)",
  " (in 'binomial', line 715, column 9 to column 58)",
  " (in 'binomial', line 714, column 37 to column 52)",
  " (in 'binomial', line 714, column 22 to column 52)",
  " (in 'binomial', line 714, column 4 to line 715, column 58)",
  " (in 'binomial', line 712, column 15 to line 716, column 5)",
  " (in 'binomial', line 712, column 4 to line 716, column 5)",
  " (in 'binomial', line 728, column 2 to column 33)",
  " (in 'binomial', line 725, column 11 to line 729, column 5)",
  " (in 'binomial', line 721, column 8 to column 30)",
  " (in 'binomial', line 722, column 8 to column 32)",
  " (in 'binomial', line 723, column 8 to column 26)",
  " (in 'binomial', line 720, column 11 to line 724, column 7)",
  " (in 'binomial', line 719, column 8 to column 24)",
  " (in 'binomial', line 718, column 6 to line 724, column 7)",
  " (in 'binomial', line 717, column 28 to line 725, column 5)",
  " (in 'binomial', line 717, column 4 to line 729, column 5)",
  " (in 'binomial', line 730, column 4 to column 34)",
  " (in 'binomial', line 732, column 6 to column 49)",
  " (in 'binomial', line 731, column 4 to line 732, column 49)",
  " (in 'binomial', line 733, column 4 to column 18)",
  " (in 'binomial', line 701, column 24 to line 734, column 3)",
  " (in 'binomial', line 701, column 2 to line 734, column 3)",
  " (in 'binomial', line 597, column 9 to column 10)",
  " (in 'binomial', line 597, column 2 to column 16)",
  " (in 'binomial', line 602, column 7 to column 32)",
  " (in 'binomial', line 600, column 9 to column 66)",
  " (in 'binomial', line 599, column 17 to column 35)",
  " (in 'binomial', line 599, column 4 to line 600, column 66)",
  " (in 'binomial', line 598, column 13 to line 601, column 3)",
  " (in 'binomial', line 598, column 2 to line 602, column 32)",
  " (in 'binomial', line 603, column 23 to column 38)",
  " (in 'binomial', line 603, column 2 to column 38)",
  " (in 'binomial', line 604, column 16 to column 39)",
  " (in 'binomial', line 604, column 2 to column 39)",
  " (in 'binomial', line 608, column 9 to column 58)",
  " (in 'binomial', line 607, column 37 to column 52)",
  " (in 'binomial', line 607, column 22 to column 52)",
  " (in 'binomial', line 607, column 4 to line 608, column 58)",
  " (in 'binomial', line 605, column 15 to line 609, column 5)",
  " (in 'binomial', line 605, column 4 to line 609, column 5)",
  " (in 'binomial', line 618, column 2 to column 33)",
  " (in 'binomial', line 615, column 11 to line 619, column 5)",
  " (in 'binomial', line 614, column 8 to column 35)",
  " (in 'binomial', line 612, column 8 to column 24)",
  " (in 'binomial', line 611, column 6 to line 614, column 35)",
  " (in 'binomial', line 610, column 28 to line 615, column 5)",
  " (in 'binomial', line 610, column 4 to line 619, column 5)",
  " (in 'binomial', line 625, column 6 to column 69)",
  " (in 'binomial', line 623, column 6 to column 50)",
  " (in 'binomial', line 621, column 26 to line 624, column 5)",
  " (in 'binomial', line 621, column 4 to line 625, column 69)",
  " (in 'binomial', line 595, column 21 to line 626, column 3)",
  " (in 'binomial', line 595, column 2 to line 626, column 3)",
  " (in 'binomial', line 662, column 4 to column 41)",
  " (in 'binomial', line 661, column 28 to line 663, column 3)",
  " (in 'binomial', line 661, column 7 to line 663, column 3)",
  " (in 'binomial', line 657, column 4 to column 41)",
  " (in 'binomial', line 658, column 4 to column 43)",
  " (in 'binomial', line 659, column 4 to column 64)",
  " (in 'binomial', line 656, column 28 to line 660, column 3)",
  " (in 'binomial', line 656, column 7 to line 663, column 3)",
  " (in 'binomial', line 653, column 4 to column 41)",
  " (in 'binomial', line 654, column 4 to column 43)",
  " (in 'binomial', line 652, column 28 to line 655, column 3)",
  " (in 'binomial', line 652, column 7 to line 663, column 3)",
  " (in 'binomial', line 641, column 4 to column 42)",
  " (in 'binomial', line 642, column 4 to column 41)",
  " (in 'binomial', line 643, column 4 to column 54)",
  " (in 'binomial', line 644, column 4 to column 72)",
  " (in 'binomial', line 645, column 4 to column 54)",
  " (in 'binomial', line 647, column 4 to column 78)",
  " (in 'binomial', line 648, column 4 to column 55)",
  " (in 'binomial', line 649, column 4 to column 87)",
  " (in 'binomial', line 650, column 4 to column 66)",
  " (in 'binomial', line 640, column 28 to line 651, column 3)",
  " (in 'binomial', line 640, column 7 to line 663, column 3)",
  " (in 'binomial', line 632, column 4 to column 42)",
  " (in 'binomial', line 633, column 4 to column 41)",
  " (in 'binomial', line 634, column 4 to column 54)",
  " (in 'binomial', line 635, column 4 to column 72)",
  " (in 'binomial', line 636, column 4 to column 55)",
  " (in 'binomial', line 637, column 4 to column 87)",
  " (in 'binomial', line 638, column 4 to column 66)",
  " (in 'binomial', line 631, column 28 to line 639, column 3)",
  " (in 'binomial', line 631, column 7 to line 663, column 3)",
  " (in 'binomial', line 630, column 28 to column 65)",
  " (in 'binomial', line 630, column 7 to line 663, column 3)",
  " (in 'binomial', line 629, column 28 to column 65)",
  " (in 'binomial', line 629, column 7 to line 663, column 3)",
  " (in 'binomial', line 671, column 6 to line 672, column 58)",
  " (in 'binomial', line 670, column 9 to line 672, column 58)",
  " (in 'binomial', line 669, column 6 to column 89)",
  " (in 'binomial', line 668, column 4 to line 672, column 58)",
  " (in 'binomial', line 667, column 26 to line 674, column 3)",
  " (in 'binomial', line 667, column 2 to line 674, column 3)",
  " (in 'binomial', line 677, column 4 to column 48)",
  " (in 'binomial', line 679, column 6 to column 44)",
  " (in 'binomial', line 685, column 8 to column 54)",
  " (in 'binomial', line 684, column 11 to line 685, column 54)",
  " (in 'binomial', line 683, column 8 to column 87)",
  " (in 'binomial', line 682, column 11 to line 685, column 54)",
  " (in 'binomial', line 681, column 8 to column 63)",
  " (in 'binomial', line 680, column 6 to line 685, column 54)",
  " (in 'binomial', line 678, column 35 to line 686, column 5)",
  " (in 'binomial', line 678, column 4 to line 686, column 5)",
  " (in 'binomial', line 676, column 16 to line 687, column 3)",
  " (in 'binomial', line 676, column 2 to line 687, column 3)",
  " (in 'binomial', line 689, column 4 to column 88)",
  " (in 'binomial', line 688, column 13 to line 690, column 3)",
  " (in 'binomial', line 688, column 2 to line 690, column 3)",
  " (in 'binomial', line 383, column 2 to column 17)",
  " (in 'binomial', line 384, column 2 to column 17)",
  " (in 'binomial', line 387, column 9 to column 10)",
  " (in 'binomial', line 387, column 2 to column 17)",
  " (in 'binomial', line 388, column 2 to column 31)",
  " (in 'binomial', line 389, column 8 to column 15)",
  " (in 'binomial', line 389, column 24 to column 25)",
  " (in 'binomial', line 389, column 26 to column 27)",
  " (in 'binomial', line 389, column 2 to column 31)",
  " (in 'binomial', line 392, column 2 to column 21)",
  " (in 'binomial', line 393, column 9 to column 14)",
  " (in 'binomial', line 393, column 2 to column 20)",
  " (in 'binomial', line 394, column 8 to column 13)",
  " (in 'binomial', line 394, column 2 to column 43)",
  " (in 'binomial', line 396, column 8 to column 27)",
  " (in 'binomial', line 396, column 2 to column 69)",
  " (in 'binomial', line 399, column 2 to column 24)",
  " (in 'binomial', line 400, column 9 to column 10)",
  " (in 'binomial', line 400, column 11 to column 19)",
  " (in 'binomial', line 400, column 2 to column 23)",
  " (in 'binomial', line 401, column 8 to column 16)",
  " (in 'binomial', line 401, column 2 to column 42)",
  " (in 'binomial', line 402, column 8 to column 9)",
  " (in 'binomial', line 402, column 2 to column 26)",
  " (in 'binomial', line 403, column 8 to column 9)",
  " (in 'binomial', line 403, column 2 to column 31)",
  " (in 'binomial', line 407, column 2 to column 32)",
  " (in 'binomial', line 408, column 2 to column 40)",
  " (in 'binomial', line 411, column 2 to column 37)",
  " (in 'binomial', line 414, column 2 to column 20)",
  " (in 'binomial', line 418, column 2 to column 34)",
  " (in 'binomial', line 419, column 2 to column 48)",
  " (in 'binomial', line 422, column 2 to column 42)",
  " (in 'binomial', line 425, column 2 to column 45)",
  " (in 'binomial', line 429, column 2 to column 35)",
  " (in 'binomial', line 430, column 9 to column 28)",
  " (in 'binomial', line 430, column 2 to column 38)",
  " (in 'binomial', line 433, column 2 to column 34)",
  " (in 'binomial', line 434, column 9 to column 27)",
  " (in 'binomial', line 434, column 2 to column 37)",
  " (in 'binomial', line 435, column 2 to column 31)",
  " (in 'binomial', line 439, column 18 to column 19)",
  " (in 'binomial', line 439, column 2 to column 33)",
  " (in 'binomial', line 440, column 2 to column 42)",
  " (in 'binomial', line 441, column 2 to column 36)",
  " (in 'binomial', line 442, column 18 to column 52)",
  " (in 'binomial', line 442, column 2 to column 77)",
  " (in 'binomial', line 443, column 9 to column 10)",
  " (in 'binomial', line 443, column 2 to column 23)",
  " (in 'binomial', line 444, column 2 to column 32)",
  " (in 'binomial', line 445, column 2 to column 35)",
  " (in 'binomial', line 446, column 18 to column 52)",
  " (in 'binomial', line 446, column 2 to column 76)",
  " (in 'binomial', line 447, column 18 to column 19)",
  " (in 'binomial', line 447, column 2 to column 30)",
  " (in 'binomial', line 448, column 2 to column 39)",
  " (in 'binomial', line 449, column 2 to column 33)",
  " (in 'binomial', line 450, column 18 to column 52)",
  " (in 'binomial', line 450, column 2 to column 74)",
  " (in 'binomial', line 451, column 2 to column 32)",
  " (in 'binomial', line 452, column 2 to column 35)",
  " (in 'binomial', line 453, column 2 to column 24)",
  " (in 'binomial', line 454, column 2 to column 27)",
  " (in 'binomial', line 455, column 8 to column 31)",
  " (in 'binomial', line 455, column 2 to column 58)",
  " (in 'binomial', line 460, column 2 to column 17)",
  " (in 'binomial', line 461, column 8 to column 9)",
  " (in 'binomial', line 461, column 2 to column 26)",
  " (in 'binomial', line 462, column 8 to column 9)",
  " (in 'binomial', line 462, column 2 to column 26)",
  " (in 'binomial', line 463, column 2 to column 17)",
  " (in 'binomial', line 464, column 2 to column 27)",
  " (in 'binomial', line 467, column 18 to column 19)",
  " (in 'binomial', line 467, column 2 to column 27)",
  " (in 'binomial', line 468, column 18 to column 19)",
  " (in 'binomial', line 468, column 2 to column 27)",
  " (in 'binomial', line 469, column 2 to column 33)",
  " (in 'binomial', line 470, column 8 to column 25)",
  " (in 'binomial', line 470, column 2 to column 55)",
  " (in 'binomial', line 471, column 2 to column 34)",
  " (in 'binomial', line 472, column 8 to column 26)",
  " (in 'binomial', line 472, column 2 to column 57)",
  " (in 'binomial', line 475, column 2 to column 28)",
  " (in 'binomial', line 476, column 9 to column 21)",
  " (in 'binomial', line 476, column 2 to column 25)",
  " (in 'binomial', line 477, column 8 to column 20)",
  " (in 'binomial', line 477, column 2 to column 48)",
  " (in 'binomial', line 478, column 8 to column 25)",
  " (in 'binomial', line 478, column 2 to column 61)",
  " (in 'binomial', line 479, column 2 to column 36)",
  " (in 'binomial', line 482, column 2 to column 28)",
  " (in 'binomial', line 483, column 8 to column 28)",
  " (in 'binomial', line 483, column 30 to column 31)",
  " (in 'binomial', line 483, column 2 to line 485, column 60)",
  " (in 'binomial', line 488, column 2 to column 27)",
  " (in 'binomial', line 489, column 2 to column 48)",
  " (in 'binomial', line 490, column 2 to column 36)",
  " (in 'binomial', line 491, column 2 to column 42)",
  " (in 'binomial', line 492, column 2 to column 23)",
  " (in 'binomial', line 493, column 8 to column 25)",
  " (in 'binomial', line 493, column 2 to column 47)",
  " (in 'binomial', line 494, column 2 to column 18)",
  " (in 'binomial', line 498, column 7 to column 14)",
  " (in 'binomial', line 497, column 28 to column 35)",
  " (in 'binomial', line 497, column 7 to line 498, column 14)",
  " (in 'binomial', line 496, column 28 to column 35)",
  " (in 'binomial', line 496, column 7 to line 498, column 14)",
  " (in 'binomial', line 495, column 23 to column 30)",
  " (in 'binomial', line 495, column 2 to line 498, column 14)",
  " (in 'binomial', line 503, column 8 to column 38)",
  " (in 'binomial', line 504, column 8 to column 17)",
  " (in 'binomial', line 502, column 24 to line 505, column 7)",
  " (in 'binomial', line 502, column 6 to line 505, column 7)",
  " (in 'binomial', line 501, column 18 to line 506, column 5)",
  " (in 'binomial', line 501, column 4 to line 506, column 5)",
  " (in 'binomial', line 507, column 22 to column 42)",
  " (in 'binomial', line 507, column 4 to column 42)",
  " (in 'binomial', line 500, column 17 to line 508, column 3)",
  " (in 'binomial', line 500, column 2 to line 508, column 3)",
  " (in 'binomial', line 511, column 8 to column 21)",
  " (in 'binomial', line 514, column 9 to column 47)",
  " (in 'binomial', line 515, column 9 to column 17)",
  " (in 'binomial', line 516, column 18 to column 57)",
  " (in 'binomial', line 517, column 8 to column 10)",
  " (in 'binomial', line 518, column 8 to column 10)",
  " (in 'binomial', line 518, column 28 to column 29)",
  " (in 'binomial', line 519, column 8 to column 14)",
  " (in 'binomial', line 520, column 8 to column 42)",
  " (in 'binomial', line 520, column 60 to column 61)",
  " (in 'binomial', line 521, column 8 to column 23)",
  " (in 'binomial', line 522, column 9 to column 10)",
  " (in 'binomial', line 523, column 9 to column 16)",
  " (in 'binomial', line 524, column 26 to column 33)",
  " (in 'binomial', line 525, column 18 to column 35)",
  " (in 'binomial', line 526, column 18 to column 19)",
  " (in 'binomial', line 531, column 9 to column 10)",
  " (in 'binomial', line 532, column 9 to column 17)",
  " (in 'binomial', line 533, column 9 to column 48)",
  " (in 'binomial', line 534, column 9 to column 10)",
  " (in 'binomial', line 535, column 9 to column 20)",
  " (in 'binomial', line 694, column 8 to column 21)",
  " (in 'binomial', line 44, column 11 to column 22)",
  " (in 'binomial', line 44, column 4 to column 32)",
  " (in 'binomial', line 45, column 4 to column 22)",
  " (in 'binomial', line 46, column 4 to column 21)",
  " (in 'binomial', line 47, column 4 to column 21)",
  " (in 'binomial', line 48, column 4 to column 25)",
  " (in 'binomial', line 52, column 6 to column 20)",
  " (in 'binomial', line 59, column 15 to column 17)",
  " (in 'binomial', line 59, column 18 to column 20)",
  " (in 'binomial', line 59, column 8 to column 26)",
  " (in 'binomial', line 60, column 8 to column 21)",
  " (in 'binomial', line 61, column 8 to column 17)",
  " (in 'binomial', line 62, column 8 to column 69)",
  " (in 'binomial', line 63, column 15 to column 17)",
  " (in 'binomial', line 63, column 8 to column 53)",
  " (in 'binomial', line 64, column 8 to column 22)",
  " (in 'binomial', line 67, column 8 to column 24)",
  " (in 'binomial', line 68, column 8 to column 42)",
  " (in 'binomial', line 69, column 8 to column 27)",
  " (in 'binomial', line 72, column 8 to column 42)",
  " (in 'binomial', line 73, column 8 to column 40)",
  " (in 'binomial', line 74, column 8 to column 22)",
  " (in 'binomial', line 75, column 8 to column 53)",
  " (in 'binomial', line 76, column 8 to column 33)",
  " (in 'binomial', line 79, column 10 to column 26)",
  " (in 'binomial', line 80, column 17 to column 18)",
  " (in 'binomial', line 80, column 10 to column 54)",
  " (in 'binomial', line 81, column 10 to column 78)",
  " (in 'binomial', line 82, column 10 to column 24)",
  " (in 'binomial', line 83, column 10 to column 46)",
  " (in 'binomial', line 84, column 24 to column 61)",
  " (in 'binomial', line 84, column 10 to column 61)",
  " (in 'binomial', line 85, column 10 to column 61)",
  " (in 'binomial', line 86, column 10 to column 24)",
  " (in 'binomial', line 78, column 30 to line 87, column 9)",
  " (in 'binomial', line 78, column 8 to line 87, column 9)",
  " (in 'binomial', line 91, column 10 to column 43)",
  " (in 'binomial', line 92, column 10 to column 28)",
  " (in 'binomial', line 90, column 40 to line 93, column 9)",
  " (in 'binomial', line 90, column 24 to line 93, column 9)",
  " (in 'binomial', line 90, column 8 to line 93, column 9)",
  " (in 'binomial', line 58, column 11 to line 94, column 7)",
  " (in 'binomial', line 54, column 8 to column 63)",
  " (in 'binomial', line 56, column 8 to column 26)",
  " (in 'binomial', line 53, column 19 to line 57, column 7)",
  " (in 'binomial', line 53, column 6 to line 94, column 7)",
  " (in 'binomial', line 51, column 25 to line 95, column 5)",
  " (in 'binomial', line 51, column 4 to line 95, column 5)",
  " (in 'binomial', line 96, column 4 to column 19)",
  " (in 'binomial', line 43, column 46 to line 97, column 3)",
  " (in 'binomial', line 111, column 11 to column 20)",
  " (in 'binomial', line 111, column 4 to column 24)",
  " (in 'binomial', line 112, column 4 to column 19)",
  " (in 'binomial', line 113, column 4 to column 25)",
  " (in 'binomial', line 115, column 6 to column 20)",
  " (in 'binomial', line 124, column 15 to column 17)",
  " (in 'binomial', line 124, column 18 to column 20)",
  " (in 'binomial', line 124, column 8 to column 50)",
  " (in 'binomial', line 126, column 10 to column 43)",
  " (in 'binomial', line 127, column 10 to column 28)",
  " (in 'binomial', line 129, column 12 to column 45)",
  " (in 'binomial', line 130, column 12 to column 30)",
  " (in 'binomial', line 128, column 29 to line 131, column 11)",
  " (in 'binomial', line 128, column 10 to line 131, column 11)",
  " (in 'binomial', line 125, column 24 to line 132, column 9)",
  " (in 'binomial', line 125, column 8 to line 132, column 9)",
  " (in 'binomial', line 134, column 17 to column 19)",
  " (in 'binomial', line 134, column 10 to column 59)",
  " (in 'binomial', line 135, column 10 to column 22)",
  " (in 'binomial', line 136, column 26 to column 50)",
  " (in 'binomial', line 136, column 10 to column 50)",
  " (in 'binomial', line 137, column 10 to column 27)",
  " (in 'binomial', line 133, column 26 to line 138, column 9)",
  " (in 'binomial', line 133, column 8 to line 138, column 9)",
  " (in 'binomial', line 123, column 11 to line 139, column 7)",
  " (in 'binomial', line 117, column 8 to column 51)",
  " (in 'binomial', line 119, column 10 to column 40)",
  " (in 'binomial', line 118, column 8 to line 119, column 40)",
  " (in 'binomial', line 120, column 8 to column 23)",
  " (in 'binomial', line 121, column 8 to column 26)",
  " (in 'binomial', line 116, column 19 to line 122, column 7)",
  " (in 'binomial', line 116, column 6 to line 139, column 7)",
  " (in 'binomial', line 114, column 25 to line 140, column 5)",
  " (in 'binomial', line 114, column 4 to line 140, column 5)",
  " (in 'binomial', line 141, column 4 to column 13)",
  " (in 'binomial', line 110, column 74 to line 142, column 3)",
  " (in 'binomial', line 162, column 4 to column 16)",
  " (in 'binomial', line 163, column 4 to column 20)",
  " (in 'binomial', line 164, column 4 to column 20)",
  " (in 'binomial', line 165, column 4 to column 34)",
  " (in 'binomial', line 166, column 4 to column 34)",
  " (in 'binomial', line 168, column 13 to column 21)",
  " (in 'binomial', line 168, column 6 to column 30)",
  " (in 'binomial', line 169, column 13 to column 21)",
  " (in 'binomial', line 169, column 6 to column 30)",
  " (in 'binomial', line 170, column 6 to column 59)",
  " (in 'binomial', line 171, column 6 to column 19)",
  " (in 'binomial', line 172, column 6 to column 21)",
  " (in 'binomial', line 173, column 6 to column 21)",
  " (in 'binomial', line 175, column 8 to column 18)",
  " (in 'binomial', line 176, column 8 to column 28)",
  " (in 'binomial', line 177, column 8 to column 23)",
  " (in 'binomial', line 174, column 28 to line 178, column 7)",
  " (in 'binomial', line 174, column 6 to line 178, column 7)",
  " (in 'binomial', line 179, column 6 to column 74)",
  " (in 'binomial', line 180, column 6 to column 26)",
  " (in 'binomial', line 167, column 33 to line 181, column 5)",
  " (in 'binomial', line 167, column 19 to line 181, column 5)",
  " (in 'binomial', line 167, column 4 to line 181, column 5)",
  " (in 'binomial', line 182, column 4 to column 38)",
  " (in 'binomial', line 183, column 4 to column 38)",
  " (in 'binomial', line 184, column 4 to column 14)",
  " (in 'binomial', line 161, column 38 to line 185, column 3)",
  " (in 'binomial', line 200, column 4 to column 25)",
  " (in 'binomial', line 201, column 11 to column 12)",
  " (in 'binomial', line 201, column 4 to column 50)",
  " (in 'binomial', line 202, column 4 to column 78)",
  " (in 'binomial', line 203, column 11 to column 12)",
  " (in 'binomial', line 203, column 4 to column 39)",
  " (in 'binomial', line 204, column 11 to column 12)",
  " (in 'binomial', line 204, column 4 to column 82)",
  " (in 'binomial', line 205, column 4 to column 40)",
  " (in 'binomial', line 199, column 70 to line 206, column 3)",
  " (in 'binomial', line 221, column 4 to column 25)",
  " (in 'binomial', line 222, column 11 to column 12)",
  " (in 'binomial', line 222, column 4 to column 50)",
  " (in 'binomial', line 223, column 11 to column 12)",
  " (in 'binomial', line 223, column 4 to column 47)",
  " (in 'binomial', line 224, column 4 to column 78)",
  " (in 'binomial', line 225, column 11 to column 12)",
  " (in 'binomial', line 225, column 4 to column 50)",
  " (in 'binomial', line 226, column 11 to column 12)",
  " (in 'binomial', line 226, column 4 to line 227, column 69)",
  " (in 'binomial', line 228, column 4 to column 40)",
  " (in 'binomial', line 220, column 74 to line 229, column 3)",
  " (in 'binomial', line 242, column 4 to column 24)",
  " (in 'binomial', line 243, column 4 to column 21)",
  " (in 'binomial', line 244, column 4 to column 22)",
  " (in 'binomial', line 245, column 4 to column 22)",
  " (in 'binomial', line 246, column 4 to column 22)",
  " (in 'binomial', line 247, column 4 to column 26)",
  " (in 'binomial', line 248, column 4 to column 24)",
  " (in 'binomial', line 249, column 4 to column 25)",
  " (in 'binomial', line 250, column 4 to line 252, column 84)",
  " (in 'binomial', line 241, column 28 to line 253, column 3)",
  " (in 'binomial', line 264, column 10 to column 11)",
  " (in 'binomial', line 264, column 12 to column 13)",
  " (in 'binomial', line 264, column 4 to column 21)",
  " (in 'binomial', line 265, column 4 to column 16)",
  " (in 'binomial', line 267, column 6 to column 22)",
  " (in 'binomial', line 268, column 6 to column 15)",
  " (in 'binomial', line 266, column 45 to line 269, column 5)",
  " (in 'binomial', line 266, column 30 to line 269, column 5)",
  " (in 'binomial', line 266, column 15 to line 269, column 5)",
  " (in 'binomial', line 266, column 4 to line 269, column 5)",
  " (in 'binomial', line 270, column 4 to column 13)",
  " (in 'binomial', line 263, column 51 to line 271, column 3)",
  " (in 'binomial', line 289, column 21 to column 48)",
  " (in 'binomial', line 289, column 4 to column 48)",
  " (in 'binomial', line 291, column 21 to column 48)",
  " (in 'binomial', line 291, column 6 to column 48)",
  " (in 'binomial', line 292, column 6 to column 15)",
  " (in 'binomial', line 290, column 21 to line 293, column 5)",
  " (in 'binomial', line 290, column 4 to line 293, column 5)",
  " (in 'binomial', line 294, column 4 to column 31)",
  " (in 'binomial', line 288, column 40 to line 295, column 3)",
  " (in 'binomial', line 305, column 34 to column 43)",
  " (in 'binomial', line 305, column 4 to column 43)",
  " (in 'binomial', line 306, column 4 to column 31)",
  " (in 'binomial', line 304, column 40 to line 307, column 3)",
  " (in 'binomial', line 322, column 9 to column 32)",
  " (in 'binomial', line 321, column 24 to column 49)",
  " (in 'binomial', line 321, column 9 to line 322, column 32)",
  " (in 'binomial', line 320, column 24 to column 41)",
  " (in 'binomial', line 320, column 9 to line 322, column 32)",
  " (in 'binomial', line 319, column 24 to column 55)",
  " (in 'binomial', line 319, column 9 to line 322, column 32)",
  " (in 'binomial', line 318, column 24 to column 41)",
  " (in 'binomial', line 318, column 9 to line 322, column 32)",
  " (in 'binomial', line 317, column 24 to column 47)",
  " (in 'binomial', line 317, column 4 to line 322, column 32)",
  " (in 'binomial', line 323, column 4 to column 15)",
  " (in 'binomial', line 316, column 45 to line 324, column 3)",
  " (in 'binomial', line 335, column 4 to column 16)",
  " (in 'binomial', line 353, column 9 to column 32)",
  " (in 'binomial', line 347, column 8 to column 40)",
  " (in 'binomial', line 348, column 8 to column 44)",
  " (in 'binomial', line 349, column 8 to column 47)",
  " (in 'binomial', line 350, column 8 to column 39)",
  " (in 'binomial', line 346, column 35 to line 351, column 7)",
  " (in 'binomial', line 346, column 6 to line 351, column 7)",
  " (in 'binomial', line 345, column 24 to line 352, column 5)",
  " (in 'binomial', line 345, column 9 to line 353, column 32)",
  " (in 'binomial', line 340, column 8 to column 28)",
  " (in 'binomial', line 341, column 8 to column 53)",
  " (in 'binomial', line 342, column 8 to column 39)",
  " (in 'binomial', line 339, column 35 to line 343, column 7)",
  " (in 'binomial', line 339, column 6 to line 343, column 7)",
  " (in 'binomial', line 338, column 24 to line 344, column 5)",
  " (in 'binomial', line 338, column 9 to line 353, column 32)",
  " (in 'binomial', line 337, column 24 to column 83)",
  " (in 'binomial', line 337, column 9 to line 353, column 32)",
  " (in 'binomial', line 336, column 19 to column 62)",
  " (in 'binomial', line 336, column 4 to line 353, column 32)",
  " (in 'binomial', line 354, column 4 to column 14)",
  " (in 'binomial', line 334, column 75 to line 355, column 3)",
  " (in 'binomial', line 365, column 4 to column 22)",
  " (in 'binomial', line 366, column 11 to column 12)",
  " (in 'binomial', line 366, column 4 to column 17)",
  " (in 'binomial', line 375, column 9 to column 32)",
  " (in 'binomial', line 372, column 13 to column 14)",
  " (in 'binomial', line 372, column 6 to column 46)",
  " (in 'binomial', line 373, column 21 to column 69)",
  " (in 'binomial', line 373, column 6 to column 69)",
  " (in 'binomial', line 371, column 24 to line 374, column 5)",
  " (in 'binomial', line 371, column 9 to line 375, column 32)",
  " (in 'binomial', line 369, column 8 to column 62)",
  " (in 'binomial', line 368, column 6 to line 369, column 62)",
  " (in 'binomial', line 367, column 19 to line 370, column 5)",
  " (in 'binomial', line 367, column 4 to line 375, column 32)",
  " (in 'binomial', line 376, column 4 to column 14)",
  " (in 'binomial', line 364, column 75 to line 377, column 3)"};
template <typename T2__, typename T3__, typename T4__, typename T5__,
          typename T6__, typename T7__,
          stan::require_all_t<stan::is_stan_scalar<T2__>,
                              stan::is_col_vector<T3__>,
                              stan::is_vt_not_complex<T3__>,
                              stan::is_col_vector<T4__>,
                              stan::is_vt_not_complex<T4__>,
                              stan::is_col_vector<T5__>,
                              stan::is_vt_not_complex<T5__>,
                              stan::is_col_vector<T6__>,
                              stan::is_vt_not_complex<T6__>,
                              stan::is_col_vector<T7__>,
                              stan::is_vt_not_complex<T7__>>* = nullptr>
Eigen::Matrix<stan::promote_args_t<T2__, stan::base_type_t<T3__>,
                stan::base_type_t<T4__>, stan::base_type_t<T5__>,
                stan::base_type_t<T6__>,
                stan::promote_args_t<stan::base_type_t<T7__>>>,-1,1>
make_theta_L(const int& len_theta_L, const std::vector<int>& p, const T2__&
             dispersion, const T3__& tau_arg__, const T4__& scale_arg__,
             const T5__& zeta_arg__, const T6__& rho_arg__, const T7__&
             z_T_arg__, std::ostream* pstream__);
template <typename T0__, typename T1__,
          stan::require_all_t<stan::is_col_vector<T0__>,
                              stan::is_vt_not_complex<T0__>,
                              stan::is_col_vector<T1__>,
                              stan::is_vt_not_complex<T1__>>* = nullptr>
Eigen::Matrix<stan::promote_args_t<stan::base_type_t<T0__>,
                stan::base_type_t<T1__>>,-1,1>
make_b(const T0__& z_b_arg__, const T1__& theta_L_arg__,
       const std::vector<int>& p, const std::vector<int>& l, std::ostream*
       pstream__);
template <bool propto__, typename T0__, typename T1__, typename T2__,
          typename T3__, typename T4__, typename T5__, typename T6__,
          typename T7__,
          stan::require_all_t<stan::is_col_vector<T0__>,
                              stan::is_vt_not_complex<T0__>,
                              stan::is_col_vector<T1__>,
                              stan::is_vt_not_complex<T1__>,
                              stan::is_col_vector<T2__>,
                              stan::is_vt_not_complex<T2__>,
                              stan::is_col_vector<T3__>,
                              stan::is_vt_not_complex<T3__>,
                              stan::is_col_vector<T4__>,
                              stan::is_vt_not_complex<T4__>,
                              stan::is_stan_scalar<T5__>,
                              stan::is_stan_scalar<T6__>,
                              stan::is_col_vector<T7__>,
                              stan::is_vt_not_complex<T7__>>* = nullptr>
stan::promote_args_t<stan::base_type_t<T0__>, stan::base_type_t<T1__>,
  stan::base_type_t<T2__>, stan::base_type_t<T3__>, stan::base_type_t<T4__>,
  stan::promote_args_t<T5__, T6__, stan::base_type_t<T7__>>>
decov_lpdf(const T0__& z_b_arg__, const T1__& z_T_arg__, const T2__&
           rho_arg__, const T3__& zeta_arg__, const T4__& tau_arg__,
           const std::vector<T5__>& regularization, const std::vector<T6__>&
           delta, const T7__& shape_arg__, const int& t,
           const std::vector<int>& p, std::ostream* pstream__);
template <typename T0__, typename T1__, typename T2__, typename T3__,
          typename T4__, typename T5__,
          stan::require_all_t<stan::is_col_vector<T0__>,
                              stan::is_vt_not_complex<T0__>,
                              stan::is_stan_scalar<T1__>,
                              stan::is_stan_scalar<T2__>,
                              stan::is_stan_scalar<T3__>,
                              stan::is_stan_scalar<T4__>,
                              stan::is_stan_scalar<T5__>>* = nullptr>
Eigen::Matrix<stan::promote_args_t<stan::base_type_t<T0__>, T1__, T2__, T3__,
                T4__, stan::promote_args_t<T5__>>,-1,1>
hs_prior(const T0__& z_beta_arg__, const std::vector<T1__>& global,
         const std::vector<Eigen::Matrix<T2__,-1,1>>& local, const T3__&
         global_prior_scale, const T4__& error_scale, const T5__& c2,
         std::ostream* pstream__);
template <typename T0__, typename T1__, typename T2__, typename T3__,
          typename T4__, typename T5__,
          stan::require_all_t<stan::is_col_vector<T0__>,
                              stan::is_vt_not_complex<T0__>,
                              stan::is_stan_scalar<T1__>,
                              stan::is_stan_scalar<T2__>,
                              stan::is_stan_scalar<T3__>,
                              stan::is_stan_scalar<T4__>,
                              stan::is_stan_scalar<T5__>>* = nullptr>
Eigen::Matrix<stan::promote_args_t<stan::base_type_t<T0__>, T1__, T2__, T3__,
                T4__, stan::promote_args_t<T5__>>,-1,1>
hsplus_prior(const T0__& z_beta_arg__, const std::vector<T1__>& global,
             const std::vector<Eigen::Matrix<T2__,-1,1>>& local, const T3__&
             global_prior_scale, const T4__& error_scale, const T5__& c2,
             std::ostream* pstream__);
template <typename T0__, typename T1__,
          stan::require_all_t<stan::is_stan_scalar<T0__>,
                              stan::is_stan_scalar<T1__>>* = nullptr>
stan::promote_args_t<T0__, T1__>
CFt(const T0__& z, const T1__& df, std::ostream* pstream__);
std::vector<std::vector<int>>
make_V(const int& N, const int& t, const std::vector<int>& v, std::ostream*
       pstream__);
double
make_lower(const int& family, const int& link, std::ostream* pstream__);
double
make_upper(const int& family, const int& link, std::ostream* pstream__);
template <typename T0__,
          stan::require_all_t<stan::is_col_vector<T0__>,
                              stan::is_vt_not_complex<T0__>>* = nullptr>
Eigen::Matrix<stan::promote_args_t<stan::base_type_t<T0__>>,-1,1>
linkinv_binom(const T0__& eta_arg__, const int& link, std::ostream* pstream__);
template <bool propto__, typename T2__,
          stan::require_all_t<stan::is_col_vector<T2__>,
                              stan::is_vt_not_complex<T2__>>* = nullptr>
stan::promote_args_t<stan::base_type_t<T2__>>
binom_lpmf(const std::vector<int>& y, const std::vector<int>& trials,
           const T2__& eta_arg__, const int& link, std::ostream* pstream__);
template <typename T2__,
          stan::require_all_t<stan::is_col_vector<T2__>,
                              stan::is_vt_not_complex<T2__>>* = nullptr>
Eigen::Matrix<stan::promote_args_t<stan::base_type_t<T2__>>,-1,1>
pw_binom(const std::vector<int>& y, const std::vector<int>& trials,
         const T2__& eta_arg__, const int& link, std::ostream* pstream__);
template <typename T2__, typename T3__, typename T4__, typename T5__,
          typename T6__, typename T7__,
          stan::require_all_t<stan::is_stan_scalar<T2__>,
                              stan::is_col_vector<T3__>,
                              stan::is_vt_not_complex<T3__>,
                              stan::is_col_vector<T4__>,
                              stan::is_vt_not_complex<T4__>,
                              stan::is_col_vector<T5__>,
                              stan::is_vt_not_complex<T5__>,
                              stan::is_col_vector<T6__>,
                              stan::is_vt_not_complex<T6__>,
                              stan::is_col_vector<T7__>,
                              stan::is_vt_not_complex<T7__>>*>
Eigen::Matrix<stan::promote_args_t<T2__, stan::base_type_t<T3__>,
                stan::base_type_t<T4__>, stan::base_type_t<T5__>,
                stan::base_type_t<T6__>,
                stan::promote_args_t<stan::base_type_t<T7__>>>,-1,1>
make_theta_L(const int& len_theta_L, const std::vector<int>& p, const T2__&
             dispersion, const T3__& tau_arg__, const T4__& scale_arg__,
             const T5__& zeta_arg__, const T6__& rho_arg__, const T7__&
             z_T_arg__, std::ostream* pstream__) {
  using local_scalar_t__ = stan::promote_args_t<T2__,
                             stan::base_type_t<T3__>,
                             stan::base_type_t<T4__>,
                             stan::base_type_t<T5__>,
                             stan::base_type_t<T6__>,
                             stan::promote_args_t<stan::base_type_t<T7__>>>;
  int current_statement__ = 0;
  const auto& tau = stan::math::to_ref(tau_arg__);
  const auto& scale = stan::math::to_ref(scale_arg__);
  const auto& zeta = stan::math::to_ref(zeta_arg__);
  const auto& rho = stan::math::to_ref(rho_arg__);
  const auto& z_T = stan::math::to_ref(z_T_arg__);
  static constexpr bool propto__ = true;
  // suppress unused var warning
  (void) propto__;
  local_scalar_t__ DUMMY_VAR__(std::numeric_limits<double>::quiet_NaN());
  // suppress unused var warning
  (void) DUMMY_VAR__;
  try {
    current_statement__ = 351;
    stan::math::validate_non_negative_index("theta_L", "len_theta_L",
      len_theta_L);
    Eigen::Matrix<local_scalar_t__,-1,1> theta_L =
      Eigen::Matrix<local_scalar_t__,-1,1>::Constant(len_theta_L,
        DUMMY_VAR__);
    int zeta_mark = std::numeric_limits<int>::min();
    current_statement__ = 353;
    zeta_mark = 1;
    int rho_mark = std::numeric_limits<int>::min();
    current_statement__ = 354;
    rho_mark = 1;
    int z_T_mark = std::numeric_limits<int>::min();
    current_statement__ = 355;
    z_T_mark = 1;
    int theta_L_mark = std::numeric_limits<int>::min();
    current_statement__ = 356;
    theta_L_mark = 1;
    current_statement__ = 398;
    for (int i = 1; i <= stan::math::size(p); ++i) {
      int nc = std::numeric_limits<int>::min();
      current_statement__ = 357;
      nc = stan::model::rvalue(p, "p", stan::model::index_uni(i));
      current_statement__ = 396;
      if (stan::math::logical_eq(nc, 1)) {
        current_statement__ = 393;
        stan::model::assign(theta_L,
          ((stan::model::rvalue(tau, "tau", stan::model::index_uni(i)) *
          stan::model::rvalue(scale, "scale", stan::model::index_uni(i))) *
          dispersion), "assigning variable theta_L",
          stan::model::index_uni(theta_L_mark));
        current_statement__ = 394;
        theta_L_mark = (theta_L_mark + 1);
      } else {
        current_statement__ = 358;
        stan::math::validate_non_negative_index("T_i", "nc", nc);
        current_statement__ = 359;
        stan::math::validate_non_negative_index("T_i", "nc", nc);
        Eigen::Matrix<local_scalar_t__,-1,-1> T_i =
          Eigen::Matrix<local_scalar_t__,-1,-1>::Constant(nc, nc,
            DUMMY_VAR__);
        local_scalar_t__ std_dev = DUMMY_VAR__;
        local_scalar_t__ T21 = DUMMY_VAR__;
        local_scalar_t__ trace_T_i = DUMMY_VAR__;
        current_statement__ = 363;
        trace_T_i = (stan::math::square(
                       ((stan::model::rvalue(tau, "tau",
                           stan::model::index_uni(i)) *
                       stan::model::rvalue(scale, "scale",
                         stan::model::index_uni(i))) * dispersion))
          * nc);
        current_statement__ = 364;
        stan::math::validate_non_negative_index("pi", "nc", nc);
        Eigen::Matrix<local_scalar_t__,-1,1> pi =
          Eigen::Matrix<local_scalar_t__,-1,1>::Constant(nc, DUMMY_VAR__);
        current_statement__ = 365;
        stan::model::assign(pi, stan::math::segment(zeta, zeta_mark, nc),
          "assigning variable pi");
        current_statement__ = 366;
        stan::model::assign(pi,
          stan::math::divide(stan::model::deep_copy(pi), stan::math::sum(pi)),
          "assigning variable pi");
        current_statement__ = 367;
        zeta_mark = (zeta_mark + nc);
        current_statement__ = 368;
        std_dev = stan::math::sqrt(
                    (stan::model::rvalue(pi, "pi", stan::model::index_uni(1))
                    * trace_T_i));
        current_statement__ = 369;
        stan::model::assign(T_i, std_dev, "assigning variable T_i",
          stan::model::index_uni(1), stan::model::index_uni(1));
        current_statement__ = 370;
        std_dev = stan::math::sqrt(
                    (stan::model::rvalue(pi, "pi", stan::model::index_uni(2))
                    * trace_T_i));
        current_statement__ = 371;
        T21 = ((2.0 *
          stan::model::rvalue(rho, "rho", stan::model::index_uni(rho_mark)))
          - 1.0);
        current_statement__ = 372;
        rho_mark = (rho_mark + 1);
        current_statement__ = 373;
        stan::model::assign(T_i, (std_dev *
          stan::math::sqrt((1.0 - stan::math::square(T21)))),
          "assigning variable T_i", stan::model::index_uni(2),
          stan::model::index_uni(2));
        current_statement__ = 374;
        stan::model::assign(T_i, (std_dev * T21), "assigning variable T_i",
          stan::model::index_uni(2), stan::model::index_uni(1));
        current_statement__ = 386;
        for (int r = 2; r <= (nc - 1); ++r) {
          int rp1 = std::numeric_limits<int>::min();
          current_statement__ = 375;
          rp1 = (r + 1);
          current_statement__ = 376;
          stan::math::validate_non_negative_index("T_row", "r", r);
          Eigen::Matrix<local_scalar_t__,-1,1> T_row =
            Eigen::Matrix<local_scalar_t__,-1,1>::Constant(r, DUMMY_VAR__);
          current_statement__ = 377;
          stan::model::assign(T_row, stan::math::segment(z_T, z_T_mark, r),
            "assigning variable T_row");
          local_scalar_t__ scale_factor = DUMMY_VAR__;
          current_statement__ = 378;
          scale_factor = (stan::math::sqrt(
                            (stan::model::rvalue(rho, "rho",
                               stan::model::index_uni(rho_mark)) /
                            stan::math::dot_self(T_row)))
            * std_dev);
          current_statement__ = 379;
          z_T_mark = (z_T_mark + r);
          current_statement__ = 380;
          std_dev = stan::math::sqrt(
                      (stan::model::rvalue(pi, "pi",
                         stan::model::index_uni(rp1)) * trace_T_i));
          current_statement__ = 382;
          for (int c = 1; c <= r; ++c) {
            current_statement__ = 381;
            stan::model::assign(T_i,
              (stan::model::rvalue(T_row, "T_row", stan::model::index_uni(c))
              * scale_factor), "assigning variable T_i",
              stan::model::index_uni(rp1), stan::model::index_uni(c));
          }
          current_statement__ = 383;
          stan::model::assign(T_i,
            (stan::math::sqrt((1.0 -
               stan::model::rvalue(rho, "rho",
                 stan::model::index_uni(rho_mark)))) * std_dev),
            "assigning variable T_i", stan::model::index_uni(rp1),
            stan::model::index_uni(rp1));
          current_statement__ = 384;
          rho_mark = (rho_mark + 1);
        }
        current_statement__ = 391;
        for (int c = 1; c <= nc; ++c) {
          current_statement__ = 390;
          for (int r = c; r <= nc; ++r) {
            current_statement__ = 387;
            stan::model::assign(theta_L,
              stan::model::rvalue(T_i, "T_i", stan::model::index_uni(r),
                stan::model::index_uni(c)), "assigning variable theta_L",
              stan::model::index_uni(theta_L_mark));
            current_statement__ = 388;
            theta_L_mark = (theta_L_mark + 1);
          }
        }
      }
    }
    current_statement__ = 399;
    return theta_L;
  } catch (const std::exception& e) {
    stan::lang::rethrow_located(e, locations_array__[current_statement__]);
  }
}
template <typename T0__, typename T1__,
          stan::require_all_t<stan::is_col_vector<T0__>,
                              stan::is_vt_not_complex<T0__>,
                              stan::is_col_vector<T1__>,
                              stan::is_vt_not_complex<T1__>>*>
Eigen::Matrix<stan::promote_args_t<stan::base_type_t<T0__>,
                stan::base_type_t<T1__>>,-1,1>
make_b(const T0__& z_b_arg__, const T1__& theta_L_arg__,
       const std::vector<int>& p, const std::vector<int>& l, std::ostream*
       pstream__) {
  using local_scalar_t__ = stan::promote_args_t<stan::base_type_t<T0__>,
                             stan::base_type_t<T1__>>;
  int current_statement__ = 0;
  const auto& z_b = stan::math::to_ref(z_b_arg__);
  const auto& theta_L = stan::math::to_ref(theta_L_arg__);
  static constexpr bool propto__ = true;
  // suppress unused var warning
  (void) propto__;
  local_scalar_t__ DUMMY_VAR__(std::numeric_limits<double>::quiet_NaN());
  // suppress unused var warning
  (void) DUMMY_VAR__;
  try {
    current_statement__ = 401;
    stan::math::validate_non_negative_index("b", "rows(z_b)",
      stan::math::rows(z_b));
    Eigen::Matrix<local_scalar_t__,-1,1> b =
      Eigen::Matrix<local_scalar_t__,-1,1>::Constant(stan::math::rows(z_b),
        DUMMY_VAR__);
    int b_mark = std::numeric_limits<int>::min();
    current_statement__ = 403;
    b_mark = 1;
    int theta_L_mark = std::numeric_limits<int>::min();
    current_statement__ = 404;
    theta_L_mark = 1;
    current_statement__ = 434;
    for (int i = 1; i <= stan::math::size(p); ++i) {
      int nc = std::numeric_limits<int>::min();
      current_statement__ = 405;
      nc = stan::model::rvalue(p, "p", stan::model::index_uni(i));
      current_statement__ = 432;
      if (stan::math::logical_eq(nc, 1)) {
        local_scalar_t__ theta_L_start = DUMMY_VAR__;
        current_statement__ = 426;
        theta_L_start = stan::model::rvalue(theta_L, "theta_L",
                          stan::model::index_uni(theta_L_mark));
        current_statement__ = 428;
        for (int s = b_mark; s <= ((b_mark +
             stan::model::rvalue(l, "l", stan::model::index_uni(i))) -
             1); ++s) {
          current_statement__ = 427;
          stan::model::assign(b, (theta_L_start *
            stan::model::rvalue(z_b, "z_b", stan::model::index_uni(s))),
            "assigning variable b", stan::model::index_uni(s));
        }
        current_statement__ = 429;
        b_mark = (b_mark +
          stan::model::rvalue(l, "l", stan::model::index_uni(i)));
        current_statement__ = 430;
        theta_L_mark = (theta_L_mark + 1);
      } else {
        current_statement__ = 406;
        stan::math::validate_non_negative_index("T_i", "nc", nc);
        current_statement__ = 407;
        stan::math::validate_non_negative_index("T_i", "nc", nc);
        Eigen::Matrix<local_scalar_t__,-1,-1> T_i =
          Eigen::Matrix<local_scalar_t__,-1,-1>::Constant(nc, nc,
            DUMMY_VAR__);
        current_statement__ = 408;
        stan::model::assign(T_i, stan::math::rep_matrix(0, nc, nc),
          "assigning variable T_i");
        current_statement__ = 416;
        for (int c = 1; c <= nc; ++c) {
          current_statement__ = 409;
          stan::model::assign(T_i,
            stan::model::rvalue(theta_L, "theta_L",
              stan::model::index_uni(theta_L_mark)),
            "assigning variable T_i", stan::model::index_uni(c),
            stan::model::index_uni(c));
          current_statement__ = 410;
          theta_L_mark = (theta_L_mark + 1);
          current_statement__ = 414;
          for (int r = (c + 1); r <= nc; ++r) {
            current_statement__ = 411;
            stan::model::assign(T_i,
              stan::model::rvalue(theta_L, "theta_L",
                stan::model::index_uni(theta_L_mark)),
              "assigning variable T_i", stan::model::index_uni(r),
              stan::model::index_uni(c));
            current_statement__ = 412;
            theta_L_mark = (theta_L_mark + 1);
          }
        }
        current_statement__ = 424;
        for (int j = 1; j <=
             stan::model::rvalue(l, "l", stan::model::index_uni(i)); ++j) {
          current_statement__ = 417;
          stan::math::validate_non_negative_index("temp", "nc", nc);
          Eigen::Matrix<local_scalar_t__,-1,1> temp =
            Eigen::Matrix<local_scalar_t__,-1,1>::Constant(nc, DUMMY_VAR__);
          current_statement__ = 418;
          stan::model::assign(temp,
            stan::math::multiply(T_i, stan::math::segment(z_b, b_mark, nc)),
            "assigning variable temp");
          current_statement__ = 419;
          b_mark = (b_mark - 1);
          current_statement__ = 421;
          for (int s = 1; s <= nc; ++s) {
            current_statement__ = 420;
            stan::model::assign(b,
              stan::model::rvalue(temp, "temp", stan::model::index_uni(s)),
              "assigning variable b", stan::model::index_uni((b_mark + s)));
          }
          current_statement__ = 422;
          b_mark = (b_mark + (nc + 1));
        }
      }
    }
    current_statement__ = 435;
    return b;
  } catch (const std::exception& e) {
    stan::lang::rethrow_located(e, locations_array__[current_statement__]);
  }
}
template <bool propto__, typename T0__, typename T1__, typename T2__,
          typename T3__, typename T4__, typename T5__, typename T6__,
          typename T7__,
          stan::require_all_t<stan::is_col_vector<T0__>,
                              stan::is_vt_not_complex<T0__>,
                              stan::is_col_vector<T1__>,
                              stan::is_vt_not_complex<T1__>,
                              stan::is_col_vector<T2__>,
                              stan::is_vt_not_complex<T2__>,
                              stan::is_col_vector<T3__>,
                              stan::is_vt_not_complex<T3__>,
                              stan::is_col_vector<T4__>,
                              stan::is_vt_not_complex<T4__>,
                              stan::is_stan_scalar<T5__>,
                              stan::is_stan_scalar<T6__>,
                              stan::is_col_vector<T7__>,
                              stan::is_vt_not_complex<T7__>>*>
stan::promote_args_t<stan::base_type_t<T0__>, stan::base_type_t<T1__>,
  stan::base_type_t<T2__>, stan::base_type_t<T3__>, stan::base_type_t<T4__>,
  stan::promote_args_t<T5__, T6__, stan::base_type_t<T7__>>>
decov_lpdf(const T0__& z_b_arg__, const T1__& z_T_arg__, const T2__&
           rho_arg__, const T3__& zeta_arg__, const T4__& tau_arg__,
           const std::vector<T5__>& regularization, const std::vector<T6__>&
           delta, const T7__& shape_arg__, const int& t,
           const std::vector<int>& p, std::ostream* pstream__) {
  using local_scalar_t__ = stan::promote_args_t<stan::base_type_t<T0__>,
                             stan::base_type_t<T1__>,
                             stan::base_type_t<T2__>,
                             stan::base_type_t<T3__>,
                             stan::base_type_t<T4__>,
                             stan::promote_args_t<T5__, T6__,
                               stan::base_type_t<T7__>>>;
  int current_statement__ = 0;
  const auto& z_b = stan::math::to_ref(z_b_arg__);
  const auto& z_T = stan::math::to_ref(z_T_arg__);
  const auto& rho = stan::math::to_ref(rho_arg__);
  const auto& zeta = stan::math::to_ref(zeta_arg__);
  const auto& tau = stan::math::to_ref(tau_arg__);
  const auto& shape = stan::math::to_ref(shape_arg__);
  local_scalar_t__ DUMMY_VAR__(std::numeric_limits<double>::quiet_NaN());
  // suppress unused var warning
  (void) DUMMY_VAR__;
  try {
    local_scalar_t__ lp = DUMMY_VAR__;
    current_statement__ = 437;
    lp = 0;
    int pos_reg = std::numeric_limits<int>::min();
    current_statement__ = 438;
    pos_reg = 1;
    int pos_rho = std::numeric_limits<int>::min();
    current_statement__ = 439;
    pos_rho = 1;
    current_statement__ = 440;
    lp = (lp + stan::math::normal_lpdf<false>(z_b, 0, 1));
    current_statement__ = 441;
    lp = (lp + stan::math::normal_lpdf<false>(z_T, 0, 1));
    current_statement__ = 459;
    for (int i = 1; i <= t; ++i) {
      current_statement__ = 458;
      if (stan::math::logical_gt(
            stan::model::rvalue(p, "p", stan::model::index_uni(i)), 1)) {
        current_statement__ = 442;
        stan::math::validate_non_negative_index("shape1", "p[i] - 1",
          (stan::model::rvalue(p, "p", stan::model::index_uni(i)) - 1));
        Eigen::Matrix<local_scalar_t__,-1,1> shape1 =
          Eigen::Matrix<local_scalar_t__,-1,1>::Constant((stan::model::rvalue(
                                                            p, "p",
                                                            stan::model::index_uni(
                                                              i)) - 1),
            DUMMY_VAR__);
        current_statement__ = 444;
        stan::math::validate_non_negative_index("shape2", "p[i] - 1",
          (stan::model::rvalue(p, "p", stan::model::index_uni(i)) - 1));
        Eigen::Matrix<local_scalar_t__,-1,1> shape2 =
          Eigen::Matrix<local_scalar_t__,-1,1>::Constant((stan::model::rvalue(
                                                            p, "p",
                                                            stan::model::index_uni(
                                                              i)) - 1),
            DUMMY_VAR__);
        local_scalar_t__ nu = DUMMY_VAR__;
        current_statement__ = 446;
        nu = (stan::model::rvalue(regularization, "regularization",
                stan::model::index_uni(pos_reg))
          + (0.5 * (stan::model::rvalue(p, "p", stan::model::index_uni(i)) -
          2)));
        current_statement__ = 447;
        pos_reg = (pos_reg + 1);
        current_statement__ = 448;
        stan::model::assign(shape1, nu, "assigning variable shape1",
          stan::model::index_uni(1));
        current_statement__ = 449;
        stan::model::assign(shape2, nu, "assigning variable shape2",
          stan::model::index_uni(1));
        current_statement__ = 454;
        for (int j = 2; j <=
             (stan::model::rvalue(p, "p", stan::model::index_uni(i)) -
             1); ++j) {
          current_statement__ = 450;
          nu = (nu - 0.5);
          current_statement__ = 451;
          stan::model::assign(shape1, (0.5 * j), "assigning variable shape1",
            stan::model::index_uni(j));
          current_statement__ = 452;
          stan::model::assign(shape2, nu, "assigning variable shape2",
            stan::model::index_uni(j));
        }
        current_statement__ = 455;
        lp = (lp +
          stan::math::beta_lpdf<false>(
            stan::model::rvalue(rho, "rho",
              stan::model::index_min_max(pos_rho, ((pos_rho +
                stan::model::rvalue(p, "p", stan::model::index_uni(i))) - 2))),
            shape1, shape2));
        current_statement__ = 456;
        pos_rho = (pos_rho +
          (stan::model::rvalue(p, "p", stan::model::index_uni(i)) - 1));
      }
    }
    current_statement__ = 460;
    lp = (lp + stan::math::gamma_lpdf<false>(zeta, delta, 1));
    current_statement__ = 461;
    lp = (lp + stan::math::gamma_lpdf<false>(tau, shape, 1));
    current_statement__ = 462;
    return lp;
  } catch (const std::exception& e) {
    stan::lang::rethrow_located(e, locations_array__[current_statement__]);
  }
}
template <typename T0__, typename T1__, typename T2__, typename T3__,
          typename T4__, typename T5__,
          stan::require_all_t<stan::is_col_vector<T0__>,
                              stan::is_vt_not_complex<T0__>,
                              stan::is_stan_scalar<T1__>,
                              stan::is_stan_scalar<T2__>,
                              stan::is_stan_scalar<T3__>,
                              stan::is_stan_scalar<T4__>,
                              stan::is_stan_scalar<T5__>>*>
Eigen::Matrix<stan::promote_args_t<stan::base_type_t<T0__>, T1__, T2__, T3__,
                T4__, stan::promote_args_t<T5__>>,-1,1>
hs_prior(const T0__& z_beta_arg__, const std::vector<T1__>& global,
         const std::vector<Eigen::Matrix<T2__,-1,1>>& local, const T3__&
         global_prior_scale, const T4__& error_scale, const T5__& c2,
         std::ostream* pstream__) {
  using local_scalar_t__ = stan::promote_args_t<stan::base_type_t<T0__>,
                             T1__, T2__, T3__, T4__,
                             stan::promote_args_t<T5__>>;
  int current_statement__ = 0;
  const auto& z_beta = stan::math::to_ref(z_beta_arg__);
  static constexpr bool propto__ = true;
  // suppress unused var warning
  (void) propto__;
  local_scalar_t__ DUMMY_VAR__(std::numeric_limits<double>::quiet_NaN());
  // suppress unused var warning
  (void) DUMMY_VAR__;
  try {
    int K = std::numeric_limits<int>::min();
    current_statement__ = 464;
    K = stan::math::rows(z_beta);
    current_statement__ = 465;
    stan::math::validate_non_negative_index("lambda", "K", K);
    Eigen::Matrix<local_scalar_t__,-1,1> lambda =
      Eigen::Matrix<local_scalar_t__,-1,1>::Constant(K, DUMMY_VAR__);
    current_statement__ = 466;
    stan::model::assign(lambda,
      stan::math::elt_multiply(
        stan::model::rvalue(local, "local", stan::model::index_uni(1)),
        stan::math::sqrt(
          stan::model::rvalue(local, "local", stan::model::index_uni(2)))),
      "assigning variable lambda");
    local_scalar_t__ tau = DUMMY_VAR__;
    current_statement__ = 467;
    tau = (((stan::model::rvalue(global, "global", stan::model::index_uni(1))
      *
      stan::math::sqrt(
        stan::model::rvalue(global, "global", stan::model::index_uni(2))))
      * global_prior_scale) * error_scale);
    current_statement__ = 468;
    stan::math::validate_non_negative_index("lambda2", "K", K);
    Eigen::Matrix<local_scalar_t__,-1,1> lambda2 =
      Eigen::Matrix<local_scalar_t__,-1,1>::Constant(K, DUMMY_VAR__);
    current_statement__ = 469;
    stan::model::assign(lambda2, stan::math::square(lambda),
      "assigning variable lambda2");
    current_statement__ = 470;
    stan::math::validate_non_negative_index("lambda_tilde", "K", K);
    Eigen::Matrix<local_scalar_t__,-1,1> lambda_tilde =
      Eigen::Matrix<local_scalar_t__,-1,1>::Constant(K, DUMMY_VAR__);
    current_statement__ = 471;
    stan::model::assign(lambda_tilde,
      stan::math::sqrt(
        stan::math::elt_divide(stan::math::multiply(c2, lambda2),
          stan::math::add(c2,
            stan::math::multiply(stan::math::square(tau), lambda2)))),
      "assigning variable lambda_tilde");
    current_statement__ = 472;
    return stan::math::multiply(
             stan::math::elt_multiply(z_beta, lambda_tilde), tau);
  } catch (const std::exception& e) {
    stan::lang::rethrow_located(e, locations_array__[current_statement__]);
  }
}
template <typename T0__, typename T1__, typename T2__, typename T3__,
          typename T4__, typename T5__,
          stan::require_all_t<stan::is_col_vector<T0__>,
                              stan::is_vt_not_complex<T0__>,
                              stan::is_stan_scalar<T1__>,
                              stan::is_stan_scalar<T2__>,
                              stan::is_stan_scalar<T3__>,
                              stan::is_stan_scalar<T4__>,
                              stan::is_stan_scalar<T5__>>*>
Eigen::Matrix<stan::promote_args_t<stan::base_type_t<T0__>, T1__, T2__, T3__,
                T4__, stan::promote_args_t<T5__>>,-1,1>
hsplus_prior(const T0__& z_beta_arg__, const std::vector<T1__>& global,
             const std::vector<Eigen::Matrix<T2__,-1,1>>& local, const T3__&
             global_prior_scale, const T4__& error_scale, const T5__& c2,
             std::ostream* pstream__) {
  using local_scalar_t__ = stan::promote_args_t<stan::base_type_t<T0__>,
                             T1__, T2__, T3__, T4__,
                             stan::promote_args_t<T5__>>;
  int current_statement__ = 0;
  const auto& z_beta = stan::math::to_ref(z_beta_arg__);
  static constexpr bool propto__ = true;
  // suppress unused var warning
  (void) propto__;
  local_scalar_t__ DUMMY_VAR__(std::numeric_limits<double>::quiet_NaN());
  // suppress unused var warning
  (void) DUMMY_VAR__;
  try {
    int K = std::numeric_limits<int>::min();
    current_statement__ = 474;
    K = stan::math::rows(z_beta);
    current_statement__ = 475;
    stan::math::validate_non_negative_index("lambda", "K", K);
    Eigen::Matrix<local_scalar_t__,-1,1> lambda =
      Eigen::Matrix<local_scalar_t__,-1,1>::Constant(K, DUMMY_VAR__);
    current_statement__ = 476;
    stan::model::assign(lambda,
      stan::math::elt_multiply(
        stan::model::rvalue(local, "local", stan::model::index_uni(1)),
        stan::math::sqrt(
          stan::model::rvalue(local, "local", stan::model::index_uni(2)))),
      "assigning variable lambda");
    current_statement__ = 477;
    stan::math::validate_non_negative_index("eta", "K", K);
    Eigen::Matrix<local_scalar_t__,-1,1> eta =
      Eigen::Matrix<local_scalar_t__,-1,1>::Constant(K, DUMMY_VAR__);
    current_statement__ = 478;
    stan::model::assign(eta,
      stan::math::elt_multiply(
        stan::model::rvalue(local, "local", stan::model::index_uni(3)),
        stan::math::sqrt(
          stan::model::rvalue(local, "local", stan::model::index_uni(4)))),
      "assigning variable eta");
    local_scalar_t__ tau = DUMMY_VAR__;
    current_statement__ = 479;
    tau = (((stan::model::rvalue(global, "global", stan::model::index_uni(1))
      *
      stan::math::sqrt(
        stan::model::rvalue(global, "global", stan::model::index_uni(2))))
      * global_prior_scale) * error_scale);
    current_statement__ = 480;
    stan::math::validate_non_negative_index("lambda_eta2", "K", K);
    Eigen::Matrix<local_scalar_t__,-1,1> lambda_eta2 =
      Eigen::Matrix<local_scalar_t__,-1,1>::Constant(K, DUMMY_VAR__);
    current_statement__ = 481;
    stan::model::assign(lambda_eta2,
      stan::math::square(stan::math::elt_multiply(lambda, eta)),
      "assigning variable lambda_eta2");
    current_statement__ = 482;
    stan::math::validate_non_negative_index("lambda_tilde", "K", K);
    Eigen::Matrix<local_scalar_t__,-1,1> lambda_tilde =
      Eigen::Matrix<local_scalar_t__,-1,1>::Constant(K, DUMMY_VAR__);
    current_statement__ = 483;
    stan::model::assign(lambda_tilde,
      stan::math::sqrt(
        stan::math::elt_divide(stan::math::multiply(c2, lambda_eta2),
          stan::math::add(c2,
            stan::math::multiply(stan::math::square(tau), lambda_eta2)))),
      "assigning variable lambda_tilde");
    current_statement__ = 484;
    return stan::math::multiply(
             stan::math::elt_multiply(z_beta, lambda_tilde), tau);
  } catch (const std::exception& e) {
    stan::lang::rethrow_located(e, locations_array__[current_statement__]);
  }
}
template <typename T0__, typename T1__,
          stan::require_all_t<stan::is_stan_scalar<T0__>,
                              stan::is_stan_scalar<T1__>>*>
stan::promote_args_t<T0__, T1__>
CFt(const T0__& z, const T1__& df, std::ostream* pstream__) {
  using local_scalar_t__ = stan::promote_args_t<T0__, T1__>;
  int current_statement__ = 0;
  static constexpr bool propto__ = true;
  // suppress unused var warning
  (void) propto__;
  local_scalar_t__ DUMMY_VAR__(std::numeric_limits<double>::quiet_NaN());
  // suppress unused var warning
  (void) DUMMY_VAR__;
  try {
    local_scalar_t__ z2 = DUMMY_VAR__;
    current_statement__ = 486;
    z2 = stan::math::square(z);
    local_scalar_t__ z3 = DUMMY_VAR__;
    current_statement__ = 487;
    z3 = (z2 * z);
    local_scalar_t__ z5 = DUMMY_VAR__;
    current_statement__ = 488;
    z5 = (z2 * z3);
    local_scalar_t__ z7 = DUMMY_VAR__;
    current_statement__ = 489;
    z7 = (z2 * z5);
    local_scalar_t__ z9 = DUMMY_VAR__;
    current_statement__ = 490;
    z9 = (z2 * z7);
    local_scalar_t__ df2 = DUMMY_VAR__;
    current_statement__ = 491;
    df2 = stan::math::square(df);
    local_scalar_t__ df3 = DUMMY_VAR__;
    current_statement__ = 492;
    df3 = (df2 * df);
    local_scalar_t__ df4 = DUMMY_VAR__;
    current_statement__ = 493;
    df4 = (df2 * df2);
    current_statement__ = 494;
    return ((((z + ((z3 + z) / (4 * df))) + ((((5 * z5) + (16 * z3)) + (3 *
           z)) / (96 * df2))) + (((((3 * z7) + (19 * z5)) + (17 * z3)) - (15
           * z)) / (384 * df3))) + ((((((79 * z9) + (776 * z7)) + (1482 *
           z5)) - (1920 * z3)) - (945 * z)) / (92160 * df4)));
  } catch (const std::exception& e) {
    stan::lang::rethrow_located(e, locations_array__[current_statement__]);
  }
}
std::vector<std::vector<int>>
make_V(const int& N, const int& t, const std::vector<int>& v, std::ostream*
       pstream__) {
  using local_scalar_t__ = double;
  int current_statement__ = 0;
  static constexpr bool propto__ = true;
  // suppress unused var warning
  (void) propto__;
  local_scalar_t__ DUMMY_VAR__(std::numeric_limits<double>::quiet_NaN());
  // suppress unused var warning
  (void) DUMMY_VAR__;
  try {
    current_statement__ = 496;
    stan::math::validate_non_negative_index("V", "t", t);
    current_statement__ = 497;
    stan::math::validate_non_negative_index("V", "N", N);
    std::vector<std::vector<int>> V =
      std::vector<std::vector<int>>(t,
        std::vector<int>(N, std::numeric_limits<int>::min()));
    int pos = std::numeric_limits<int>::min();
    current_statement__ = 499;
    pos = 1;
    current_statement__ = 505;
    if (stan::math::logical_gt(t, 0)) {
      current_statement__ = 504;
      for (int j = 1; j <= N; ++j) {
        current_statement__ = 503;
        for (int i = 1; i <= t; ++i) {
          current_statement__ = 500;
          stan::model::assign(V,
            stan::model::rvalue(v, "v", stan::model::index_uni(pos)),
            "assigning variable V", stan::model::index_uni(i),
            stan::model::index_uni(j));
          current_statement__ = 501;
          pos = (pos + 1);
        }
      }
    }
    current_statement__ = 506;
    return V;
  } catch (const std::exception& e) {
    stan::lang::rethrow_located(e, locations_array__[current_statement__]);
  }
}
double
make_lower(const int& family, const int& link, std::ostream* pstream__) {
  using local_scalar_t__ = double;
  int current_statement__ = 0;
  static constexpr bool propto__ = true;
  // suppress unused var warning
  (void) propto__;
  local_scalar_t__ DUMMY_VAR__(std::numeric_limits<double>::quiet_NaN());
  // suppress unused var warning
  (void) DUMMY_VAR__;
  try {
    current_statement__ = 509;
    if (stan::math::logical_eq(family, 1)) {
      current_statement__ = 508;
      return stan::math::negative_infinity();
    }
    current_statement__ = 514;
    if (stan::math::logical_lte(family, 3)) {
      current_statement__ = 511;
      if (stan::math::logical_eq(link, 2)) {
        current_statement__ = 510;
        return stan::math::negative_infinity();
      }
      current_statement__ = 512;
      return 0;
    }
    current_statement__ = 515;
    return stan::math::negative_infinity();
  } catch (const std::exception& e) {
    stan::lang::rethrow_located(e, locations_array__[current_statement__]);
  }
}
double
make_upper(const int& family, const int& link, std::ostream* pstream__) {
  using local_scalar_t__ = double;
  int current_statement__ = 0;
  static constexpr bool propto__ = true;
  // suppress unused var warning
  (void) propto__;
  local_scalar_t__ DUMMY_VAR__(std::numeric_limits<double>::quiet_NaN());
  // suppress unused var warning
  (void) DUMMY_VAR__;
  try {
    current_statement__ = 518;
    if ((stan::math::primitive_value(stan::math::logical_eq(family, 4)) &&
        stan::math::primitive_value(stan::math::logical_eq(link, 5)))) {
      current_statement__ = 517;
      return 0;
    }
    current_statement__ = 519;
    return stan::math::positive_infinity();
  } catch (const std::exception& e) {
    stan::lang::rethrow_located(e, locations_array__[current_statement__]);
  }
}
template <typename T0__,
          stan::require_all_t<stan::is_col_vector<T0__>,
                              stan::is_vt_not_complex<T0__>>*>
Eigen::Matrix<stan::promote_args_t<stan::base_type_t<T0__>>,-1,1>
linkinv_binom(const T0__& eta_arg__, const int& link, std::ostream* pstream__) {
  using local_scalar_t__ = stan::promote_args_t<stan::base_type_t<T0__>>;
  int current_statement__ = 0;
  const auto& eta = stan::math::to_ref(eta_arg__);
  static constexpr bool propto__ = true;
  // suppress unused var warning
  (void) propto__;
  local_scalar_t__ DUMMY_VAR__(std::numeric_limits<double>::quiet_NaN());
  // suppress unused var warning
  (void) DUMMY_VAR__;
  try {
    current_statement__ = 531;
    if (stan::math::logical_eq(link, 1)) {
      current_statement__ = 530;
      return stan::math::inv_logit(eta);
    } else {
      current_statement__ = 529;
      if (stan::math::logical_eq(link, 2)) {
        current_statement__ = 528;
        return stan::math::Phi(eta);
      } else {
        current_statement__ = 527;
        if (stan::math::logical_eq(link, 3)) {
          current_statement__ = 526;
          return stan::math::add(
                   stan::math::divide(stan::math::atan(eta), stan::math::pi()),
                   0.5);
        } else {
          current_statement__ = 525;
          if (stan::math::logical_eq(link, 4)) {
            current_statement__ = 524;
            return stan::math::exp(eta);
          } else {
            current_statement__ = 523;
            if (stan::math::logical_eq(link, 5)) {
              current_statement__ = 522;
              return stan::math::inv_cloglog(eta);
            } else {
              current_statement__ = 521;
              std::stringstream errmsg_stream__;
              stan::math::stan_print(&errmsg_stream__, "Invalid link");
              throw std::domain_error(errmsg_stream__.str());
            }
          }
        }
      }
    }
    current_statement__ = 532;
    return eta;
  } catch (const std::exception& e) {
    stan::lang::rethrow_located(e, locations_array__[current_statement__]);
  }
}
template <bool propto__, typename T2__,
          stan::require_all_t<stan::is_col_vector<T2__>,
                              stan::is_vt_not_complex<T2__>>*>
stan::promote_args_t<stan::base_type_t<T2__>>
binom_lpmf(const std::vector<int>& y, const std::vector<int>& trials,
           const T2__& eta_arg__, const int& link, std::ostream* pstream__) {
  using local_scalar_t__ = stan::promote_args_t<stan::base_type_t<T2__>>;
  int current_statement__ = 0;
  const auto& eta = stan::math::to_ref(eta_arg__);
  local_scalar_t__ DUMMY_VAR__(std::numeric_limits<double>::quiet_NaN());
  // suppress unused var warning
  (void) DUMMY_VAR__;
  try {
    local_scalar_t__ lp = DUMMY_VAR__;
    current_statement__ = 534;
    lp = 0;
    current_statement__ = 554;
    if (stan::math::logical_eq(link, 1)) {
      current_statement__ = 553;
      lp = (lp + stan::math::binomial_logit_lpmf<false>(y, trials, eta));
    } else {
      current_statement__ = 552;
      if (stan::math::logical_lt(link, 4)) {
        current_statement__ = 551;
        lp = (lp +
          stan::math::binomial_lpmf<false>(y, trials,
            linkinv_binom(eta, link, pstream__)));
      } else {
        current_statement__ = 550;
        if (stan::math::logical_eq(link, 4)) {
          current_statement__ = 548;
          for (int n = 1; n <= stan::math::num_elements(y); ++n) {
            current_statement__ = 544;
            lp = (lp +
              (stan::model::rvalue(y, "y", stan::model::index_uni(n)) *
              stan::model::rvalue(eta, "eta", stan::model::index_uni(n))));
            current_statement__ = 545;
            lp = (lp +
              ((stan::model::rvalue(trials, "trials",
                  stan::model::index_uni(n))
              - stan::model::rvalue(y, "y", stan::model::index_uni(n))) *
              stan::math::log1m_exp(
                stan::model::rvalue(eta, "eta", stan::model::index_uni(n)))));
            current_statement__ = 546;
            lp = (lp +
              stan::math::binomial_coefficient_log(
                stan::model::rvalue(trials, "trials",
                  stan::model::index_uni(n)),
                stan::model::rvalue(y, "y", stan::model::index_uni(n))));
          }
        } else {
          current_statement__ = 543;
          if (stan::math::logical_eq(link, 5)) {
            current_statement__ = 541;
            for (int n = 1; n <= stan::math::num_elements(y); ++n) {
              local_scalar_t__ neg_exp_eta = DUMMY_VAR__;
              current_statement__ = 536;
              neg_exp_eta = -stan::math::exp(
                               stan::model::rvalue(eta, "eta",
                                 stan::model::index_uni(n)));
              current_statement__ = 537;
              lp = (lp +
                (stan::model::rvalue(y, "y", stan::model::index_uni(n)) *
                stan::math::log1m_exp(neg_exp_eta)));
              current_statement__ = 538;
              lp = (lp +
                ((stan::model::rvalue(trials, "trials",
                    stan::model::index_uni(n))
                - stan::model::rvalue(y, "y", stan::model::index_uni(n))) *
                neg_exp_eta));
              current_statement__ = 539;
              lp = (lp +
                stan::math::binomial_coefficient_log(
                  stan::model::rvalue(trials, "trials",
                    stan::model::index_uni(n)),
                  stan::model::rvalue(y, "y", stan::model::index_uni(n))));
            }
          } else {
            current_statement__ = 535;
            std::stringstream errmsg_stream__;
            stan::math::stan_print(&errmsg_stream__, "Invalid link");
            throw std::domain_error(errmsg_stream__.str());
          }
        }
      }
    }
    current_statement__ = 555;
    return lp;
  } catch (const std::exception& e) {
    stan::lang::rethrow_located(e, locations_array__[current_statement__]);
  }
}
template <typename T2__,
          stan::require_all_t<stan::is_col_vector<T2__>,
                              stan::is_vt_not_complex<T2__>>*>
Eigen::Matrix<stan::promote_args_t<stan::base_type_t<T2__>>,-1,1>
pw_binom(const std::vector<int>& y, const std::vector<int>& trials,
         const T2__& eta_arg__, const int& link, std::ostream* pstream__) {
  using local_scalar_t__ = stan::promote_args_t<stan::base_type_t<T2__>>;
  int current_statement__ = 0;
  const auto& eta = stan::math::to_ref(eta_arg__);
  static constexpr bool propto__ = true;
  // suppress unused var warning
  (void) propto__;
  local_scalar_t__ DUMMY_VAR__(std::numeric_limits<double>::quiet_NaN());
  // suppress unused var warning
  (void) DUMMY_VAR__;
  try {
    int N = std::numeric_limits<int>::min();
    current_statement__ = 557;
    N = stan::math::rows(eta);
    current_statement__ = 558;
    stan::math::validate_non_negative_index("ll", "N", N);
    Eigen::Matrix<local_scalar_t__,-1,1> ll =
      Eigen::Matrix<local_scalar_t__,-1,1>::Constant(N, DUMMY_VAR__);
    current_statement__ = 570;
    if (stan::math::logical_eq(link, 1)) {
      current_statement__ = 568;
      for (int n = 1; n <= N; ++n) {
        current_statement__ = 567;
        stan::model::assign(ll,
          stan::math::binomial_logit_lpmf<false>(
            stan::model::rvalue(y, "y", stan::model::index_uni(n)),
            stan::model::rvalue(trials, "trials", stan::model::index_uni(n)),
            stan::model::rvalue(eta, "eta", stan::model::index_uni(n))),
          "assigning variable ll", stan::model::index_uni(n));
      }
    } else {
      current_statement__ = 566;
      if (stan::math::logical_lte(link, 5)) {
        current_statement__ = 561;
        stan::math::validate_non_negative_index("pi", "N", N);
        Eigen::Matrix<local_scalar_t__,-1,1> pi =
          Eigen::Matrix<local_scalar_t__,-1,1>::Constant(N, DUMMY_VAR__);
        current_statement__ = 562;
        stan::model::assign(pi, linkinv_binom(eta, link, pstream__),
          "assigning variable pi");
        current_statement__ = 564;
        for (int n = 1; n <= N; ++n) {
          current_statement__ = 563;
          stan::model::assign(ll,
            stan::math::binomial_lpmf<false>(
              stan::model::rvalue(y, "y", stan::model::index_uni(n)),
              stan::model::rvalue(trials, "trials", stan::model::index_uni(n)),
              stan::model::rvalue(pi, "pi", stan::model::index_uni(n))),
            "assigning variable ll", stan::model::index_uni(n));
        }
      } else {
        current_statement__ = 560;
        std::stringstream errmsg_stream__;
        stan::math::stan_print(&errmsg_stream__, "Invalid link");
        throw std::domain_error(errmsg_stream__.str());
      }
    }
    current_statement__ = 571;
    return ll;
  } catch (const std::exception& e) {
    stan::lang::rethrow_located(e, locations_array__[current_statement__]);
  }
}
#include <stan_meta_header.hpp>
class model_binomial final : public model_base_crtp<model_binomial> {
private:
  int N;
  int K;
  Eigen::Matrix<double,-1,1> xbar_data__;
  int dense_X;
  std::vector<Eigen::Matrix<double,-1,-1>> X;
  int nnz_X;
  Eigen::Matrix<double,-1,1> w_X_data__;
  std::vector<int> v_X;
  std::vector<int> u_X;
  int K_smooth;
  Eigen::Matrix<double,-1,-1> S_data__;
  std::vector<int> smooth_map;
  std::vector<int> y;
  std::vector<int> trials;
  int prior_PD;
  int compute_mean_PPD;
  int has_intercept;
  int link;
  int prior_dist;
  int prior_dist_for_intercept;
  int prior_dist_for_aux;
  int prior_dist_for_smooth;
  int has_weights;
  Eigen::Matrix<double,-1,1> weights_data__;
  int has_offset;
  Eigen::Matrix<double,-1,1> offset__data__;
  int family;
  Eigen::Matrix<double,-1,1> prior_scale_data__;
  double prior_scale_for_intercept;
  double prior_scale_for_aux;
  Eigen::Matrix<double,-1,1> prior_scale_for_smooth_data__;
  Eigen::Matrix<double,-1,1> prior_mean_data__;
  double prior_mean_for_intercept;
  double prior_mean_for_aux;
  Eigen::Matrix<double,-1,1> prior_mean_for_smooth_data__;
  Eigen::Matrix<double,-1,1> prior_df_data__;
  double prior_df_for_intercept;
  double prior_df_for_aux;
  Eigen::Matrix<double,-1,1> prior_df_for_smooth_data__;
  double global_prior_df;
  double global_prior_scale;
  double slab_df;
  double slab_scale;
  std::vector<int> num_normals;
  int t;
  std::vector<int> p;
  std::vector<int> l;
  int q;
  int len_theta_L;
  Eigen::Matrix<double,-1,1> shape_data__;
  Eigen::Matrix<double,-1,1> scale_data__;
  int len_concentration;
  std::vector<double> concentration;
  int len_regularization;
  std::vector<double> regularization;
  int num_non_zero;
  Eigen::Matrix<double,-1,1> w_data__;
  std::vector<int> v;
  std::vector<int> u;
  int special_case;
  double aux;
  std::vector<std::vector<int>> V;
  int len_z_T;
  int len_var_group;
  int len_rho;
  int is_continuous;
  int pos;
  std::vector<double> delta;
  int hs;
  int z_beta_1dim__;
  int smooth_sd_raw_1dim__;
  int caux_1dim__;
  int mix_1dim__;
  int one_over_lambda_1dim__;
  int smooth_sd_1dim__;
  Eigen::Map<Eigen::Matrix<double,-1,1>> xbar{nullptr, 0};
  Eigen::Map<Eigen::Matrix<double,-1,1>> w_X{nullptr, 0};
  Eigen::Map<Eigen::Matrix<double,-1,-1>> S{nullptr, 0, 0};
  Eigen::Map<Eigen::Matrix<double,-1,1>> weights{nullptr, 0};
  Eigen::Map<Eigen::Matrix<double,-1,1>> offset_{nullptr, 0};
  Eigen::Map<Eigen::Matrix<double,-1,1>> prior_scale{nullptr, 0};
  Eigen::Map<Eigen::Matrix<double,-1,1>> prior_scale_for_smooth{nullptr, 0};
  Eigen::Map<Eigen::Matrix<double,-1,1>> prior_mean{nullptr, 0};
  Eigen::Map<Eigen::Matrix<double,-1,1>> prior_mean_for_smooth{nullptr, 0};
  Eigen::Map<Eigen::Matrix<double,-1,1>> prior_df{nullptr, 0};
  Eigen::Map<Eigen::Matrix<double,-1,1>> prior_df_for_smooth{nullptr, 0};
  Eigen::Map<Eigen::Matrix<double,-1,1>> shape{nullptr, 0};
  Eigen::Map<Eigen::Matrix<double,-1,1>> scale{nullptr, 0};
  Eigen::Map<Eigen::Matrix<double,-1,1>> w{nullptr, 0};
public:
  ~model_binomial() {}
  model_binomial(stan::io::var_context& context__, unsigned int
                 random_seed__ = 0, std::ostream* pstream__ = nullptr)
      : model_base_crtp(0) {
    int current_statement__ = 0;
    using local_scalar_t__ = double;
    boost::ecuyer1988 base_rng__ =
      stan::services::util::create_rng(random_seed__, 0);
    // suppress unused var warning
    (void) base_rng__;
    static constexpr const char* function__ =
      "model_binomial_namespace::model_binomial";
    // suppress unused var warning
    (void) function__;
    local_scalar_t__ DUMMY_VAR__(std::numeric_limits<double>::quiet_NaN());
    // suppress unused var warning
    (void) DUMMY_VAR__;
    try {
      int pos__ = std::numeric_limits<int>::min();
      pos__ = 1;
      current_statement__ = 210;
      context__.validate_dims("data initialization", "N", "int",
        std::vector<size_t>{});
      N = std::numeric_limits<int>::min();
      current_statement__ = 210;
      N = context__.vals_i("N")[(1 - 1)];
      current_statement__ = 210;
      stan::math::check_greater_or_equal(function__, "N", N, 0);
      current_statement__ = 211;
      context__.validate_dims("data initialization", "K", "int",
        std::vector<size_t>{});
      K = std::numeric_limits<int>::min();
      current_statement__ = 211;
      K = context__.vals_i("K")[(1 - 1)];
      current_statement__ = 211;
      stan::math::check_greater_or_equal(function__, "K", K, 0);
      current_statement__ = 212;
      stan::math::validate_non_negative_index("xbar", "K", K);
      current_statement__ = 213;
      context__.validate_dims("data initialization", "xbar", "double",
        std::vector<size_t>{static_cast<size_t>(K)});
      xbar_data__ = Eigen::Matrix<double,-1,1>::Constant(K,
                      std::numeric_limits<double>::quiet_NaN());
      new (&xbar) Eigen::Map<Eigen::Matrix<double,-1,1>>(xbar_data__.data(),
        K);
      {
        std::vector<local_scalar_t__> xbar_flat__;
        current_statement__ = 213;
        xbar_flat__ = context__.vals_r("xbar");
        current_statement__ = 213;
        pos__ = 1;
        current_statement__ = 213;
        for (int sym1__ = 1; sym1__ <= K; ++sym1__) {
          current_statement__ = 213;
          stan::model::assign(xbar, xbar_flat__[(pos__ - 1)],
            "assigning variable xbar", stan::model::index_uni(sym1__));
          current_statement__ = 213;
          pos__ = (pos__ + 1);
        }
      }
      current_statement__ = 214;
      context__.validate_dims("data initialization", "dense_X", "int",
        std::vector<size_t>{});
      dense_X = std::numeric_limits<int>::min();
      current_statement__ = 214;
      dense_X = context__.vals_i("dense_X")[(1 - 1)];
      current_statement__ = 214;
      stan::math::check_greater_or_equal(function__, "dense_X", dense_X, 0);
      current_statement__ = 214;
      stan::math::check_less_or_equal(function__, "dense_X", dense_X, 1);
      current_statement__ = 215;
      stan::math::validate_non_negative_index("X", "dense_X", dense_X);
      current_statement__ = 216;
      stan::math::validate_non_negative_index("X", "N", N);
      current_statement__ = 217;
      stan::math::validate_non_negative_index("X", "K", K);
      current_statement__ = 218;
      context__.validate_dims("data initialization", "X", "double",
        std::vector<size_t>{static_cast<size_t>(dense_X),
          static_cast<size_t>(N), static_cast<size_t>(K)});
      X = std::vector<Eigen::Matrix<double,-1,-1>>(dense_X,
            Eigen::Matrix<double,-1,-1>::Constant(N, K,
              std::numeric_limits<double>::quiet_NaN()));
      {
        std::vector<local_scalar_t__> X_flat__;
        current_statement__ = 218;
        X_flat__ = context__.vals_r("X");
        current_statement__ = 218;
        pos__ = 1;
        current_statement__ = 218;
        for (int sym1__ = 1; sym1__ <= K; ++sym1__) {
          current_statement__ = 218;
          for (int sym2__ = 1; sym2__ <= N; ++sym2__) {
            current_statement__ = 218;
            for (int sym3__ = 1; sym3__ <= dense_X; ++sym3__) {
              current_statement__ = 218;
              stan::model::assign(X, X_flat__[(pos__ - 1)],
                "assigning variable X", stan::model::index_uni(sym3__),
                stan::model::index_uni(sym2__),
                stan::model::index_uni(sym1__));
              current_statement__ = 218;
              pos__ = (pos__ + 1);
            }
          }
        }
      }
      current_statement__ = 219;
      context__.validate_dims("data initialization", "nnz_X", "int",
        std::vector<size_t>{});
      nnz_X = std::numeric_limits<int>::min();
      current_statement__ = 219;
      nnz_X = context__.vals_i("nnz_X")[(1 - 1)];
      current_statement__ = 219;
      stan::math::check_greater_or_equal(function__, "nnz_X", nnz_X, 0);
      current_statement__ = 220;
      stan::math::validate_non_negative_index("w_X", "nnz_X", nnz_X);
      current_statement__ = 221;
      context__.validate_dims("data initialization", "w_X", "double",
        std::vector<size_t>{static_cast<size_t>(nnz_X)});
      w_X_data__ = Eigen::Matrix<double,-1,1>::Constant(nnz_X,
                     std::numeric_limits<double>::quiet_NaN());
      new (&w_X) Eigen::Map<Eigen::Matrix<double,-1,1>>(w_X_data__.data(),
        nnz_X);
      {
        std::vector<local_scalar_t__> w_X_flat__;
        current_statement__ = 221;
        w_X_flat__ = context__.vals_r("w_X");
        current_statement__ = 221;
        pos__ = 1;
        current_statement__ = 221;
        for (int sym1__ = 1; sym1__ <= nnz_X; ++sym1__) {
          current_statement__ = 221;
          stan::model::assign(w_X, w_X_flat__[(pos__ - 1)],
            "assigning variable w_X", stan::model::index_uni(sym1__));
          current_statement__ = 221;
          pos__ = (pos__ + 1);
        }
      }
      current_statement__ = 222;
      stan::math::validate_non_negative_index("v_X", "nnz_X", nnz_X);
      current_statement__ = 223;
      context__.validate_dims("data initialization", "v_X", "int",
        std::vector<size_t>{static_cast<size_t>(nnz_X)});
      v_X = std::vector<int>(nnz_X, std::numeric_limits<int>::min());
      current_statement__ = 223;
      v_X = context__.vals_i("v_X");
      current_statement__ = 223;
      stan::math::check_greater_or_equal(function__, "v_X", v_X, 1);
      current_statement__ = 223;
      stan::math::check_less_or_equal(function__, "v_X", v_X, K);
      current_statement__ = 224;
      stan::math::validate_non_negative_index("u_X", "dense_X ? 0 : N + 1",
        (dense_X ? 0 : (N + 1)));
      current_statement__ = 225;
      context__.validate_dims("data initialization", "u_X", "int",
        std::vector<size_t>{static_cast<size_t>((dense_X ? 0 : (N + 1)))});
      u_X = std::vector<int>((dense_X ? 0 : (N + 1)),
              std::numeric_limits<int>::min());
      current_statement__ = 225;
      u_X = context__.vals_i("u_X");
      current_statement__ = 225;
      stan::math::check_greater_or_equal(function__, "u_X", u_X, 1);
      current_statement__ = 225;
      stan::math::check_less_or_equal(function__, "u_X", u_X,
        (stan::math::rows(w_X) + 1));
      current_statement__ = 226;
      context__.validate_dims("data initialization", "K_smooth", "int",
        std::vector<size_t>{});
      K_smooth = std::numeric_limits<int>::min();
      current_statement__ = 226;
      K_smooth = context__.vals_i("K_smooth")[(1 - 1)];
      current_statement__ = 226;
      stan::math::check_greater_or_equal(function__, "K_smooth", K_smooth, 0);
      current_statement__ = 227;
      stan::math::validate_non_negative_index("S", "N", N);
      current_statement__ = 228;
      stan::math::validate_non_negative_index("S", "K_smooth", K_smooth);
      current_statement__ = 229;
      context__.validate_dims("data initialization", "S", "double",
        std::vector<size_t>{static_cast<size_t>(N),
          static_cast<size_t>(K_smooth)});
      S_data__ = Eigen::Matrix<double,-1,-1>::Constant(N, K_smooth,
                   std::numeric_limits<double>::quiet_NaN());
      new (&S) Eigen::Map<Eigen::Matrix<double,-1,-1>>(S_data__.data(), N,
        K_smooth);
      {
        std::vector<local_scalar_t__> S_flat__;
        current_statement__ = 229;
        S_flat__ = context__.vals_r("S");
        current_statement__ = 229;
        pos__ = 1;
        current_statement__ = 229;
        for (int sym1__ = 1; sym1__ <= K_smooth; ++sym1__) {
          current_statement__ = 229;
          for (int sym2__ = 1; sym2__ <= N; ++sym2__) {
            current_statement__ = 229;
            stan::model::assign(S, S_flat__[(pos__ - 1)],
              "assigning variable S", stan::model::index_uni(sym2__),
              stan::model::index_uni(sym1__));
            current_statement__ = 229;
            pos__ = (pos__ + 1);
          }
        }
      }
      current_statement__ = 230;
      stan::math::validate_non_negative_index("smooth_map", "K_smooth",
        K_smooth);
      current_statement__ = 231;
      context__.validate_dims("data initialization", "smooth_map", "int",
        std::vector<size_t>{static_cast<size_t>(K_smooth)});
      smooth_map = std::vector<int>(K_smooth,
                     std::numeric_limits<int>::min());
      current_statement__ = 231;
      smooth_map = context__.vals_i("smooth_map");
      current_statement__ = 231;
      stan::math::check_greater_or_equal(function__, "smooth_map",
        smooth_map, 1);
      current_statement__ = 232;
      stan::math::validate_non_negative_index("y", "N", N);
      current_statement__ = 233;
      context__.validate_dims("data initialization", "y", "int",
        std::vector<size_t>{static_cast<size_t>(N)});
      y = std::vector<int>(N, std::numeric_limits<int>::min());
      current_statement__ = 233;
      y = context__.vals_i("y");
      current_statement__ = 233;
      stan::math::check_greater_or_equal(function__, "y", y, 0);
      current_statement__ = 234;
      stan::math::validate_non_negative_index("trials", "N", N);
      current_statement__ = 235;
      context__.validate_dims("data initialization", "trials", "int",
        std::vector<size_t>{static_cast<size_t>(N)});
      trials = std::vector<int>(N, std::numeric_limits<int>::min());
      current_statement__ = 235;
      trials = context__.vals_i("trials");
      current_statement__ = 235;
      stan::math::check_greater_or_equal(function__, "trials", trials, 0);
      current_statement__ = 236;
      context__.validate_dims("data initialization", "prior_PD", "int",
        std::vector<size_t>{});
      prior_PD = std::numeric_limits<int>::min();
      current_statement__ = 236;
      prior_PD = context__.vals_i("prior_PD")[(1 - 1)];
      current_statement__ = 236;
      stan::math::check_greater_or_equal(function__, "prior_PD", prior_PD, 0);
      current_statement__ = 236;
      stan::math::check_less_or_equal(function__, "prior_PD", prior_PD, 1);
      current_statement__ = 237;
      context__.validate_dims("data initialization", "compute_mean_PPD",
        "int", std::vector<size_t>{});
      compute_mean_PPD = std::numeric_limits<int>::min();
      current_statement__ = 237;
      compute_mean_PPD = context__.vals_i("compute_mean_PPD")[(1 - 1)];
      current_statement__ = 237;
      stan::math::check_greater_or_equal(function__, "compute_mean_PPD",
        compute_mean_PPD, 0);
      current_statement__ = 237;
      stan::math::check_less_or_equal(function__, "compute_mean_PPD",
        compute_mean_PPD, 1);
      current_statement__ = 238;
      context__.validate_dims("data initialization", "has_intercept", "int",
        std::vector<size_t>{});
      has_intercept = std::numeric_limits<int>::min();
      current_statement__ = 238;
      has_intercept = context__.vals_i("has_intercept")[(1 - 1)];
      current_statement__ = 238;
      stan::math::check_greater_or_equal(function__, "has_intercept",
        has_intercept, 0);
      current_statement__ = 238;
      stan::math::check_less_or_equal(function__, "has_intercept",
        has_intercept, 1);
      current_statement__ = 239;
      context__.validate_dims("data initialization", "link", "int",
        std::vector<size_t>{});
      link = std::numeric_limits<int>::min();
      current_statement__ = 239;
      link = context__.vals_i("link")[(1 - 1)];
      current_statement__ = 239;
      stan::math::check_greater_or_equal(function__, "link", link, 1);
      current_statement__ = 240;
      context__.validate_dims("data initialization", "prior_dist", "int",
        std::vector<size_t>{});
      prior_dist = std::numeric_limits<int>::min();
      current_statement__ = 240;
      prior_dist = context__.vals_i("prior_dist")[(1 - 1)];
      current_statement__ = 240;
      stan::math::check_greater_or_equal(function__, "prior_dist",
        prior_dist, 0);
      current_statement__ = 240;
      stan::math::check_less_or_equal(function__, "prior_dist", prior_dist, 7);
      current_statement__ = 241;
      context__.validate_dims("data initialization",
        "prior_dist_for_intercept", "int", std::vector<size_t>{});
      prior_dist_for_intercept = std::numeric_limits<int>::min();
      current_statement__ = 241;
      prior_dist_for_intercept = context__.vals_i("prior_dist_for_intercept")[(1
        - 1)];
      current_statement__ = 241;
      stan::math::check_greater_or_equal(function__,
        "prior_dist_for_intercept", prior_dist_for_intercept, 0);
      current_statement__ = 241;
      stan::math::check_less_or_equal(function__, "prior_dist_for_intercept",
        prior_dist_for_intercept, 2);
      current_statement__ = 242;
      context__.validate_dims("data initialization", "prior_dist_for_aux",
        "int", std::vector<size_t>{});
      prior_dist_for_aux = std::numeric_limits<int>::min();
      current_statement__ = 242;
      prior_dist_for_aux = context__.vals_i("prior_dist_for_aux")[(1 - 1)];
      current_statement__ = 242;
      stan::math::check_greater_or_equal(function__, "prior_dist_for_aux",
        prior_dist_for_aux, 0);
      current_statement__ = 242;
      stan::math::check_less_or_equal(function__, "prior_dist_for_aux",
        prior_dist_for_aux, 3);
      current_statement__ = 243;
      context__.validate_dims("data initialization", "prior_dist_for_smooth",
        "int", std::vector<size_t>{});
      prior_dist_for_smooth = std::numeric_limits<int>::min();
      current_statement__ = 243;
      prior_dist_for_smooth = context__.vals_i("prior_dist_for_smooth")[(1 -
        1)];
      current_statement__ = 243;
      stan::math::check_greater_or_equal(function__, "prior_dist_for_smooth",
        prior_dist_for_smooth, 0);
      current_statement__ = 243;
      stan::math::check_less_or_equal(function__, "prior_dist_for_smooth",
        prior_dist_for_smooth, 3);
      current_statement__ = 244;
      context__.validate_dims("data initialization", "has_weights", "int",
        std::vector<size_t>{});
      has_weights = std::numeric_limits<int>::min();
      current_statement__ = 244;
      has_weights = context__.vals_i("has_weights")[(1 - 1)];
      current_statement__ = 244;
      stan::math::check_greater_or_equal(function__, "has_weights",
        has_weights, 0);
      current_statement__ = 244;
      stan::math::check_less_or_equal(function__, "has_weights", has_weights,
        1);
      current_statement__ = 245;
      stan::math::validate_non_negative_index("weights",
        "has_weights ? N : 0", (has_weights ? N : 0));
      current_statement__ = 246;
      context__.validate_dims("data initialization", "weights", "double",
        std::vector<size_t>{static_cast<size_t>((has_weights ? N : 0))});
      weights_data__ = Eigen::Matrix<double,-1,1>::Constant((has_weights ? N : 0),
                         std::numeric_limits<double>::quiet_NaN());
      new (&weights)
        Eigen::Map<Eigen::Matrix<double,-1,1>>(weights_data__.data(),
        (has_weights ? N : 0));
      {
        std::vector<local_scalar_t__> weights_flat__;
        current_statement__ = 246;
        weights_flat__ = context__.vals_r("weights");
        current_statement__ = 246;
        pos__ = 1;
        current_statement__ = 246;
        for (int sym1__ = 1; sym1__ <= (has_weights ? N : 0); ++sym1__) {
          current_statement__ = 246;
          stan::model::assign(weights, weights_flat__[(pos__ - 1)],
            "assigning variable weights", stan::model::index_uni(sym1__));
          current_statement__ = 246;
          pos__ = (pos__ + 1);
        }
      }
      current_statement__ = 247;
      context__.validate_dims("data initialization", "has_offset", "int",
        std::vector<size_t>{});
      has_offset = std::numeric_limits<int>::min();
      current_statement__ = 247;
      has_offset = context__.vals_i("has_offset")[(1 - 1)];
      current_statement__ = 247;
      stan::math::check_greater_or_equal(function__, "has_offset",
        has_offset, 0);
      current_statement__ = 247;
      stan::math::check_less_or_equal(function__, "has_offset", has_offset, 1);
      current_statement__ = 248;
      stan::math::validate_non_negative_index("offset_",
        "has_offset ? N : 0", (has_offset ? N : 0));
      current_statement__ = 249;
      context__.validate_dims("data initialization", "offset_", "double",
        std::vector<size_t>{static_cast<size_t>((has_offset ? N : 0))});
      offset__data__ = Eigen::Matrix<double,-1,1>::Constant((has_offset ? N : 0),
                         std::numeric_limits<double>::quiet_NaN());
      new (&offset_)
        Eigen::Map<Eigen::Matrix<double,-1,1>>(offset__data__.data(),
        (has_offset ? N : 0));
      {
        std::vector<local_scalar_t__> offset__flat__;
        current_statement__ = 249;
        offset__flat__ = context__.vals_r("offset_");
        current_statement__ = 249;
        pos__ = 1;
        current_statement__ = 249;
        for (int sym1__ = 1; sym1__ <= (has_offset ? N : 0); ++sym1__) {
          current_statement__ = 249;
          stan::model::assign(offset_, offset__flat__[(pos__ - 1)],
            "assigning variable offset_", stan::model::index_uni(sym1__));
          current_statement__ = 249;
          pos__ = (pos__ + 1);
        }
      }
      current_statement__ = 250;
      context__.validate_dims("data initialization", "family", "int",
        std::vector<size_t>{});
      family = std::numeric_limits<int>::min();
      current_statement__ = 250;
      family = context__.vals_i("family")[(1 - 1)];
      current_statement__ = 250;
      stan::math::check_greater_or_equal(function__, "family", family, 5);
      current_statement__ = 250;
      stan::math::check_less_or_equal(function__, "family", family, 5);
      current_statement__ = 251;
      stan::math::validate_non_negative_index("prior_scale", "K", K);
      current_statement__ = 252;
      context__.validate_dims("data initialization", "prior_scale", "double",
        std::vector<size_t>{static_cast<size_t>(K)});
      prior_scale_data__ = Eigen::Matrix<double,-1,1>::Constant(K,
                             std::numeric_limits<double>::quiet_NaN());
      new (&prior_scale)
        Eigen::Map<Eigen::Matrix<double,-1,1>>(prior_scale_data__.data(), K);
      {
        std::vector<local_scalar_t__> prior_scale_flat__;
        current_statement__ = 252;
        prior_scale_flat__ = context__.vals_r("prior_scale");
        current_statement__ = 252;
        pos__ = 1;
        current_statement__ = 252;
        for (int sym1__ = 1; sym1__ <= K; ++sym1__) {
          current_statement__ = 252;
          stan::model::assign(prior_scale, prior_scale_flat__[(pos__ - 1)],
            "assigning variable prior_scale", stan::model::index_uni(sym1__));
          current_statement__ = 252;
          pos__ = (pos__ + 1);
        }
      }
      current_statement__ = 252;
      stan::math::check_greater_or_equal(function__, "prior_scale",
        prior_scale, 0);
      current_statement__ = 253;
      context__.validate_dims("data initialization",
        "prior_scale_for_intercept", "double", std::vector<size_t>{});
      prior_scale_for_intercept = std::numeric_limits<double>::quiet_NaN();
      current_statement__ = 253;
      prior_scale_for_intercept = context__.vals_r("prior_scale_for_intercept")[(1
        - 1)];
      current_statement__ = 253;
      stan::math::check_greater_or_equal(function__,
        "prior_scale_for_intercept", prior_scale_for_intercept, 0);
      current_statement__ = 254;
      context__.validate_dims("data initialization", "prior_scale_for_aux",
        "double", std::vector<size_t>{});
      prior_scale_for_aux = std::numeric_limits<double>::quiet_NaN();
      current_statement__ = 254;
      prior_scale_for_aux = context__.vals_r("prior_scale_for_aux")[(1 - 1)];
      current_statement__ = 254;
      stan::math::check_greater_or_equal(function__, "prior_scale_for_aux",
        prior_scale_for_aux, 0);
      current_statement__ = 255;
      stan::math::validate_non_negative_index("prior_scale_for_smooth",
        "K_smooth > 0 ? max(smooth_map) : 0",
        (stan::math::logical_gt(K_smooth, 0) ? stan::math::max(smooth_map) : 0));
      current_statement__ = 256;
      context__.validate_dims("data initialization",
        "prior_scale_for_smooth", "double",
        std::vector<size_t>{static_cast<size_t>(
                              (stan::math::logical_gt(K_smooth, 0) ? 
                              stan::math::max(smooth_map) : 0))});
      prior_scale_for_smooth_data__ = Eigen::Matrix<double,-1,1>::Constant((
                                        stan::math::logical_gt(K_smooth, 0) ? 
                                        stan::math::max(smooth_map) : 0),
                                        std::numeric_limits<double>::quiet_NaN(
                                          ));
      new (&prior_scale_for_smooth)
        Eigen::Map<Eigen::Matrix<double,-1,1>>(prior_scale_for_smooth_data__.data(),
        (stan::math::logical_gt(K_smooth, 0) ? stan::math::max(smooth_map) : 0));
      {
        std::vector<local_scalar_t__> prior_scale_for_smooth_flat__;
        current_statement__ = 256;
        prior_scale_for_smooth_flat__ = context__.vals_r("prior_scale_for_smooth");
        current_statement__ = 256;
        pos__ = 1;
        current_statement__ = 256;
        for (int sym1__ = 1; sym1__ <=
             (stan::math::logical_gt(K_smooth, 0) ? stan::math::max(
                                                      smooth_map) : 0); ++sym1__) {
          current_statement__ = 256;
          stan::model::assign(prior_scale_for_smooth,
            prior_scale_for_smooth_flat__[(pos__ - 1)],
            "assigning variable prior_scale_for_smooth",
            stan::model::index_uni(sym1__));
          current_statement__ = 256;
          pos__ = (pos__ + 1);
        }
      }
      current_statement__ = 256;
      stan::math::check_greater_or_equal(function__,
        "prior_scale_for_smooth", prior_scale_for_smooth, 0);
      current_statement__ = 257;
      stan::math::validate_non_negative_index("prior_mean", "K", K);
      current_statement__ = 258;
      context__.validate_dims("data initialization", "prior_mean", "double",
        std::vector<size_t>{static_cast<size_t>(K)});
      prior_mean_data__ = Eigen::Matrix<double,-1,1>::Constant(K,
                            std::numeric_limits<double>::quiet_NaN());
      new (&prior_mean)
        Eigen::Map<Eigen::Matrix<double,-1,1>>(prior_mean_data__.data(), K);
      {
        std::vector<local_scalar_t__> prior_mean_flat__;
        current_statement__ = 258;
        prior_mean_flat__ = context__.vals_r("prior_mean");
        current_statement__ = 258;
        pos__ = 1;
        current_statement__ = 258;
        for (int sym1__ = 1; sym1__ <= K; ++sym1__) {
          current_statement__ = 258;
          stan::model::assign(prior_mean, prior_mean_flat__[(pos__ - 1)],
            "assigning variable prior_mean", stan::model::index_uni(sym1__));
          current_statement__ = 258;
          pos__ = (pos__ + 1);
        }
      }
      current_statement__ = 259;
      context__.validate_dims("data initialization",
        "prior_mean_for_intercept", "double", std::vector<size_t>{});
      prior_mean_for_intercept = std::numeric_limits<double>::quiet_NaN();
      current_statement__ = 259;
      prior_mean_for_intercept = context__.vals_r("prior_mean_for_intercept")[(1
        - 1)];
      current_statement__ = 260;
      context__.validate_dims("data initialization", "prior_mean_for_aux",
        "double", std::vector<size_t>{});
      prior_mean_for_aux = std::numeric_limits<double>::quiet_NaN();
      current_statement__ = 260;
      prior_mean_for_aux = context__.vals_r("prior_mean_for_aux")[(1 - 1)];
      current_statement__ = 260;
      stan::math::check_greater_or_equal(function__, "prior_mean_for_aux",
        prior_mean_for_aux, 0);
      current_statement__ = 261;
      stan::math::validate_non_negative_index("prior_mean_for_smooth",
        "K_smooth > 0 ? max(smooth_map) : 0",
        (stan::math::logical_gt(K_smooth, 0) ? stan::math::max(smooth_map) : 0));
      current_statement__ = 262;
      context__.validate_dims("data initialization", "prior_mean_for_smooth",
        "double",
        std::vector<size_t>{static_cast<size_t>(
                              (stan::math::logical_gt(K_smooth, 0) ? 
                              stan::math::max(smooth_map) : 0))});
      prior_mean_for_smooth_data__ = Eigen::Matrix<double,-1,1>::Constant((
                                       stan::math::logical_gt(K_smooth, 0) ? 
                                       stan::math::max(smooth_map) : 0),
                                       std::numeric_limits<double>::quiet_NaN());
      new (&prior_mean_for_smooth)
        Eigen::Map<Eigen::Matrix<double,-1,1>>(prior_mean_for_smooth_data__.data(),
        (stan::math::logical_gt(K_smooth, 0) ? stan::math::max(smooth_map) : 0));
      {
        std::vector<local_scalar_t__> prior_mean_for_smooth_flat__;
        current_statement__ = 262;
        prior_mean_for_smooth_flat__ = context__.vals_r("prior_mean_for_smooth");
        current_statement__ = 262;
        pos__ = 1;
        current_statement__ = 262;
        for (int sym1__ = 1; sym1__ <=
             (stan::math::logical_gt(K_smooth, 0) ? stan::math::max(
                                                      smooth_map) : 0); ++sym1__) {
          current_statement__ = 262;
          stan::model::assign(prior_mean_for_smooth,
            prior_mean_for_smooth_flat__[(pos__ - 1)],
            "assigning variable prior_mean_for_smooth",
            stan::model::index_uni(sym1__));
          current_statement__ = 262;
          pos__ = (pos__ + 1);
        }
      }
      current_statement__ = 262;
      stan::math::check_greater_or_equal(function__, "prior_mean_for_smooth",
        prior_mean_for_smooth, 0);
      current_statement__ = 263;
      stan::math::validate_non_negative_index("prior_df", "K", K);
      current_statement__ = 264;
      context__.validate_dims("data initialization", "prior_df", "double",
        std::vector<size_t>{static_cast<size_t>(K)});
      prior_df_data__ = Eigen::Matrix<double,-1,1>::Constant(K,
                          std::numeric_limits<double>::quiet_NaN());
      new (&prior_df)
        Eigen::Map<Eigen::Matrix<double,-1,1>>(prior_df_data__.data(), K);
      {
        std::vector<local_scalar_t__> prior_df_flat__;
        current_statement__ = 264;
        prior_df_flat__ = context__.vals_r("prior_df");
        current_statement__ = 264;
        pos__ = 1;
        current_statement__ = 264;
        for (int sym1__ = 1; sym1__ <= K; ++sym1__) {
          current_statement__ = 264;
          stan::model::assign(prior_df, prior_df_flat__[(pos__ - 1)],
            "assigning variable prior_df", stan::model::index_uni(sym1__));
          current_statement__ = 264;
          pos__ = (pos__ + 1);
        }
      }
      current_statement__ = 264;
      stan::math::check_greater_or_equal(function__, "prior_df", prior_df, 0);
      current_statement__ = 265;
      context__.validate_dims("data initialization",
        "prior_df_for_intercept", "double", std::vector<size_t>{});
      prior_df_for_intercept = std::numeric_limits<double>::quiet_NaN();
      current_statement__ = 265;
      prior_df_for_intercept = context__.vals_r("prior_df_for_intercept")[(1
        - 1)];
      current_statement__ = 265;
      stan::math::check_greater_or_equal(function__,
        "prior_df_for_intercept", prior_df_for_intercept, 0);
      current_statement__ = 266;
      context__.validate_dims("data initialization", "prior_df_for_aux",
        "double", std::vector<size_t>{});
      prior_df_for_aux = std::numeric_limits<double>::quiet_NaN();
      current_statement__ = 266;
      prior_df_for_aux = context__.vals_r("prior_df_for_aux")[(1 - 1)];
      current_statement__ = 266;
      stan::math::check_greater_or_equal(function__, "prior_df_for_aux",
        prior_df_for_aux, 0);
      current_statement__ = 267;
      stan::math::validate_non_negative_index("prior_df_for_smooth",
        "K_smooth > 0 ? max(smooth_map) : 0",
        (stan::math::logical_gt(K_smooth, 0) ? stan::math::max(smooth_map) : 0));
      current_statement__ = 268;
      context__.validate_dims("data initialization", "prior_df_for_smooth",
        "double",
        std::vector<size_t>{static_cast<size_t>(
                              (stan::math::logical_gt(K_smooth, 0) ? 
                              stan::math::max(smooth_map) : 0))});
      prior_df_for_smooth_data__ = Eigen::Matrix<double,-1,1>::Constant((
                                     stan::math::logical_gt(K_smooth, 0) ? 
                                     stan::math::max(smooth_map) : 0),
                                     std::numeric_limits<double>::quiet_NaN());
      new (&prior_df_for_smooth)
        Eigen::Map<Eigen::Matrix<double,-1,1>>(prior_df_for_smooth_data__.data(),
        (stan::math::logical_gt(K_smooth, 0) ? stan::math::max(smooth_map) : 0));
      {
        std::vector<local_scalar_t__> prior_df_for_smooth_flat__;
        current_statement__ = 268;
        prior_df_for_smooth_flat__ = context__.vals_r("prior_df_for_smooth");
        current_statement__ = 268;
        pos__ = 1;
        current_statement__ = 268;
        for (int sym1__ = 1; sym1__ <=
             (stan::math::logical_gt(K_smooth, 0) ? stan::math::max(
                                                      smooth_map) : 0); ++sym1__) {
          current_statement__ = 268;
          stan::model::assign(prior_df_for_smooth,
            prior_df_for_smooth_flat__[(pos__ - 1)],
            "assigning variable prior_df_for_smooth",
            stan::model::index_uni(sym1__));
          current_statement__ = 268;
          pos__ = (pos__ + 1);
        }
      }
      current_statement__ = 268;
      stan::math::check_greater_or_equal(function__, "prior_df_for_smooth",
        prior_df_for_smooth, 0);
      current_statement__ = 269;
      context__.validate_dims("data initialization", "global_prior_df",
        "double", std::vector<size_t>{});
      global_prior_df = std::numeric_limits<double>::quiet_NaN();
      current_statement__ = 269;
      global_prior_df = context__.vals_r("global_prior_df")[(1 - 1)];
      current_statement__ = 269;
      stan::math::check_greater_or_equal(function__, "global_prior_df",
        global_prior_df, 0);
      current_statement__ = 270;
      context__.validate_dims("data initialization", "global_prior_scale",
        "double", std::vector<size_t>{});
      global_prior_scale = std::numeric_limits<double>::quiet_NaN();
      current_statement__ = 270;
      global_prior_scale = context__.vals_r("global_prior_scale")[(1 - 1)];
      current_statement__ = 270;
      stan::math::check_greater_or_equal(function__, "global_prior_scale",
        global_prior_scale, 0);
      current_statement__ = 271;
      context__.validate_dims("data initialization", "slab_df", "double",
        std::vector<size_t>{});
      slab_df = std::numeric_limits<double>::quiet_NaN();
      current_statement__ = 271;
      slab_df = context__.vals_r("slab_df")[(1 - 1)];
      current_statement__ = 271;
      stan::math::check_greater_or_equal(function__, "slab_df", slab_df, 0);
      current_statement__ = 272;
      context__.validate_dims("data initialization", "slab_scale", "double",
        std::vector<size_t>{});
      slab_scale = std::numeric_limits<double>::quiet_NaN();
      current_statement__ = 272;
      slab_scale = context__.vals_r("slab_scale")[(1 - 1)];
      current_statement__ = 272;
      stan::math::check_greater_or_equal(function__, "slab_scale",
        slab_scale, 0);
      current_statement__ = 273;
      stan::math::validate_non_negative_index("num_normals",
        "prior_dist == 7 ? K : 0",
        (stan::math::logical_eq(prior_dist, 7) ? K : 0));
      current_statement__ = 274;
      context__.validate_dims("data initialization", "num_normals", "int",
        std::vector<size_t>{static_cast<size_t>(
                              (stan::math::logical_eq(prior_dist, 7) ? K : 0))});
      num_normals = std::vector<int>((stan::math::logical_eq(prior_dist, 7) ? K : 0),
                      std::numeric_limits<int>::min());
      current_statement__ = 274;
      num_normals = context__.vals_i("num_normals");
      current_statement__ = 274;
      stan::math::check_greater_or_equal(function__, "num_normals",
        num_normals, 2);
      current_statement__ = 275;
      context__.validate_dims("data initialization", "t", "int",
        std::vector<size_t>{});
      t = std::numeric_limits<int>::min();
      current_statement__ = 275;
      t = context__.vals_i("t")[(1 - 1)];
      current_statement__ = 275;
      stan::math::check_greater_or_equal(function__, "t", t, 0);
      current_statement__ = 276;
      stan::math::validate_non_negative_index("p", "t", t);
      current_statement__ = 277;
      context__.validate_dims("data initialization", "p", "int",
        std::vector<size_t>{static_cast<size_t>(t)});
      p = std::vector<int>(t, std::numeric_limits<int>::min());
      current_statement__ = 277;
      p = context__.vals_i("p");
      current_statement__ = 277;
      stan::math::check_greater_or_equal(function__, "p", p, 1);
      current_statement__ = 278;
      stan::math::validate_non_negative_index("l", "t", t);
      current_statement__ = 279;
      context__.validate_dims("data initialization", "l", "int",
        std::vector<size_t>{static_cast<size_t>(t)});
      l = std::vector<int>(t, std::numeric_limits<int>::min());
      current_statement__ = 279;
      l = context__.vals_i("l");
      current_statement__ = 279;
      stan::math::check_greater_or_equal(function__, "l", l, 1);
      current_statement__ = 280;
      context__.validate_dims("data initialization", "q", "int",
        std::vector<size_t>{});
      q = std::numeric_limits<int>::min();
      current_statement__ = 280;
      q = context__.vals_i("q")[(1 - 1)];
      current_statement__ = 280;
      stan::math::check_greater_or_equal(function__, "q", q, 0);
      current_statement__ = 281;
      context__.validate_dims("data initialization", "len_theta_L", "int",
        std::vector<size_t>{});
      len_theta_L = std::numeric_limits<int>::min();
      current_statement__ = 281;
      len_theta_L = context__.vals_i("len_theta_L")[(1 - 1)];
      current_statement__ = 281;
      stan::math::check_greater_or_equal(function__, "len_theta_L",
        len_theta_L, 0);
      current_statement__ = 282;
      stan::math::validate_non_negative_index("shape", "t", t);
      current_statement__ = 283;
      context__.validate_dims("data initialization", "shape", "double",
        std::vector<size_t>{static_cast<size_t>(t)});
      shape_data__ = Eigen::Matrix<double,-1,1>::Constant(t,
                       std::numeric_limits<double>::quiet_NaN());
      new (&shape)
        Eigen::Map<Eigen::Matrix<double,-1,1>>(shape_data__.data(), t);
      {
        std::vector<local_scalar_t__> shape_flat__;
        current_statement__ = 283;
        shape_flat__ = context__.vals_r("shape");
        current_statement__ = 283;
        pos__ = 1;
        current_statement__ = 283;
        for (int sym1__ = 1; sym1__ <= t; ++sym1__) {
          current_statement__ = 283;
          stan::model::assign(shape, shape_flat__[(pos__ - 1)],
            "assigning variable shape", stan::model::index_uni(sym1__));
          current_statement__ = 283;
          pos__ = (pos__ + 1);
        }
      }
      current_statement__ = 283;
      stan::math::check_greater_or_equal(function__, "shape", shape, 0);
      current_statement__ = 284;
      stan::math::validate_non_negative_index("scale", "t", t);
      current_statement__ = 285;
      context__.validate_dims("data initialization", "scale", "double",
        std::vector<size_t>{static_cast<size_t>(t)});
      scale_data__ = Eigen::Matrix<double,-1,1>::Constant(t,
                       std::numeric_limits<double>::quiet_NaN());
      new (&scale)
        Eigen::Map<Eigen::Matrix<double,-1,1>>(scale_data__.data(), t);
      {
        std::vector<local_scalar_t__> scale_flat__;
        current_statement__ = 285;
        scale_flat__ = context__.vals_r("scale");
        current_statement__ = 285;
        pos__ = 1;
        current_statement__ = 285;
        for (int sym1__ = 1; sym1__ <= t; ++sym1__) {
          current_statement__ = 285;
          stan::model::assign(scale, scale_flat__[(pos__ - 1)],
            "assigning variable scale", stan::model::index_uni(sym1__));
          current_statement__ = 285;
          pos__ = (pos__ + 1);
        }
      }
      current_statement__ = 285;
      stan::math::check_greater_or_equal(function__, "scale", scale, 0);
      current_statement__ = 286;
      context__.validate_dims("data initialization", "len_concentration",
        "int", std::vector<size_t>{});
      len_concentration = std::numeric_limits<int>::min();
      current_statement__ = 286;
      len_concentration = context__.vals_i("len_concentration")[(1 - 1)];
      current_statement__ = 286;
      stan::math::check_greater_or_equal(function__, "len_concentration",
        len_concentration, 0);
      current_statement__ = 287;
      stan::math::validate_non_negative_index("concentration",
        "len_concentration", len_concentration);
      current_statement__ = 288;
      context__.validate_dims("data initialization", "concentration",
        "double",
        std::vector<size_t>{static_cast<size_t>(len_concentration)});
      concentration = std::vector<double>(len_concentration,
                        std::numeric_limits<double>::quiet_NaN());
      current_statement__ = 288;
      concentration = context__.vals_r("concentration");
      current_statement__ = 288;
      stan::math::check_greater_or_equal(function__, "concentration",
        concentration, 0);
      current_statement__ = 289;
      context__.validate_dims("data initialization", "len_regularization",
        "int", std::vector<size_t>{});
      len_regularization = std::numeric_limits<int>::min();
      current_statement__ = 289;
      len_regularization = context__.vals_i("len_regularization")[(1 - 1)];
      current_statement__ = 289;
      stan::math::check_greater_or_equal(function__, "len_regularization",
        len_regularization, 0);
      current_statement__ = 290;
      stan::math::validate_non_negative_index("regularization",
        "len_regularization", len_regularization);
      current_statement__ = 291;
      context__.validate_dims("data initialization", "regularization",
        "double",
        std::vector<size_t>{static_cast<size_t>(len_regularization)});
      regularization = std::vector<double>(len_regularization,
                         std::numeric_limits<double>::quiet_NaN());
      current_statement__ = 291;
      regularization = context__.vals_r("regularization");
      current_statement__ = 291;
      stan::math::check_greater_or_equal(function__, "regularization",
        regularization, 0);
      current_statement__ = 292;
      context__.validate_dims("data initialization", "num_non_zero", "int",
        std::vector<size_t>{});
      num_non_zero = std::numeric_limits<int>::min();
      current_statement__ = 292;
      num_non_zero = context__.vals_i("num_non_zero")[(1 - 1)];
      current_statement__ = 292;
      stan::math::check_greater_or_equal(function__, "num_non_zero",
        num_non_zero, 0);
      current_statement__ = 293;
      stan::math::validate_non_negative_index("w", "num_non_zero",
        num_non_zero);
      current_statement__ = 294;
      context__.validate_dims("data initialization", "w", "double",
        std::vector<size_t>{static_cast<size_t>(num_non_zero)});
      w_data__ = Eigen::Matrix<double,-1,1>::Constant(num_non_zero,
                   std::numeric_limits<double>::quiet_NaN());
      new (&w) Eigen::Map<Eigen::Matrix<double,-1,1>>(w_data__.data(),
        num_non_zero);
      {
        std::vector<local_scalar_t__> w_flat__;
        current_statement__ = 294;
        w_flat__ = context__.vals_r("w");
        current_statement__ = 294;
        pos__ = 1;
        current_statement__ = 294;
        for (int sym1__ = 1; sym1__ <= num_non_zero; ++sym1__) {
          current_statement__ = 294;
          stan::model::assign(w, w_flat__[(pos__ - 1)],
            "assigning variable w", stan::model::index_uni(sym1__));
          current_statement__ = 294;
          pos__ = (pos__ + 1);
        }
      }
      current_statement__ = 295;
      stan::math::validate_non_negative_index("v", "num_non_zero",
        num_non_zero);
      current_statement__ = 296;
      context__.validate_dims("data initialization", "v", "int",
        std::vector<size_t>{static_cast<size_t>(num_non_zero)});
      v = std::vector<int>(num_non_zero, std::numeric_limits<int>::min());
      current_statement__ = 296;
      v = context__.vals_i("v");
      current_statement__ = 296;
      stan::math::check_greater_or_equal(function__, "v", v, 0);
      current_statement__ = 296;
      stan::math::check_less_or_equal(function__, "v", v, (q - 1));
      current_statement__ = 297;
      stan::math::validate_non_negative_index("u", "t > 0 ? N + 1 : 0",
        (stan::math::logical_gt(t, 0) ? (N + 1) : 0));
      current_statement__ = 298;
      context__.validate_dims("data initialization", "u", "int",
        std::vector<size_t>{static_cast<size_t>(
                              (stan::math::logical_gt(t, 0) ? (N + 1) : 0))});
      u = std::vector<int>((stan::math::logical_gt(t, 0) ? (N + 1) : 0),
            std::numeric_limits<int>::min());
      current_statement__ = 298;
      u = context__.vals_i("u");
      current_statement__ = 298;
      stan::math::check_greater_or_equal(function__, "u", u, 0);
      current_statement__ = 298;
      stan::math::check_less_or_equal(function__, "u", u,
        (stan::math::rows(w) + 1));
      current_statement__ = 299;
      context__.validate_dims("data initialization", "special_case", "int",
        std::vector<size_t>{});
      special_case = std::numeric_limits<int>::min();
      current_statement__ = 299;
      special_case = context__.vals_i("special_case")[(1 - 1)];
      current_statement__ = 299;
      stan::math::check_greater_or_equal(function__, "special_case",
        special_case, 0);
      current_statement__ = 299;
      stan::math::check_less_or_equal(function__, "special_case",
        special_case, 1);
      current_statement__ = 300;
      aux = std::numeric_limits<double>::quiet_NaN();
      current_statement__ = 300;
      aux = stan::math::not_a_number();
      current_statement__ = 301;
      stan::math::validate_non_negative_index("V", "special_case ? t : 0",
        (special_case ? t : 0));
      current_statement__ = 302;
      stan::math::validate_non_negative_index("V", "N", N);
      current_statement__ = 303;
      V = std::vector<std::vector<int>>((special_case ? t : 0),
            std::vector<int>(N, std::numeric_limits<int>::min()));
      current_statement__ = 303;
      stan::model::assign(V, make_V(N, (special_case ? t : 0), v, pstream__),
        "assigning variable V");
      current_statement__ = 304;
      len_z_T = std::numeric_limits<int>::min();
      current_statement__ = 304;
      len_z_T = 0;
      current_statement__ = 305;
      len_var_group = std::numeric_limits<int>::min();
      current_statement__ = 305;
      len_var_group = (stan::math::sum(p) * stan::math::logical_gt(t, 0));
      current_statement__ = 306;
      len_rho = std::numeric_limits<int>::min();
      current_statement__ = 306;
      len_rho = (stan::math::sum(p) - t);
      current_statement__ = 307;
      is_continuous = std::numeric_limits<int>::min();
      current_statement__ = 307;
      is_continuous = 0;
      current_statement__ = 308;
      pos = std::numeric_limits<int>::min();
      current_statement__ = 308;
      pos = 1;
      current_statement__ = 309;
      stan::math::validate_non_negative_index("delta", "len_concentration",
        len_concentration);
      current_statement__ = 310;
      delta = std::vector<double>(len_concentration,
                std::numeric_limits<double>::quiet_NaN());
      current_statement__ = 311;
      hs = std::numeric_limits<int>::min();
      current_statement__ = 318;
      if (stan::math::logical_lte(prior_dist, 2)) {
        current_statement__ = 317;
        hs = 0;
      } else {
        current_statement__ = 316;
        if (stan::math::logical_eq(prior_dist, 3)) {
          current_statement__ = 315;
          hs = 2;
        } else {
          current_statement__ = 314;
          if (stan::math::logical_eq(prior_dist, 4)) {
            current_statement__ = 313;
            hs = 4;
          } else {
            current_statement__ = 312;
            hs = 0;
          }
        }
      }
      current_statement__ = 328;
      for (int i = 1; i <= t; ++i) {
        current_statement__ = 324;
        if (stan::math::logical_gt(
              stan::model::rvalue(p, "p", stan::model::index_uni(i)), 1)) {
          current_statement__ = 322;
          for (int j = 1; j <=
               stan::model::rvalue(p, "p", stan::model::index_uni(i)); ++j) {
            current_statement__ = 319;
            stan::model::assign(delta,
              stan::model::rvalue(concentration, "concentration",
                stan::model::index_uni(j)), "assigning variable delta",
              stan::model::index_uni(pos));
            current_statement__ = 320;
            pos = (pos + 1);
          }
        }
        current_statement__ = 326;
        for (int j = 3; j <=
             stan::model::rvalue(p, "p", stan::model::index_uni(i)); ++j) {
          current_statement__ = 325;
          len_z_T = (len_z_T +
            (stan::model::rvalue(p, "p", stan::model::index_uni(i)) - 1));
        }
      }
      current_statement__ = 303;
      stan::math::check_greater_or_equal(function__, "V", V, 1);
      current_statement__ = 304;
      stan::math::check_greater_or_equal(function__, "len_z_T", len_z_T, 0);
      current_statement__ = 305;
      stan::math::check_greater_or_equal(function__, "len_var_group",
        len_var_group, 0);
      current_statement__ = 306;
      stan::math::check_greater_or_equal(function__, "len_rho", len_rho, 0);
      current_statement__ = 307;
      stan::math::check_greater_or_equal(function__, "is_continuous",
        is_continuous, 0);
      current_statement__ = 307;
      stan::math::check_less_or_equal(function__, "is_continuous",
        is_continuous, 1);
      current_statement__ = 308;
      stan::math::check_greater_or_equal(function__, "pos", pos, 1);
      current_statement__ = 310;
      stan::math::check_greater_or_equal(function__, "delta", delta, 0);
      current_statement__ = 311;
      stan::math::check_greater_or_equal(function__, "hs", hs, 0);
      current_statement__ = 329;
      stan::math::validate_non_negative_index("gamma", "has_intercept",
        has_intercept);
      current_statement__ = 330;
      z_beta_1dim__ = std::numeric_limits<int>::min();
      current_statement__ = 330;
      z_beta_1dim__ = (stan::math::logical_eq(prior_dist, 7) ? stan::math::sum(
                                                                 num_normals) : K);
      current_statement__ = 330;
      stan::math::validate_non_negative_index("z_beta",
        "prior_dist == 7 ? sum(num_normals) : K", z_beta_1dim__);
      current_statement__ = 331;
      stan::math::validate_non_negative_index("z_beta_smooth", "K_smooth",
        K_smooth);
      current_statement__ = 332;
      smooth_sd_raw_1dim__ = std::numeric_limits<int>::min();
      current_statement__ = 332;
      smooth_sd_raw_1dim__ = (stan::math::logical_gt(K_smooth, 0) ? stan::model::rvalue(
                                                                    smooth_map,
                                                                    "smooth_map",
                                                                    stan::model::index_uni(
                                                                    K_smooth)) : 0);
      current_statement__ = 332;
      stan::math::validate_non_negative_index("smooth_sd_raw",
        "K_smooth > 0 ? smooth_map[K_smooth] : 0", smooth_sd_raw_1dim__);
      current_statement__ = 333;
      stan::math::validate_non_negative_index("global", "hs", hs);
      current_statement__ = 334;
      stan::math::validate_non_negative_index("local", "hs", hs);
      current_statement__ = 335;
      stan::math::validate_non_negative_index("local", "K", K);
      current_statement__ = 336;
      caux_1dim__ = std::numeric_limits<int>::min();
      current_statement__ = 336;
      caux_1dim__ = stan::math::logical_gt(hs, 0);
      current_statement__ = 336;
      stan::math::validate_non_negative_index("caux", "hs > 0", caux_1dim__);
      current_statement__ = 337;
      mix_1dim__ = std::numeric_limits<int>::min();
      current_statement__ = 337;
      mix_1dim__ = (stan::math::primitive_value(
                      stan::math::logical_eq(prior_dist, 5))
        ||
        stan::math::primitive_value(stan::math::logical_eq(prior_dist, 6)));
      current_statement__ = 337;
      stan::math::validate_non_negative_index("mix",
        "prior_dist == 5 || prior_dist == 6", mix_1dim__);
      current_statement__ = 338;
      stan::math::validate_non_negative_index("mix", "K", K);
      current_statement__ = 339;
      one_over_lambda_1dim__ = std::numeric_limits<int>::min();
      current_statement__ = 339;
      one_over_lambda_1dim__ = stan::math::logical_eq(prior_dist, 6);
      current_statement__ = 339;
      stan::math::validate_non_negative_index("one_over_lambda",
        "prior_dist == 6", one_over_lambda_1dim__);
      current_statement__ = 340;
      stan::math::validate_non_negative_index("z_b", "q", q);
      current_statement__ = 341;
      stan::math::validate_non_negative_index("z_T", "len_z_T", len_z_T);
      current_statement__ = 342;
      stan::math::validate_non_negative_index("rho", "len_rho", len_rho);
      current_statement__ = 343;
      stan::math::validate_non_negative_index("zeta", "len_concentration",
        len_concentration);
      current_statement__ = 344;
      stan::math::validate_non_negative_index("tau", "t", t);
      current_statement__ = 345;
      stan::math::validate_non_negative_index("beta", "K", K);
      current_statement__ = 346;
      stan::math::validate_non_negative_index("beta_smooth", "K_smooth",
        K_smooth);
      current_statement__ = 347;
      smooth_sd_1dim__ = std::numeric_limits<int>::min();
      current_statement__ = 347;
      smooth_sd_1dim__ = (stan::math::logical_gt(K_smooth, 0) ? stan::model::rvalue(
                                                                  smooth_map,
                                                                  "smooth_map",
                                                                  stan::model::index_uni(
                                                                    K_smooth)) : 0);
      current_statement__ = 347;
      stan::math::validate_non_negative_index("smooth_sd",
        "K_smooth > 0 ? smooth_map[K_smooth] : 0", smooth_sd_1dim__);
      current_statement__ = 348;
      stan::math::validate_non_negative_index("b", "q", q);
      current_statement__ = 349;
      stan::math::validate_non_negative_index("theta_L", "len_theta_L",
        len_theta_L);
      current_statement__ = 350;
      stan::math::validate_non_negative_index("alpha", "has_intercept",
        has_intercept);
    } catch (const std::exception& e) {
      stan::lang::rethrow_located(e, locations_array__[current_statement__]);
    }
    num_params_r__ = has_intercept + z_beta_1dim__ + K_smooth +
      smooth_sd_raw_1dim__ + hs + (hs * K) + caux_1dim__ + (mix_1dim__ * K) +
      one_over_lambda_1dim__ + q + len_z_T + len_rho + len_concentration + t;
  }
  inline std::string model_name() const final {
    return "model_binomial";
  }
  inline std::vector<std::string> model_compile_info() const noexcept {
    return std::vector<std::string>{"stanc_version = stanc3 v2.32.2",
             "stancflags = --allow-undefined"};
  }
  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__;
    stan::io::deserializer<local_scalar_t__> in__(params_r__, params_i__);
    int current_statement__ = 0;
    local_scalar_t__ DUMMY_VAR__(std::numeric_limits<double>::quiet_NaN());
    // suppress unused var warning
    (void) DUMMY_VAR__;
    static constexpr const char* function__ =
      "model_binomial_namespace::log_prob";
    // suppress unused var warning
    (void) function__;
    try {
      std::vector<local_scalar_t__> gamma =
        std::vector<local_scalar_t__>(has_intercept, DUMMY_VAR__);
      current_statement__ = 1;
      gamma = in__.template read_constrain_ub<std::vector<local_scalar_t__>,
                jacobian__>((stan::math::logical_eq(link, 4) ? 0.0 : 
                stan::math::positive_infinity()), lp__, has_intercept);
      Eigen::Matrix<local_scalar_t__,-1,1> z_beta =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(z_beta_1dim__,
          DUMMY_VAR__);
      current_statement__ = 2;
      z_beta = in__.template read<
                 Eigen::Matrix<local_scalar_t__,-1,1>>(z_beta_1dim__);
      Eigen::Matrix<local_scalar_t__,-1,1> z_beta_smooth =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(K_smooth, DUMMY_VAR__);
      current_statement__ = 3;
      z_beta_smooth = in__.template read<
                        Eigen::Matrix<local_scalar_t__,-1,1>>(K_smooth);
      Eigen::Matrix<local_scalar_t__,-1,1> smooth_sd_raw =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(smooth_sd_raw_1dim__,
          DUMMY_VAR__);
      current_statement__ = 4;
      smooth_sd_raw = in__.template read_constrain_lb<
                        Eigen::Matrix<local_scalar_t__,-1,1>, jacobian__>(0,
                        lp__, smooth_sd_raw_1dim__);
      std::vector<local_scalar_t__> global =
        std::vector<local_scalar_t__>(hs, DUMMY_VAR__);
      current_statement__ = 5;
      global = in__.template read_constrain_lb<std::vector<local_scalar_t__>,
                 jacobian__>(0, lp__, hs);
      std::vector<Eigen::Matrix<local_scalar_t__,-1,1>> local =
        std::vector<Eigen::Matrix<local_scalar_t__,-1,1>>(hs,
          Eigen::Matrix<local_scalar_t__,-1,1>::Constant(K, DUMMY_VAR__));
      current_statement__ = 6;
      local = in__.template read_constrain_lb<
                std::vector<Eigen::Matrix<local_scalar_t__,-1,1>>,
                jacobian__>(0, lp__, hs, K);
      std::vector<local_scalar_t__> caux =
        std::vector<local_scalar_t__>(caux_1dim__, DUMMY_VAR__);
      current_statement__ = 7;
      caux = in__.template read_constrain_lb<std::vector<local_scalar_t__>,
               jacobian__>(0, lp__, caux_1dim__);
      std::vector<Eigen::Matrix<local_scalar_t__,-1,1>> mix =
        std::vector<Eigen::Matrix<local_scalar_t__,-1,1>>(mix_1dim__,
          Eigen::Matrix<local_scalar_t__,-1,1>::Constant(K, DUMMY_VAR__));
      current_statement__ = 8;
      mix = in__.template read_constrain_lb<
              std::vector<Eigen::Matrix<local_scalar_t__,-1,1>>,
              jacobian__>(0, lp__, mix_1dim__, K);
      std::vector<local_scalar_t__> one_over_lambda =
        std::vector<local_scalar_t__>(one_over_lambda_1dim__, DUMMY_VAR__);
      current_statement__ = 9;
      one_over_lambda = in__.template read_constrain_lb<
                          std::vector<local_scalar_t__>, jacobian__>(0, lp__,
                          one_over_lambda_1dim__);
      Eigen::Matrix<local_scalar_t__,-1,1> z_b =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(q, DUMMY_VAR__);
      current_statement__ = 10;
      z_b = in__.template read<Eigen::Matrix<local_scalar_t__,-1,1>>(q);
      Eigen::Matrix<local_scalar_t__,-1,1> z_T =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(len_z_T, DUMMY_VAR__);
      current_statement__ = 11;
      z_T = in__.template read<Eigen::Matrix<local_scalar_t__,-1,1>>(len_z_T);
      Eigen::Matrix<local_scalar_t__,-1,1> rho =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(len_rho, DUMMY_VAR__);
      current_statement__ = 12;
      rho = in__.template read_constrain_lub<
              Eigen::Matrix<local_scalar_t__,-1,1>, jacobian__>(0, 1, lp__,
              len_rho);
      Eigen::Matrix<local_scalar_t__,-1,1> zeta =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(len_concentration,
          DUMMY_VAR__);
      current_statement__ = 13;
      zeta = in__.template read_constrain_lb<
               Eigen::Matrix<local_scalar_t__,-1,1>, jacobian__>(0, lp__,
               len_concentration);
      Eigen::Matrix<local_scalar_t__,-1,1> tau =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(t, DUMMY_VAR__);
      current_statement__ = 14;
      tau = in__.template read_constrain_lb<
              Eigen::Matrix<local_scalar_t__,-1,1>, jacobian__>(0, lp__, t);
      Eigen::Matrix<local_scalar_t__,-1,1> beta =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(K, DUMMY_VAR__);
      Eigen::Matrix<local_scalar_t__,-1,1> beta_smooth =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(K_smooth, DUMMY_VAR__);
      Eigen::Matrix<local_scalar_t__,-1,1> smooth_sd =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(smooth_sd_1dim__,
          DUMMY_VAR__);
      Eigen::Matrix<local_scalar_t__,-1,1> b =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(q, DUMMY_VAR__);
      Eigen::Matrix<local_scalar_t__,-1,1> theta_L =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(len_theta_L,
          DUMMY_VAR__);
      current_statement__ = 58;
      if (stan::math::logical_eq(prior_dist, 0)) {
        current_statement__ = 57;
        stan::model::assign(beta, z_beta, "assigning variable beta");
      } else {
        current_statement__ = 56;
        if (stan::math::logical_eq(prior_dist, 1)) {
          current_statement__ = 55;
          stan::model::assign(beta,
            stan::math::add(stan::math::elt_multiply(z_beta, prior_scale),
              prior_mean), "assigning variable beta");
        } else {
          current_statement__ = 54;
          if (stan::math::logical_eq(prior_dist, 2)) {
            current_statement__ = 53;
            for (int k = 1; k <= K; ++k) {
              current_statement__ = 51;
              stan::model::assign(beta,
                ((CFt(
                    stan::model::rvalue(z_beta, "z_beta",
                      stan::model::index_uni(k)),
                    stan::model::rvalue(prior_df, "prior_df",
                      stan::model::index_uni(k)), pstream__) *
                stan::model::rvalue(prior_scale, "prior_scale",
                  stan::model::index_uni(k))) +
                stan::model::rvalue(prior_mean, "prior_mean",
                  stan::model::index_uni(k))), "assigning variable beta",
                stan::model::index_uni(k));
            }
          } else {
            current_statement__ = 50;
            if (stan::math::logical_eq(prior_dist, 3)) {
              local_scalar_t__ c2 = DUMMY_VAR__;
              current_statement__ = 45;
              c2 = (stan::math::square(slab_scale) *
                stan::model::rvalue(caux, "caux", stan::model::index_uni(1)));
              current_statement__ = 48;
              if ((stan::math::primitive_value(
                     stan::math::logical_eq(is_continuous, 1))
                  &&
                  stan::math::primitive_value(
                    stan::math::logical_eq(family, 1)))) {
                current_statement__ = 47;
                stan::model::assign(beta,
                  hs_prior(z_beta, global, local, global_prior_scale, aux,
                    c2, pstream__), "assigning variable beta");
              } else {
                current_statement__ = 46;
                stan::model::assign(beta,
                  hs_prior(z_beta, global, local, global_prior_scale,
                    static_cast<double>(1), c2, pstream__),
                  "assigning variable beta");
              }
            } else {
              current_statement__ = 44;
              if (stan::math::logical_eq(prior_dist, 4)) {
                local_scalar_t__ c2 = DUMMY_VAR__;
                current_statement__ = 39;
                c2 = (stan::math::square(slab_scale) *
                  stan::model::rvalue(caux, "caux", stan::model::index_uni(1)));
                current_statement__ = 42;
                if ((stan::math::primitive_value(
                       stan::math::logical_eq(is_continuous, 1))
                    &&
                    stan::math::primitive_value(
                      stan::math::logical_eq(family, 1)))) {
                  current_statement__ = 41;
                  stan::model::assign(beta,
                    hsplus_prior(z_beta, global, local, global_prior_scale,
                      aux, c2, pstream__), "assigning variable beta");
                } else {
                  current_statement__ = 40;
                  stan::model::assign(beta,
                    hsplus_prior(z_beta, global, local, global_prior_scale,
                      static_cast<double>(1), c2, pstream__),
                    "assigning variable beta");
                }
              } else {
                current_statement__ = 38;
                if (stan::math::logical_eq(prior_dist, 5)) {
                  current_statement__ = 37;
                  stan::model::assign(beta,
                    stan::math::add(prior_mean,
                      stan::math::elt_multiply(
                        stan::math::elt_multiply(prior_scale,
                          stan::math::sqrt(
                            stan::math::multiply(2,
                              stan::model::rvalue(mix, "mix",
                                stan::model::index_uni(1))))), z_beta)),
                    "assigning variable beta");
                } else {
                  current_statement__ = 36;
                  if (stan::math::logical_eq(prior_dist, 6)) {
                    current_statement__ = 35;
                    stan::model::assign(beta,
                      stan::math::add(prior_mean,
                        stan::math::elt_multiply(
                          stan::math::elt_multiply(
                            stan::math::multiply(
                              stan::model::rvalue(one_over_lambda,
                                "one_over_lambda", stan::model::index_uni(1)),
                              prior_scale),
                            stan::math::sqrt(
                              stan::math::multiply(2,
                                stan::model::rvalue(mix, "mix",
                                  stan::model::index_uni(1))))), z_beta)),
                      "assigning variable beta");
                  } else {
                    current_statement__ = 34;
                    if (stan::math::logical_eq(prior_dist, 7)) {
                      int z_pos = std::numeric_limits<int>::min();
                      current_statement__ = 22;
                      z_pos = 1;
                      current_statement__ = 32;
                      for (int k = 1; k <= K; ++k) {
                        current_statement__ = 23;
                        stan::model::assign(beta,
                          stan::model::rvalue(z_beta, "z_beta",
                            stan::model::index_uni(z_pos)),
                          "assigning variable beta",
                          stan::model::index_uni(k));
                        current_statement__ = 24;
                        z_pos = (z_pos + 1);
                        current_statement__ = 28;
                        for (int n = 2; n <=
                             stan::model::rvalue(num_normals, "num_normals",
                               stan::model::index_uni(k)); ++n) {
                          current_statement__ = 25;
                          stan::model::assign(beta,
                            (stan::model::rvalue(beta, "beta",
                               stan::model::index_uni(k)) *
                            stan::model::rvalue(z_beta, "z_beta",
                              stan::model::index_uni(z_pos))),
                            "assigning variable beta",
                            stan::model::index_uni(k));
                          current_statement__ = 26;
                          z_pos = (z_pos + 1);
                        }
                        current_statement__ = 29;
                        stan::model::assign(beta,
                          (stan::model::rvalue(beta, "beta",
                             stan::model::index_uni(k)) *
                          stan::math::pow(
                            stan::model::rvalue(prior_scale, "prior_scale",
                              stan::model::index_uni(k)),
                            stan::model::rvalue(num_normals, "num_normals",
                              stan::model::index_uni(k)))),
                          "assigning variable beta",
                          stan::model::index_uni(k));
                        current_statement__ = 30;
                        stan::model::assign(beta,
                          (stan::model::rvalue(beta, "beta",
                             stan::model::index_uni(k)) +
                          stan::model::rvalue(prior_mean, "prior_mean",
                            stan::model::index_uni(k))),
                          "assigning variable beta",
                          stan::model::index_uni(k));
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
      current_statement__ = 64;
      if (K_smooth) {
        current_statement__ = 59;
        stan::model::assign(smooth_sd,
          stan::math::add(prior_mean_for_smooth,
            stan::math::elt_multiply(prior_scale_for_smooth, smooth_sd_raw)),
          "assigning variable smooth_sd");
        current_statement__ = 61;
        if ((stan::math::primitive_value(is_continuous) &&
            stan::math::primitive_value(stan::math::logical_eq(family, 1)))) {
          current_statement__ = 60;
          stan::model::assign(smooth_sd,
            stan::math::multiply(stan::model::deep_copy(smooth_sd), aux),
            "assigning variable smooth_sd");
        }
        current_statement__ = 62;
        stan::model::assign(beta_smooth,
          stan::math::elt_multiply(z_beta_smooth,
            stan::model::rvalue(smooth_sd, "smooth_sd",
              stan::model::index_multi(smooth_map))),
          "assigning variable beta_smooth");
      }
      current_statement__ = 80;
      if (stan::math::logical_gt(t, 0)) {
        current_statement__ = 78;
        if (stan::math::logical_eq(special_case, 1)) {
          int start = std::numeric_limits<int>::min();
          current_statement__ = 68;
          start = 1;
          current_statement__ = 69;
          stan::model::assign(theta_L, stan::math::elt_multiply(scale, tau),
            "assigning variable theta_L");
          current_statement__ = 76;
          if (stan::math::logical_eq(t, 1)) {
            current_statement__ = 75;
            stan::model::assign(b,
              stan::math::multiply(
                stan::model::rvalue(theta_L, "theta_L",
                  stan::model::index_uni(1)), z_b), "assigning variable b");
          } else {
            current_statement__ = 74;
            for (int i = 1; i <= t; ++i) {
              int end = std::numeric_limits<int>::min();
              current_statement__ = 70;
              end = ((start +
                stan::model::rvalue(l, "l", stan::model::index_uni(i))) - 1);
              current_statement__ = 71;
              stan::model::assign(b,
                stan::math::multiply(
                  stan::model::rvalue(theta_L, "theta_L",
                    stan::model::index_uni(i)),
                  stan::model::rvalue(z_b, "z_b",
                    stan::model::index_min_max(start, end))),
                "assigning variable b",
                stan::model::index_min_max(start, end));
              current_statement__ = 72;
              start = (end + 1);
            }
          }
        } else {
          current_statement__ = 65;
          stan::model::assign(theta_L,
            make_theta_L(len_theta_L, p, 1.0, tau, scale, zeta, rho, z_T,
              pstream__), "assigning variable theta_L");
          current_statement__ = 66;
          stan::model::assign(b, make_b(z_b, theta_L, p, l, pstream__),
            "assigning variable b");
        }
      }
      {
        current_statement__ = 152;
        if (stan::math::logical_eq(prior_PD, 0)) {
          current_statement__ = 122;
          stan::math::validate_non_negative_index("eta", "N", N);
          Eigen::Matrix<local_scalar_t__,-1,1> eta =
            Eigen::Matrix<local_scalar_t__,-1,1>::Constant(N, DUMMY_VAR__);
          current_statement__ = 129;
          if (stan::math::logical_gt(K, 0)) {
            current_statement__ = 127;
            if (dense_X) {
              current_statement__ = 126;
              stan::model::assign(eta,
                stan::math::multiply(
                  stan::model::rvalue(X, "X", stan::model::index_uni(1)),
                  beta), "assigning variable eta");
            } else {
              current_statement__ = 125;
              stan::model::assign(eta,
                stan::math::csr_matrix_times_vector(N, K, w_X, v_X, u_X, beta),
                "assigning variable eta");
            }
          } else {
            current_statement__ = 124;
            stan::model::assign(eta, stan::math::rep_vector(0.0, N),
              "assigning variable eta");
          }
          current_statement__ = 131;
          if (stan::math::logical_eq(has_offset, 1)) {
            current_statement__ = 130;
            stan::model::assign(eta,
              stan::math::add(stan::model::deep_copy(eta), offset_),
              "assigning variable eta");
          }
          current_statement__ = 133;
          if (K_smooth) {
            current_statement__ = 132;
            stan::model::assign(eta,
              stan::math::add(stan::model::deep_copy(eta),
                stan::math::multiply(S, beta_smooth)),
              "assigning variable eta");
          }
          current_statement__ = 139;
          if (stan::math::logical_gt(t, 0)) {
            current_statement__ = 137;
            if (special_case) {
              current_statement__ = 136;
              for (int i = 1; i <= t; ++i) {
                current_statement__ = 135;
                stan::model::assign(eta,
                  stan::math::add(stan::model::deep_copy(eta),
                    stan::model::rvalue(b, "b",
                      stan::model::index_multi(
                        stan::model::rvalue(V, "V", stan::model::index_uni(i))))),
                  "assigning variable eta");
              }
            } else {
              current_statement__ = 134;
              stan::model::assign(eta,
                stan::math::add(stan::model::deep_copy(eta),
                  stan::math::csr_matrix_times_vector(N, q, w, v, u, b)),
                "assigning variable eta");
            }
          }
          current_statement__ = 146;
          if (stan::math::logical_eq(has_intercept, 1)) {
            current_statement__ = 144;
            if (stan::math::logical_neq(link, 4)) {
              current_statement__ = 143;
              stan::model::assign(eta,
                stan::math::add(stan::model::deep_copy(eta),
                  stan::model::rvalue(gamma, "gamma",
                    stan::model::index_uni(1))), "assigning variable eta");
            } else {
              current_statement__ = 142;
              stan::model::assign(eta,
                stan::math::add(stan::model::deep_copy(eta),
                  (stan::model::rvalue(gamma, "gamma",
                     stan::model::index_uni(1)) - stan::math::max(eta))),
                "assigning variable eta");
            }
          } else {
            current_statement__ = 140;
            stan::model::assign(eta,
              stan::math::add(stan::model::deep_copy(eta),
                stan::math::dot_product(xbar, beta)),
              "assigning variable eta");
          }
          current_statement__ = 150;
          if (stan::math::logical_eq(has_weights, 0)) {
            current_statement__ = 148;
            lp_accum__.add(binom_lpmf<false>(y, trials, eta, link, pstream__));
          } else {
            current_statement__ = 147;
            lp_accum__.add(stan::math::dot_product(weights,
                             pw_binom(y, trials, eta, link, pstream__)));
          }
        }
        current_statement__ = 188;
        if (stan::math::logical_eq(prior_dist, 1)) {
          current_statement__ = 187;
          lp_accum__.add(stan::math::normal_lpdf<false>(z_beta, 0, 1));
        } else {
          current_statement__ = 186;
          if (stan::math::logical_eq(prior_dist, 2)) {
            current_statement__ = 185;
            lp_accum__.add(stan::math::normal_lpdf<false>(z_beta, 0, 1));
          } else {
            current_statement__ = 184;
            if (stan::math::logical_eq(prior_dist, 3)) {
              local_scalar_t__ log_half = DUMMY_VAR__;
              current_statement__ = 176;
              log_half = -0.693147180559945286;
              current_statement__ = 177;
              lp_accum__.add(stan::math::normal_lpdf<false>(z_beta, 0, 1));
              current_statement__ = 178;
              lp_accum__.add((stan::math::normal_lpdf<false>(
                                stan::model::rvalue(local, "local",
                                  stan::model::index_uni(1)), 0, 1) -
                log_half));
              current_statement__ = 179;
              lp_accum__.add(stan::math::inv_gamma_lpdf<false>(
                               stan::model::rvalue(local, "local",
                                 stan::model::index_uni(2)),
                               stan::math::multiply(0.5, prior_df),
                               stan::math::multiply(0.5, prior_df)));
              current_statement__ = 180;
              lp_accum__.add((stan::math::normal_lpdf<false>(
                                stan::model::rvalue(global, "global",
                                  stan::model::index_uni(1)), 0, 1) -
                log_half));
              current_statement__ = 181;
              lp_accum__.add(stan::math::inv_gamma_lpdf<false>(
                               stan::model::rvalue(global, "global",
                                 stan::model::index_uni(2)), (0.5 *
                               global_prior_df), (0.5 * global_prior_df)));
              current_statement__ = 182;
              lp_accum__.add(stan::math::inv_gamma_lpdf<false>(caux, (0.5 *
                               slab_df), (0.5 * slab_df)));
            } else {
              current_statement__ = 175;
              if (stan::math::logical_eq(prior_dist, 4)) {
                local_scalar_t__ log_half = DUMMY_VAR__;
                current_statement__ = 165;
                log_half = -0.693147180559945286;
                current_statement__ = 166;
                lp_accum__.add(stan::math::normal_lpdf<false>(z_beta, 0, 1));
                current_statement__ = 167;
                lp_accum__.add((stan::math::normal_lpdf<false>(
                                  stan::model::rvalue(local, "local",
                                    stan::model::index_uni(1)), 0, 1) -
                  log_half));
                current_statement__ = 168;
                lp_accum__.add(stan::math::inv_gamma_lpdf<false>(
                                 stan::model::rvalue(local, "local",
                                   stan::model::index_uni(2)),
                                 stan::math::multiply(0.5, prior_df),
                                 stan::math::multiply(0.5, prior_df)));
                current_statement__ = 169;
                lp_accum__.add((stan::math::normal_lpdf<false>(
                                  stan::model::rvalue(local, "local",
                                    stan::model::index_uni(3)), 0, 1) -
                  log_half));
                current_statement__ = 170;
                lp_accum__.add(stan::math::inv_gamma_lpdf<false>(
                                 stan::model::rvalue(local, "local",
                                   stan::model::index_uni(4)),
                                 stan::math::multiply(0.5, prior_scale),
                                 stan::math::multiply(0.5, prior_scale)));
                current_statement__ = 171;
                lp_accum__.add((stan::math::normal_lpdf<false>(
                                  stan::model::rvalue(global, "global",
                                    stan::model::index_uni(1)), 0, 1) -
                  log_half));
                current_statement__ = 172;
                lp_accum__.add(stan::math::inv_gamma_lpdf<false>(
                                 stan::model::rvalue(global, "global",
                                   stan::model::index_uni(2)), (0.5 *
                                 global_prior_df), (0.5 * global_prior_df)));
                current_statement__ = 173;
                lp_accum__.add(stan::math::inv_gamma_lpdf<false>(caux, (0.5 *
                                 slab_df), (0.5 * slab_df)));
              } else {
                current_statement__ = 164;
                if (stan::math::logical_eq(prior_dist, 5)) {
                  current_statement__ = 161;
                  lp_accum__.add(stan::math::normal_lpdf<false>(z_beta, 0, 1));
                  current_statement__ = 162;
                  lp_accum__.add(stan::math::exponential_lpdf<false>(
                                   stan::model::rvalue(mix, "mix",
                                     stan::model::index_uni(1)), 1));
                } else {
                  current_statement__ = 160;
                  if (stan::math::logical_eq(prior_dist, 6)) {
                    current_statement__ = 156;
                    lp_accum__.add(stan::math::normal_lpdf<false>(z_beta, 0,
                                     1));
                    current_statement__ = 157;
                    lp_accum__.add(stan::math::exponential_lpdf<false>(
                                     stan::model::rvalue(mix, "mix",
                                       stan::model::index_uni(1)), 1));
                    current_statement__ = 158;
                    lp_accum__.add(stan::math::chi_square_lpdf<false>(
                                     stan::model::rvalue(one_over_lambda,
                                       "one_over_lambda",
                                       stan::model::index_uni(1)),
                                     stan::model::rvalue(prior_df,
                                       "prior_df", stan::model::index_uni(1))));
                  } else {
                    current_statement__ = 155;
                    if (stan::math::logical_eq(prior_dist, 7)) {
                      current_statement__ = 153;
                      lp_accum__.add(stan::math::normal_lpdf<false>(z_beta,
                                       0, 1));
                    }
                  }
                }
              }
            }
          }
        }
        current_statement__ = 194;
        if (stan::math::logical_eq(has_intercept, 1)) {
          current_statement__ = 192;
          if (stan::math::logical_eq(prior_dist_for_intercept, 1)) {
            current_statement__ = 191;
            lp_accum__.add(stan::math::normal_lpdf<false>(gamma,
                             prior_mean_for_intercept,
                             prior_scale_for_intercept));
          } else {
            current_statement__ = 190;
            if (stan::math::logical_eq(prior_dist_for_intercept, 2)) {
              current_statement__ = 189;
              lp_accum__.add(stan::math::student_t_lpdf<false>(gamma,
                               prior_df_for_intercept,
                               prior_mean_for_intercept,
                               prior_scale_for_intercept));
            }
          }
        }
        current_statement__ = 206;
        if (K_smooth) {
          current_statement__ = 195;
          lp_accum__.add(stan::math::normal_lpdf<false>(z_beta_smooth, 0, 1));
          current_statement__ = 204;
          if (stan::math::logical_gt(prior_dist_for_smooth, 0)) {
            local_scalar_t__ log_half = DUMMY_VAR__;
            current_statement__ = 196;
            log_half = -0.693147180559945286;
            current_statement__ = 202;
            if (stan::math::logical_eq(prior_dist_for_smooth, 1)) {
              current_statement__ = 201;
              lp_accum__.add((stan::math::normal_lpdf<false>(smooth_sd_raw,
                                0, 1) - log_half));
            } else {
              current_statement__ = 200;
              if (stan::math::logical_eq(prior_dist_for_smooth, 2)) {
                current_statement__ = 199;
                lp_accum__.add((stan::math::student_t_lpdf<false>(
                                  smooth_sd_raw, prior_df_for_smooth, 0, 1) -
                  log_half));
              } else {
                current_statement__ = 198;
                if (stan::math::logical_eq(prior_dist_for_smooth, 3)) {
                  current_statement__ = 197;
                  lp_accum__.add(stan::math::exponential_lpdf<false>(
                                   smooth_sd_raw, 1));
                }
              }
            }
          }
        }
        current_statement__ = 209;
        if (stan::math::logical_gt(t, 0)) {
          current_statement__ = 207;
          lp_accum__.add(decov_lpdf<false>(z_b, z_T, rho, zeta, tau,
                           regularization, delta, shape, t, p, pstream__));
        }
      }
    } catch (const std::exception& e) {
      stan::lang::rethrow_located(e, locations_array__[current_statement__]);
    }
    lp_accum__.add(lp__);
    return lp_accum__.sum();
  }
  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_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;
    stan::io::deserializer<local_scalar_t__> in__(params_r__, params_i__);
    stan::io::serializer<local_scalar_t__> out__(vars__);
    static constexpr bool propto__ = true;
    // suppress unused var warning
    (void) propto__;
    double lp__ = 0.0;
    // suppress unused var warning
    (void) lp__;
    int current_statement__ = 0;
    stan::math::accumulator<double> lp_accum__;
    local_scalar_t__ DUMMY_VAR__(std::numeric_limits<double>::quiet_NaN());
    // suppress unused var warning
    (void) DUMMY_VAR__;
    constexpr bool jacobian__ = false;
    static constexpr const char* function__ =
      "model_binomial_namespace::write_array";
    // suppress unused var warning
    (void) function__;
    try {
      std::vector<double> gamma =
        std::vector<double>(has_intercept,
          std::numeric_limits<double>::quiet_NaN());
      current_statement__ = 1;
      gamma = in__.template read_constrain_ub<std::vector<local_scalar_t__>,
                jacobian__>((stan::math::logical_eq(link, 4) ? 0.0 : 
                stan::math::positive_infinity()), lp__, has_intercept);
      Eigen::Matrix<double,-1,1> z_beta =
        Eigen::Matrix<double,-1,1>::Constant(z_beta_1dim__,
          std::numeric_limits<double>::quiet_NaN());
      current_statement__ = 2;
      z_beta = in__.template read<
                 Eigen::Matrix<local_scalar_t__,-1,1>>(z_beta_1dim__);
      Eigen::Matrix<double,-1,1> z_beta_smooth =
        Eigen::Matrix<double,-1,1>::Constant(K_smooth,
          std::numeric_limits<double>::quiet_NaN());
      current_statement__ = 3;
      z_beta_smooth = in__.template read<
                        Eigen::Matrix<local_scalar_t__,-1,1>>(K_smooth);
      Eigen::Matrix<double,-1,1> smooth_sd_raw =
        Eigen::Matrix<double,-1,1>::Constant(smooth_sd_raw_1dim__,
          std::numeric_limits<double>::quiet_NaN());
      current_statement__ = 4;
      smooth_sd_raw = in__.template read_constrain_lb<
                        Eigen::Matrix<local_scalar_t__,-1,1>, jacobian__>(0,
                        lp__, smooth_sd_raw_1dim__);
      std::vector<double> global =
        std::vector<double>(hs, std::numeric_limits<double>::quiet_NaN());
      current_statement__ = 5;
      global = in__.template read_constrain_lb<std::vector<local_scalar_t__>,
                 jacobian__>(0, lp__, hs);
      std::vector<Eigen::Matrix<double,-1,1>> local =
        std::vector<Eigen::Matrix<double,-1,1>>(hs,
          Eigen::Matrix<double,-1,1>::Constant(K,
            std::numeric_limits<double>::quiet_NaN()));
      current_statement__ = 6;
      local = in__.template read_constrain_lb<
                std::vector<Eigen::Matrix<local_scalar_t__,-1,1>>,
                jacobian__>(0, lp__, hs, K);
      std::vector<double> caux =
        std::vector<double>(caux_1dim__,
          std::numeric_limits<double>::quiet_NaN());
      current_statement__ = 7;
      caux = in__.template read_constrain_lb<std::vector<local_scalar_t__>,
               jacobian__>(0, lp__, caux_1dim__);
      std::vector<Eigen::Matrix<double,-1,1>> mix =
        std::vector<Eigen::Matrix<double,-1,1>>(mix_1dim__,
          Eigen::Matrix<double,-1,1>::Constant(K,
            std::numeric_limits<double>::quiet_NaN()));
      current_statement__ = 8;
      mix = in__.template read_constrain_lb<
              std::vector<Eigen::Matrix<local_scalar_t__,-1,1>>,
              jacobian__>(0, lp__, mix_1dim__, K);
      std::vector<double> one_over_lambda =
        std::vector<double>(one_over_lambda_1dim__,
          std::numeric_limits<double>::quiet_NaN());
      current_statement__ = 9;
      one_over_lambda = in__.template read_constrain_lb<
                          std::vector<local_scalar_t__>, jacobian__>(0, lp__,
                          one_over_lambda_1dim__);
      Eigen::Matrix<double,-1,1> z_b =
        Eigen::Matrix<double,-1,1>::Constant(q,
          std::numeric_limits<double>::quiet_NaN());
      current_statement__ = 10;
      z_b = in__.template read<Eigen::Matrix<local_scalar_t__,-1,1>>(q);
      Eigen::Matrix<double,-1,1> z_T =
        Eigen::Matrix<double,-1,1>::Constant(len_z_T,
          std::numeric_limits<double>::quiet_NaN());
      current_statement__ = 11;
      z_T = in__.template read<Eigen::Matrix<local_scalar_t__,-1,1>>(len_z_T);
      Eigen::Matrix<double,-1,1> rho =
        Eigen::Matrix<double,-1,1>::Constant(len_rho,
          std::numeric_limits<double>::quiet_NaN());
      current_statement__ = 12;
      rho = in__.template read_constrain_lub<
              Eigen::Matrix<local_scalar_t__,-1,1>, jacobian__>(0, 1, lp__,
              len_rho);
      Eigen::Matrix<double,-1,1> zeta =
        Eigen::Matrix<double,-1,1>::Constant(len_concentration,
          std::numeric_limits<double>::quiet_NaN());
      current_statement__ = 13;
      zeta = in__.template read_constrain_lb<
               Eigen::Matrix<local_scalar_t__,-1,1>, jacobian__>(0, lp__,
               len_concentration);
      Eigen::Matrix<double,-1,1> tau =
        Eigen::Matrix<double,-1,1>::Constant(t,
          std::numeric_limits<double>::quiet_NaN());
      current_statement__ = 14;
      tau = in__.template read_constrain_lb<
              Eigen::Matrix<local_scalar_t__,-1,1>, jacobian__>(0, lp__, t);
      Eigen::Matrix<double,-1,1> beta =
        Eigen::Matrix<double,-1,1>::Constant(K,
          std::numeric_limits<double>::quiet_NaN());
      Eigen::Matrix<double,-1,1> beta_smooth =
        Eigen::Matrix<double,-1,1>::Constant(K_smooth,
          std::numeric_limits<double>::quiet_NaN());
      Eigen::Matrix<double,-1,1> smooth_sd =
        Eigen::Matrix<double,-1,1>::Constant(smooth_sd_1dim__,
          std::numeric_limits<double>::quiet_NaN());
      Eigen::Matrix<double,-1,1> b =
        Eigen::Matrix<double,-1,1>::Constant(q,
          std::numeric_limits<double>::quiet_NaN());
      Eigen::Matrix<double,-1,1> theta_L =
        Eigen::Matrix<double,-1,1>::Constant(len_theta_L,
          std::numeric_limits<double>::quiet_NaN());
      out__.write(gamma);
      out__.write(z_beta);
      out__.write(z_beta_smooth);
      out__.write(smooth_sd_raw);
      out__.write(global);
      for (int sym1__ = 1; sym1__ <= K; ++sym1__) {
        for (int sym2__ = 1; sym2__ <= hs; ++sym2__) {
          out__.write(local[(sym2__ - 1)][(sym1__ - 1)]);
        }
      }
      out__.write(caux);
      for (int sym1__ = 1; sym1__ <= K; ++sym1__) {
        for (int sym2__ = 1; sym2__ <= mix_1dim__; ++sym2__) {
          out__.write(mix[(sym2__ - 1)][(sym1__ - 1)]);
        }
      }
      out__.write(one_over_lambda);
      out__.write(z_b);
      out__.write(z_T);
      out__.write(rho);
      out__.write(zeta);
      out__.write(tau);
      if (stan::math::logical_negation(
            (stan::math::primitive_value(emit_transformed_parameters__) ||
            stan::math::primitive_value(emit_generated_quantities__)))) {
        return ;
      }
      current_statement__ = 58;
      if (stan::math::logical_eq(prior_dist, 0)) {
        current_statement__ = 57;
        stan::model::assign(beta, z_beta, "assigning variable beta");
      } else {
        current_statement__ = 56;
        if (stan::math::logical_eq(prior_dist, 1)) {
          current_statement__ = 55;
          stan::model::assign(beta,
            stan::math::add(stan::math::elt_multiply(z_beta, prior_scale),
              prior_mean), "assigning variable beta");
        } else {
          current_statement__ = 54;
          if (stan::math::logical_eq(prior_dist, 2)) {
            current_statement__ = 53;
            for (int k = 1; k <= K; ++k) {
              current_statement__ = 51;
              stan::model::assign(beta,
                ((CFt(
                    stan::model::rvalue(z_beta, "z_beta",
                      stan::model::index_uni(k)),
                    stan::model::rvalue(prior_df, "prior_df",
                      stan::model::index_uni(k)), pstream__) *
                stan::model::rvalue(prior_scale, "prior_scale",
                  stan::model::index_uni(k))) +
                stan::model::rvalue(prior_mean, "prior_mean",
                  stan::model::index_uni(k))), "assigning variable beta",
                stan::model::index_uni(k));
            }
          } else {
            current_statement__ = 50;
            if (stan::math::logical_eq(prior_dist, 3)) {
              double c2 = std::numeric_limits<double>::quiet_NaN();
              current_statement__ = 45;
              c2 = (stan::math::square(slab_scale) *
                stan::model::rvalue(caux, "caux", stan::model::index_uni(1)));
              current_statement__ = 48;
              if ((stan::math::primitive_value(
                     stan::math::logical_eq(is_continuous, 1))
                  &&
                  stan::math::primitive_value(
                    stan::math::logical_eq(family, 1)))) {
                current_statement__ = 47;
                stan::model::assign(beta,
                  hs_prior(z_beta, global, local, global_prior_scale, aux,
                    c2, pstream__), "assigning variable beta");
              } else {
                current_statement__ = 46;
                stan::model::assign(beta,
                  hs_prior(z_beta, global, local, global_prior_scale,
                    static_cast<double>(1), c2, pstream__),
                  "assigning variable beta");
              }
            } else {
              current_statement__ = 44;
              if (stan::math::logical_eq(prior_dist, 4)) {
                double c2 = std::numeric_limits<double>::quiet_NaN();
                current_statement__ = 39;
                c2 = (stan::math::square(slab_scale) *
                  stan::model::rvalue(caux, "caux", stan::model::index_uni(1)));
                current_statement__ = 42;
                if ((stan::math::primitive_value(
                       stan::math::logical_eq(is_continuous, 1))
                    &&
                    stan::math::primitive_value(
                      stan::math::logical_eq(family, 1)))) {
                  current_statement__ = 41;
                  stan::model::assign(beta,
                    hsplus_prior(z_beta, global, local, global_prior_scale,
                      aux, c2, pstream__), "assigning variable beta");
                } else {
                  current_statement__ = 40;
                  stan::model::assign(beta,
                    hsplus_prior(z_beta, global, local, global_prior_scale,
                      static_cast<double>(1), c2, pstream__),
                    "assigning variable beta");
                }
              } else {
                current_statement__ = 38;
                if (stan::math::logical_eq(prior_dist, 5)) {
                  current_statement__ = 37;
                  stan::model::assign(beta,
                    stan::math::add(prior_mean,
                      stan::math::elt_multiply(
                        stan::math::elt_multiply(prior_scale,
                          stan::math::sqrt(
                            stan::math::multiply(2,
                              stan::model::rvalue(mix, "mix",
                                stan::model::index_uni(1))))), z_beta)),
                    "assigning variable beta");
                } else {
                  current_statement__ = 36;
                  if (stan::math::logical_eq(prior_dist, 6)) {
                    current_statement__ = 35;
                    stan::model::assign(beta,
                      stan::math::add(prior_mean,
                        stan::math::elt_multiply(
                          stan::math::elt_multiply(
                            stan::math::multiply(
                              stan::model::rvalue(one_over_lambda,
                                "one_over_lambda", stan::model::index_uni(1)),
                              prior_scale),
                            stan::math::sqrt(
                              stan::math::multiply(2,
                                stan::model::rvalue(mix, "mix",
                                  stan::model::index_uni(1))))), z_beta)),
                      "assigning variable beta");
                  } else {
                    current_statement__ = 34;
                    if (stan::math::logical_eq(prior_dist, 7)) {
                      int z_pos = std::numeric_limits<int>::min();
                      current_statement__ = 22;
                      z_pos = 1;
                      current_statement__ = 32;
                      for (int k = 1; k <= K; ++k) {
                        current_statement__ = 23;
                        stan::model::assign(beta,
                          stan::model::rvalue(z_beta, "z_beta",
                            stan::model::index_uni(z_pos)),
                          "assigning variable beta",
                          stan::model::index_uni(k));
                        current_statement__ = 24;
                        z_pos = (z_pos + 1);
                        current_statement__ = 28;
                        for (int n = 2; n <=
                             stan::model::rvalue(num_normals, "num_normals",
                               stan::model::index_uni(k)); ++n) {
                          current_statement__ = 25;
                          stan::model::assign(beta,
                            (stan::model::rvalue(beta, "beta",
                               stan::model::index_uni(k)) *
                            stan::model::rvalue(z_beta, "z_beta",
                              stan::model::index_uni(z_pos))),
                            "assigning variable beta",
                            stan::model::index_uni(k));
                          current_statement__ = 26;
                          z_pos = (z_pos + 1);
                        }
                        current_statement__ = 29;
                        stan::model::assign(beta,
                          (stan::model::rvalue(beta, "beta",
                             stan::model::index_uni(k)) *
                          stan::math::pow(
                            stan::model::rvalue(prior_scale, "prior_scale",
                              stan::model::index_uni(k)),
                            stan::model::rvalue(num_normals, "num_normals",
                              stan::model::index_uni(k)))),
                          "assigning variable beta",
                          stan::model::index_uni(k));
                        current_statement__ = 30;
                        stan::model::assign(beta,
                          (stan::model::rvalue(beta, "beta",
                             stan::model::index_uni(k)) +
                          stan::model::rvalue(prior_mean, "prior_mean",
                            stan::model::index_uni(k))),
                          "assigning variable beta",
                          stan::model::index_uni(k));
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
      current_statement__ = 64;
      if (K_smooth) {
        current_statement__ = 59;
        stan::model::assign(smooth_sd,
          stan::math::add(prior_mean_for_smooth,
            stan::math::elt_multiply(prior_scale_for_smooth, smooth_sd_raw)),
          "assigning variable smooth_sd");
        current_statement__ = 61;
        if ((stan::math::primitive_value(is_continuous) &&
            stan::math::primitive_value(stan::math::logical_eq(family, 1)))) {
          current_statement__ = 60;
          stan::model::assign(smooth_sd,
            stan::math::multiply(stan::model::deep_copy(smooth_sd), aux),
            "assigning variable smooth_sd");
        }
        current_statement__ = 62;
        stan::model::assign(beta_smooth,
          stan::math::elt_multiply(z_beta_smooth,
            stan::model::rvalue(smooth_sd, "smooth_sd",
              stan::model::index_multi(smooth_map))),
          "assigning variable beta_smooth");
      }
      current_statement__ = 80;
      if (stan::math::logical_gt(t, 0)) {
        current_statement__ = 78;
        if (stan::math::logical_eq(special_case, 1)) {
          int start = std::numeric_limits<int>::min();
          current_statement__ = 68;
          start = 1;
          current_statement__ = 69;
          stan::model::assign(theta_L, stan::math::elt_multiply(scale, tau),
            "assigning variable theta_L");
          current_statement__ = 76;
          if (stan::math::logical_eq(t, 1)) {
            current_statement__ = 75;
            stan::model::assign(b,
              stan::math::multiply(
                stan::model::rvalue(theta_L, "theta_L",
                  stan::model::index_uni(1)), z_b), "assigning variable b");
          } else {
            current_statement__ = 74;
            for (int i = 1; i <= t; ++i) {
              int end = std::numeric_limits<int>::min();
              current_statement__ = 70;
              end = ((start +
                stan::model::rvalue(l, "l", stan::model::index_uni(i))) - 1);
              current_statement__ = 71;
              stan::model::assign(b,
                stan::math::multiply(
                  stan::model::rvalue(theta_L, "theta_L",
                    stan::model::index_uni(i)),
                  stan::model::rvalue(z_b, "z_b",
                    stan::model::index_min_max(start, end))),
                "assigning variable b",
                stan::model::index_min_max(start, end));
              current_statement__ = 72;
              start = (end + 1);
            }
          }
        } else {
          current_statement__ = 65;
          stan::model::assign(theta_L,
            make_theta_L(len_theta_L, p, 1.0, tau, scale, zeta, rho, z_T,
              pstream__), "assigning variable theta_L");
          current_statement__ = 66;
          stan::model::assign(b, make_b(z_b, theta_L, p, l, pstream__),
            "assigning variable b");
        }
      }
      if (emit_transformed_parameters__) {
        out__.write(beta);
        out__.write(beta_smooth);
        out__.write(smooth_sd);
        out__.write(b);
        out__.write(theta_L);
      }
      if (stan::math::logical_negation(emit_generated_quantities__)) {
        return ;
      }
      double mean_PPD = std::numeric_limits<double>::quiet_NaN();
      current_statement__ = 20;
      mean_PPD = (compute_mean_PPD ? 0 : stan::math::negative_infinity());
      std::vector<double> alpha =
        std::vector<double>(has_intercept,
          std::numeric_limits<double>::quiet_NaN());
      current_statement__ = 85;
      if (stan::math::logical_eq(has_intercept, 1)) {
        current_statement__ = 83;
        if (dense_X) {
          current_statement__ = 82;
          stan::model::assign(alpha,
            (stan::model::rvalue(gamma, "gamma", stan::model::index_uni(1)) -
            stan::math::dot_product(xbar, beta)), "assigning variable alpha",
            stan::model::index_uni(1));
        } else {
          current_statement__ = 81;
          stan::model::assign(alpha,
            stan::model::rvalue(gamma, "gamma", stan::model::index_uni(1)),
            "assigning variable alpha", stan::model::index_uni(1));
        }
      }
      current_statement__ = 121;
      if (compute_mean_PPD) {
        current_statement__ = 86;
        stan::math::validate_non_negative_index("pi", "N", N);
        Eigen::Matrix<double,-1,1> pi =
          Eigen::Matrix<double,-1,1>::Constant(N,
            std::numeric_limits<double>::quiet_NaN());
        current_statement__ = 88;
        stan::math::validate_non_negative_index("eta", "N", N);
        Eigen::Matrix<double,-1,1> eta =
          Eigen::Matrix<double,-1,1>::Constant(N,
            std::numeric_limits<double>::quiet_NaN());
        current_statement__ = 95;
        if (stan::math::logical_gt(K, 0)) {
          current_statement__ = 93;
          if (dense_X) {
            current_statement__ = 92;
            stan::model::assign(eta,
              stan::math::multiply(
                stan::model::rvalue(X, "X", stan::model::index_uni(1)), beta),
              "assigning variable eta");
          } else {
            current_statement__ = 91;
            stan::model::assign(eta,
              stan::math::csr_matrix_times_vector(N, K, w_X, v_X, u_X, beta),
              "assigning variable eta");
          }
        } else {
          current_statement__ = 90;
          stan::model::assign(eta, stan::math::rep_vector(0.0, N),
            "assigning variable eta");
        }
        current_statement__ = 97;
        if (stan::math::logical_eq(has_offset, 1)) {
          current_statement__ = 96;
          stan::model::assign(eta,
            stan::math::add(stan::model::deep_copy(eta), offset_),
            "assigning variable eta");
        }
        current_statement__ = 99;
        if (K_smooth) {
          current_statement__ = 98;
          stan::model::assign(eta,
            stan::math::add(stan::model::deep_copy(eta),
              stan::math::multiply(S, beta_smooth)), "assigning variable eta");
        }
        current_statement__ = 105;
        if (stan::math::logical_gt(t, 0)) {
          current_statement__ = 103;
          if (special_case) {
            current_statement__ = 102;
            for (int i = 1; i <= t; ++i) {
              current_statement__ = 101;
              stan::model::assign(eta,
                stan::math::add(stan::model::deep_copy(eta),
                  stan::model::rvalue(b, "b",
                    stan::model::index_multi(
                      stan::model::rvalue(V, "V", stan::model::index_uni(i))))),
                "assigning variable eta");
            }
          } else {
            current_statement__ = 100;
            stan::model::assign(eta,
              stan::math::add(stan::model::deep_copy(eta),
                stan::math::csr_matrix_times_vector(N, q, w, v, u, b)),
              "assigning variable eta");
          }
        }
        current_statement__ = 115;
        if (stan::math::logical_eq(has_intercept, 1)) {
          current_statement__ = 113;
          if (stan::math::logical_neq(link, 4)) {
            current_statement__ = 112;
            stan::model::assign(eta,
              stan::math::add(stan::model::deep_copy(eta),
                stan::model::rvalue(gamma, "gamma", stan::model::index_uni(1))),
              "assigning variable eta");
          } else {
            double shift = std::numeric_limits<double>::quiet_NaN();
            current_statement__ = 108;
            shift = stan::math::max(eta);
            current_statement__ = 109;
            stan::model::assign(eta,
              stan::math::add(stan::model::deep_copy(eta),
                (stan::model::rvalue(gamma, "gamma",
                   stan::model::index_uni(1)) - shift)),
              "assigning variable eta");
            current_statement__ = 110;
            stan::model::assign(alpha,
              (stan::model::rvalue(alpha, "alpha", stan::model::index_uni(1))
              - shift), "assigning variable alpha", stan::model::index_uni(1));
          }
        } else {
          current_statement__ = 106;
          stan::model::assign(eta,
            stan::math::add(stan::model::deep_copy(eta),
              stan::math::dot_product(xbar, beta)), "assigning variable eta");
        }
        current_statement__ = 116;
        stan::model::assign(pi, linkinv_binom(eta, link, pstream__),
          "assigning variable pi");
        current_statement__ = 118;
        for (int n = 1; n <= N; ++n) {
          current_statement__ = 117;
          mean_PPD = (mean_PPD +
            stan::math::binomial_rng(
              stan::model::rvalue(trials, "trials", stan::model::index_uni(n)),
              stan::model::rvalue(pi, "pi", stan::model::index_uni(n)),
              base_rng__));
        }
        current_statement__ = 119;
        mean_PPD = (mean_PPD / N);
      }
      out__.write(mean_PPD);
      out__.write(alpha);
    } catch (const std::exception& e) {
      stan::lang::rethrow_located(e, locations_array__[current_statement__]);
    }
  }
  template <typename VecVar, typename VecI,
            stan::require_vector_t<VecVar>* = nullptr,
            stan::require_vector_like_vt<std::is_integral, VecI>* = nullptr>
  inline void
  unconstrain_array_impl(const VecVar& params_r__, const VecI& params_i__,
                         VecVar& vars__, std::ostream* pstream__ = nullptr) const {
    using local_scalar_t__ = double;
    stan::io::deserializer<local_scalar_t__> in__(params_r__, params_i__);
    stan::io::serializer<local_scalar_t__> out__(vars__);
    int current_statement__ = 0;
    local_scalar_t__ DUMMY_VAR__(std::numeric_limits<double>::quiet_NaN());
    // suppress unused var warning
    (void) DUMMY_VAR__;
    try {
      int pos__ = std::numeric_limits<int>::min();
      pos__ = 1;
      std::vector<local_scalar_t__> gamma =
        std::vector<local_scalar_t__>(has_intercept, DUMMY_VAR__);
      current_statement__ = 1;
      stan::model::assign(gamma,
        in__.read<std::vector<local_scalar_t__>>(has_intercept),
        "assigning variable gamma");
      out__.write_free_ub((stan::math::logical_eq(link, 4) ? 0.0 : stan::math::positive_infinity(
                                                                    )),
        gamma);
      Eigen::Matrix<local_scalar_t__,-1,1> z_beta =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(z_beta_1dim__,
          DUMMY_VAR__);
      current_statement__ = 2;
      stan::model::assign(z_beta,
        in__.read<Eigen::Matrix<local_scalar_t__,-1,1>>(z_beta_1dim__),
        "assigning variable z_beta");
      out__.write(z_beta);
      Eigen::Matrix<local_scalar_t__,-1,1> z_beta_smooth =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(K_smooth, DUMMY_VAR__);
      current_statement__ = 3;
      stan::model::assign(z_beta_smooth,
        in__.read<Eigen::Matrix<local_scalar_t__,-1,1>>(K_smooth),
        "assigning variable z_beta_smooth");
      out__.write(z_beta_smooth);
      Eigen::Matrix<local_scalar_t__,-1,1> smooth_sd_raw =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(smooth_sd_raw_1dim__,
          DUMMY_VAR__);
      current_statement__ = 4;
      stan::model::assign(smooth_sd_raw,
        in__.read<Eigen::Matrix<local_scalar_t__,-1,1>>(smooth_sd_raw_1dim__),
        "assigning variable smooth_sd_raw");
      out__.write_free_lb(0, smooth_sd_raw);
      std::vector<local_scalar_t__> global =
        std::vector<local_scalar_t__>(hs, DUMMY_VAR__);
      current_statement__ = 5;
      stan::model::assign(global,
        in__.read<std::vector<local_scalar_t__>>(hs),
        "assigning variable global");
      out__.write_free_lb(0, global);
      std::vector<Eigen::Matrix<local_scalar_t__,-1,1>> local =
        std::vector<Eigen::Matrix<local_scalar_t__,-1,1>>(hs,
          Eigen::Matrix<local_scalar_t__,-1,1>::Constant(K, DUMMY_VAR__));
      current_statement__ = 6;
      for (int sym1__ = 1; sym1__ <= K; ++sym1__) {
        current_statement__ = 6;
        for (int sym2__ = 1; sym2__ <= hs; ++sym2__) {
          current_statement__ = 6;
          stan::model::assign(local, in__.read<local_scalar_t__>(),
            "assigning variable local", stan::model::index_uni(sym2__),
            stan::model::index_uni(sym1__));
        }
      }
      out__.write_free_lb(0, local);
      std::vector<local_scalar_t__> caux =
        std::vector<local_scalar_t__>(caux_1dim__, DUMMY_VAR__);
      current_statement__ = 7;
      stan::model::assign(caux,
        in__.read<std::vector<local_scalar_t__>>(caux_1dim__),
        "assigning variable caux");
      out__.write_free_lb(0, caux);
      std::vector<Eigen::Matrix<local_scalar_t__,-1,1>> mix =
        std::vector<Eigen::Matrix<local_scalar_t__,-1,1>>(mix_1dim__,
          Eigen::Matrix<local_scalar_t__,-1,1>::Constant(K, DUMMY_VAR__));
      current_statement__ = 8;
      for (int sym1__ = 1; sym1__ <= K; ++sym1__) {
        current_statement__ = 8;
        for (int sym2__ = 1; sym2__ <= mix_1dim__; ++sym2__) {
          current_statement__ = 8;
          stan::model::assign(mix, in__.read<local_scalar_t__>(),
            "assigning variable mix", stan::model::index_uni(sym2__),
            stan::model::index_uni(sym1__));
        }
      }
      out__.write_free_lb(0, mix);
      std::vector<local_scalar_t__> one_over_lambda =
        std::vector<local_scalar_t__>(one_over_lambda_1dim__, DUMMY_VAR__);
      current_statement__ = 9;
      stan::model::assign(one_over_lambda,
        in__.read<std::vector<local_scalar_t__>>(one_over_lambda_1dim__),
        "assigning variable one_over_lambda");
      out__.write_free_lb(0, one_over_lambda);
      Eigen::Matrix<local_scalar_t__,-1,1> z_b =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(q, DUMMY_VAR__);
      current_statement__ = 10;
      stan::model::assign(z_b,
        in__.read<Eigen::Matrix<local_scalar_t__,-1,1>>(q),
        "assigning variable z_b");
      out__.write(z_b);
      Eigen::Matrix<local_scalar_t__,-1,1> z_T =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(len_z_T, DUMMY_VAR__);
      current_statement__ = 11;
      stan::model::assign(z_T,
        in__.read<Eigen::Matrix<local_scalar_t__,-1,1>>(len_z_T),
        "assigning variable z_T");
      out__.write(z_T);
      Eigen::Matrix<local_scalar_t__,-1,1> rho =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(len_rho, DUMMY_VAR__);
      current_statement__ = 12;
      stan::model::assign(rho,
        in__.read<Eigen::Matrix<local_scalar_t__,-1,1>>(len_rho),
        "assigning variable rho");
      out__.write_free_lub(0, 1, rho);
      Eigen::Matrix<local_scalar_t__,-1,1> zeta =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(len_concentration,
          DUMMY_VAR__);
      current_statement__ = 13;
      stan::model::assign(zeta,
        in__.read<Eigen::Matrix<local_scalar_t__,-1,1>>(len_concentration),
        "assigning variable zeta");
      out__.write_free_lb(0, zeta);
      Eigen::Matrix<local_scalar_t__,-1,1> tau =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(t, DUMMY_VAR__);
      current_statement__ = 14;
      stan::model::assign(tau,
        in__.read<Eigen::Matrix<local_scalar_t__,-1,1>>(t),
        "assigning variable tau");
      out__.write_free_lb(0, tau);
    } catch (const std::exception& e) {
      stan::lang::rethrow_located(e, locations_array__[current_statement__]);
    }
  }
  template <typename VecVar, stan::require_vector_t<VecVar>* = nullptr>
  inline void
  transform_inits_impl(const stan::io::var_context& context__, VecVar&
                       vars__, std::ostream* pstream__ = nullptr) const {
    using local_scalar_t__ = double;
    stan::io::serializer<local_scalar_t__> out__(vars__);
    int current_statement__ = 0;
    local_scalar_t__ DUMMY_VAR__(std::numeric_limits<double>::quiet_NaN());
    // suppress unused var warning
    (void) DUMMY_VAR__;
    try {
      current_statement__ = 1;
      context__.validate_dims("parameter initialization", "gamma", "double",
        std::vector<size_t>{static_cast<size_t>(has_intercept)});
      current_statement__ = 2;
      context__.validate_dims("parameter initialization", "z_beta", "double",
        std::vector<size_t>{static_cast<size_t>(z_beta_1dim__)});
      current_statement__ = 3;
      context__.validate_dims("parameter initialization", "z_beta_smooth",
        "double", std::vector<size_t>{static_cast<size_t>(K_smooth)});
      current_statement__ = 4;
      context__.validate_dims("parameter initialization", "smooth_sd_raw",
        "double",
        std::vector<size_t>{static_cast<size_t>(smooth_sd_raw_1dim__)});
      current_statement__ = 5;
      context__.validate_dims("parameter initialization", "global", "double",
        std::vector<size_t>{static_cast<size_t>(hs)});
      current_statement__ = 6;
      context__.validate_dims("parameter initialization", "local", "double",
        std::vector<size_t>{static_cast<size_t>(hs), static_cast<size_t>(K)});
      current_statement__ = 7;
      context__.validate_dims("parameter initialization", "caux", "double",
        std::vector<size_t>{static_cast<size_t>(caux_1dim__)});
      current_statement__ = 8;
      context__.validate_dims("parameter initialization", "mix", "double",
        std::vector<size_t>{static_cast<size_t>(mix_1dim__),
          static_cast<size_t>(K)});
      current_statement__ = 9;
      context__.validate_dims("parameter initialization", "one_over_lambda",
        "double",
        std::vector<size_t>{static_cast<size_t>(one_over_lambda_1dim__)});
      current_statement__ = 10;
      context__.validate_dims("parameter initialization", "z_b", "double",
        std::vector<size_t>{static_cast<size_t>(q)});
      current_statement__ = 11;
      context__.validate_dims("parameter initialization", "z_T", "double",
        std::vector<size_t>{static_cast<size_t>(len_z_T)});
      current_statement__ = 12;
      context__.validate_dims("parameter initialization", "rho", "double",
        std::vector<size_t>{static_cast<size_t>(len_rho)});
      current_statement__ = 13;
      context__.validate_dims("parameter initialization", "zeta", "double",
        std::vector<size_t>{static_cast<size_t>(len_concentration)});
      current_statement__ = 14;
      context__.validate_dims("parameter initialization", "tau", "double",
        std::vector<size_t>{static_cast<size_t>(t)});
      int pos__ = std::numeric_limits<int>::min();
      pos__ = 1;
      std::vector<local_scalar_t__> gamma =
        std::vector<local_scalar_t__>(has_intercept, DUMMY_VAR__);
      current_statement__ = 1;
      gamma = context__.vals_r("gamma");
      out__.write_free_ub((stan::math::logical_eq(link, 4) ? 0.0 : stan::math::positive_infinity(
                                                                    )),
        gamma);
      Eigen::Matrix<local_scalar_t__,-1,1> z_beta =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(z_beta_1dim__,
          DUMMY_VAR__);
      {
        std::vector<local_scalar_t__> z_beta_flat__;
        current_statement__ = 2;
        z_beta_flat__ = context__.vals_r("z_beta");
        current_statement__ = 2;
        pos__ = 1;
        current_statement__ = 2;
        for (int sym1__ = 1; sym1__ <= z_beta_1dim__; ++sym1__) {
          current_statement__ = 2;
          stan::model::assign(z_beta, z_beta_flat__[(pos__ - 1)],
            "assigning variable z_beta", stan::model::index_uni(sym1__));
          current_statement__ = 2;
          pos__ = (pos__ + 1);
        }
      }
      out__.write(z_beta);
      Eigen::Matrix<local_scalar_t__,-1,1> z_beta_smooth =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(K_smooth, DUMMY_VAR__);
      {
        std::vector<local_scalar_t__> z_beta_smooth_flat__;
        current_statement__ = 3;
        z_beta_smooth_flat__ = context__.vals_r("z_beta_smooth");
        current_statement__ = 3;
        pos__ = 1;
        current_statement__ = 3;
        for (int sym1__ = 1; sym1__ <= K_smooth; ++sym1__) {
          current_statement__ = 3;
          stan::model::assign(z_beta_smooth, z_beta_smooth_flat__[(pos__ -
            1)], "assigning variable z_beta_smooth",
            stan::model::index_uni(sym1__));
          current_statement__ = 3;
          pos__ = (pos__ + 1);
        }
      }
      out__.write(z_beta_smooth);
      Eigen::Matrix<local_scalar_t__,-1,1> smooth_sd_raw =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(smooth_sd_raw_1dim__,
          DUMMY_VAR__);
      {
        std::vector<local_scalar_t__> smooth_sd_raw_flat__;
        current_statement__ = 4;
        smooth_sd_raw_flat__ = context__.vals_r("smooth_sd_raw");
        current_statement__ = 4;
        pos__ = 1;
        current_statement__ = 4;
        for (int sym1__ = 1; sym1__ <= smooth_sd_raw_1dim__; ++sym1__) {
          current_statement__ = 4;
          stan::model::assign(smooth_sd_raw, smooth_sd_raw_flat__[(pos__ -
            1)], "assigning variable smooth_sd_raw",
            stan::model::index_uni(sym1__));
          current_statement__ = 4;
          pos__ = (pos__ + 1);
        }
      }
      out__.write_free_lb(0, smooth_sd_raw);
      std::vector<local_scalar_t__> global =
        std::vector<local_scalar_t__>(hs, DUMMY_VAR__);
      current_statement__ = 5;
      global = context__.vals_r("global");
      out__.write_free_lb(0, global);
      std::vector<Eigen::Matrix<local_scalar_t__,-1,1>> local =
        std::vector<Eigen::Matrix<local_scalar_t__,-1,1>>(hs,
          Eigen::Matrix<local_scalar_t__,-1,1>::Constant(K, DUMMY_VAR__));
      {
        std::vector<local_scalar_t__> local_flat__;
        current_statement__ = 6;
        local_flat__ = context__.vals_r("local");
        current_statement__ = 6;
        pos__ = 1;
        current_statement__ = 6;
        for (int sym1__ = 1; sym1__ <= K; ++sym1__) {
          current_statement__ = 6;
          for (int sym2__ = 1; sym2__ <= hs; ++sym2__) {
            current_statement__ = 6;
            stan::model::assign(local, local_flat__[(pos__ - 1)],
              "assigning variable local", stan::model::index_uni(sym2__),
              stan::model::index_uni(sym1__));
            current_statement__ = 6;
            pos__ = (pos__ + 1);
          }
        }
      }
      out__.write_free_lb(0, local);
      std::vector<local_scalar_t__> caux =
        std::vector<local_scalar_t__>(caux_1dim__, DUMMY_VAR__);
      current_statement__ = 7;
      caux = context__.vals_r("caux");
      out__.write_free_lb(0, caux);
      std::vector<Eigen::Matrix<local_scalar_t__,-1,1>> mix =
        std::vector<Eigen::Matrix<local_scalar_t__,-1,1>>(mix_1dim__,
          Eigen::Matrix<local_scalar_t__,-1,1>::Constant(K, DUMMY_VAR__));
      {
        std::vector<local_scalar_t__> mix_flat__;
        current_statement__ = 8;
        mix_flat__ = context__.vals_r("mix");
        current_statement__ = 8;
        pos__ = 1;
        current_statement__ = 8;
        for (int sym1__ = 1; sym1__ <= K; ++sym1__) {
          current_statement__ = 8;
          for (int sym2__ = 1; sym2__ <= mix_1dim__; ++sym2__) {
            current_statement__ = 8;
            stan::model::assign(mix, mix_flat__[(pos__ - 1)],
              "assigning variable mix", stan::model::index_uni(sym2__),
              stan::model::index_uni(sym1__));
            current_statement__ = 8;
            pos__ = (pos__ + 1);
          }
        }
      }
      out__.write_free_lb(0, mix);
      std::vector<local_scalar_t__> one_over_lambda =
        std::vector<local_scalar_t__>(one_over_lambda_1dim__, DUMMY_VAR__);
      current_statement__ = 9;
      one_over_lambda = context__.vals_r("one_over_lambda");
      out__.write_free_lb(0, one_over_lambda);
      Eigen::Matrix<local_scalar_t__,-1,1> z_b =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(q, DUMMY_VAR__);
      {
        std::vector<local_scalar_t__> z_b_flat__;
        current_statement__ = 10;
        z_b_flat__ = context__.vals_r("z_b");
        current_statement__ = 10;
        pos__ = 1;
        current_statement__ = 10;
        for (int sym1__ = 1; sym1__ <= q; ++sym1__) {
          current_statement__ = 10;
          stan::model::assign(z_b, z_b_flat__[(pos__ - 1)],
            "assigning variable z_b", stan::model::index_uni(sym1__));
          current_statement__ = 10;
          pos__ = (pos__ + 1);
        }
      }
      out__.write(z_b);
      Eigen::Matrix<local_scalar_t__,-1,1> z_T =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(len_z_T, DUMMY_VAR__);
      {
        std::vector<local_scalar_t__> z_T_flat__;
        current_statement__ = 11;
        z_T_flat__ = context__.vals_r("z_T");
        current_statement__ = 11;
        pos__ = 1;
        current_statement__ = 11;
        for (int sym1__ = 1; sym1__ <= len_z_T; ++sym1__) {
          current_statement__ = 11;
          stan::model::assign(z_T, z_T_flat__[(pos__ - 1)],
            "assigning variable z_T", stan::model::index_uni(sym1__));
          current_statement__ = 11;
          pos__ = (pos__ + 1);
        }
      }
      out__.write(z_T);
      Eigen::Matrix<local_scalar_t__,-1,1> rho =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(len_rho, DUMMY_VAR__);
      {
        std::vector<local_scalar_t__> rho_flat__;
        current_statement__ = 12;
        rho_flat__ = context__.vals_r("rho");
        current_statement__ = 12;
        pos__ = 1;
        current_statement__ = 12;
        for (int sym1__ = 1; sym1__ <= len_rho; ++sym1__) {
          current_statement__ = 12;
          stan::model::assign(rho, rho_flat__[(pos__ - 1)],
            "assigning variable rho", stan::model::index_uni(sym1__));
          current_statement__ = 12;
          pos__ = (pos__ + 1);
        }
      }
      out__.write_free_lub(0, 1, rho);
      Eigen::Matrix<local_scalar_t__,-1,1> zeta =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(len_concentration,
          DUMMY_VAR__);
      {
        std::vector<local_scalar_t__> zeta_flat__;
        current_statement__ = 13;
        zeta_flat__ = context__.vals_r("zeta");
        current_statement__ = 13;
        pos__ = 1;
        current_statement__ = 13;
        for (int sym1__ = 1; sym1__ <= len_concentration; ++sym1__) {
          current_statement__ = 13;
          stan::model::assign(zeta, zeta_flat__[(pos__ - 1)],
            "assigning variable zeta", stan::model::index_uni(sym1__));
          current_statement__ = 13;
          pos__ = (pos__ + 1);
        }
      }
      out__.write_free_lb(0, zeta);
      Eigen::Matrix<local_scalar_t__,-1,1> tau =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(t, DUMMY_VAR__);
      {
        std::vector<local_scalar_t__> tau_flat__;
        current_statement__ = 14;
        tau_flat__ = context__.vals_r("tau");
        current_statement__ = 14;
        pos__ = 1;
        current_statement__ = 14;
        for (int sym1__ = 1; sym1__ <= t; ++sym1__) {
          current_statement__ = 14;
          stan::model::assign(tau, tau_flat__[(pos__ - 1)],
            "assigning variable tau", stan::model::index_uni(sym1__));
          current_statement__ = 14;
          pos__ = (pos__ + 1);
        }
      }
      out__.write_free_lb(0, tau);
    } catch (const std::exception& e) {
      stan::lang::rethrow_located(e, locations_array__[current_statement__]);
    }
  }
  inline void
  get_param_names(std::vector<std::string>& names__, const bool
                  emit_transformed_parameters__ = true, const bool
                  emit_generated_quantities__ = true) const {
    names__ = std::vector<std::string>{"gamma", "z_beta", "z_beta_smooth",
                "smooth_sd_raw", "global", "local", "caux", "mix",
                "one_over_lambda", "z_b", "z_T", "rho", "zeta", "tau"};
    if (emit_transformed_parameters__) {
      std::vector<std::string>
        temp{"beta", "beta_smooth", "smooth_sd", "b", "theta_L"};
      names__.reserve(names__.size() + temp.size());
      names__.insert(names__.end(), temp.begin(), temp.end());
    }
    if (emit_generated_quantities__) {
      std::vector<std::string> temp{"mean_PPD", "alpha"};
      names__.reserve(names__.size() + temp.size());
      names__.insert(names__.end(), temp.begin(), temp.end());
    }
  }
  inline void
  get_dims(std::vector<std::vector<size_t>>& dimss__, const bool
           emit_transformed_parameters__ = true, const bool
           emit_generated_quantities__ = true) const {
    dimss__ = std::vector<std::vector<size_t>>{std::vector<size_t>{static_cast<
                                                                    size_t>(
                                                                    has_intercept)},
                std::vector<size_t>{static_cast<size_t>(z_beta_1dim__)},
                std::vector<size_t>{static_cast<size_t>(K_smooth)},
                std::vector<size_t>{static_cast<size_t>(smooth_sd_raw_1dim__)},
                std::vector<size_t>{static_cast<size_t>(hs)},
                std::vector<size_t>{static_cast<size_t>(hs),
                  static_cast<size_t>(K)},
                std::vector<size_t>{static_cast<size_t>(caux_1dim__)},
                std::vector<size_t>{static_cast<size_t>(mix_1dim__),
                  static_cast<size_t>(K)},
                std::vector<size_t>{static_cast<size_t>(
                                      one_over_lambda_1dim__)},
                std::vector<size_t>{static_cast<size_t>(q)},
                std::vector<size_t>{static_cast<size_t>(len_z_T)},
                std::vector<size_t>{static_cast<size_t>(len_rho)},
                std::vector<size_t>{static_cast<size_t>(len_concentration)},
                std::vector<size_t>{static_cast<size_t>(t)}};
    if (emit_transformed_parameters__) {
      std::vector<std::vector<size_t>>
        temp{std::vector<size_t>{static_cast<size_t>(K)},
             std::vector<size_t>{static_cast<size_t>(K_smooth)},
             std::vector<size_t>{static_cast<size_t>(smooth_sd_1dim__)},
             std::vector<size_t>{static_cast<size_t>(q)},
             std::vector<size_t>{static_cast<size_t>(len_theta_L)}};
      dimss__.reserve(dimss__.size() + temp.size());
      dimss__.insert(dimss__.end(), temp.begin(), temp.end());
    }
    if (emit_generated_quantities__) {
      std::vector<std::vector<size_t>>
        temp{std::vector<size_t>{},
             std::vector<size_t>{static_cast<size_t>(has_intercept)}};
      dimss__.reserve(dimss__.size() + temp.size());
      dimss__.insert(dimss__.end(), temp.begin(), temp.end());
    }
  }
  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__ <= has_intercept; ++sym1__) {
      param_names__.emplace_back(std::string() + "gamma" + '.' +
        std::to_string(sym1__));
    }
    for (int sym1__ = 1; sym1__ <= z_beta_1dim__; ++sym1__) {
      param_names__.emplace_back(std::string() + "z_beta" + '.' +
        std::to_string(sym1__));
    }
    for (int sym1__ = 1; sym1__ <= K_smooth; ++sym1__) {
      param_names__.emplace_back(std::string() + "z_beta_smooth" + '.' +
        std::to_string(sym1__));
    }
    for (int sym1__ = 1; sym1__ <= smooth_sd_raw_1dim__; ++sym1__) {
      param_names__.emplace_back(std::string() + "smooth_sd_raw" + '.' +
        std::to_string(sym1__));
    }
    for (int sym1__ = 1; sym1__ <= hs; ++sym1__) {
      param_names__.emplace_back(std::string() + "global" + '.' +
        std::to_string(sym1__));
    }
    for (int sym1__ = 1; sym1__ <= K; ++sym1__) {
      for (int sym2__ = 1; sym2__ <= hs; ++sym2__) {
        param_names__.emplace_back(std::string() + "local" + '.' +
          std::to_string(sym2__) + '.' + std::to_string(sym1__));
      }
    }
    for (int sym1__ = 1; sym1__ <= caux_1dim__; ++sym1__) {
      param_names__.emplace_back(std::string() + "caux" + '.' +
        std::to_string(sym1__));
    }
    for (int sym1__ = 1; sym1__ <= K; ++sym1__) {
      for (int sym2__ = 1; sym2__ <= mix_1dim__; ++sym2__) {
        param_names__.emplace_back(std::string() + "mix" + '.' +
          std::to_string(sym2__) + '.' + std::to_string(sym1__));
      }
    }
    for (int sym1__ = 1; sym1__ <= one_over_lambda_1dim__; ++sym1__) {
      param_names__.emplace_back(std::string() + "one_over_lambda" + '.' +
        std::to_string(sym1__));
    }
    for (int sym1__ = 1; sym1__ <= q; ++sym1__) {
      param_names__.emplace_back(std::string() + "z_b" + '.' +
        std::to_string(sym1__));
    }
    for (int sym1__ = 1; sym1__ <= len_z_T; ++sym1__) {
      param_names__.emplace_back(std::string() + "z_T" + '.' +
        std::to_string(sym1__));
    }
    for (int sym1__ = 1; sym1__ <= len_rho; ++sym1__) {
      param_names__.emplace_back(std::string() + "rho" + '.' +
        std::to_string(sym1__));
    }
    for (int sym1__ = 1; sym1__ <= len_concentration; ++sym1__) {
      param_names__.emplace_back(std::string() + "zeta" + '.' +
        std::to_string(sym1__));
    }
    for (int sym1__ = 1; sym1__ <= t; ++sym1__) {
      param_names__.emplace_back(std::string() + "tau" + '.' +
        std::to_string(sym1__));
    }
    if (emit_transformed_parameters__) {
      for (int sym1__ = 1; sym1__ <= K; ++sym1__) {
        param_names__.emplace_back(std::string() + "beta" + '.' +
          std::to_string(sym1__));
      }
      for (int sym1__ = 1; sym1__ <= K_smooth; ++sym1__) {
        param_names__.emplace_back(std::string() + "beta_smooth" + '.' +
          std::to_string(sym1__));
      }
      for (int sym1__ = 1; sym1__ <= smooth_sd_1dim__; ++sym1__) {
        param_names__.emplace_back(std::string() + "smooth_sd" + '.' +
          std::to_string(sym1__));
      }
      for (int sym1__ = 1; sym1__ <= q; ++sym1__) {
        param_names__.emplace_back(std::string() + "b" + '.' +
          std::to_string(sym1__));
      }
      for (int sym1__ = 1; sym1__ <= len_theta_L; ++sym1__) {
        param_names__.emplace_back(std::string() + "theta_L" + '.' +
          std::to_string(sym1__));
      }
    }
    if (emit_generated_quantities__) {
      param_names__.emplace_back(std::string() + "mean_PPD");
      for (int sym1__ = 1; sym1__ <= has_intercept; ++sym1__) {
        param_names__.emplace_back(std::string() + "alpha" + '.' +
          std::to_string(sym1__));
      }
    }
  }
  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__ <= has_intercept; ++sym1__) {
      param_names__.emplace_back(std::string() + "gamma" + '.' +
        std::to_string(sym1__));
    }
    for (int sym1__ = 1; sym1__ <= z_beta_1dim__; ++sym1__) {
      param_names__.emplace_back(std::string() + "z_beta" + '.' +
        std::to_string(sym1__));
    }
    for (int sym1__ = 1; sym1__ <= K_smooth; ++sym1__) {
      param_names__.emplace_back(std::string() + "z_beta_smooth" + '.' +
        std::to_string(sym1__));
    }
    for (int sym1__ = 1; sym1__ <= smooth_sd_raw_1dim__; ++sym1__) {
      param_names__.emplace_back(std::string() + "smooth_sd_raw" + '.' +
        std::to_string(sym1__));
    }
    for (int sym1__ = 1; sym1__ <= hs; ++sym1__) {
      param_names__.emplace_back(std::string() + "global" + '.' +
        std::to_string(sym1__));
    }
    for (int sym1__ = 1; sym1__ <= K; ++sym1__) {
      for (int sym2__ = 1; sym2__ <= hs; ++sym2__) {
        param_names__.emplace_back(std::string() + "local" + '.' +
          std::to_string(sym2__) + '.' + std::to_string(sym1__));
      }
    }
    for (int sym1__ = 1; sym1__ <= caux_1dim__; ++sym1__) {
      param_names__.emplace_back(std::string() + "caux" + '.' +
        std::to_string(sym1__));
    }
    for (int sym1__ = 1; sym1__ <= K; ++sym1__) {
      for (int sym2__ = 1; sym2__ <= mix_1dim__; ++sym2__) {
        param_names__.emplace_back(std::string() + "mix" + '.' +
          std::to_string(sym2__) + '.' + std::to_string(sym1__));
      }
    }
    for (int sym1__ = 1; sym1__ <= one_over_lambda_1dim__; ++sym1__) {
      param_names__.emplace_back(std::string() + "one_over_lambda" + '.' +
        std::to_string(sym1__));
    }
    for (int sym1__ = 1; sym1__ <= q; ++sym1__) {
      param_names__.emplace_back(std::string() + "z_b" + '.' +
        std::to_string(sym1__));
    }
    for (int sym1__ = 1; sym1__ <= len_z_T; ++sym1__) {
      param_names__.emplace_back(std::string() + "z_T" + '.' +
        std::to_string(sym1__));
    }
    for (int sym1__ = 1; sym1__ <= len_rho; ++sym1__) {
      param_names__.emplace_back(std::string() + "rho" + '.' +
        std::to_string(sym1__));
    }
    for (int sym1__ = 1; sym1__ <= len_concentration; ++sym1__) {
      param_names__.emplace_back(std::string() + "zeta" + '.' +
        std::to_string(sym1__));
    }
    for (int sym1__ = 1; sym1__ <= t; ++sym1__) {
      param_names__.emplace_back(std::string() + "tau" + '.' +
        std::to_string(sym1__));
    }
    if (emit_transformed_parameters__) {
      for (int sym1__ = 1; sym1__ <= K; ++sym1__) {
        param_names__.emplace_back(std::string() + "beta" + '.' +
          std::to_string(sym1__));
      }
      for (int sym1__ = 1; sym1__ <= K_smooth; ++sym1__) {
        param_names__.emplace_back(std::string() + "beta_smooth" + '.' +
          std::to_string(sym1__));
      }
      for (int sym1__ = 1; sym1__ <= smooth_sd_1dim__; ++sym1__) {
        param_names__.emplace_back(std::string() + "smooth_sd" + '.' +
          std::to_string(sym1__));
      }
      for (int sym1__ = 1; sym1__ <= q; ++sym1__) {
        param_names__.emplace_back(std::string() + "b" + '.' +
          std::to_string(sym1__));
      }
      for (int sym1__ = 1; sym1__ <= len_theta_L; ++sym1__) {
        param_names__.emplace_back(std::string() + "theta_L" + '.' +
          std::to_string(sym1__));
      }
    }
    if (emit_generated_quantities__) {
      param_names__.emplace_back(std::string() + "mean_PPD");
      for (int sym1__ = 1; sym1__ <= has_intercept; ++sym1__) {
        param_names__.emplace_back(std::string() + "alpha" + '.' +
          std::to_string(sym1__));
      }
    }
  }
  inline std::string get_constrained_sizedtypes() const {
    return std::string("[{\"name\":\"gamma\",\"type\":{\"name\":\"array\",\"length\":" + std::to_string(has_intercept) + ",\"element_type\":{\"name\":\"real\"}},\"block\":\"parameters\"},{\"name\":\"z_beta\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(z_beta_1dim__) + "},\"block\":\"parameters\"},{\"name\":\"z_beta_smooth\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(K_smooth) + "},\"block\":\"parameters\"},{\"name\":\"smooth_sd_raw\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(smooth_sd_raw_1dim__) + "},\"block\":\"parameters\"},{\"name\":\"global\",\"type\":{\"name\":\"array\",\"length\":" + std::to_string(hs) + ",\"element_type\":{\"name\":\"real\"}},\"block\":\"parameters\"},{\"name\":\"local\",\"type\":{\"name\":\"array\",\"length\":" + std::to_string(hs) + ",\"element_type\":{\"name\":\"vector\",\"length\":" + std::to_string(K) + "}},\"block\":\"parameters\"},{\"name\":\"caux\",\"type\":{\"name\":\"array\",\"length\":" + std::to_string(caux_1dim__) + ",\"element_type\":{\"name\":\"real\"}},\"block\":\"parameters\"},{\"name\":\"mix\",\"type\":{\"name\":\"array\",\"length\":" + std::to_string(mix_1dim__) + ",\"element_type\":{\"name\":\"vector\",\"length\":" + std::to_string(K) + "}},\"block\":\"parameters\"},{\"name\":\"one_over_lambda\",\"type\":{\"name\":\"array\",\"length\":" + std::to_string(one_over_lambda_1dim__) + ",\"element_type\":{\"name\":\"real\"}},\"block\":\"parameters\"},{\"name\":\"z_b\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(q) + "},\"block\":\"parameters\"},{\"name\":\"z_T\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(len_z_T) + "},\"block\":\"parameters\"},{\"name\":\"rho\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(len_rho) + "},\"block\":\"parameters\"},{\"name\":\"zeta\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(len_concentration) + "},\"block\":\"parameters\"},{\"name\":\"tau\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(t) + "},\"block\":\"parameters\"},{\"name\":\"beta\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(K) + "},\"block\":\"transformed_parameters\"},{\"name\":\"beta_smooth\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(K_smooth) + "},\"block\":\"transformed_parameters\"},{\"name\":\"smooth_sd\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(smooth_sd_1dim__) + "},\"block\":\"transformed_parameters\"},{\"name\":\"b\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(q) + "},\"block\":\"transformed_parameters\"},{\"name\":\"theta_L\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(len_theta_L) + "},\"block\":\"transformed_parameters\"},{\"name\":\"mean_PPD\",\"type\":{\"name\":\"real\"},\"block\":\"generated_quantities\"},{\"name\":\"alpha\",\"type\":{\"name\":\"array\",\"length\":" + std::to_string(has_intercept) + ",\"element_type\":{\"name\":\"real\"}},\"block\":\"generated_quantities\"}]");
  }
  inline std::string get_unconstrained_sizedtypes() const {
    return std::string("[{\"name\":\"gamma\",\"type\":{\"name\":\"array\",\"length\":" + std::to_string(has_intercept) + ",\"element_type\":{\"name\":\"real\"}},\"block\":\"parameters\"},{\"name\":\"z_beta\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(z_beta_1dim__) + "},\"block\":\"parameters\"},{\"name\":\"z_beta_smooth\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(K_smooth) + "},\"block\":\"parameters\"},{\"name\":\"smooth_sd_raw\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(smooth_sd_raw_1dim__) + "},\"block\":\"parameters\"},{\"name\":\"global\",\"type\":{\"name\":\"array\",\"length\":" + std::to_string(hs) + ",\"element_type\":{\"name\":\"real\"}},\"block\":\"parameters\"},{\"name\":\"local\",\"type\":{\"name\":\"array\",\"length\":" + std::to_string(hs) + ",\"element_type\":{\"name\":\"vector\",\"length\":" + std::to_string(K) + "}},\"block\":\"parameters\"},{\"name\":\"caux\",\"type\":{\"name\":\"array\",\"length\":" + std::to_string(caux_1dim__) + ",\"element_type\":{\"name\":\"real\"}},\"block\":\"parameters\"},{\"name\":\"mix\",\"type\":{\"name\":\"array\",\"length\":" + std::to_string(mix_1dim__) + ",\"element_type\":{\"name\":\"vector\",\"length\":" + std::to_string(K) + "}},\"block\":\"parameters\"},{\"name\":\"one_over_lambda\",\"type\":{\"name\":\"array\",\"length\":" + std::to_string(one_over_lambda_1dim__) + ",\"element_type\":{\"name\":\"real\"}},\"block\":\"parameters\"},{\"name\":\"z_b\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(q) + "},\"block\":\"parameters\"},{\"name\":\"z_T\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(len_z_T) + "},\"block\":\"parameters\"},{\"name\":\"rho\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(len_rho) + "},\"block\":\"parameters\"},{\"name\":\"zeta\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(len_concentration) + "},\"block\":\"parameters\"},{\"name\":\"tau\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(t) + "},\"block\":\"parameters\"},{\"name\":\"beta\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(K) + "},\"block\":\"transformed_parameters\"},{\"name\":\"beta_smooth\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(K_smooth) + "},\"block\":\"transformed_parameters\"},{\"name\":\"smooth_sd\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(smooth_sd_1dim__) + "},\"block\":\"transformed_parameters\"},{\"name\":\"b\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(q) + "},\"block\":\"transformed_parameters\"},{\"name\":\"theta_L\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(len_theta_L) + "},\"block\":\"transformed_parameters\"},{\"name\":\"mean_PPD\",\"type\":{\"name\":\"real\"},\"block\":\"generated_quantities\"},{\"name\":\"alpha\",\"type\":{\"name\":\"array\",\"length\":" + std::to_string(has_intercept) + ",\"element_type\":{\"name\":\"real\"}},\"block\":\"generated_quantities\"}]");
  }
  // Begin method overload boilerplate
  template <typename RNG> inline void
  write_array(RNG& base_rng, Eigen::Matrix<double,-1,1>& params_r,
              Eigen::Matrix<double,-1,1>& vars, const bool
              emit_transformed_parameters = true, const bool
              emit_generated_quantities = true, std::ostream*
              pstream = nullptr) const {
    const size_t num_params__ = (((((((((((((has_intercept + z_beta_1dim__) +
      K_smooth) + smooth_sd_raw_1dim__) + hs) + (hs * K)) + caux_1dim__) +
      (mix_1dim__ * K)) + one_over_lambda_1dim__) + q) + len_z_T) + len_rho)
      + len_concentration) + t);
    const size_t num_transformed = emit_transformed_parameters * (((((K +
      K_smooth) + smooth_sd_1dim__) + q) + len_theta_L));
    const size_t num_gen_quantities = emit_generated_quantities * ((1 +
      has_intercept));
    const size_t num_to_write = num_params__ + num_transformed +
      num_gen_quantities;
    std::vector<int> params_i;
    vars = Eigen::Matrix<double,-1,1>::Constant(num_to_write,
             std::numeric_limits<double>::quiet_NaN());
    write_array_impl(base_rng, params_r, params_i, vars,
      emit_transformed_parameters, emit_generated_quantities, pstream);
  }
  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 {
    const size_t num_params__ = (((((((((((((has_intercept + z_beta_1dim__) +
      K_smooth) + smooth_sd_raw_1dim__) + hs) + (hs * K)) + caux_1dim__) +
      (mix_1dim__ * K)) + one_over_lambda_1dim__) + q) + len_z_T) + len_rho)
      + len_concentration) + t);
    const size_t num_transformed = emit_transformed_parameters * (((((K +
      K_smooth) + smooth_sd_1dim__) + q) + len_theta_L));
    const size_t num_gen_quantities = emit_generated_quantities * ((1 +
      has_intercept));
    const size_t num_to_write = num_params__ + num_transformed +
      num_gen_quantities;
    vars = std::vector<double>(num_to_write,
             std::numeric_limits<double>::quiet_NaN());
    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_,-1,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,-1,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(context, params_i, params_r_vec, pstream);
    params_r = Eigen::Map<Eigen::Matrix<double,-1,1>>(params_r_vec.data(),
                 params_r_vec.size());
  }
  inline void
  transform_inits(const stan::io::var_context& context, std::vector<int>&
                  params_i, std::vector<double>& vars, std::ostream*
                  pstream__ = nullptr) const {
    vars.resize(num_params_r__);
    transform_inits_impl(context, vars, pstream__);
  }
  inline void
  unconstrain_array(const std::vector<double>& params_constrained,
                    std::vector<double>& params_unconstrained, std::ostream*
                    pstream = nullptr) const {
    const std::vector<int> params_i;
    params_unconstrained = std::vector<double>(num_params_r__,
                             std::numeric_limits<double>::quiet_NaN());
    unconstrain_array_impl(params_constrained, params_i,
      params_unconstrained, pstream);
  }
  inline void
  unconstrain_array(const Eigen::Matrix<double,-1,1>& params_constrained,
                    Eigen::Matrix<double,-1,1>& params_unconstrained,
                    std::ostream* pstream = nullptr) const {
    const std::vector<int> params_i;
    params_unconstrained = Eigen::Matrix<double,-1,1>::Constant(num_params_r__,
                             std::numeric_limits<double>::quiet_NaN());
    unconstrain_array_impl(params_constrained, params_i,
      params_unconstrained, pstream);
  }
};
}
using stan_model = model_binomial_namespace::model_binomial;
#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 model_binomial_namespace::profiles__;
}
#endif
#endif
