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

/*
    multinma 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.

    multinma 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 multinma.  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_poisson_namespace {
using stan::model::model_base_crtp;
using namespace stan::math;
stan::math::profile_map profiles__;
static constexpr std::array<const char*, 555> locations_array__ =
  {" (found before start of program)",
  " (in 'string', line 282, column 0 to column 22)",
  " (in 'string', line 285, column 0 to column 24)",
  " (in 'string', line 286, column 0 to column 34)",
  " (in 'string', line 289, column 0 to column 53)",
  " (in 'string', line 290, column 0 to column 63)",
  " (in 'string', line 293, column 0 to column 49)",
  " (in 'string', line 296, column 2 to column 27)",
  " (in 'string', line 297, column 2 to column 46)",
  " (in 'string', line 301, column 0 to column 25)",
  " (in 'string', line 302, column 0 to column 62)",
  " (in 'string', line 303, column 0 to column 37)",
  " (in 'string', line 308, column 0 to column 23)",
  " (in 'string', line 313, column 0 to line 318, column 14)",
  " (in 'string', line 321, column 0 to column 54)",
  " (in 'string', line 324, column 0 to column 58)",
  " (in 'string', line 326, column 0 to column 17)",
  " (in 'string', line 328, column 0 to column 56)",
  " (in 'string', line 330, column 0 to column 24)",
  " (in 'string', line 332, column 0 to column 47)",
  " (in 'string', line 337, column 0 to column 70)",
  " (in 'string', line 338, column 0 to column 45)",
  " (in 'string', line 638, column 0 to column 26)",
  " (in 'string', line 639, column 0 to column 34)",
  " (in 'string', line 640, column 0 to column 54)",
  " (in 'string', line 645, column 0 to column 54)",
  " (in 'string', line 646, column 0 to column 53)",
  " (in 'string', line 647, column 0 to column 44)",
  " (in 'string', line 650, column 2 to column 66)",
  " (in 'string', line 654, column 0 to column 22)",
  " (in 'string', line 344, column 2 to column 24)",
  " (in 'string', line 343, column 11 to line 345, column 1)",
  " (in 'string', line 343, column 0 to line 345, column 1)",
  " (in 'string', line 350, column 2 to column 44)",
  " (in 'string', line 349, column 39 to line 351, column 1)",
  " (in 'string', line 349, column 0 to line 351, column 1)",
  " (in 'string', line 356, column 2 to column 33)",
  " (in 'string', line 355, column 15 to line 357, column 1)",
  " (in 'string', line 355, column 0 to line 357, column 1)",
  " (in 'string', line 361, column 2 to column 123)",
  " (in 'string', line 362, column 2 to column 113)",
  " (in 'string', line 360, column 19 to line 363, column 1)",
  " (in 'string', line 360, column 0 to line 363, column 1)",
  " (in 'string', line 385, column 4 to line 387, column 23)",
  " (in 'string', line 384, column 9 to line 388, column 3)",
  " (in 'string', line 373, column 13 to column 19)",
  " (in 'string', line 373, column 6 to line 375, column 25)",
  " (in 'string', line 381, column 8 to column 37)",
  " (in 'string', line 379, column 8 to column 69)",
  " (in 'string', line 378, column 8 to line 381, column 37)",
  " (in 'string', line 377, column 26 to line 382, column 7)",
  " (in 'string', line 377, column 6 to line 382, column 7)",
  " (in 'string', line 372, column 4 to line 383, column 5)",
  " (in 'string', line 371, column 10 to line 384, column 3)",
  " (in 'string', line 371, column 2 to line 388, column 3)",
  " (in 'string', line 395, column 4 to column 97)",
  " (in 'string', line 391, column 22 to line 396, column 3)",
  " (in 'string', line 391, column 2 to line 396, column 3)",
  " (in 'string', line 402, column 8 to column 69)",
  " (in 'string', line 401, column 72 to line 403, column 7)",
  " (in 'string', line 401, column 6 to line 403, column 7)",
  " (in 'string', line 400, column 24 to line 404, column 5)",
  " (in 'string', line 400, column 4 to line 404, column 5)",
  " (in 'string', line 399, column 21 to line 405, column 3)",
  " (in 'string', line 399, column 2 to line 405, column 3)",
  " (in 'string', line 370, column 12 to line 406, column 1)",
  " (in 'string', line 370, column 0 to line 406, column 1)",
  " (in 'string', line 461, column 6 to line 463, column 34)",
  " (in 'string', line 460, column 11 to line 464, column 5)",
  " (in 'string', line 450, column 13 to column 35)",
  " (in 'string', line 450, column 6 to line 452, column 34)",
  " (in 'string', line 458, column 8 to column 59)",
  " (in 'string', line 456, column 8 to column 108)",
  " (in 'string', line 455, column 8 to line 458, column 59)",
  " (in 'string', line 454, column 35 to line 459, column 7)",
  " (in 'string', line 454, column 6 to line 459, column 7)",
  " (in 'string', line 449, column 12 to line 460, column 5)",
  " (in 'string', line 449, column 4 to line 464, column 5)",
  " (in 'string', line 469, column 10 to column 84)",
  " (in 'string', line 468, column 74 to line 470, column 9)",
  " (in 'string', line 468, column 8 to line 470, column 9)",
  " (in 'string', line 472, column 10 to column 86)",
  " (in 'string', line 471, column 78 to line 473, column 9)",
  " (in 'string', line 471, column 8 to line 473, column 9)",
  " (in 'string', line 467, column 35 to line 474, column 7)",
  " (in 'string', line 467, column 6 to line 474, column 7)",
  " (in 'string', line 466, column 23 to line 475, column 5)",
  " (in 'string', line 466, column 4 to line 475, column 5)",
  " (in 'string', line 448, column 9 to line 476, column 3)",
  " (in 'string', line 411, column 11 to column 37)",
  " (in 'string', line 411, column 4 to line 413, column 32)",
  " (in 'string', line 419, column 10 to column 128)",
  " (in 'string', line 418, column 74 to line 420, column 9)",
  " (in 'string', line 418, column 8 to line 420, column 9)",
  " (in 'string', line 422, column 10 to column 130)",
  " (in 'string', line 421, column 78 to line 423, column 9)",
  " (in 'string', line 421, column 8 to line 423, column 9)",
  " (in 'string', line 417, column 29 to line 424, column 7)",
  " (in 'string', line 417, column 6 to line 424, column 7)",
  " (in 'string', line 416, column 23 to line 425, column 5)",
  " (in 'string', line 416, column 4 to line 425, column 5)",
  " (in 'string', line 441, column 8 to column 125)",
  " (in 'string', line 440, column 40 to line 442, column 7)",
  " (in 'string', line 440, column 11 to line 442, column 7)",
  " (in 'string', line 439, column 28 to column 72)",
  " (in 'string', line 439, column 6 to line 442, column 7)",
  " (in 'string', line 445, column 8 to column 87)",
  " (in 'string', line 444, column 35 to line 446, column 7)",
  " (in 'string', line 444, column 6 to line 446, column 7)",
  " (in 'string', line 438, column 11 to line 447, column 5)",
  " (in 'string', line 433, column 8 to line 434, column 76)",
  " (in 'string', line 430, column 8 to line 431, column 125)",
  " (in 'string', line 429, column 8 to line 434, column 76)",
  " (in 'string', line 436, column 8 to column 87)",
  " (in 'string', line 428, column 35 to line 437, column 7)",
  " (in 'string', line 428, column 6 to line 437, column 7)",
  " (in 'string', line 427, column 12 to line 438, column 5)",
  " (in 'string', line 427, column 4 to line 447, column 5)",
  " (in 'string', line 410, column 20 to line 448, column 3)",
  " (in 'string', line 410, column 2 to line 476, column 3)",
  " (in 'string', line 409, column 21 to line 477, column 1)",
  " (in 'string', line 409, column 0 to line 477, column 1)",
  " (in 'string', line 480, column 4 to column 29)",
  " (in 'string', line 479, column 2 to line 480, column 29)",
  " (in 'string', line 483, column 11 to column 32)",
  " (in 'string', line 483, column 4 to line 485, column 29)",
  " (in 'string', line 491, column 6 to column 116)",
  " (in 'string', line 487, column 24 to line 492, column 5)",
  " (in 'string', line 487, column 4 to line 492, column 5)",
  " (in 'string', line 544, column 14 to column 79)",
  " (in 'string', line 543, column 68 to line 545, column 13)",
  " (in 'string', line 543, column 12 to line 545, column 13)",
  " (in 'string', line 542, column 34 to line 546, column 11)",
  " (in 'string', line 542, column 10 to line 546, column 11)",
  " (in 'string', line 541, column 27 to line 547, column 9)",
  " (in 'string', line 541, column 8 to line 547, column 9)",
  " (in 'string', line 549, column 10 to column 52)",
  " (in 'string', line 548, column 8 to line 549, column 52)",
  " (in 'string', line 540, column 13 to line 550, column 7)",
  " (in 'string', line 528, column 12 to column 77)",
  " (in 'string', line 527, column 68 to line 529, column 13)",
  " (in 'string', line 527, column 12 to line 529, column 13)",
  " (in 'string', line 526, column 34 to line 530, column 11)",
  " (in 'string', line 526, column 10 to line 530, column 11)",
  " (in 'string', line 525, column 27 to line 531, column 9)",
  " (in 'string', line 525, column 8 to line 531, column 9)",
  " (in 'string', line 537, column 14 to column 62)",
  " (in 'string', line 535, column 14 to column 96)",
  " (in 'string', line 534, column 12 to line 537, column 62)",
  " (in 'string', line 533, column 34 to line 538, column 11)",
  " (in 'string', line 533, column 10 to line 538, column 11)",
  " (in 'string', line 532, column 23 to line 539, column 9)",
  " (in 'string', line 532, column 8 to line 539, column 9)",
  " (in 'string', line 524, column 14 to line 540, column 7)",
  " (in 'string', line 524, column 6 to line 550, column 7)",
  " (in 'string', line 523, column 11 to line 551, column 5)",
  " (in 'string', line 498, column 12 to column 120)",
  " (in 'string', line 497, column 66 to line 499, column 11)",
  " (in 'string', line 497, column 10 to line 499, column 11)",
  " (in 'string', line 496, column 32 to line 500, column 9)",
  " (in 'string', line 496, column 8 to line 500, column 9)",
  " (in 'string', line 495, column 25 to line 501, column 7)",
  " (in 'string', line 495, column 6 to line 501, column 7)",
  " (in 'string', line 517, column 39 to column 153)",
  " (in 'string', line 517, column 15 to column 153)",
  " (in 'string', line 516, column 32 to column 73)",
  " (in 'string', line 516, column 10 to line 517, column 153)",
  " (in 'string', line 515, column 23 to line 518, column 9)",
  " (in 'string', line 515, column 8 to line 518, column 9)",
  " (in 'string', line 520, column 10 to column 83)",
  " (in 'string', line 519, column 32 to line 521, column 9)",
  " (in 'string', line 519, column 8 to line 521, column 9)",
  " (in 'string', line 514, column 13 to line 522, column 7)",
  " (in 'string', line 508, column 14 to column 128)",
  " (in 'string', line 506, column 14 to column 162)",
  " (in 'string', line 505, column 12 to line 508, column 128)",
  " (in 'string', line 504, column 34 to line 509, column 11)",
  " (in 'string', line 504, column 10 to line 509, column 11)",
  " (in 'string', line 503, column 23 to line 510, column 9)",
  " (in 'string', line 503, column 8 to line 510, column 9)",
  " (in 'string', line 512, column 10 to column 83)",
  " (in 'string', line 511, column 32 to line 513, column 9)",
  " (in 'string', line 511, column 8 to line 513, column 9)",
  " (in 'string', line 502, column 14 to line 514, column 7)",
  " (in 'string', line 502, column 6 to line 522, column 7)",
  " (in 'string', line 493, column 22 to line 523, column 5)",
  " (in 'string', line 493, column 4 to line 551, column 5)",
  " (in 'string', line 482, column 18 to line 552, column 3)",
  " (in 'string', line 482, column 2 to line 552, column 3)",
  " (in 'string', line 554, column 2 to column 33)",
  " (in 'string', line 555, column 2 to column 51)",
  " (in 'string', line 657, column 2 to column 12)",
  " (in 'string', line 660, column 6 to column 93)",
  " (in 'string', line 661, column 6 to column 13)",
  " (in 'string', line 659, column 21 to line 662, column 5)",
  " (in 'string', line 659, column 4 to line 662, column 5)",
  " (in 'string', line 658, column 41 to line 663, column 3)",
  " (in 'string', line 658, column 2 to line 663, column 3)",
  " (in 'string', line 666, column 6 to line 667, column 101)",
  " (in 'string', line 670, column 8 to column 49)",
  " (in 'string', line 669, column 6 to line 670, column 49)",
  " (in 'string', line 672, column 6 to column 13)",
  " (in 'string', line 665, column 47 to line 673, column 5)",
  " (in 'string', line 665, column 4 to line 673, column 5)",
  " (in 'string', line 664, column 31 to line 674, column 3)",
  " (in 'string', line 664, column 2 to line 674, column 3)",
  " (in 'string', line 656, column 8 to line 675, column 1)",
  " (in 'string', line 656, column 0 to line 675, column 1)",
  " (in 'string', line 680, column 4 to column 125)",
  " (in 'string', line 679, column 26 to line 681, column 3)",
  " (in 'string', line 679, column 2 to line 681, column 3)",
  " (in 'string', line 678, column 29 to line 682, column 1)",
  " (in 'string', line 678, column 0 to line 682, column 1)",
  " (in 'string', line 684, column 0 to column 43)",
  " (in 'string', line 688, column 2 to column 12)",
  " (in 'string', line 689, column 2 to column 9)",
  " (in 'string', line 691, column 4 to column 28)",
  " (in 'string', line 692, column 4 to line 693, column 102)",
  " (in 'string', line 694, column 4 to line 695, column 123)",
  " (in 'string', line 696, column 4 to column 12)",
  " (in 'string', line 690, column 31 to line 697, column 3)",
  " (in 'string', line 690, column 2 to line 697, column 3)",
  " (in 'string', line 687, column 0 to line 698, column 1)",
  " (in 'string', line 707, column 4 to column 117)",
  " (in 'string', line 706, column 26 to line 708, column 3)",
  " (in 'string', line 706, column 2 to line 708, column 3)",
  " (in 'string', line 705, column 24 to line 709, column 1)",
  " (in 'string', line 705, column 0 to line 709, column 1)",
  " (in 'string', line 712, column 11 to column 17)",
  " (in 'string', line 712, column 4 to column 48)",
  " (in 'string', line 714, column 6 to column 61)",
  " (in 'string', line 715, column 6 to column 101)",
  " (in 'string', line 716, column 6 to column 37)",
  " (in 'string', line 713, column 24 to line 717, column 5)",
  " (in 'string', line 713, column 4 to line 717, column 5)",
  " (in 'string', line 711, column 17 to line 718, column 3)",
  " (in 'string', line 711, column 2 to line 718, column 3)",
  " (in 'string', line 721, column 4 to column 74)",
  " (in 'string', line 722, column 4 to line 723, column 90)",
  " (in 'string', line 724, column 4 to column 43)",
  " (in 'string', line 720, column 26 to line 725, column 3)",
  " (in 'string', line 720, column 2 to line 725, column 3)",
  " (in 'string', line 563, column 0 to column 111)",
  " (in 'string', line 569, column 4 to column 127)",
  " (in 'string', line 572, column 4 to column 117)",
  " (in 'string', line 567, column 9 to line 573, column 1)",
  " (in 'string', line 566, column 4 to column 90)",
  " (in 'string', line 565, column 26 to line 567, column 3)",
  " (in 'string', line 565, column 2 to line 573, column 1)",
  " (in 'string', line 576, column 0 to column 89)",
  " (in 'string', line 579, column 0 to column 90)",
  " (in 'string', line 588, column 11 to column 21)",
  " (in 'string', line 588, column 4 to column 29)",
  " (in 'string', line 595, column 6 to column 27)",
  " (in 'string', line 596, column 6 to column 28)",
  " (in 'string', line 594, column 34 to line 597, column 5)",
  " (in 'string', line 594, column 9 to line 597, column 5)",
  " (in 'string', line 591, column 6 to column 26)",
  " (in 'string', line 592, column 6 to column 25)",
  " (in 'string', line 590, column 29 to line 593, column 5)",
  " (in 'string', line 590, column 4 to line 597, column 5)",
  " (in 'string', line 598, column 4 to column 94)",
  " (in 'string', line 586, column 10 to line 599, column 3)",
  " (in 'string', line 586, column 9 to line 599, column 4)",
  " (in 'string', line 584, column 4 to column 92)",
  " (in 'string', line 583, column 27 to line 586, column 3)",
  " (in 'string', line 583, column 2 to line 599, column 4)",
  " (in 'string', line 582, column 8 to line 600, column 1)",
  " (in 'string', line 582, column 0 to line 600, column 1)",
  " (in 'string', line 603, column 0 to column 23)",
  " (in 'string', line 607, column 2 to column 74)",
  " (in 'string', line 606, column 21 to line 608, column 1)",
  " (in 'string', line 606, column 0 to line 608, column 1)",
  " (in 'string', line 618, column 6 to column 42)",
  " (in 'string', line 616, column 11 to line 619, column 5)",
  " (in 'string', line 615, column 6 to column 96)",
  " (in 'string', line 613, column 26 to line 616, column 5)",
  " (in 'string', line 613, column 4 to line 619, column 5)",
  " (in 'string', line 612, column 22 to line 620, column 3)",
  " (in 'string', line 612, column 2 to line 620, column 3)",
  " (in 'string', line 611, column 19 to line 621, column 1)",
  " (in 'string', line 611, column 0 to line 621, column 1)",
  " (in 'string', line 624, column 0 to column 23)",
  " (in 'string', line 628, column 4 to column 35)",
  " (in 'string', line 627, column 17 to line 629, column 3)",
  " (in 'string', line 627, column 2 to line 629, column 3)",
  " (in 'string', line 631, column 2 to column 39)",
  " (in 'string', line 80, column 0 to column 20)",
  " (in 'string', line 81, column 0 to column 24)",
  " (in 'string', line 82, column 0 to column 29)",
  " (in 'string', line 84, column 0 to column 20)",
  " (in 'string', line 85, column 0 to column 24)",
  " (in 'string', line 86, column 0 to column 29)",
  " (in 'string', line 89, column 0 to column 22)",
  " (in 'string', line 90, column 6 to column 12)",
  " (in 'string', line 90, column 0 to column 35)",
  " (in 'string', line 91, column 6 to column 14)",
  " (in 'string', line 91, column 0 to column 37)",
  " (in 'string', line 92, column 0 to column 26)",
  " (in 'string', line 93, column 6 to column 18)",
  " (in 'string', line 93, column 0 to column 45)",
  " (in 'string', line 94, column 6 to column 21)",
  " (in 'string', line 94, column 0 to column 53)",
  " (in 'string', line 95, column 6 to column 21)",
  " (in 'string', line 95, column 0 to column 55)",
  " (in 'string', line 102, column 0 to column 16)",
  " (in 'string', line 103, column 0 to column 16)",
  " (in 'string', line 106, column 0 to column 21)",
  " (in 'string', line 107, column 0 to column 36)",
  " (in 'string', line 108, column 6 to column 13)",
  " (in 'string', line 108, column 0 to column 37)",
  " (in 'string', line 109, column 0 to column 22)",
  " (in 'string', line 110, column 0 to column 22)",
  " (in 'string', line 112, column 0 to column 18)",
  " (in 'string', line 115, column 7 to column 22)",
  " (in 'string', line 115, column 0 to column 39)",
  " (in 'string', line 116, column 11 to column 48)",
  " (in 'string', line 116, column 0 to column 69)",
  " (in 'string', line 119, column 0 to column 25)",
  " (in 'string', line 120, column 7 to column 57)",
  " (in 'string', line 120, column 59 to column 61)",
  " (in 'string', line 120, column 0 to column 65)",
  " (in 'string', line 121, column 7 to column 18)",
  " (in 'string', line 121, column 20 to column 31)",
  " (in 'string', line 121, column 0 to column 39)",
  " (in 'string', line 124, column 0 to column 33)",
  " (in 'string', line 125, column 7 to column 74)",
  " (in 'string', line 125, column 0 to column 84)",
  " (in 'string', line 128, column 0 to column 25)",
  " (in 'string', line 129, column 6 to column 56)",
  " (in 'string', line 129, column 0 to column 80)",
  " (in 'string', line 130, column 12 to column 34)",
  " (in 'string', line 130, column 0 to column 43)",
  " (in 'string', line 133, column 0 to column 32)",
  " (in 'string', line 136, column 0 to column 24)",
  " (in 'string', line 137, column 6 to column 16)",
  " (in 'string', line 137, column 0 to column 40)",
  " (in 'string', line 138, column 0 to column 13)",
  " (in 'string', line 141, column 0 to column 42)",
  " (in 'string', line 142, column 0 to column 30)",
  " (in 'string', line 143, column 0 to column 36)",
  " (in 'string', line 144, column 0 to column 33)",
  " (in 'string', line 146, column 0 to column 36)",
  " (in 'string', line 147, column 0 to column 24)",
  " (in 'string', line 148, column 0 to column 30)",
  " (in 'string', line 149, column 0 to column 27)",
  " (in 'string', line 151, column 0 to column 36)",
  " (in 'string', line 152, column 0 to column 36)",
  " (in 'string', line 153, column 0 to column 24)",
  " (in 'string', line 154, column 0 to column 30)",
  " (in 'string', line 155, column 0 to column 27)",
  " (in 'string', line 157, column 0 to column 36)",
  " (in 'string', line 158, column 0 to column 24)",
  " (in 'string', line 159, column 0 to column 30)",
  " (in 'string', line 160, column 0 to column 27)",
  " (in 'string', line 163, column 0 to column 36)",
  " (in 'string', line 164, column 6 to column 30)",
  " (in 'string', line 164, column 0 to column 54)",
  " (in 'string', line 165, column 6 to column 30)",
  " (in 'string', line 165, column 0 to column 57)",
  " (in 'string', line 167, column 0 to column 43)",
  " (in 'string', line 168, column 0 to column 31)",
  " (in 'string', line 169, column 0 to column 37)",
  " (in 'string', line 170, column 0 to column 34)",
  " (in 'string', line 172, column 0 to column 41)",
  " (in 'string', line 173, column 0 to column 29)",
  " (in 'string', line 174, column 0 to column 35)",
  " (in 'string', line 175, column 0 to column 32)",
  " (in 'string', line 177, column 8 to column 14)",
  " (in 'string', line 177, column 2 to column 35)",
  " (in 'string', line 178, column 18 to column 24)",
  " (in 'string', line 178, column 2 to column 32)",
  " (in 'string', line 179, column 8 to column 18)",
  " (in 'string', line 179, column 2 to column 43)",
  " (in 'string', line 180, column 18 to column 28)",
  " (in 'string', line 180, column 2 to column 40)",
  " (in 'string', line 183, column 9 to column 15)",
  " (in 'string', line 183, column 2 to column 39)",
  " (in 'string', line 189, column 0 to column 54)",
  " (in 'string', line 193, column 0 to column 46)",
  " (in 'string', line 195, column 7 to column 14)",
  " (in 'string', line 195, column 0 to column 47)",
  " (in 'string', line 197, column 0 to column 21)",
  " (in 'string', line 198, column 21 to column 28)",
  " (in 'string', line 198, column 0 to column 84)",
  " (in 'string', line 200, column 0 to column 17)",
  " (in 'string', line 201, column 0 to column 21)",
  " (in 'string', line 202, column 0 to column 34)",
  " (in 'string', line 203, column 0 to column 58)",
  " (in 'string', line 204, column 7 to column 30)",
  " (in 'string', line 204, column 0 to column 81)",
  " (in 'string', line 205, column 6 to column 29)",
  " (in 'string', line 205, column 0 to column 85)",
  " (in 'string', line 206, column 6 to column 33)",
  " (in 'string', line 206, column 0 to column 90)",
  " (in 'string', line 212, column 0 to column 32)",
  " (in 'string', line 218, column 6 to column 47)",
  " (in 'string', line 218, column 0 to column 135)",
  " (in 'string', line 221, column 10 to column 12)",
  " (in 'string', line 221, column 0 to column 21)",
  " (in 'string', line 222, column 7 to column 13)",
  " (in 'string', line 222, column 15 to column 17)",
  " (in 'string', line 222, column 0 to column 57)",
  " (in 'string', line 223, column 7 to column 28)",
  " (in 'string', line 223, column 30 to column 32)",
  " (in 'string', line 223, column 0 to column 117)",
  " (in 'string', line 224, column 7 to column 33)",
  " (in 'string', line 224, column 35 to column 37)",
  " (in 'string', line 224, column 0 to column 176)",
  " (in 'string', line 227, column 0 to column 17)",
  " (in 'string', line 228, column 7 to column 40)",
  " (in 'string', line 228, column 0 to column 105)",
  " (in 'string', line 229, column 7 to column 59)",
  " (in 'string', line 229, column 0 to column 169)",
  " (in 'string', line 230, column 7 to column 69)",
  " (in 'string', line 230, column 0 to column 233)",
  " (in 'string', line 233, column 0 to column 72)",
  " (in 'string', line 236, column 7 to column 44)",
  " (in 'string', line 236, column 46 to column 83)",
  " (in 'string', line 236, column 0 to column 129)",
  " (in 'string', line 240, column 6 to column 21)",
  " (in 'string', line 240, column 0 to column 43)",
  " (in 'string', line 242, column 2 to column 12)",
  " (in 'string', line 243, column 2 to column 12)",
  " (in 'string', line 250, column 6 to column 13)",
  " (in 'string', line 249, column 11 to line 251, column 5)",
  " (in 'string', line 246, column 6 to column 29)",
  " (in 'string', line 247, column 6 to column 13)",
  " (in 'string', line 248, column 6 to column 12)",
  " (in 'string', line 245, column 41 to line 249, column 5)",
  " (in 'string', line 245, column 4 to line 251, column 5)",
  " (in 'string', line 244, column 37 to line 252, column 3)",
  " (in 'string', line 244, column 2 to line 252, column 3)",
  " (in 'string', line 254, column 2 to column 25)",
  " (in 'string', line 241, column 21 to line 255, column 1)",
  " (in 'string', line 241, column 0 to line 255, column 1)",
  " (in 'string', line 258, column 0 to column 63)",
  " (in 'string', line 259, column 6 to column 18)",
  " (in 'string', line 259, column 0 to column 63)",
  " (in 'string', line 262, column 0 to column 57)",
  " (in 'string', line 263, column 6 to column 30)",
  " (in 'string', line 263, column 0 to column 58)",
  " (in 'string', line 266, column 2 to column 16)",
  " (in 'string', line 273, column 6 to column 26)",
  " (in 'string', line 272, column 11 to line 274, column 5)",
  " (in 'string', line 270, column 6 to column 30)",
  " (in 'string', line 271, column 6 to column 17)",
  " (in 'string', line 269, column 28 to line 272, column 5)",
  " (in 'string', line 269, column 4 to line 274, column 5)",
  " (in 'string', line 268, column 24 to line 275, column 3)",
  " (in 'string', line 268, column 2 to line 275, column 3)",
  " (in 'string', line 265, column 19 to line 276, column 1)",
  " (in 'string', line 265, column 0 to line 276, column 1)",
  " (in 'string', line 282, column 7 to column 9)",
  " (in 'string', line 285, column 7 to column 14)",
  " (in 'string', line 286, column 18 to column 28)",
  " (in 'string', line 289, column 7 to column 40)",
  " (in 'string', line 290, column 16 to column 52)",
  " (in 'string', line 293, column 7 to column 39)",
  " (in 'string', line 296, column 9 to column 15)",
  " (in 'string', line 297, column 18 to column 28)",
  " (in 'string', line 301, column 7 to column 13)",
  " (in 'string', line 302, column 7 to column 43)",
  " (in 'string', line 303, column 7 to column 17)",
  " (in 'string', line 308, column 7 to column 13)",
  " (in 'string', line 313, column 7 to column 14)",
  " (in 'string', line 321, column 7 to column 44)",
  " (in 'string', line 324, column 7 to column 9)",
  " (in 'string', line 326, column 7 to column 12)",
  " (in 'string', line 328, column 7 to column 13)",
  " (in 'string', line 330, column 7 to column 16)",
  " (in 'string', line 332, column 7 to column 40)",
  " (in 'string', line 337, column 7 to column 48)",
  " (in 'string', line 338, column 7 to column 22)",
  " (in 'string', line 638, column 7 to column 13)",
  " (in 'string', line 639, column 7 to column 17)",
  " (in 'string', line 640, column 7 to column 30)",
  " (in 'string', line 645, column 7 to column 44)",
  " (in 'string', line 646, column 7 to column 44)",
  " (in 'string', line 647, column 7 to column 22)",
  " (in 'string', line 650, column 9 to column 37)",
  " (in 'string', line 654, column 7 to column 14)",
  " (in 'string', line 21, column 4 to column 42)",
  " (in 'string', line 20, column 9 to line 22, column 3)",
  " (in 'string', line 18, column 4 to column 44)",
  " (in 'string', line 19, column 4 to column 22)",
  " (in 'string', line 17, column 24 to line 20, column 3)",
  " (in 'string', line 17, column 9 to line 22, column 3)",
  " (in 'string', line 16, column 4 to column 35)",
  " (in 'string', line 15, column 24 to line 17, column 3)",
  " (in 'string', line 15, column 9 to line 22, column 3)",
  " (in 'string', line 14, column 4 to column 29)",
  " (in 'string', line 13, column 24 to line 15, column 3)",
  " (in 'string', line 13, column 9 to line 22, column 3)",
  " (in 'string', line 12, column 4 to column 39)",
  " (in 'string', line 11, column 24 to line 13, column 3)",
  " (in 'string', line 11, column 9 to line 22, column 3)",
  " (in 'string', line 10, column 4 to column 32)",
  " (in 'string', line 9, column 24 to line 11, column 3)",
  " (in 'string', line 9, column 9 to line 22, column 3)",
  " (in 'string', line 8, column 4 to column 32)",
  " (in 'string', line 7, column 24 to line 9, column 3)",
  " (in 'string', line 7, column 9 to line 22, column 3)",
  " (in 'string', line 5, column 17 to line 7, column 3)",
  " (in 'string', line 5, column 2 to line 22, column 3)",
  " (in 'string', line 23, column 2 to column 9)",
  " (in 'string', line 4, column 77 to line 24, column 1)",
  " (in 'string', line 43, column 4 to column 42)",
  " (in 'string', line 42, column 9 to line 44, column 3)",
  " (in 'string', line 40, column 4 to column 44)",
  " (in 'string', line 41, column 4 to column 22)",
  " (in 'string', line 39, column 24 to line 42, column 3)",
  " (in 'string', line 39, column 9 to line 44, column 3)",
  " (in 'string', line 38, column 4 to column 35)",
  " (in 'string', line 37, column 24 to line 39, column 3)",
  " (in 'string', line 37, column 9 to line 44, column 3)",
  " (in 'string', line 36, column 4 to column 29)",
  " (in 'string', line 35, column 24 to line 37, column 3)",
  " (in 'string', line 35, column 9 to line 44, column 3)",
  " (in 'string', line 34, column 4 to column 39)",
  " (in 'string', line 33, column 24 to line 35, column 3)",
  " (in 'string', line 33, column 9 to line 44, column 3)",
  " (in 'string', line 32, column 4 to column 32)",
  " (in 'string', line 31, column 24 to line 33, column 3)",
  " (in 'string', line 31, column 9 to line 44, column 3)",
  " (in 'string', line 30, column 4 to column 32)",
  " (in 'string', line 29, column 24 to line 31, column 3)",
  " (in 'string', line 29, column 9 to line 44, column 3)",
  " (in 'string', line 27, column 17 to line 29, column 3)",
  " (in 'string', line 27, column 2 to line 44, column 3)",
  " (in 'string', line 45, column 2 to column 9)",
  " (in 'string', line 26, column 76 to line 46, column 1)",
  " (in 'string', line 51, column 2 to column 18)",
  " (in 'string', line 52, column 2 to column 18)",
  " (in 'string', line 53, column 2 to column 12)",
  " (in 'string', line 56, column 23 to column 30)",
  " (in 'string', line 56, column 6 to column 30)",
  " (in 'string', line 55, column 19 to line 57, column 5)",
  " (in 'string', line 55, column 4 to line 57, column 5)",
  " (in 'string', line 54, column 17 to line 58, column 3)",
  " (in 'string', line 54, column 2 to line 58, column 3)",
  " (in 'string', line 59, column 2 to column 11)",
  " (in 'string', line 50, column 28 to line 60, column 1)",
  " (in 'string', line 64, column 2 to column 26)",
  " (in 'string', line 65, column 8 to column 9)",
  " (in 'string', line 65, column 2 to column 17)",
  " (in 'string', line 66, column 2 to column 12)",
  " (in 'string', line 69, column 6 to column 15)",
  " (in 'string', line 70, column 6 to column 13)",
  " (in 'string', line 68, column 18 to line 71, column 5)",
  " (in 'string', line 68, column 4 to line 71, column 5)",
  " (in 'string', line 67, column 17 to line 72, column 3)",
  " (in 'string', line 67, column 2 to line 72, column 3)",
  " (in 'string', line 73, column 2 to column 20)",
  " (in 'string', line 63, column 38 to line 74, column 1)"};
template <bool propto__, typename T0__, typename T2__, typename T3__,
          typename T4__, typename T_lp__, typename T_lp_accum__,
          stan::require_all_t<stan::is_col_vector<T0__>,
                              stan::is_vt_not_complex<T0__>,
                              stan::is_stan_scalar<T2__>,
                              stan::is_stan_scalar<T3__>,
                              stan::is_stan_scalar<T4__>>* = nullptr>
void
prior_select_lp(const T0__& y_arg__, const int& dist, const T2__& location,
                const T3__& scale, const T4__& df, T_lp__& lp__,
                T_lp_accum__& lp_accum__, std::ostream* pstream__);
template <bool propto__, typename T0__, typename T2__, typename T3__,
          typename T4__, typename T_lp__, typename T_lp_accum__,
          stan::require_all_t<stan::is_stan_scalar<T0__>,
                              stan::is_stan_scalar<T2__>,
                              stan::is_stan_scalar<T3__>,
                              stan::is_stan_scalar<T4__>>* = nullptr>
void
prior_select2_lp(const T0__& y, const int& dist, const T2__& location,
                 const T3__& scale, const T4__& df, T_lp__& lp__,
                 T_lp_accum__& lp_accum__, std::ostream* pstream__);
template <typename T0__,
          stan::require_all_t<stan::is_eigen_matrix_dynamic<T0__>,
                              stan::is_vt_not_complex<T0__>>* = nullptr>
int count_nonzero(const T0__& m_arg__, std::ostream* pstream__);
std::vector<int>
which_gt0a(const std::vector<int>& x, std::ostream* pstream__);
template <bool propto__, typename T0__, typename T2__, typename T3__,
          typename T4__, typename T_lp__, typename T_lp_accum__,
          stan::require_all_t<stan::is_col_vector<T0__>,
                              stan::is_vt_not_complex<T0__>,
                              stan::is_stan_scalar<T2__>,
                              stan::is_stan_scalar<T3__>,
                              stan::is_stan_scalar<T4__>>*>
void
prior_select_lp(const T0__& y_arg__, const int& dist, const T2__& location,
                const T3__& scale, const T4__& df, T_lp__& lp__,
                T_lp_accum__& lp_accum__, std::ostream* pstream__) {
  using local_scalar_t__ = stan::promote_args_t<stan::base_type_t<T0__>,
                             T2__, T3__, T4__>;
  int current_statement__ = 0;
  const auto& y = stan::math::to_ref(y_arg__);
  local_scalar_t__ DUMMY_VAR__(std::numeric_limits<double>::quiet_NaN());
  // suppress unused var warning
  (void) DUMMY_VAR__;
  try {
    current_statement__ = 504;
    if (stan::math::logical_eq(dist, 0)) {} else {
                                            current_statement__ = 502;
                                            if (stan::math::logical_eq(dist,
                                                  1)) {
                                              current_statement__ = 500;
                                              lp_accum__.add(stan::math::normal_lpdf<
                                                               propto__>(y,
                                                               location,
                                                               scale));
                                            } else {
                                              current_statement__ = 499;
                                              if (stan::math::logical_eq(
                                                    dist, 2)) {
                                                current_statement__ = 497;
                                                lp_accum__.add(stan::math::cauchy_lpdf<
                                                                 propto__>(y,
                                                                 location,
                                                                 scale));
                                              } else {
                                                current_statement__ = 496;
                                                if (stan::math::logical_eq(
                                                      dist, 3)) {
                                                  current_statement__ = 494;
                                                  lp_accum__.add(stan::math::student_t_lpdf<
                                                                   propto__>(
                                                                   y, df,
                                                                   location,
                                                                   scale));
                                                } else {
                                                  current_statement__ = 493;
                                                  if (stan::math::logical_eq(
                                                        dist, 4)) {
                                                    current_statement__ = 491;
                                                    lp_accum__.add(stan::math::exponential_lpdf<
                                                                    propto__>(
                                                                    y, (1 /
                                                                    scale)));
                                                  } else {
                                                    current_statement__ = 490;
                                                    if (stan::math::logical_eq(
                                                          dist, 5)) {
                                                      current_statement__ = 488;
                                                      lp_accum__.add(
                                                        stan::math::lognormal_lpdf<
                                                          propto__>(y,
                                                          location, scale));
                                                    } else {
                                                      current_statement__ = 487;
                                                      if (stan::math::logical_eq(
                                                            dist, 6)) {
                                                        current_statement__ = 484;
                                                        lp_accum__.add(
                                                          stan::math::student_t_lpdf<
                                                            propto__>(
                                                            stan::math::log(y),
                                                            df, location,
                                                            scale));
                                                        current_statement__ = 485;
                                                        lp_accum__.add(
                                                          stan::math::minus(
                                                            stan::math::log(y)));
                                                      } else {
                                                        current_statement__ = 482;
                                                        std::stringstream
                                                          errmsg_stream__;
                                                        stan::math::stan_print(
                                                          &errmsg_stream__,
                                                          "Not a supported prior dist.");
                                                        throw std::domain_error(
                                                                errmsg_stream__.str());
                                                      }
                                                    }
                                                  }
                                                }
                                              }
                                            }
    }
    current_statement__ = 505;
    return ;
  } catch (const std::exception& e) {
    stan::lang::rethrow_located(e, locations_array__[current_statement__]);
  }
}
template <bool propto__, typename T0__, typename T2__, typename T3__,
          typename T4__, typename T_lp__, typename T_lp_accum__,
          stan::require_all_t<stan::is_stan_scalar<T0__>,
                              stan::is_stan_scalar<T2__>,
                              stan::is_stan_scalar<T3__>,
                              stan::is_stan_scalar<T4__>>*>
void
prior_select2_lp(const T0__& y, const int& dist, const T2__& location,
                 const T3__& scale, const T4__& df, T_lp__& lp__,
                 T_lp_accum__& lp_accum__, std::ostream* pstream__) {
  using local_scalar_t__ = stan::promote_args_t<T0__, T2__, T3__, T4__>;
  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__ = 529;
    if (stan::math::logical_eq(dist, 0)) {} else {
                                            current_statement__ = 527;
                                            if (stan::math::logical_eq(dist,
                                                  1)) {
                                              current_statement__ = 525;
                                              lp_accum__.add(stan::math::normal_lpdf<
                                                               propto__>(y,
                                                               location,
                                                               scale));
                                            } else {
                                              current_statement__ = 524;
                                              if (stan::math::logical_eq(
                                                    dist, 2)) {
                                                current_statement__ = 522;
                                                lp_accum__.add(stan::math::cauchy_lpdf<
                                                                 propto__>(y,
                                                                 location,
                                                                 scale));
                                              } else {
                                                current_statement__ = 521;
                                                if (stan::math::logical_eq(
                                                      dist, 3)) {
                                                  current_statement__ = 519;
                                                  lp_accum__.add(stan::math::student_t_lpdf<
                                                                   propto__>(
                                                                   y, df,
                                                                   location,
                                                                   scale));
                                                } else {
                                                  current_statement__ = 518;
                                                  if (stan::math::logical_eq(
                                                        dist, 4)) {
                                                    current_statement__ = 516;
                                                    lp_accum__.add(stan::math::exponential_lpdf<
                                                                    propto__>(
                                                                    y, (1 /
                                                                    scale)));
                                                  } else {
                                                    current_statement__ = 515;
                                                    if (stan::math::logical_eq(
                                                          dist, 5)) {
                                                      current_statement__ = 513;
                                                      lp_accum__.add(
                                                        stan::math::lognormal_lpdf<
                                                          propto__>(y,
                                                          location, scale));
                                                    } else {
                                                      current_statement__ = 512;
                                                      if (stan::math::logical_eq(
                                                            dist, 6)) {
                                                        current_statement__ = 509;
                                                        lp_accum__.add(
                                                          stan::math::student_t_lpdf<
                                                            propto__>(
                                                            stan::math::log(y),
                                                            df, location,
                                                            scale));
                                                        current_statement__ = 510;
                                                        lp_accum__.add(-
                                                          stan::math::log(y));
                                                      } else {
                                                        current_statement__ = 507;
                                                        std::stringstream
                                                          errmsg_stream__;
                                                        stan::math::stan_print(
                                                          &errmsg_stream__,
                                                          "Not a supported prior dist.");
                                                        throw std::domain_error(
                                                                errmsg_stream__.str());
                                                      }
                                                    }
                                                  }
                                                }
                                              }
                                            }
    }
    current_statement__ = 530;
    return ;
  } catch (const std::exception& e) {
    stan::lang::rethrow_located(e, locations_array__[current_statement__]);
  }
}
template <typename T0__,
          stan::require_all_t<stan::is_eigen_matrix_dynamic<T0__>,
                              stan::is_vt_not_complex<T0__>>*>
int count_nonzero(const T0__& m_arg__, std::ostream* pstream__) {
  using local_scalar_t__ = stan::promote_args_t<stan::base_type_t<T0__>>;
  int current_statement__ = 0;
  const auto& m = stan::math::to_ref(m_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 I = std::numeric_limits<int>::min();
    current_statement__ = 532;
    I = stan::math::rows(m);
    int J = std::numeric_limits<int>::min();
    current_statement__ = 533;
    J = stan::math::cols(m);
    int c = std::numeric_limits<int>::min();
    current_statement__ = 534;
    c = 0;
    current_statement__ = 540;
    for (int j = 1; j <= I; ++j) {
      current_statement__ = 538;
      for (int i = 1; i <= J; ++i) {
        current_statement__ = 536;
        if (stan::math::logical_neq(
              stan::model::rvalue(m, "m", stan::model::index_uni(i),
                stan::model::index_uni(j)), 0)) {
          current_statement__ = 535;
          c = (c + 1);
        }
      }
    }
    current_statement__ = 541;
    return c;
  } catch (const std::exception& e) {
    stan::lang::rethrow_located(e, locations_array__[current_statement__]);
  }
}
std::vector<int>
which_gt0a(const std::vector<int>& x, 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 {
    int n = std::numeric_limits<int>::min();
    current_statement__ = 543;
    n = stan::math::num_elements(x);
    current_statement__ = 544;
    stan::math::validate_non_negative_index("w", "n", n);
    std::vector<int> w = std::vector<int>(n, std::numeric_limits<int>::min());
    int c = std::numeric_limits<int>::min();
    current_statement__ = 546;
    c = 1;
    current_statement__ = 552;
    for (int i = 1; i <= n; ++i) {
      current_statement__ = 550;
      if (stan::math::logical_gt(
            stan::model::rvalue(x, "x", stan::model::index_uni(i)), 0)) {
        current_statement__ = 547;
        stan::model::assign(w, i, "assigning variable w",
          stan::model::index_uni(c));
        current_statement__ = 548;
        c = (c + 1);
      }
    }
    current_statement__ = 553;
    return stan::model::rvalue(w, "w", stan::model::index_min_max(1, (c - 1)));
  } catch (const std::exception& e) {
    stan::lang::rethrow_located(e, locations_array__[current_statement__]);
  }
}
#include <stan_meta_header.hpp>
class model_poisson final : public model_base_crtp<model_poisson> {
private:
  int ns_ipd;
  int ns_agd_arm;
  int ns_agd_contrast;
  int ni_ipd;
  int ni_agd_arm;
  int ni_agd_contrast;
  int narm_ipd;
  std::vector<int> ipd_arm;
  std::vector<int> ipd_trt;
  int narm_agd_arm;
  std::vector<int> agd_arm_trt;
  std::vector<int> agd_contrast_trt;
  std::vector<int> agd_contrast_trt_b;
  int nt;
  int nX;
  int nchains;
  int CHAIN_ID;
  std::vector<int> nint_vec;
  int nint_max;
  int int_thin;
  int link;
  Eigen::Matrix<double,-1,1> agd_contrast_y_data__;
  Eigen::Matrix<double,-1,-1> agd_contrast_Sigma_data__;
  int QR;
  Eigen::Matrix<double,-1,-1> X_data__;
  Eigen::Matrix<double,-1,-1> R_inv_data__;
  int has_offset;
  Eigen::Matrix<double,-1,1> offsets_data__;
  int RE;
  std::vector<int> which_RE;
  Eigen::Matrix<double,-1,-1> RE_cor_data__;
  int nodesplit;
  int brmr_n_col;
  std::vector<int> brmr_col;
  double xbar_mu;
  int prior_intercept_dist;
  double prior_intercept_location;
  double prior_intercept_scale;
  double prior_intercept_df;
  int prior_trt_dist;
  double prior_trt_location;
  double prior_trt_scale;
  double prior_trt_df;
  int prior_het_dist;
  int prior_het_type;
  double prior_het_location;
  double prior_het_scale;
  double prior_het_df;
  int prior_reg_dist;
  double prior_reg_location;
  double prior_reg_scale;
  double prior_reg_df;
  int class_effects;
  std::vector<int> which_CE;
  std::vector<int> which_CE_sd;
  int prior_class_mean_dist;
  double prior_class_mean_location;
  double prior_class_mean_scale;
  double prior_class_mean_df;
  int prior_class_sd_dist;
  double prior_class_sd_location;
  double prior_class_sd_scale;
  double prior_class_sd_df;
  std::vector<int> ipd_r;
  Eigen::Matrix<double,-1,1> ipd_E_data__;
  std::vector<int> agd_arm_r;
  Eigen::Matrix<double,-1,1> agd_arm_E_data__;
  Eigen::Matrix<double,-1,1> ipd_logE_data__;
  int nint;
  int n_delta;
  Eigen::Matrix<double,-1,1> RE_mu_data__;
  Eigen::Matrix<double,-1,-1> REdummy_data__;
  Eigen::Matrix<double,-1,-1> RE_L_data__;
  Eigen::Matrix<double,-1,1> wdummy_data__;
  std::vector<int> vudummy;
  int RE_L_nz;
  int RE_sparse;
  Eigen::Matrix<double,-1,1> RE_L_w_data__;
  std::vector<int> RE_L_v;
  std::vector<int> RE_L_u;
  int totns;
  std::vector<int> trt;
  Eigen::Matrix<double,-1,-1> Xdummy_data__;
  Eigen::Matrix<double,-1,-1> X_ipd_data__;
  Eigen::Matrix<double,-1,-1> X_agd_arm_data__;
  Eigen::Matrix<double,-1,-1> X_agd_contrast_data__;
  Eigen::Matrix<double,-1,1> odummy_data__;
  Eigen::Matrix<double,-1,1> offset_ipd_data__;
  Eigen::Matrix<double,-1,1> offset_agd_arm_data__;
  Eigen::Matrix<double,-1,1> offset_agd_contrast_data__;
  int n_int_thin;
  Eigen::Matrix<double,-1,-1> inv_Sigma_data__;
  std::vector<int> nc_agd_contrast;
  int n_class_trts;
  std::vector<int> which_class_trt;
  int n_class;
  std::vector<int> which_fclass;
  int tau_1dim__;
  int class_mean_1dim__;
  int class_sd_1dim__;
  int z_class_1dim__;
  int theta_agd_arm_ii_1dim__;
  int f_class_1dim__;
  int d_1dim__;
  int beta_1dim__;
  int eta_agd_contrast_ii_1dim__;
  int theta_bar_cum_agd_arm_1dim__;
  int log_lik_1dim__;
  int resdev_1dim__;
  int theta_bar_cum_agd_contrast_1dim__;
  Eigen::Map<Eigen::Matrix<double,-1,1>> agd_contrast_y{nullptr, 0};
  Eigen::Map<Eigen::Matrix<double,-1,-1>> agd_contrast_Sigma{nullptr, 0, 0};
  Eigen::Map<Eigen::Matrix<double,-1,-1>> X{nullptr, 0, 0};
  Eigen::Map<Eigen::Matrix<double,-1,-1>> R_inv{nullptr, 0, 0};
  Eigen::Map<Eigen::Matrix<double,-1,1>> offsets{nullptr, 0};
  Eigen::Map<Eigen::Matrix<double,-1,-1>> RE_cor{nullptr, 0, 0};
  Eigen::Map<Eigen::Matrix<double,-1,1>> ipd_E{nullptr, 0};
  Eigen::Map<Eigen::Matrix<double,-1,1>> agd_arm_E{nullptr, 0};
  Eigen::Map<Eigen::Matrix<double,-1,1>> ipd_logE{nullptr, 0};
  Eigen::Map<Eigen::Matrix<double,-1,1>> RE_mu{nullptr, 0};
  Eigen::Map<Eigen::Matrix<double,-1,-1>> REdummy{nullptr, 0, 0};
  Eigen::Map<Eigen::Matrix<double,-1,-1>> RE_L{nullptr, 0, 0};
  Eigen::Map<Eigen::Matrix<double,-1,1>> wdummy{nullptr, 0};
  Eigen::Map<Eigen::Matrix<double,-1,1>> RE_L_w{nullptr, 0};
  Eigen::Map<Eigen::Matrix<double,-1,-1>> Xdummy{nullptr, 0, 0};
  Eigen::Map<Eigen::Matrix<double,-1,-1>> X_ipd{nullptr, 0, 0};
  Eigen::Map<Eigen::Matrix<double,-1,-1>> X_agd_arm{nullptr, 0, 0};
  Eigen::Map<Eigen::Matrix<double,-1,-1>> X_agd_contrast{nullptr, 0, 0};
  Eigen::Map<Eigen::Matrix<double,-1,1>> odummy{nullptr, 0};
  Eigen::Map<Eigen::Matrix<double,-1,1>> offset_ipd{nullptr, 0};
  Eigen::Map<Eigen::Matrix<double,-1,1>> offset_agd_arm{nullptr, 0};
  Eigen::Map<Eigen::Matrix<double,-1,1>> offset_agd_contrast{nullptr, 0};
  Eigen::Map<Eigen::Matrix<double,-1,-1>> inv_Sigma{nullptr, 0, 0};
public:
  ~model_poisson() {}
  model_poisson(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_poisson_namespace::model_poisson";
    // 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__ = 287;
      context__.validate_dims("data initialization", "ns_ipd", "int",
        std::vector<size_t>{});
      ns_ipd = std::numeric_limits<int>::min();
      current_statement__ = 287;
      ns_ipd = context__.vals_i("ns_ipd")[(1 - 1)];
      current_statement__ = 287;
      stan::math::check_greater_or_equal(function__, "ns_ipd", ns_ipd, 0);
      current_statement__ = 288;
      context__.validate_dims("data initialization", "ns_agd_arm", "int",
        std::vector<size_t>{});
      ns_agd_arm = std::numeric_limits<int>::min();
      current_statement__ = 288;
      ns_agd_arm = context__.vals_i("ns_agd_arm")[(1 - 1)];
      current_statement__ = 288;
      stan::math::check_greater_or_equal(function__, "ns_agd_arm",
        ns_agd_arm, 0);
      current_statement__ = 289;
      context__.validate_dims("data initialization", "ns_agd_contrast",
        "int", std::vector<size_t>{});
      ns_agd_contrast = std::numeric_limits<int>::min();
      current_statement__ = 289;
      ns_agd_contrast = context__.vals_i("ns_agd_contrast")[(1 - 1)];
      current_statement__ = 289;
      stan::math::check_greater_or_equal(function__, "ns_agd_contrast",
        ns_agd_contrast, 0);
      current_statement__ = 290;
      context__.validate_dims("data initialization", "ni_ipd", "int",
        std::vector<size_t>{});
      ni_ipd = std::numeric_limits<int>::min();
      current_statement__ = 290;
      ni_ipd = context__.vals_i("ni_ipd")[(1 - 1)];
      current_statement__ = 290;
      stan::math::check_greater_or_equal(function__, "ni_ipd", ni_ipd, 0);
      current_statement__ = 291;
      context__.validate_dims("data initialization", "ni_agd_arm", "int",
        std::vector<size_t>{});
      ni_agd_arm = std::numeric_limits<int>::min();
      current_statement__ = 291;
      ni_agd_arm = context__.vals_i("ni_agd_arm")[(1 - 1)];
      current_statement__ = 291;
      stan::math::check_greater_or_equal(function__, "ni_agd_arm",
        ni_agd_arm, 0);
      current_statement__ = 292;
      context__.validate_dims("data initialization", "ni_agd_contrast",
        "int", std::vector<size_t>{});
      ni_agd_contrast = std::numeric_limits<int>::min();
      current_statement__ = 292;
      ni_agd_contrast = context__.vals_i("ni_agd_contrast")[(1 - 1)];
      current_statement__ = 292;
      stan::math::check_greater_or_equal(function__, "ni_agd_contrast",
        ni_agd_contrast, 0);
      current_statement__ = 293;
      context__.validate_dims("data initialization", "narm_ipd", "int",
        std::vector<size_t>{});
      narm_ipd = std::numeric_limits<int>::min();
      current_statement__ = 293;
      narm_ipd = context__.vals_i("narm_ipd")[(1 - 1)];
      current_statement__ = 293;
      stan::math::check_greater_or_equal(function__, "narm_ipd", narm_ipd, 0);
      current_statement__ = 294;
      stan::math::validate_non_negative_index("ipd_arm", "ni_ipd", ni_ipd);
      current_statement__ = 295;
      context__.validate_dims("data initialization", "ipd_arm", "int",
        std::vector<size_t>{static_cast<size_t>(ni_ipd)});
      ipd_arm = std::vector<int>(ni_ipd, std::numeric_limits<int>::min());
      current_statement__ = 295;
      ipd_arm = context__.vals_i("ipd_arm");
      current_statement__ = 295;
      stan::math::check_greater_or_equal(function__, "ipd_arm", ipd_arm, 1);
      current_statement__ = 296;
      stan::math::validate_non_negative_index("ipd_trt", "narm_ipd", narm_ipd);
      current_statement__ = 297;
      context__.validate_dims("data initialization", "ipd_trt", "int",
        std::vector<size_t>{static_cast<size_t>(narm_ipd)});
      ipd_trt = std::vector<int>(narm_ipd, std::numeric_limits<int>::min());
      current_statement__ = 297;
      ipd_trt = context__.vals_i("ipd_trt");
      current_statement__ = 297;
      stan::math::check_greater_or_equal(function__, "ipd_trt", ipd_trt, 1);
      current_statement__ = 298;
      context__.validate_dims("data initialization", "narm_agd_arm", "int",
        std::vector<size_t>{});
      narm_agd_arm = std::numeric_limits<int>::min();
      current_statement__ = 298;
      narm_agd_arm = context__.vals_i("narm_agd_arm")[(1 - 1)];
      current_statement__ = 298;
      stan::math::check_greater_or_equal(function__, "narm_agd_arm",
        narm_agd_arm, 0);
      current_statement__ = 299;
      stan::math::validate_non_negative_index("agd_arm_trt", "narm_agd_arm",
        narm_agd_arm);
      current_statement__ = 300;
      context__.validate_dims("data initialization", "agd_arm_trt", "int",
        std::vector<size_t>{static_cast<size_t>(narm_agd_arm)});
      agd_arm_trt = std::vector<int>(narm_agd_arm,
                      std::numeric_limits<int>::min());
      current_statement__ = 300;
      agd_arm_trt = context__.vals_i("agd_arm_trt");
      current_statement__ = 300;
      stan::math::check_greater_or_equal(function__, "agd_arm_trt",
        agd_arm_trt, 1);
      current_statement__ = 301;
      stan::math::validate_non_negative_index("agd_contrast_trt",
        "ni_agd_contrast", ni_agd_contrast);
      current_statement__ = 302;
      context__.validate_dims("data initialization", "agd_contrast_trt",
        "int", std::vector<size_t>{static_cast<size_t>(ni_agd_contrast)});
      agd_contrast_trt = std::vector<int>(ni_agd_contrast,
                           std::numeric_limits<int>::min());
      current_statement__ = 302;
      agd_contrast_trt = context__.vals_i("agd_contrast_trt");
      current_statement__ = 302;
      stan::math::check_greater_or_equal(function__, "agd_contrast_trt",
        agd_contrast_trt, 1);
      current_statement__ = 303;
      stan::math::validate_non_negative_index("agd_contrast_trt_b",
        "ni_agd_contrast", ni_agd_contrast);
      current_statement__ = 304;
      context__.validate_dims("data initialization", "agd_contrast_trt_b",
        "int", std::vector<size_t>{static_cast<size_t>(ni_agd_contrast)});
      agd_contrast_trt_b = std::vector<int>(ni_agd_contrast,
                             std::numeric_limits<int>::min());
      current_statement__ = 304;
      agd_contrast_trt_b = context__.vals_i("agd_contrast_trt_b");
      current_statement__ = 304;
      stan::math::check_greater_or_equal(function__, "agd_contrast_trt_b",
        agd_contrast_trt_b, 1);
      current_statement__ = 305;
      context__.validate_dims("data initialization", "nt", "int",
        std::vector<size_t>{});
      nt = std::numeric_limits<int>::min();
      current_statement__ = 305;
      nt = context__.vals_i("nt")[(1 - 1)];
      current_statement__ = 305;
      stan::math::check_greater_or_equal(function__, "nt", nt, 1);
      current_statement__ = 306;
      context__.validate_dims("data initialization", "nX", "int",
        std::vector<size_t>{});
      nX = std::numeric_limits<int>::min();
      current_statement__ = 306;
      nX = context__.vals_i("nX")[(1 - 1)];
      current_statement__ = 306;
      stan::math::check_greater_or_equal(function__, "nX", nX, 0);
      current_statement__ = 307;
      context__.validate_dims("data initialization", "nchains", "int",
        std::vector<size_t>{});
      nchains = std::numeric_limits<int>::min();
      current_statement__ = 307;
      nchains = context__.vals_i("nchains")[(1 - 1)];
      current_statement__ = 307;
      stan::math::check_greater_or_equal(function__, "nchains", nchains, 1);
      current_statement__ = 308;
      context__.validate_dims("data initialization", "CHAIN_ID", "int",
        std::vector<size_t>{});
      CHAIN_ID = std::numeric_limits<int>::min();
      current_statement__ = 308;
      CHAIN_ID = context__.vals_i("CHAIN_ID")[(1 - 1)];
      current_statement__ = 308;
      stan::math::check_greater_or_equal(function__, "CHAIN_ID", CHAIN_ID, 1);
      current_statement__ = 308;
      stan::math::check_less_or_equal(function__, "CHAIN_ID", CHAIN_ID,
        nchains);
      current_statement__ = 309;
      stan::math::validate_non_negative_index("nint_vec", "nchains", nchains);
      current_statement__ = 310;
      context__.validate_dims("data initialization", "nint_vec", "int",
        std::vector<size_t>{static_cast<size_t>(nchains)});
      nint_vec = std::vector<int>(nchains, std::numeric_limits<int>::min());
      current_statement__ = 310;
      nint_vec = context__.vals_i("nint_vec");
      current_statement__ = 310;
      stan::math::check_greater_or_equal(function__, "nint_vec", nint_vec, 1);
      current_statement__ = 311;
      context__.validate_dims("data initialization", "nint_max", "int",
        std::vector<size_t>{});
      nint_max = std::numeric_limits<int>::min();
      current_statement__ = 311;
      nint_max = context__.vals_i("nint_max")[(1 - 1)];
      current_statement__ = 311;
      stan::math::check_greater_or_equal(function__, "nint_max", nint_max, 1);
      current_statement__ = 312;
      context__.validate_dims("data initialization", "int_thin", "int",
        std::vector<size_t>{});
      int_thin = std::numeric_limits<int>::min();
      current_statement__ = 312;
      int_thin = context__.vals_i("int_thin")[(1 - 1)];
      current_statement__ = 312;
      stan::math::check_greater_or_equal(function__, "int_thin", int_thin, 0);
      current_statement__ = 313;
      context__.validate_dims("data initialization", "link", "int",
        std::vector<size_t>{});
      link = std::numeric_limits<int>::min();
      current_statement__ = 313;
      link = context__.vals_i("link")[(1 - 1)];
      current_statement__ = 313;
      stan::math::check_greater_or_equal(function__, "link", link, 1);
      current_statement__ = 314;
      stan::math::validate_non_negative_index("agd_contrast_y",
        "ni_agd_contrast", ni_agd_contrast);
      current_statement__ = 315;
      context__.validate_dims("data initialization", "agd_contrast_y",
        "double", std::vector<size_t>{static_cast<size_t>(ni_agd_contrast)});
      agd_contrast_y_data__ = Eigen::Matrix<double,-1,1>::Constant(ni_agd_contrast,
                                std::numeric_limits<double>::quiet_NaN());
      new (&agd_contrast_y)
        Eigen::Map<Eigen::Matrix<double,-1,1>>(agd_contrast_y_data__.data(),
        ni_agd_contrast);
      {
        std::vector<local_scalar_t__> agd_contrast_y_flat__;
        current_statement__ = 315;
        agd_contrast_y_flat__ = context__.vals_r("agd_contrast_y");
        current_statement__ = 315;
        pos__ = 1;
        current_statement__ = 315;
        for (int sym1__ = 1; sym1__ <= ni_agd_contrast; ++sym1__) {
          current_statement__ = 315;
          stan::model::assign(agd_contrast_y, agd_contrast_y_flat__[(pos__ -
            1)], "assigning variable agd_contrast_y",
            stan::model::index_uni(sym1__));
          current_statement__ = 315;
          pos__ = (pos__ + 1);
        }
      }
      current_statement__ = 316;
      stan::math::validate_non_negative_index("agd_contrast_Sigma",
        "ni_agd_contrast ? ni_agd_contrast : 1",
        (ni_agd_contrast ? ni_agd_contrast : 1));
      current_statement__ = 316;
      stan::math::validate_non_negative_index("agd_contrast_Sigma",
        "ni_agd_contrast ? ni_agd_contrast : 1",
        (ni_agd_contrast ? ni_agd_contrast : 1));
      current_statement__ = 317;
      context__.validate_dims("data initialization", "agd_contrast_Sigma",
        "double",
        std::vector<size_t>{static_cast<size_t>(
                              (ni_agd_contrast ? ni_agd_contrast : 1)),
          static_cast<size_t>((ni_agd_contrast ? ni_agd_contrast : 1))});
      agd_contrast_Sigma_data__ = Eigen::Matrix<double,-1,-1>::Constant((ni_agd_contrast ? ni_agd_contrast : 1),
                                    (ni_agd_contrast ? ni_agd_contrast : 1),
                                    std::numeric_limits<double>::quiet_NaN());
      new (&agd_contrast_Sigma)
        Eigen::Map<Eigen::Matrix<double,-1,-1>>(agd_contrast_Sigma_data__.data(),
        (ni_agd_contrast ? ni_agd_contrast : 1),
        (ni_agd_contrast ? ni_agd_contrast : 1));
      {
        std::vector<local_scalar_t__> agd_contrast_Sigma_flat__;
        current_statement__ = 317;
        agd_contrast_Sigma_flat__ = context__.vals_r("agd_contrast_Sigma");
        current_statement__ = 317;
        pos__ = 1;
        current_statement__ = 317;
        for (int sym1__ = 1; sym1__ <=
             (ni_agd_contrast ? ni_agd_contrast : 1); ++sym1__) {
          current_statement__ = 317;
          for (int sym2__ = 1; sym2__ <=
               (ni_agd_contrast ? ni_agd_contrast : 1); ++sym2__) {
            current_statement__ = 317;
            stan::model::assign(agd_contrast_Sigma,
              agd_contrast_Sigma_flat__[(pos__ - 1)],
              "assigning variable agd_contrast_Sigma",
              stan::model::index_uni(sym2__), stan::model::index_uni(sym1__));
            current_statement__ = 317;
            pos__ = (pos__ + 1);
          }
        }
      }
      current_statement__ = 317;
      stan::math::check_cov_matrix(function__, "agd_contrast_Sigma",
        agd_contrast_Sigma);
      current_statement__ = 318;
      context__.validate_dims("data initialization", "QR", "int",
        std::vector<size_t>{});
      QR = std::numeric_limits<int>::min();
      current_statement__ = 318;
      QR = context__.vals_i("QR")[(1 - 1)];
      current_statement__ = 318;
      stan::math::check_greater_or_equal(function__, "QR", QR, 0);
      current_statement__ = 318;
      stan::math::check_less_or_equal(function__, "QR", QR, 1);
      current_statement__ = 319;
      stan::math::validate_non_negative_index("X",
        "ni_ipd + nint_max * (ni_agd_arm + ni_agd_contrast)", (ni_ipd +
        (nint_max * (ni_agd_arm + ni_agd_contrast))));
      current_statement__ = 320;
      stan::math::validate_non_negative_index("X", "nX", nX);
      current_statement__ = 321;
      context__.validate_dims("data initialization", "X", "double",
        std::vector<size_t>{static_cast<size_t>((ni_ipd + (nint_max *
                              (ni_agd_arm + ni_agd_contrast)))),
          static_cast<size_t>(nX)});
      X_data__ = Eigen::Matrix<double,-1,-1>::Constant((ni_ipd + (nint_max *
                   (ni_agd_arm + ni_agd_contrast))), nX,
                   std::numeric_limits<double>::quiet_NaN());
      new (&X) Eigen::Map<Eigen::Matrix<double,-1,-1>>(X_data__.data(),
        (ni_ipd + (nint_max * (ni_agd_arm + ni_agd_contrast))), nX);
      {
        std::vector<local_scalar_t__> X_flat__;
        current_statement__ = 321;
        X_flat__ = context__.vals_r("X");
        current_statement__ = 321;
        pos__ = 1;
        current_statement__ = 321;
        for (int sym1__ = 1; sym1__ <= nX; ++sym1__) {
          current_statement__ = 321;
          for (int sym2__ = 1; sym2__ <= (ni_ipd + (nint_max * (ni_agd_arm +
               ni_agd_contrast))); ++sym2__) {
            current_statement__ = 321;
            stan::model::assign(X, X_flat__[(pos__ - 1)],
              "assigning variable X", stan::model::index_uni(sym2__),
              stan::model::index_uni(sym1__));
            current_statement__ = 321;
            pos__ = (pos__ + 1);
          }
        }
      }
      current_statement__ = 322;
      stan::math::validate_non_negative_index("R_inv", "QR ? nX : 0",
        (QR ? nX : 0));
      current_statement__ = 323;
      stan::math::validate_non_negative_index("R_inv", "QR ? nX : 0",
        (QR ? nX : 0));
      current_statement__ = 324;
      context__.validate_dims("data initialization", "R_inv", "double",
        std::vector<size_t>{static_cast<size_t>((QR ? nX : 0)),
          static_cast<size_t>((QR ? nX : 0))});
      R_inv_data__ = Eigen::Matrix<double,-1,-1>::Constant((QR ? nX : 0),
                       (QR ? nX : 0),
                       std::numeric_limits<double>::quiet_NaN());
      new (&R_inv)
        Eigen::Map<Eigen::Matrix<double,-1,-1>>(R_inv_data__.data(),
        (QR ? nX : 0), (QR ? nX : 0));
      {
        std::vector<local_scalar_t__> R_inv_flat__;
        current_statement__ = 324;
        R_inv_flat__ = context__.vals_r("R_inv");
        current_statement__ = 324;
        pos__ = 1;
        current_statement__ = 324;
        for (int sym1__ = 1; sym1__ <= (QR ? nX : 0); ++sym1__) {
          current_statement__ = 324;
          for (int sym2__ = 1; sym2__ <= (QR ? nX : 0); ++sym2__) {
            current_statement__ = 324;
            stan::model::assign(R_inv, R_inv_flat__[(pos__ - 1)],
              "assigning variable R_inv", stan::model::index_uni(sym2__),
              stan::model::index_uni(sym1__));
            current_statement__ = 324;
            pos__ = (pos__ + 1);
          }
        }
      }
      current_statement__ = 325;
      context__.validate_dims("data initialization", "has_offset", "int",
        std::vector<size_t>{});
      has_offset = std::numeric_limits<int>::min();
      current_statement__ = 325;
      has_offset = context__.vals_i("has_offset")[(1 - 1)];
      current_statement__ = 325;
      stan::math::check_greater_or_equal(function__, "has_offset",
        has_offset, 0);
      current_statement__ = 325;
      stan::math::check_less_or_equal(function__, "has_offset", has_offset, 1);
      current_statement__ = 326;
      stan::math::validate_non_negative_index("offsets",
        "has_offset ? ni_ipd + nint_max * (ni_agd_arm + ni_agd_contrast) : 0",
        (has_offset ? (ni_ipd + (nint_max * (ni_agd_arm +
        ni_agd_contrast))) : 0));
      current_statement__ = 327;
      context__.validate_dims("data initialization", "offsets", "double",
        std::vector<size_t>{static_cast<size_t>((has_offset ? (ni_ipd +
                              (nint_max * (ni_agd_arm +
                              ni_agd_contrast))) : 0))});
      offsets_data__ = Eigen::Matrix<double,-1,1>::Constant((has_offset ? (ni_ipd
                         + (nint_max * (ni_agd_arm + ni_agd_contrast))) : 0),
                         std::numeric_limits<double>::quiet_NaN());
      new (&offsets)
        Eigen::Map<Eigen::Matrix<double,-1,1>>(offsets_data__.data(),
        (has_offset ? (ni_ipd + (nint_max * (ni_agd_arm +
        ni_agd_contrast))) : 0));
      {
        std::vector<local_scalar_t__> offsets_flat__;
        current_statement__ = 327;
        offsets_flat__ = context__.vals_r("offsets");
        current_statement__ = 327;
        pos__ = 1;
        current_statement__ = 327;
        for (int sym1__ = 1; sym1__ <= (has_offset ? (ni_ipd + (nint_max *
             (ni_agd_arm + ni_agd_contrast))) : 0); ++sym1__) {
          current_statement__ = 327;
          stan::model::assign(offsets, offsets_flat__[(pos__ - 1)],
            "assigning variable offsets", stan::model::index_uni(sym1__));
          current_statement__ = 327;
          pos__ = (pos__ + 1);
        }
      }
      current_statement__ = 328;
      context__.validate_dims("data initialization", "RE", "int",
        std::vector<size_t>{});
      RE = std::numeric_limits<int>::min();
      current_statement__ = 328;
      RE = context__.vals_i("RE")[(1 - 1)];
      current_statement__ = 328;
      stan::math::check_greater_or_equal(function__, "RE", RE, 0);
      current_statement__ = 328;
      stan::math::check_less_or_equal(function__, "RE", RE, 1);
      current_statement__ = 329;
      stan::math::validate_non_negative_index("which_RE",
        "RE ? narm_ipd + narm_agd_arm + ni_agd_contrast : 0",
        (RE ? ((narm_ipd + narm_agd_arm) + ni_agd_contrast) : 0));
      current_statement__ = 330;
      context__.validate_dims("data initialization", "which_RE", "int",
        std::vector<size_t>{static_cast<size_t>((RE ? ((narm_ipd +
                              narm_agd_arm) + ni_agd_contrast) : 0))});
      which_RE = std::vector<int>((RE ? ((narm_ipd + narm_agd_arm) +
                   ni_agd_contrast) : 0), std::numeric_limits<int>::min());
      current_statement__ = 330;
      which_RE = context__.vals_i("which_RE");
      current_statement__ = 330;
      stan::math::check_greater_or_equal(function__, "which_RE", which_RE, 0);
      current_statement__ = 331;
      stan::math::validate_non_negative_index("RE_cor",
        "RE ? max(which_RE) : 1", (RE ? stan::math::max(which_RE) : 1));
      current_statement__ = 331;
      stan::math::validate_non_negative_index("RE_cor",
        "RE ? max(which_RE) : 1", (RE ? stan::math::max(which_RE) : 1));
      current_statement__ = 332;
      context__.validate_dims("data initialization", "RE_cor", "double",
        std::vector<size_t>{static_cast<size_t>(
                              (RE ? stan::math::max(which_RE) : 1)),
          static_cast<size_t>((RE ? stan::math::max(which_RE) : 1))});
      RE_cor_data__ = Eigen::Matrix<double,-1,-1>::Constant((RE ? stan::math::max(
                                                                    which_RE) : 1),
                        (RE ? stan::math::max(which_RE) : 1),
                        std::numeric_limits<double>::quiet_NaN());
      new (&RE_cor)
        Eigen::Map<Eigen::Matrix<double,-1,-1>>(RE_cor_data__.data(),
        (RE ? stan::math::max(which_RE) : 1),
        (RE ? stan::math::max(which_RE) : 1));
      {
        std::vector<local_scalar_t__> RE_cor_flat__;
        current_statement__ = 332;
        RE_cor_flat__ = context__.vals_r("RE_cor");
        current_statement__ = 332;
        pos__ = 1;
        current_statement__ = 332;
        for (int sym1__ = 1; sym1__ <=
             (RE ? stan::math::max(which_RE) : 1); ++sym1__) {
          current_statement__ = 332;
          for (int sym2__ = 1; sym2__ <=
               (RE ? stan::math::max(which_RE) : 1); ++sym2__) {
            current_statement__ = 332;
            stan::model::assign(RE_cor, RE_cor_flat__[(pos__ - 1)],
              "assigning variable RE_cor", stan::model::index_uni(sym2__),
              stan::model::index_uni(sym1__));
            current_statement__ = 332;
            pos__ = (pos__ + 1);
          }
        }
      }
      current_statement__ = 332;
      stan::math::check_corr_matrix(function__, "RE_cor", RE_cor);
      current_statement__ = 333;
      context__.validate_dims("data initialization", "nodesplit", "int",
        std::vector<size_t>{});
      nodesplit = std::numeric_limits<int>::min();
      current_statement__ = 333;
      nodesplit = context__.vals_i("nodesplit")[(1 - 1)];
      current_statement__ = 333;
      stan::math::check_greater_or_equal(function__, "nodesplit", nodesplit,
        0);
      current_statement__ = 333;
      stan::math::check_less_or_equal(function__, "nodesplit", nodesplit, 1);
      current_statement__ = 334;
      context__.validate_dims("data initialization", "brmr_n_col", "int",
        std::vector<size_t>{});
      brmr_n_col = std::numeric_limits<int>::min();
      current_statement__ = 334;
      brmr_n_col = context__.vals_i("brmr_n_col")[(1 - 1)];
      current_statement__ = 334;
      stan::math::check_greater_or_equal(function__, "brmr_n_col",
        brmr_n_col, 0);
      current_statement__ = 335;
      stan::math::validate_non_negative_index("brmr_col", "brmr_n_col",
        brmr_n_col);
      current_statement__ = 336;
      context__.validate_dims("data initialization", "brmr_col", "int",
        std::vector<size_t>{static_cast<size_t>(brmr_n_col)});
      brmr_col = std::vector<int>(brmr_n_col,
                   std::numeric_limits<int>::min());
      current_statement__ = 336;
      brmr_col = context__.vals_i("brmr_col");
      current_statement__ = 336;
      stan::math::check_greater_or_equal(function__, "brmr_col", brmr_col, 1);
      current_statement__ = 337;
      context__.validate_dims("data initialization", "xbar_mu", "double",
        std::vector<size_t>{});
      xbar_mu = std::numeric_limits<double>::quiet_NaN();
      current_statement__ = 337;
      xbar_mu = context__.vals_r("xbar_mu")[(1 - 1)];
      current_statement__ = 338;
      context__.validate_dims("data initialization", "prior_intercept_dist",
        "int", std::vector<size_t>{});
      prior_intercept_dist = std::numeric_limits<int>::min();
      current_statement__ = 338;
      prior_intercept_dist = context__.vals_i("prior_intercept_dist")[(1 -
        1)];
      current_statement__ = 338;
      stan::math::check_greater_or_equal(function__, "prior_intercept_dist",
        prior_intercept_dist, 0);
      current_statement__ = 338;
      stan::math::check_less_or_equal(function__, "prior_intercept_dist",
        prior_intercept_dist, 3);
      current_statement__ = 339;
      context__.validate_dims("data initialization",
        "prior_intercept_location", "double", std::vector<size_t>{});
      prior_intercept_location = std::numeric_limits<double>::quiet_NaN();
      current_statement__ = 339;
      prior_intercept_location = context__.vals_r("prior_intercept_location")[(1
        - 1)];
      current_statement__ = 340;
      context__.validate_dims("data initialization", "prior_intercept_scale",
        "double", std::vector<size_t>{});
      prior_intercept_scale = std::numeric_limits<double>::quiet_NaN();
      current_statement__ = 340;
      prior_intercept_scale = context__.vals_r("prior_intercept_scale")[(1 -
        1)];
      current_statement__ = 340;
      stan::math::check_greater_or_equal(function__, "prior_intercept_scale",
        prior_intercept_scale, 0);
      current_statement__ = 341;
      context__.validate_dims("data initialization", "prior_intercept_df",
        "double", std::vector<size_t>{});
      prior_intercept_df = std::numeric_limits<double>::quiet_NaN();
      current_statement__ = 341;
      prior_intercept_df = context__.vals_r("prior_intercept_df")[(1 - 1)];
      current_statement__ = 341;
      stan::math::check_greater_or_equal(function__, "prior_intercept_df",
        prior_intercept_df, 0);
      current_statement__ = 342;
      context__.validate_dims("data initialization", "prior_trt_dist", "int",
        std::vector<size_t>{});
      prior_trt_dist = std::numeric_limits<int>::min();
      current_statement__ = 342;
      prior_trt_dist = context__.vals_i("prior_trt_dist")[(1 - 1)];
      current_statement__ = 342;
      stan::math::check_greater_or_equal(function__, "prior_trt_dist",
        prior_trt_dist, 0);
      current_statement__ = 342;
      stan::math::check_less_or_equal(function__, "prior_trt_dist",
        prior_trt_dist, 3);
      current_statement__ = 343;
      context__.validate_dims("data initialization", "prior_trt_location",
        "double", std::vector<size_t>{});
      prior_trt_location = std::numeric_limits<double>::quiet_NaN();
      current_statement__ = 343;
      prior_trt_location = context__.vals_r("prior_trt_location")[(1 - 1)];
      current_statement__ = 344;
      context__.validate_dims("data initialization", "prior_trt_scale",
        "double", std::vector<size_t>{});
      prior_trt_scale = std::numeric_limits<double>::quiet_NaN();
      current_statement__ = 344;
      prior_trt_scale = context__.vals_r("prior_trt_scale")[(1 - 1)];
      current_statement__ = 344;
      stan::math::check_greater_or_equal(function__, "prior_trt_scale",
        prior_trt_scale, 0);
      current_statement__ = 345;
      context__.validate_dims("data initialization", "prior_trt_df",
        "double", std::vector<size_t>{});
      prior_trt_df = std::numeric_limits<double>::quiet_NaN();
      current_statement__ = 345;
      prior_trt_df = context__.vals_r("prior_trt_df")[(1 - 1)];
      current_statement__ = 345;
      stan::math::check_greater_or_equal(function__, "prior_trt_df",
        prior_trt_df, 0);
      current_statement__ = 346;
      context__.validate_dims("data initialization", "prior_het_dist", "int",
        std::vector<size_t>{});
      prior_het_dist = std::numeric_limits<int>::min();
      current_statement__ = 346;
      prior_het_dist = context__.vals_i("prior_het_dist")[(1 - 1)];
      current_statement__ = 346;
      stan::math::check_greater_or_equal(function__, "prior_het_dist",
        prior_het_dist, 0);
      current_statement__ = 346;
      stan::math::check_less_or_equal(function__, "prior_het_dist",
        prior_het_dist, 6);
      current_statement__ = 347;
      context__.validate_dims("data initialization", "prior_het_type", "int",
        std::vector<size_t>{});
      prior_het_type = std::numeric_limits<int>::min();
      current_statement__ = 347;
      prior_het_type = context__.vals_i("prior_het_type")[(1 - 1)];
      current_statement__ = 347;
      stan::math::check_greater_or_equal(function__, "prior_het_type",
        prior_het_type, 1);
      current_statement__ = 347;
      stan::math::check_less_or_equal(function__, "prior_het_type",
        prior_het_type, 3);
      current_statement__ = 348;
      context__.validate_dims("data initialization", "prior_het_location",
        "double", std::vector<size_t>{});
      prior_het_location = std::numeric_limits<double>::quiet_NaN();
      current_statement__ = 348;
      prior_het_location = context__.vals_r("prior_het_location")[(1 - 1)];
      current_statement__ = 349;
      context__.validate_dims("data initialization", "prior_het_scale",
        "double", std::vector<size_t>{});
      prior_het_scale = std::numeric_limits<double>::quiet_NaN();
      current_statement__ = 349;
      prior_het_scale = context__.vals_r("prior_het_scale")[(1 - 1)];
      current_statement__ = 349;
      stan::math::check_greater_or_equal(function__, "prior_het_scale",
        prior_het_scale, 0);
      current_statement__ = 350;
      context__.validate_dims("data initialization", "prior_het_df",
        "double", std::vector<size_t>{});
      prior_het_df = std::numeric_limits<double>::quiet_NaN();
      current_statement__ = 350;
      prior_het_df = context__.vals_r("prior_het_df")[(1 - 1)];
      current_statement__ = 350;
      stan::math::check_greater_or_equal(function__, "prior_het_df",
        prior_het_df, 0);
      current_statement__ = 351;
      context__.validate_dims("data initialization", "prior_reg_dist", "int",
        std::vector<size_t>{});
      prior_reg_dist = std::numeric_limits<int>::min();
      current_statement__ = 351;
      prior_reg_dist = context__.vals_i("prior_reg_dist")[(1 - 1)];
      current_statement__ = 351;
      stan::math::check_greater_or_equal(function__, "prior_reg_dist",
        prior_reg_dist, 0);
      current_statement__ = 351;
      stan::math::check_less_or_equal(function__, "prior_reg_dist",
        prior_reg_dist, 3);
      current_statement__ = 352;
      context__.validate_dims("data initialization", "prior_reg_location",
        "double", std::vector<size_t>{});
      prior_reg_location = std::numeric_limits<double>::quiet_NaN();
      current_statement__ = 352;
      prior_reg_location = context__.vals_r("prior_reg_location")[(1 - 1)];
      current_statement__ = 353;
      context__.validate_dims("data initialization", "prior_reg_scale",
        "double", std::vector<size_t>{});
      prior_reg_scale = std::numeric_limits<double>::quiet_NaN();
      current_statement__ = 353;
      prior_reg_scale = context__.vals_r("prior_reg_scale")[(1 - 1)];
      current_statement__ = 353;
      stan::math::check_greater_or_equal(function__, "prior_reg_scale",
        prior_reg_scale, 0);
      current_statement__ = 354;
      context__.validate_dims("data initialization", "prior_reg_df",
        "double", std::vector<size_t>{});
      prior_reg_df = std::numeric_limits<double>::quiet_NaN();
      current_statement__ = 354;
      prior_reg_df = context__.vals_r("prior_reg_df")[(1 - 1)];
      current_statement__ = 354;
      stan::math::check_greater_or_equal(function__, "prior_reg_df",
        prior_reg_df, 0);
      current_statement__ = 355;
      context__.validate_dims("data initialization", "class_effects", "int",
        std::vector<size_t>{});
      class_effects = std::numeric_limits<int>::min();
      current_statement__ = 355;
      class_effects = context__.vals_i("class_effects")[(1 - 1)];
      current_statement__ = 355;
      stan::math::check_greater_or_equal(function__, "class_effects",
        class_effects, 0);
      current_statement__ = 355;
      stan::math::check_less_or_equal(function__, "class_effects",
        class_effects, 1);
      current_statement__ = 356;
      stan::math::validate_non_negative_index("which_CE",
        "class_effects ? nt - 1 : 0", (class_effects ? (nt - 1) : 0));
      current_statement__ = 357;
      context__.validate_dims("data initialization", "which_CE", "int",
        std::vector<size_t>{static_cast<size_t>((class_effects ? (nt -
                              1) : 0))});
      which_CE = std::vector<int>((class_effects ? (nt - 1) : 0),
                   std::numeric_limits<int>::min());
      current_statement__ = 357;
      which_CE = context__.vals_i("which_CE");
      current_statement__ = 357;
      stan::math::check_greater_or_equal(function__, "which_CE", which_CE, 0);
      current_statement__ = 358;
      stan::math::validate_non_negative_index("which_CE_sd",
        "class_effects ? nt - 1 : 0", (class_effects ? (nt - 1) : 0));
      current_statement__ = 359;
      context__.validate_dims("data initialization", "which_CE_sd", "int",
        std::vector<size_t>{static_cast<size_t>((class_effects ? (nt -
                              1) : 0))});
      which_CE_sd = std::vector<int>((class_effects ? (nt - 1) : 0),
                      std::numeric_limits<int>::min());
      current_statement__ = 359;
      which_CE_sd = context__.vals_i("which_CE_sd");
      current_statement__ = 359;
      stan::math::check_greater_or_equal(function__, "which_CE_sd",
        which_CE_sd, 0);
      current_statement__ = 360;
      context__.validate_dims("data initialization", "prior_class_mean_dist",
        "int", std::vector<size_t>{});
      prior_class_mean_dist = std::numeric_limits<int>::min();
      current_statement__ = 360;
      prior_class_mean_dist = context__.vals_i("prior_class_mean_dist")[(1 -
        1)];
      current_statement__ = 360;
      stan::math::check_greater_or_equal(function__, "prior_class_mean_dist",
        prior_class_mean_dist, 0);
      current_statement__ = 360;
      stan::math::check_less_or_equal(function__, "prior_class_mean_dist",
        prior_class_mean_dist, 3);
      current_statement__ = 361;
      context__.validate_dims("data initialization",
        "prior_class_mean_location", "double", std::vector<size_t>{});
      prior_class_mean_location = std::numeric_limits<double>::quiet_NaN();
      current_statement__ = 361;
      prior_class_mean_location = context__.vals_r("prior_class_mean_location")[(1
        - 1)];
      current_statement__ = 362;
      context__.validate_dims("data initialization",
        "prior_class_mean_scale", "double", std::vector<size_t>{});
      prior_class_mean_scale = std::numeric_limits<double>::quiet_NaN();
      current_statement__ = 362;
      prior_class_mean_scale = context__.vals_r("prior_class_mean_scale")[(1
        - 1)];
      current_statement__ = 362;
      stan::math::check_greater_or_equal(function__,
        "prior_class_mean_scale", prior_class_mean_scale, 0);
      current_statement__ = 363;
      context__.validate_dims("data initialization", "prior_class_mean_df",
        "double", std::vector<size_t>{});
      prior_class_mean_df = std::numeric_limits<double>::quiet_NaN();
      current_statement__ = 363;
      prior_class_mean_df = context__.vals_r("prior_class_mean_df")[(1 - 1)];
      current_statement__ = 363;
      stan::math::check_greater_or_equal(function__, "prior_class_mean_df",
        prior_class_mean_df, 0);
      current_statement__ = 364;
      context__.validate_dims("data initialization", "prior_class_sd_dist",
        "int", std::vector<size_t>{});
      prior_class_sd_dist = std::numeric_limits<int>::min();
      current_statement__ = 364;
      prior_class_sd_dist = context__.vals_i("prior_class_sd_dist")[(1 - 1)];
      current_statement__ = 364;
      stan::math::check_greater_or_equal(function__, "prior_class_sd_dist",
        prior_class_sd_dist, 0);
      current_statement__ = 364;
      stan::math::check_less_or_equal(function__, "prior_class_sd_dist",
        prior_class_sd_dist, 6);
      current_statement__ = 365;
      context__.validate_dims("data initialization",
        "prior_class_sd_location", "double", std::vector<size_t>{});
      prior_class_sd_location = std::numeric_limits<double>::quiet_NaN();
      current_statement__ = 365;
      prior_class_sd_location = context__.vals_r("prior_class_sd_location")[(1
        - 1)];
      current_statement__ = 366;
      context__.validate_dims("data initialization", "prior_class_sd_scale",
        "double", std::vector<size_t>{});
      prior_class_sd_scale = std::numeric_limits<double>::quiet_NaN();
      current_statement__ = 366;
      prior_class_sd_scale = context__.vals_r("prior_class_sd_scale")[(1 -
        1)];
      current_statement__ = 366;
      stan::math::check_greater_or_equal(function__, "prior_class_sd_scale",
        prior_class_sd_scale, 0);
      current_statement__ = 367;
      context__.validate_dims("data initialization", "prior_class_sd_df",
        "double", std::vector<size_t>{});
      prior_class_sd_df = std::numeric_limits<double>::quiet_NaN();
      current_statement__ = 367;
      prior_class_sd_df = context__.vals_r("prior_class_sd_df")[(1 - 1)];
      current_statement__ = 367;
      stan::math::check_greater_or_equal(function__, "prior_class_sd_df",
        prior_class_sd_df, 0);
      current_statement__ = 368;
      stan::math::validate_non_negative_index("ipd_r", "ni_ipd", ni_ipd);
      current_statement__ = 369;
      context__.validate_dims("data initialization", "ipd_r", "int",
        std::vector<size_t>{static_cast<size_t>(ni_ipd)});
      ipd_r = std::vector<int>(ni_ipd, std::numeric_limits<int>::min());
      current_statement__ = 369;
      ipd_r = context__.vals_i("ipd_r");
      current_statement__ = 369;
      stan::math::check_greater_or_equal(function__, "ipd_r", ipd_r, 0);
      current_statement__ = 370;
      stan::math::validate_non_negative_index("ipd_E", "ni_ipd", ni_ipd);
      current_statement__ = 371;
      context__.validate_dims("data initialization", "ipd_E", "double",
        std::vector<size_t>{static_cast<size_t>(ni_ipd)});
      ipd_E_data__ = Eigen::Matrix<double,-1,1>::Constant(ni_ipd,
                       std::numeric_limits<double>::quiet_NaN());
      new (&ipd_E)
        Eigen::Map<Eigen::Matrix<double,-1,1>>(ipd_E_data__.data(), ni_ipd);
      {
        std::vector<local_scalar_t__> ipd_E_flat__;
        current_statement__ = 371;
        ipd_E_flat__ = context__.vals_r("ipd_E");
        current_statement__ = 371;
        pos__ = 1;
        current_statement__ = 371;
        for (int sym1__ = 1; sym1__ <= ni_ipd; ++sym1__) {
          current_statement__ = 371;
          stan::model::assign(ipd_E, ipd_E_flat__[(pos__ - 1)],
            "assigning variable ipd_E", stan::model::index_uni(sym1__));
          current_statement__ = 371;
          pos__ = (pos__ + 1);
        }
      }
      current_statement__ = 371;
      stan::math::check_greater_or_equal(function__, "ipd_E", ipd_E, 0);
      current_statement__ = 372;
      stan::math::validate_non_negative_index("agd_arm_r", "ni_agd_arm",
        ni_agd_arm);
      current_statement__ = 373;
      context__.validate_dims("data initialization", "agd_arm_r", "int",
        std::vector<size_t>{static_cast<size_t>(ni_agd_arm)});
      agd_arm_r = std::vector<int>(ni_agd_arm,
                    std::numeric_limits<int>::min());
      current_statement__ = 373;
      agd_arm_r = context__.vals_i("agd_arm_r");
      current_statement__ = 373;
      stan::math::check_greater_or_equal(function__, "agd_arm_r", agd_arm_r,
        0);
      current_statement__ = 374;
      stan::math::validate_non_negative_index("agd_arm_E", "ni_agd_arm",
        ni_agd_arm);
      current_statement__ = 375;
      context__.validate_dims("data initialization", "agd_arm_E", "double",
        std::vector<size_t>{static_cast<size_t>(ni_agd_arm)});
      agd_arm_E_data__ = Eigen::Matrix<double,-1,1>::Constant(ni_agd_arm,
                           std::numeric_limits<double>::quiet_NaN());
      new (&agd_arm_E)
        Eigen::Map<Eigen::Matrix<double,-1,1>>(agd_arm_E_data__.data(),
        ni_agd_arm);
      {
        std::vector<local_scalar_t__> agd_arm_E_flat__;
        current_statement__ = 375;
        agd_arm_E_flat__ = context__.vals_r("agd_arm_E");
        current_statement__ = 375;
        pos__ = 1;
        current_statement__ = 375;
        for (int sym1__ = 1; sym1__ <= ni_agd_arm; ++sym1__) {
          current_statement__ = 375;
          stan::model::assign(agd_arm_E, agd_arm_E_flat__[(pos__ - 1)],
            "assigning variable agd_arm_E", stan::model::index_uni(sym1__));
          current_statement__ = 375;
          pos__ = (pos__ + 1);
        }
      }
      current_statement__ = 375;
      stan::math::check_greater_or_equal(function__, "agd_arm_E", agd_arm_E,
        0);
      current_statement__ = 376;
      stan::math::validate_non_negative_index("ipd_logE", "ni_ipd", ni_ipd);
      current_statement__ = 377;
      ipd_logE_data__ = Eigen::Matrix<double,-1,1>::Constant(ni_ipd,
                          std::numeric_limits<double>::quiet_NaN());
      new (&ipd_logE)
        Eigen::Map<Eigen::Matrix<double,-1,1>>(ipd_logE_data__.data(),
        ni_ipd);
      current_statement__ = 377;
      stan::model::assign(ipd_logE, stan::math::log(ipd_E),
        "assigning variable ipd_logE");
      current_statement__ = 378;
      nint = std::numeric_limits<int>::min();
      current_statement__ = 378;
      nint = stan::model::rvalue(nint_vec, "nint_vec",
               stan::model::index_uni(CHAIN_ID));
      current_statement__ = 379;
      n_delta = std::numeric_limits<int>::min();
      current_statement__ = 379;
      n_delta = (RE ? stan::math::max(which_RE) : 0);
      current_statement__ = 380;
      stan::math::validate_non_negative_index("RE_mu", "n_delta", n_delta);
      current_statement__ = 381;
      RE_mu_data__ = Eigen::Matrix<double,-1,1>::Constant(n_delta,
                       std::numeric_limits<double>::quiet_NaN());
      new (&RE_mu)
        Eigen::Map<Eigen::Matrix<double,-1,1>>(RE_mu_data__.data(), n_delta);
      current_statement__ = 381;
      stan::model::assign(RE_mu, stan::math::rep_vector(0, n_delta),
        "assigning variable RE_mu");
      current_statement__ = 382;
      REdummy_data__ = Eigen::Matrix<double,-1,-1>::Constant(0, 0,
                         std::numeric_limits<double>::quiet_NaN());
      new (&REdummy)
        Eigen::Map<Eigen::Matrix<double,-1,-1>>(REdummy_data__.data(), 0, 0);
      current_statement__ = 383;
      stan::math::validate_non_negative_index("RE_L", "n_delta", n_delta);
      current_statement__ = 383;
      stan::math::validate_non_negative_index("RE_L", "n_delta", n_delta);
      current_statement__ = 384;
      RE_L_data__ = Eigen::Matrix<double,-1,-1>::Constant(n_delta, n_delta,
                      std::numeric_limits<double>::quiet_NaN());
      new (&RE_L) Eigen::Map<Eigen::Matrix<double,-1,-1>>(RE_L_data__.data(),
        n_delta, n_delta);
      current_statement__ = 384;
      stan::model::assign(RE_L,
        (n_delta ? stan::math::eval(stan::math::cholesky_decompose(RE_cor)) : 
        stan::math::eval(REdummy)), "assigning variable RE_L");
      current_statement__ = 385;
      wdummy_data__ = Eigen::Matrix<double,-1,1>::Constant(0,
                        std::numeric_limits<double>::quiet_NaN());
      new (&wdummy)
        Eigen::Map<Eigen::Matrix<double,-1,1>>(wdummy_data__.data(), 0);
      current_statement__ = 386;
      vudummy = std::vector<int>(0, std::numeric_limits<int>::min());
      current_statement__ = 387;
      RE_L_nz = std::numeric_limits<int>::min();
      current_statement__ = 387;
      RE_L_nz = count_nonzero(RE_L, pstream__);
      current_statement__ = 388;
      RE_sparse = std::numeric_limits<int>::min();
      current_statement__ = 388;
      RE_sparse = stan::math::logical_lte(((RE_L_nz * 1.0) /
                    stan::math::num_elements(RE_L)), 0.1);
      current_statement__ = 389;
      stan::math::validate_non_negative_index("RE_L_w",
        "RE_sparse ? RE_L_nz : 0", (RE_sparse ? RE_L_nz : 0));
      current_statement__ = 390;
      RE_L_w_data__ = Eigen::Matrix<double,-1,1>::Constant((RE_sparse ? RE_L_nz : 0),
                        std::numeric_limits<double>::quiet_NaN());
      new (&RE_L_w)
        Eigen::Map<Eigen::Matrix<double,-1,1>>(RE_L_w_data__.data(),
        (RE_sparse ? RE_L_nz : 0));
      current_statement__ = 390;
      stan::model::assign(RE_L_w,
        (RE_sparse ? stan::math::eval(stan::math::csr_extract_w(RE_L)) : 
        stan::math::eval(wdummy)), "assigning variable RE_L_w");
      current_statement__ = 391;
      stan::math::validate_non_negative_index("RE_L_v",
        "RE_sparse ? RE_L_nz : 0", (RE_sparse ? RE_L_nz : 0));
      current_statement__ = 392;
      RE_L_v = std::vector<int>((RE_sparse ? RE_L_nz : 0),
                 std::numeric_limits<int>::min());
      current_statement__ = 392;
      stan::model::assign(RE_L_v,
        (RE_sparse ? stan::math::csr_extract_v(RE_L) : vudummy),
        "assigning variable RE_L_v");
      current_statement__ = 393;
      stan::math::validate_non_negative_index("RE_L_u",
        "RE_sparse ? n_delta + 1 : 0", (RE_sparse ? (n_delta + 1) : 0));
      current_statement__ = 394;
      RE_L_u = std::vector<int>((RE_sparse ? (n_delta + 1) : 0),
                 std::numeric_limits<int>::min());
      current_statement__ = 394;
      stan::model::assign(RE_L_u,
        (RE_sparse ? stan::math::csr_extract_u(RE_L) : vudummy),
        "assigning variable RE_L_u");
      current_statement__ = 395;
      totns = std::numeric_limits<int>::min();
      current_statement__ = 395;
      totns = (ns_ipd + ns_agd_arm);
      current_statement__ = 396;
      stan::math::validate_non_negative_index("trt",
        "narm_ipd + narm_agd_arm + ni_agd_contrast", ((narm_ipd +
        narm_agd_arm) + ni_agd_contrast));
      current_statement__ = 397;
      trt = std::vector<int>(((narm_ipd + narm_agd_arm) + ni_agd_contrast),
              std::numeric_limits<int>::min());
      current_statement__ = 397;
      stan::model::assign(trt,
        stan::math::append_array(
          stan::math::append_array(ipd_trt, agd_arm_trt), agd_contrast_trt),
        "assigning variable trt");
      current_statement__ = 398;
      stan::math::validate_non_negative_index("Xdummy", "nX", nX);
      current_statement__ = 399;
      Xdummy_data__ = Eigen::Matrix<double,-1,-1>::Constant(0, nX,
                        std::numeric_limits<double>::quiet_NaN());
      new (&Xdummy)
        Eigen::Map<Eigen::Matrix<double,-1,-1>>(Xdummy_data__.data(), 0, nX);
      current_statement__ = 400;
      stan::math::validate_non_negative_index("X_ipd", "ni_ipd", ni_ipd);
      current_statement__ = 401;
      stan::math::validate_non_negative_index("X_ipd", "nX", nX);
      current_statement__ = 402;
      X_ipd_data__ = Eigen::Matrix<double,-1,-1>::Constant(ni_ipd, nX,
                       std::numeric_limits<double>::quiet_NaN());
      new (&X_ipd)
        Eigen::Map<Eigen::Matrix<double,-1,-1>>(X_ipd_data__.data(), ni_ipd,
        nX);
      current_statement__ = 402;
      stan::model::assign(X_ipd,
        (ni_ipd ? stan::math::eval(
                    stan::model::rvalue(X, "X",
                      stan::model::index_min_max(1, ni_ipd))) : stan::math::eval(
                                                                  Xdummy)),
        "assigning variable X_ipd");
      current_statement__ = 403;
      stan::math::validate_non_negative_index("X_agd_arm",
        "nint_max * ni_agd_arm", (nint_max * ni_agd_arm));
      current_statement__ = 404;
      stan::math::validate_non_negative_index("X_agd_arm", "nX", nX);
      current_statement__ = 405;
      X_agd_arm_data__ = Eigen::Matrix<double,-1,-1>::Constant((nint_max *
                           ni_agd_arm), nX,
                           std::numeric_limits<double>::quiet_NaN());
      new (&X_agd_arm)
        Eigen::Map<Eigen::Matrix<double,-1,-1>>(X_agd_arm_data__.data(),
        (nint_max * ni_agd_arm), nX);
      current_statement__ = 405;
      stan::model::assign(X_agd_arm,
        (ni_agd_arm ? stan::math::eval(
                        stan::model::rvalue(X, "X",
                          stan::model::index_min_max((ni_ipd + 1), (ni_ipd +
                            (nint_max * ni_agd_arm))))) : stan::math::eval(
                                                            Xdummy)),
        "assigning variable X_agd_arm");
      current_statement__ = 406;
      stan::math::validate_non_negative_index("X_agd_contrast",
        "nint_max * ni_agd_contrast", (nint_max * ni_agd_contrast));
      current_statement__ = 407;
      stan::math::validate_non_negative_index("X_agd_contrast", "nX", nX);
      current_statement__ = 408;
      X_agd_contrast_data__ = Eigen::Matrix<double,-1,-1>::Constant((nint_max
                                * ni_agd_contrast), nX,
                                std::numeric_limits<double>::quiet_NaN());
      new (&X_agd_contrast)
        Eigen::Map<Eigen::Matrix<double,-1,-1>>(X_agd_contrast_data__.data(),
        (nint_max * ni_agd_contrast), nX);
      current_statement__ = 408;
      stan::model::assign(X_agd_contrast,
        (ni_agd_contrast ? stan::math::eval(
                             stan::model::rvalue(X, "X",
                               stan::model::index_min_max(((ni_ipd +
                                 (nint_max * ni_agd_arm)) + 1), (ni_ipd +
                                 (nint_max * (ni_agd_arm + ni_agd_contrast)))))) : 
        stan::math::eval(Xdummy)), "assigning variable X_agd_contrast");
      current_statement__ = 409;
      odummy_data__ = Eigen::Matrix<double,-1,1>::Constant(0,
                        std::numeric_limits<double>::quiet_NaN());
      new (&odummy)
        Eigen::Map<Eigen::Matrix<double,-1,1>>(odummy_data__.data(), 0);
      current_statement__ = 410;
      stan::math::validate_non_negative_index("offset_ipd",
        "has_offset && ni_ipd ? ni_ipd : 0",
        ((stan::math::primitive_value(has_offset) &&
        stan::math::primitive_value(ni_ipd)) ? ni_ipd : 0));
      current_statement__ = 411;
      offset_ipd_data__ = Eigen::Matrix<double,-1,1>::Constant(((stan::math::primitive_value(
                                                                   has_offset)
                            &&
                            stan::math::primitive_value(ni_ipd)) ? ni_ipd : 0),
                            std::numeric_limits<double>::quiet_NaN());
      new (&offset_ipd)
        Eigen::Map<Eigen::Matrix<double,-1,1>>(offset_ipd_data__.data(),
        ((stan::math::primitive_value(has_offset) &&
        stan::math::primitive_value(ni_ipd)) ? ni_ipd : 0));
      current_statement__ = 411;
      stan::model::assign(offset_ipd,
        ((stan::math::primitive_value(has_offset) &&
        stan::math::primitive_value(ni_ipd)) ? stan::math::eval(
                                                 stan::model::rvalue(offsets,
                                                   "offsets",
                                                   stan::model::index_min_max(
                                                     1, ni_ipd))) : stan::math::eval(
                                                                    odummy)),
        "assigning variable offset_ipd");
      current_statement__ = 412;
      stan::math::validate_non_negative_index("offset_agd_arm",
        "has_offset && ni_agd_arm ? nint_max * ni_agd_arm : 0",
        ((stan::math::primitive_value(has_offset) &&
        stan::math::primitive_value(ni_agd_arm)) ? (nint_max *
        ni_agd_arm) : 0));
      current_statement__ = 413;
      offset_agd_arm_data__ = Eigen::Matrix<double,-1,1>::Constant(((
                                stan::math::primitive_value(has_offset) &&
                                stan::math::primitive_value(ni_agd_arm)) ? (nint_max
                                * ni_agd_arm) : 0),
                                std::numeric_limits<double>::quiet_NaN());
      new (&offset_agd_arm)
        Eigen::Map<Eigen::Matrix<double,-1,1>>(offset_agd_arm_data__.data(),
        ((stan::math::primitive_value(has_offset) &&
        stan::math::primitive_value(ni_agd_arm)) ? (nint_max *
        ni_agd_arm) : 0));
      current_statement__ = 413;
      stan::model::assign(offset_agd_arm,
        ((stan::math::primitive_value(has_offset) &&
        stan::math::primitive_value(ni_agd_arm)) ? stan::math::eval(
                                                     stan::model::rvalue(
                                                       offsets, "offsets",
                                                       stan::model::index_min_max(
                                                         (ni_ipd + 1),
                                                         (ni_ipd + (nint_max
                                                         * ni_agd_arm))))) : 
        stan::math::eval(odummy)), "assigning variable offset_agd_arm");
      current_statement__ = 414;
      stan::math::validate_non_negative_index("offset_agd_contrast",
        "has_offset && ni_agd_contrast ? nint_max * ni_agd_contrast : 0",
        ((stan::math::primitive_value(has_offset) &&
        stan::math::primitive_value(ni_agd_contrast)) ? (nint_max *
        ni_agd_contrast) : 0));
      current_statement__ = 415;
      offset_agd_contrast_data__ = Eigen::Matrix<double,-1,1>::Constant(((
                                     stan::math::primitive_value(has_offset)
                                     &&
                                     stan::math::primitive_value(
                                       ni_agd_contrast)) ? (nint_max *
                                     ni_agd_contrast) : 0),
                                     std::numeric_limits<double>::quiet_NaN());
      new (&offset_agd_contrast)
        Eigen::Map<Eigen::Matrix<double,-1,1>>(offset_agd_contrast_data__.data(),
        ((stan::math::primitive_value(has_offset) &&
        stan::math::primitive_value(ni_agd_contrast)) ? (nint_max *
        ni_agd_contrast) : 0));
      current_statement__ = 415;
      stan::model::assign(offset_agd_contrast,
        ((stan::math::primitive_value(has_offset) &&
        stan::math::primitive_value(ni_agd_contrast)) ? stan::math::eval(
                                                          stan::model::rvalue(
                                                            offsets,
                                                            "offsets",
                                                            stan::model::index_min_max(
                                                              ((ni_ipd +
                                                              (nint_max *
                                                              ni_agd_arm)) +
                                                              1), (ni_ipd +
                                                              (nint_max *
                                                              (ni_agd_arm +
                                                              ni_agd_contrast)))))) : 
        stan::math::eval(odummy)), "assigning variable offset_agd_contrast");
      current_statement__ = 416;
      n_int_thin = std::numeric_limits<int>::min();
      current_statement__ = 416;
      n_int_thin = ((stan::math::primitive_value(
                       stan::math::logical_gt(nint_max, 1))
        &&
        stan::math::primitive_value(stan::math::logical_gt(int_thin, 0))) ? (nint
        / int_thin) : 0);
      current_statement__ = 417;
      stan::math::validate_non_negative_index("inv_Sigma",
        "ni_agd_contrast ? ni_agd_contrast : 1",
        (ni_agd_contrast ? ni_agd_contrast : 1));
      current_statement__ = 418;
      stan::math::validate_non_negative_index("inv_Sigma",
        "ni_agd_contrast ? ni_agd_contrast : 1",
        (ni_agd_contrast ? ni_agd_contrast : 1));
      current_statement__ = 419;
      inv_Sigma_data__ = Eigen::Matrix<double,-1,-1>::Constant((ni_agd_contrast ? ni_agd_contrast : 1),
                           (ni_agd_contrast ? ni_agd_contrast : 1),
                           std::numeric_limits<double>::quiet_NaN());
      new (&inv_Sigma)
        Eigen::Map<Eigen::Matrix<double,-1,-1>>(inv_Sigma_data__.data(),
        (ni_agd_contrast ? ni_agd_contrast : 1),
        (ni_agd_contrast ? ni_agd_contrast : 1));
      current_statement__ = 419;
      stan::model::assign(inv_Sigma,
        stan::math::inverse_spd(agd_contrast_Sigma),
        "assigning variable inv_Sigma");
      current_statement__ = 420;
      stan::math::validate_non_negative_index("nc_agd_contrast",
        "ns_agd_contrast", ns_agd_contrast);
      current_statement__ = 421;
      nc_agd_contrast = std::vector<int>(ns_agd_contrast,
                          std::numeric_limits<int>::min());
      current_statement__ = 435;
      if (ns_agd_contrast) {
        int s = std::numeric_limits<int>::min();
        current_statement__ = 422;
        s = 1;
        int c = std::numeric_limits<int>::min();
        current_statement__ = 423;
        c = 1;
        current_statement__ = 432;
        for (int i = 1; i <= (ni_agd_contrast - 1); ++i) {
          current_statement__ = 430;
          if (stan::math::logical_eq(
                stan::model::rvalue(agd_contrast_Sigma, "agd_contrast_Sigma",
                  stan::model::index_uni(i), stan::model::index_uni((i + 1))),
                0)) {
            current_statement__ = 426;
            stan::model::assign(nc_agd_contrast, c,
              "assigning variable nc_agd_contrast", stan::model::index_uni(s));
            current_statement__ = 427;
            s = (s + 1);
            current_statement__ = 428;
            c = 1;
          } else {
            current_statement__ = 424;
            c = (c + 1);
          }
        }
        current_statement__ = 433;
        stan::model::assign(nc_agd_contrast, c,
          "assigning variable nc_agd_contrast", stan::model::index_uni(s));
      }
      current_statement__ = 436;
      n_class_trts = std::numeric_limits<int>::min();
      current_statement__ = 436;
      n_class_trts = stan::math::num_elements(which_gt0a(which_CE, pstream__));
      current_statement__ = 437;
      stan::math::validate_non_negative_index("which_class_trt",
        "n_class_trts", n_class_trts);
      current_statement__ = 438;
      which_class_trt = std::vector<int>(n_class_trts,
                          std::numeric_limits<int>::min());
      current_statement__ = 438;
      stan::model::assign(which_class_trt, which_gt0a(which_CE, pstream__),
        "assigning variable which_class_trt");
      current_statement__ = 439;
      n_class = std::numeric_limits<int>::min();
      current_statement__ = 439;
      n_class = (class_effects ? stan::math::max(which_CE) : 0);
      current_statement__ = 440;
      stan::math::validate_non_negative_index("which_fclass",
        "class_effects ? nt - 1 : 0", (class_effects ? (nt - 1) : 0));
      current_statement__ = 441;
      which_fclass = std::vector<int>((class_effects ? (nt - 1) : 0),
                       std::numeric_limits<int>::min());
      current_statement__ = 452;
      if (class_effects) {
        int count = std::numeric_limits<int>::min();
        current_statement__ = 442;
        count = 1;
        current_statement__ = 450;
        for (int t = 1; t <= (nt - 1); ++t) {
          current_statement__ = 448;
          if (stan::math::logical_gt(
                stan::model::rvalue(which_CE_sd, "which_CE_sd",
                  stan::model::index_uni(t)), 0)) {
            current_statement__ = 445;
            stan::model::assign(which_fclass, count,
              "assigning variable which_fclass", stan::model::index_uni(t));
            current_statement__ = 446;
            count = (count + 1);
          } else {
            current_statement__ = 443;
            stan::model::assign(which_fclass, 0,
              "assigning variable which_fclass", stan::model::index_uni(t));
          }
        }
      }
      current_statement__ = 378;
      stan::math::check_greater_or_equal(function__, "nint", nint, 1);
      current_statement__ = 378;
      stan::math::check_less_or_equal(function__, "nint", nint, nint_max);
      current_statement__ = 379;
      stan::math::check_greater_or_equal(function__, "n_delta", n_delta, 0);
      current_statement__ = 384;
      stan::math::check_cholesky_factor_corr(function__, "RE_L", RE_L);
      current_statement__ = 397;
      stan::math::check_greater_or_equal(function__, "trt", trt, 1);
      current_statement__ = 436;
      stan::math::check_greater_or_equal(function__, "n_class_trts",
        n_class_trts, 0);
      current_statement__ = 439;
      stan::math::check_greater_or_equal(function__, "n_class", n_class, 0);
      current_statement__ = 441;
      stan::math::check_greater_or_equal(function__, "which_fclass",
        which_fclass, 0);
      current_statement__ = 453;
      stan::math::validate_non_negative_index("beta_tilde", "nX", nX);
      current_statement__ = 454;
      stan::math::validate_non_negative_index("u_delta", "n_delta", n_delta);
      current_statement__ = 455;
      tau_1dim__ = std::numeric_limits<int>::min();
      current_statement__ = 455;
      tau_1dim__ = (RE ? 1 : 0);
      current_statement__ = 455;
      stan::math::validate_non_negative_index("tau", "RE ? 1 : 0", tau_1dim__);
      current_statement__ = 456;
      class_mean_1dim__ = std::numeric_limits<int>::min();
      current_statement__ = 456;
      class_mean_1dim__ = (class_effects ? stan::math::max(which_CE) : 0);
      current_statement__ = 456;
      stan::math::validate_non_negative_index("class_mean",
        "class_effects ? max(which_CE) : 0", class_mean_1dim__);
      current_statement__ = 457;
      class_sd_1dim__ = std::numeric_limits<int>::min();
      current_statement__ = 457;
      class_sd_1dim__ = (class_effects ? stan::math::max(which_CE_sd) : 0);
      current_statement__ = 457;
      stan::math::validate_non_negative_index("class_sd",
        "class_effects ? max(which_CE_sd) : 0", class_sd_1dim__);
      current_statement__ = 458;
      z_class_1dim__ = std::numeric_limits<int>::min();
      current_statement__ = 458;
      z_class_1dim__ = (class_effects ? n_class_trts : 0);
      current_statement__ = 458;
      stan::math::validate_non_negative_index("z_class",
        "class_effects ? n_class_trts : 0", z_class_1dim__);
      current_statement__ = 459;
      stan::math::validate_non_negative_index("E_eta_ipd", "ni_ipd", ni_ipd);
      current_statement__ = 460;
      stan::math::validate_non_negative_index("E_theta_agd_arm",
        "ni_agd_arm", ni_agd_arm);
      current_statement__ = 461;
      stan::math::validate_non_negative_index("theta_ipd", "ni_ipd", ni_ipd);
      current_statement__ = 462;
      theta_agd_arm_ii_1dim__ = std::numeric_limits<int>::min();
      current_statement__ = 462;
      theta_agd_arm_ii_1dim__ = (stan::math::logical_gt(nint_max, 1) ? (nint
        * ni_agd_arm) : 0);
      current_statement__ = 462;
      stan::math::validate_non_negative_index("theta_agd_arm_ii",
        "nint_max > 1 ? nint * ni_agd_arm : 0", theta_agd_arm_ii_1dim__);
      current_statement__ = 463;
      stan::math::validate_non_negative_index("theta_agd_arm_bar",
        "ni_agd_arm", ni_agd_arm);
      current_statement__ = 464;
      stan::math::validate_non_negative_index("eta_ipd", "ni_ipd", ni_ipd);
      current_statement__ = 465;
      stan::math::validate_non_negative_index("f_delta", "n_delta", n_delta);
      current_statement__ = 466;
      f_class_1dim__ = std::numeric_limits<int>::min();
      current_statement__ = 466;
      f_class_1dim__ = (class_effects ? stan::math::max(which_fclass) : 0);
      current_statement__ = 466;
      stan::math::validate_non_negative_index("f_class",
        "class_effects ? max(which_fclass) : 0", f_class_1dim__);
      current_statement__ = 467;
      stan::math::validate_non_negative_index("allbeta", "nX", nX);
      current_statement__ = 468;
      stan::math::validate_non_negative_index("mu", "totns", totns);
      current_statement__ = 469;
      d_1dim__ = std::numeric_limits<int>::min();
      current_statement__ = 469;
      d_1dim__ = (nt - 1);
      current_statement__ = 469;
      stan::math::validate_non_negative_index("d", "nt - 1", d_1dim__);
      current_statement__ = 470;
      stan::math::validate_non_negative_index("omega", "nodesplit", nodesplit);
      current_statement__ = 471;
      beta_1dim__ = std::numeric_limits<int>::min();
      current_statement__ = 471;
      beta_1dim__ = (((nX - totns) - (nt - 1)) - nodesplit);
      current_statement__ = 471;
      stan::math::validate_non_negative_index("beta",
        "nX - totns - (nt - 1) - nodesplit", beta_1dim__);
      current_statement__ = 472;
      eta_agd_contrast_ii_1dim__ = std::numeric_limits<int>::min();
      current_statement__ = 472;
      eta_agd_contrast_ii_1dim__ = (stan::math::logical_gt(nint_max, 1) ? (nint
        * ni_agd_contrast) : 0);
      current_statement__ = 472;
      stan::math::validate_non_negative_index("eta_agd_contrast_ii",
        "nint_max > 1 ? nint * ni_agd_contrast : 0",
        eta_agd_contrast_ii_1dim__);
      current_statement__ = 473;
      stan::math::validate_non_negative_index("eta_agd_contrast_bar",
        "ni_agd_contrast", ni_agd_contrast);
      current_statement__ = 474;
      stan::math::validate_non_negative_index("fitted_ipd", "ni_ipd", ni_ipd);
      current_statement__ = 475;
      stan::math::validate_non_negative_index("fitted_agd_arm", "ni_agd_arm",
        ni_agd_arm);
      current_statement__ = 476;
      theta_bar_cum_agd_arm_1dim__ = std::numeric_limits<int>::min();
      current_statement__ = 476;
      theta_bar_cum_agd_arm_1dim__ = (ni_agd_arm * n_int_thin);
      current_statement__ = 476;
      stan::math::validate_non_negative_index("theta_bar_cum_agd_arm",
        "ni_agd_arm * n_int_thin", theta_bar_cum_agd_arm_1dim__);
      current_statement__ = 477;
      log_lik_1dim__ = std::numeric_limits<int>::min();
      current_statement__ = 477;
      log_lik_1dim__ = ((ni_ipd + ni_agd_arm) + ns_agd_contrast);
      current_statement__ = 477;
      stan::math::validate_non_negative_index("log_lik",
        "ni_ipd + ni_agd_arm + ns_agd_contrast", log_lik_1dim__);
      current_statement__ = 478;
      resdev_1dim__ = std::numeric_limits<int>::min();
      current_statement__ = 478;
      resdev_1dim__ = ((ni_ipd + ni_agd_arm) + ns_agd_contrast);
      current_statement__ = 478;
      stan::math::validate_non_negative_index("resdev",
        "ni_ipd + ni_agd_arm + ns_agd_contrast", resdev_1dim__);
      current_statement__ = 479;
      stan::math::validate_non_negative_index("fitted_agd_contrast",
        "ni_agd_contrast", ni_agd_contrast);
      current_statement__ = 480;
      theta_bar_cum_agd_contrast_1dim__ = std::numeric_limits<int>::min();
      current_statement__ = 480;
      theta_bar_cum_agd_contrast_1dim__ = (ni_agd_contrast * n_int_thin);
      current_statement__ = 480;
      stan::math::validate_non_negative_index("theta_bar_cum_agd_contrast",
        "ni_agd_contrast * n_int_thin", theta_bar_cum_agd_contrast_1dim__);
      current_statement__ = 481;
      stan::math::validate_non_negative_index("delta", "n_delta", n_delta);
    } catch (const std::exception& e) {
      stan::lang::rethrow_located(e, locations_array__[current_statement__]);
    }
    num_params_r__ = nX + n_delta + tau_1dim__ + class_mean_1dim__ +
      class_sd_1dim__ + z_class_1dim__;
  }
  inline std::string model_name() const final {
    return "model_poisson";
  }
  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_poisson_namespace::log_prob";
    // suppress unused var warning
    (void) function__;
    try {
      Eigen::Matrix<local_scalar_t__,-1,1> beta_tilde =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(nX, DUMMY_VAR__);
      current_statement__ = 1;
      beta_tilde = in__.template read<
                     Eigen::Matrix<local_scalar_t__,-1,1>>(nX);
      Eigen::Matrix<local_scalar_t__,-1,1> u_delta =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(n_delta, DUMMY_VAR__);
      current_statement__ = 2;
      u_delta = in__.template read<
                  Eigen::Matrix<local_scalar_t__,-1,1>>(n_delta);
      Eigen::Matrix<local_scalar_t__,-1,1> tau =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(tau_1dim__,
          DUMMY_VAR__);
      current_statement__ = 3;
      tau = in__.template read_constrain_lb<
              Eigen::Matrix<local_scalar_t__,-1,1>, jacobian__>(0, lp__,
              tau_1dim__);
      Eigen::Matrix<local_scalar_t__,-1,1> class_mean =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(class_mean_1dim__,
          DUMMY_VAR__);
      current_statement__ = 4;
      class_mean = in__.template read<
                     Eigen::Matrix<local_scalar_t__,-1,1>>(class_mean_1dim__);
      Eigen::Matrix<local_scalar_t__,-1,1> class_sd =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(class_sd_1dim__,
          DUMMY_VAR__);
      current_statement__ = 5;
      class_sd = in__.template read_constrain_lb<
                   Eigen::Matrix<local_scalar_t__,-1,1>, jacobian__>(0, lp__,
                   class_sd_1dim__);
      Eigen::Matrix<local_scalar_t__,-1,1> z_class =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(z_class_1dim__,
          DUMMY_VAR__);
      current_statement__ = 6;
      z_class = in__.template read<
                  Eigen::Matrix<local_scalar_t__,-1,1>>(z_class_1dim__);
      Eigen::Matrix<local_scalar_t__,-1,1> E_eta_ipd =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(ni_ipd, DUMMY_VAR__);
      Eigen::Matrix<local_scalar_t__,-1,1> E_theta_agd_arm =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(ni_agd_arm,
          DUMMY_VAR__);
      Eigen::Matrix<local_scalar_t__,-1,1> theta_ipd =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(ni_ipd, DUMMY_VAR__);
      Eigen::Matrix<local_scalar_t__,-1,1> theta_agd_arm_ii =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(theta_agd_arm_ii_1dim__,
          DUMMY_VAR__);
      Eigen::Matrix<local_scalar_t__,-1,1> theta_agd_arm_bar =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(ni_agd_arm,
          DUMMY_VAR__);
      Eigen::Matrix<local_scalar_t__,-1,1> eta_ipd =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(ni_ipd, DUMMY_VAR__);
      Eigen::Matrix<local_scalar_t__,-1,1> f_delta =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(n_delta, DUMMY_VAR__);
      current_statement__ = 13;
      stan::model::assign(f_delta,
        (RE ? stan::math::eval(
                (RE_sparse ? stan::math::eval(
                               stan::math::multiply(
                                 stan::model::rvalue(tau, "tau",
                                   stan::model::index_uni(1)),
                                 stan::math::csr_matrix_times_vector(n_delta,
                                   n_delta, RE_L_w, RE_L_v, RE_L_u, u_delta))) : 
                stan::math::eval(
                  stan::math::multiply(
                    stan::math::multiply(
                      stan::model::rvalue(tau, "tau",
                        stan::model::index_uni(1)), RE_L), u_delta)))) : 
        stan::math::eval(u_delta)), "assigning variable f_delta");
      Eigen::Matrix<local_scalar_t__,-1,1> f_class =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(f_class_1dim__,
          DUMMY_VAR__);
      Eigen::Matrix<local_scalar_t__,-1,1> allbeta =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(nX, DUMMY_VAR__);
      current_statement__ = 15;
      stan::model::assign(allbeta,
        (QR ? stan::math::eval(stan::math::multiply(R_inv, beta_tilde)) : 
        stan::math::eval(beta_tilde)), "assigning variable allbeta");
      Eigen::Matrix<local_scalar_t__,-1,1> mu =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(totns, DUMMY_VAR__);
      Eigen::Matrix<local_scalar_t__,-1,1> d =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(d_1dim__, DUMMY_VAR__);
      current_statement__ = 17;
      stan::model::assign(d,
        stan::model::rvalue(allbeta, "allbeta",
          stan::model::index_min_max((totns + 1), ((totns + nt) - 1))),
        "assigning variable d");
      Eigen::Matrix<local_scalar_t__,-1,1> omega =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(nodesplit,
          DUMMY_VAR__);
      Eigen::Matrix<local_scalar_t__,-1,1> beta =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(beta_1dim__,
          DUMMY_VAR__);
      Eigen::Matrix<local_scalar_t__,-1,1> eta_agd_contrast_ii =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(eta_agd_contrast_ii_1dim__,
          DUMMY_VAR__);
      Eigen::Matrix<local_scalar_t__,-1,1> eta_agd_contrast_bar =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(ni_agd_contrast,
          DUMMY_VAR__);
      current_statement__ = 32;
      if (totns) {
        current_statement__ = 30;
        stan::model::assign(mu,
          stan::model::rvalue(allbeta, "allbeta",
            stan::model::index_min_max(1, totns)), "assigning variable mu");
      }
      current_statement__ = 35;
      if ((((nX - totns) - (nt - 1)) - nodesplit)) {
        current_statement__ = 33;
        stan::model::assign(beta,
          stan::model::rvalue(allbeta, "allbeta",
            stan::model::index_min(((totns + nt) + nodesplit))),
          "assigning variable beta");
      }
      current_statement__ = 38;
      if (nodesplit) {
        current_statement__ = 36;
        stan::model::assign(omega,
          stan::model::rvalue(allbeta, "allbeta",
            stan::model::index_uni((totns + nt))),
          "assigning variable omega", stan::model::index_uni(1));
      }
      current_statement__ = 42;
      if (class_effects) {
        current_statement__ = 39;
        stan::model::assign(f_class,
          stan::math::add(
            stan::math::subtract(
              stan::model::rvalue(class_mean, "class_mean",
                stan::model::index_multi(
                  stan::model::rvalue(which_CE, "which_CE",
                    stan::model::index_multi(which_class_trt)))),
              stan::model::rvalue(d, "d",
                stan::model::index_multi(which_class_trt))),
            stan::math::elt_multiply(
              stan::model::rvalue(class_sd, "class_sd",
                stan::model::index_multi(
                  stan::model::rvalue(which_CE_sd, "which_CE_sd",
                    stan::model::index_multi(which_class_trt)))), z_class)),
          "assigning variable f_class");
        current_statement__ = 40;
        stan::model::assign(d,
          stan::math::add(
            stan::model::rvalue(class_mean, "class_mean",
              stan::model::index_multi(
                stan::model::rvalue(which_CE, "which_CE",
                  stan::model::index_multi(which_class_trt)))),
            stan::math::elt_multiply(
              stan::model::rvalue(class_sd, "class_sd",
                stan::model::index_multi(
                  stan::model::rvalue(which_CE_sd, "which_CE_sd",
                    stan::model::index_multi(which_class_trt)))), z_class)),
          "assigning variable d", stan::model::index_multi(which_class_trt));
      }
      current_statement__ = 66;
      if (ni_ipd) {
        current_statement__ = 54;
        if (RE) {
          current_statement__ = 45;
          stan::math::validate_non_negative_index("eta_ipd_noRE", "ni_ipd",
            ni_ipd);
          Eigen::Matrix<local_scalar_t__,-1,1> eta_ipd_noRE =
            Eigen::Matrix<local_scalar_t__,-1,1>::Constant(ni_ipd,
              DUMMY_VAR__);
          current_statement__ = 46;
          stan::model::assign(eta_ipd_noRE,
            (has_offset ? stan::math::eval(
                            stan::math::add(
                              stan::math::multiply(X_ipd, beta_tilde),
                              offset_ipd)) : stan::math::eval(
                                               stan::math::multiply(X_ipd,
                                                 beta_tilde))),
            "assigning variable eta_ipd_noRE");
          current_statement__ = 51;
          for (int i = 1; i <= ni_ipd; ++i) {
            current_statement__ = 49;
            if (stan::model::rvalue(which_RE, "which_RE",
                  stan::model::index_uni(
                    stan::model::rvalue(ipd_arm, "ipd_arm",
                      stan::model::index_uni(i))))) {
              current_statement__ = 48;
              stan::model::assign(eta_ipd,
                (stan::model::rvalue(eta_ipd_noRE, "eta_ipd_noRE",
                   stan::model::index_uni(i)) +
                stan::model::rvalue(f_delta, "f_delta",
                  stan::model::index_uni(
                    stan::model::rvalue(which_RE, "which_RE",
                      stan::model::index_uni(
                        stan::model::rvalue(ipd_arm, "ipd_arm",
                          stan::model::index_uni(i))))))),
                "assigning variable eta_ipd", stan::model::index_uni(i));
            } else {
              current_statement__ = 47;
              stan::model::assign(eta_ipd,
                stan::model::rvalue(eta_ipd_noRE, "eta_ipd_noRE",
                  stan::model::index_uni(i)), "assigning variable eta_ipd",
                stan::model::index_uni(i));
            }
          }
        } else {
          current_statement__ = 43;
          stan::model::assign(eta_ipd,
            (has_offset ? stan::math::eval(
                            stan::math::add(
                              stan::math::multiply(X_ipd, beta_tilde),
                              offset_ipd)) : stan::math::eval(
                                               stan::math::multiply(X_ipd,
                                                 beta_tilde))),
            "assigning variable eta_ipd");
        }
        current_statement__ = 57;
        if (stan::math::logical_gt(brmr_n_col, 0)) {
          current_statement__ = 55;
          stan::model::assign(eta_ipd,
            stan::math::add(stan::model::deep_copy(eta_ipd),
              stan::math::elt_multiply(
                stan::math::subtract(
                  stan::math::subtract(
                    stan::math::multiply(
                      stan::model::rvalue(X_ipd, "X_ipd",
                        stan::model::index_omni(),
                        stan::model::index_min_max(1, totns)), mu), xbar_mu),
                  1),
                stan::math::multiply(
                  stan::model::rvalue(X_ipd, "X_ipd",
                    stan::model::index_omni(),
                    stan::model::index_multi(brmr_col)),
                  stan::model::rvalue(beta_tilde, "beta_tilde",
                    stan::model::index_multi(brmr_col))))),
            "assigning variable eta_ipd");
        }
        current_statement__ = 64;
        if (class_effects) {
          current_statement__ = 62;
          for (int i = 1; i <= ni_ipd; ++i) {
            current_statement__ = 60;
            if ((stan::math::primitive_value(
                   stan::math::logical_gt(
                     stan::model::rvalue(ipd_trt, "ipd_trt",
                       stan::model::index_uni(
                         stan::model::rvalue(ipd_arm, "ipd_arm",
                           stan::model::index_uni(i)))), 1))
                &&
                stan::math::primitive_value(
                  stan::model::rvalue(which_CE, "which_CE",
                    stan::model::index_uni(
                      (stan::model::rvalue(ipd_trt, "ipd_trt",
                         stan::model::index_uni(
                           stan::model::rvalue(ipd_arm, "ipd_arm",
                             stan::model::index_uni(i)))) - 1)))))) {
              current_statement__ = 58;
              stan::model::assign(eta_ipd,
                (stan::model::rvalue(eta_ipd, "eta_ipd",
                   stan::model::index_uni(i)) +
                stan::model::rvalue(f_class, "f_class",
                  stan::model::index_uni(
                    stan::model::rvalue(which_fclass, "which_fclass",
                      stan::model::index_uni(
                        (stan::model::rvalue(ipd_trt, "ipd_trt",
                           stan::model::index_uni(
                             stan::model::rvalue(ipd_arm, "ipd_arm",
                               stan::model::index_uni(i)))) - 1)))))),
                "assigning variable eta_ipd", stan::model::index_uni(i));
            }
          }
        }
      }
      current_statement__ = 121;
      if (ni_agd_contrast) {
        current_statement__ = 119;
        if (stan::math::logical_gt(nint_max, 1)) {
          current_statement__ = 89;
          stan::math::validate_non_negative_index("eta_agd_contrast_noRE",
            "nint_max * ni_agd_contrast", (nint_max * ni_agd_contrast));
          Eigen::Matrix<local_scalar_t__,-1,1> eta_agd_contrast_noRE =
            Eigen::Matrix<local_scalar_t__,-1,1>::Constant((nint_max *
              ni_agd_contrast), DUMMY_VAR__);
          current_statement__ = 90;
          stan::model::assign(eta_agd_contrast_noRE,
            (has_offset ? stan::math::eval(
                            stan::math::add(
                              stan::math::multiply(X_agd_contrast, beta_tilde),
                              offset_agd_contrast)) : stan::math::eval(
                                                        stan::math::multiply(
                                                          X_agd_contrast,
                                                          beta_tilde))),
            "assigning variable eta_agd_contrast_noRE");
          current_statement__ = 100;
          if (class_effects) {
            current_statement__ = 98;
            for (int i = 1; i <= ni_agd_arm; ++i) {
              current_statement__ = 93;
              if ((stan::math::primitive_value(
                     stan::math::logical_gt(
                       stan::model::rvalue(agd_contrast_trt,
                         "agd_contrast_trt", stan::model::index_uni(i)), 1))
                  &&
                  stan::math::primitive_value(
                    stan::model::rvalue(which_CE, "which_CE",
                      stan::model::index_uni(
                        (stan::model::rvalue(agd_contrast_trt,
                           "agd_contrast_trt", stan::model::index_uni(i)) -
                        1)))))) {
                current_statement__ = 91;
                stan::model::assign(eta_agd_contrast_noRE,
                  stan::math::add(
                    stan::model::deep_copy(
                      stan::model::rvalue(eta_agd_contrast_noRE,
                        "eta_agd_contrast_noRE",
                        stan::model::index_min_max((1 + ((i - 1) *
                          nint_max)), (((i - 1) * nint_max) + nint)))),
                    stan::model::rvalue(f_class, "f_class",
                      stan::model::index_uni(
                        stan::model::rvalue(which_fclass, "which_fclass",
                          stan::model::index_uni(
                            (stan::model::rvalue(agd_contrast_trt,
                               "agd_contrast_trt", stan::model::index_uni(i))
                            - 1)))))),
                  "assigning variable eta_agd_contrast_noRE",
                  stan::model::index_min_max((1 + ((i - 1) * nint_max)), (((i
                    - 1) * nint_max) + nint)));
              }
              current_statement__ = 96;
              if ((stan::math::primitive_value(
                     stan::math::logical_gt(
                       stan::model::rvalue(agd_contrast_trt_b,
                         "agd_contrast_trt_b", stan::model::index_uni(i)), 1))
                  &&
                  stan::math::primitive_value(
                    stan::model::rvalue(which_CE, "which_CE",
                      stan::model::index_uni(
                        (stan::model::rvalue(agd_contrast_trt_b,
                           "agd_contrast_trt_b", stan::model::index_uni(i)) -
                        1)))))) {
                current_statement__ = 94;
                stan::model::assign(eta_agd_contrast_noRE,
                  stan::math::subtract(
                    stan::model::deep_copy(
                      stan::model::rvalue(eta_agd_contrast_noRE,
                        "eta_agd_contrast_noRE",
                        stan::model::index_min_max((1 + ((i - 1) *
                          nint_max)), (((i - 1) * nint_max) + nint)))),
                    stan::model::rvalue(f_class, "f_class",
                      stan::model::index_uni(
                        stan::model::rvalue(which_fclass, "which_fclass",
                          stan::model::index_uni(
                            (stan::model::rvalue(agd_contrast_trt_b,
                               "agd_contrast_trt_b",
                               stan::model::index_uni(i)) - 1)))))),
                  "assigning variable eta_agd_contrast_noRE",
                  stan::model::index_min_max((1 + ((i - 1) * nint_max)), (((i
                    - 1) * nint_max) + nint)));
              }
            }
          }
          current_statement__ = 117;
          if (RE) {
            current_statement__ = 115;
            for (int i = 1; i <= ni_agd_contrast; ++i) {
              current_statement__ = 112;
              if (stan::model::rvalue(which_RE, "which_RE",
                    stan::model::index_uni(((narm_ipd + narm_agd_arm) + i)))) {
                current_statement__ = 111;
                stan::model::assign(eta_agd_contrast_ii,
                  stan::math::add(
                    stan::model::rvalue(eta_agd_contrast_noRE,
                      "eta_agd_contrast_noRE",
                      stan::model::index_min_max((1 + ((i - 1) * nint_max)),
                        (((i - 1) * nint_max) + nint))),
                    stan::model::rvalue(f_delta, "f_delta",
                      stan::model::index_uni(
                        stan::model::rvalue(which_RE, "which_RE",
                          stan::model::index_uni(((narm_ipd + narm_agd_arm) +
                            i)))))),
                  "assigning variable eta_agd_contrast_ii",
                  stan::model::index_min_max((1 + ((i - 1) * nint)), (i *
                    nint)));
              } else {
                current_statement__ = 110;
                stan::model::assign(eta_agd_contrast_ii,
                  stan::model::rvalue(eta_agd_contrast_noRE,
                    "eta_agd_contrast_noRE",
                    stan::model::index_min_max((1 + ((i - 1) * nint_max)),
                      (((i - 1) * nint_max) + nint))),
                  "assigning variable eta_agd_contrast_ii",
                  stan::model::index_min_max((1 + ((i - 1) * nint)), (i *
                    nint)));
              }
              current_statement__ = 113;
              stan::model::assign(eta_agd_contrast_bar,
                stan::math::mean(
                  stan::model::rvalue(eta_agd_contrast_ii,
                    "eta_agd_contrast_ii",
                    stan::model::index_min_max((1 + ((i - 1) * nint)), (i *
                      nint)))), "assigning variable eta_agd_contrast_bar",
                stan::model::index_uni(i));
            }
          } else {
            current_statement__ = 105;
            if (stan::math::logical_eq(nint, nint_max)) {
              current_statement__ = 104;
              stan::model::assign(eta_agd_contrast_ii, eta_agd_contrast_noRE,
                "assigning variable eta_agd_contrast_ii");
            } else {
              current_statement__ = 103;
              for (int i = 1; i <= ni_agd_contrast; ++i) {
                current_statement__ = 101;
                stan::model::assign(eta_agd_contrast_ii,
                  stan::model::rvalue(eta_agd_contrast_noRE,
                    "eta_agd_contrast_noRE",
                    stan::model::index_min_max((1 + ((i - 1) * nint_max)),
                      (((i - 1) * nint_max) + nint))),
                  "assigning variable eta_agd_contrast_ii",
                  stan::model::index_min_max((1 + ((i - 1) * nint)), (i *
                    nint)));
              }
            }
            current_statement__ = 108;
            for (int i = 1; i <= ni_agd_contrast; ++i) {
              current_statement__ = 106;
              stan::model::assign(eta_agd_contrast_bar,
                stan::math::mean(
                  stan::model::rvalue(eta_agd_contrast_ii,
                    "eta_agd_contrast_ii",
                    stan::model::index_min_max((1 + ((i - 1) * nint)), (i *
                      nint)))), "assigning variable eta_agd_contrast_bar",
                stan::model::index_uni(i));
            }
          }
        } else {
          current_statement__ = 77;
          if (RE) {
            current_statement__ = 69;
            stan::math::validate_non_negative_index("eta_agd_contrast_noRE",
              "nint * ni_agd_contrast", (nint * ni_agd_contrast));
            Eigen::Matrix<local_scalar_t__,-1,1> eta_agd_contrast_noRE =
              Eigen::Matrix<local_scalar_t__,-1,1>::Constant((nint *
                ni_agd_contrast), DUMMY_VAR__);
            current_statement__ = 70;
            stan::model::assign(eta_agd_contrast_noRE,
              (has_offset ? stan::math::eval(
                              stan::math::add(
                                stan::math::multiply(X_agd_contrast,
                                  beta_tilde), offset_agd_contrast)) : 
              stan::math::eval(
                stan::math::multiply(X_agd_contrast, beta_tilde))),
              "assigning variable eta_agd_contrast_noRE");
            current_statement__ = 75;
            for (int i = 1; i <= ni_agd_contrast; ++i) {
              current_statement__ = 73;
              if (stan::model::rvalue(which_RE, "which_RE",
                    stan::model::index_uni(((narm_ipd + narm_agd_arm) + i)))) {
                current_statement__ = 72;
                stan::model::assign(eta_agd_contrast_bar,
                  (stan::model::rvalue(eta_agd_contrast_noRE,
                     "eta_agd_contrast_noRE", stan::model::index_uni(i)) +
                  stan::model::rvalue(f_delta, "f_delta",
                    stan::model::index_uni(
                      stan::model::rvalue(which_RE, "which_RE",
                        stan::model::index_uni(((narm_ipd + narm_agd_arm) +
                          i)))))), "assigning variable eta_agd_contrast_bar",
                  stan::model::index_uni(i));
              } else {
                current_statement__ = 71;
                stan::model::assign(eta_agd_contrast_bar,
                  stan::model::rvalue(eta_agd_contrast_noRE,
                    "eta_agd_contrast_noRE", stan::model::index_uni(i)),
                  "assigning variable eta_agd_contrast_bar",
                  stan::model::index_uni(i));
              }
            }
          } else {
            current_statement__ = 67;
            stan::model::assign(eta_agd_contrast_bar,
              (has_offset ? stan::math::eval(
                              stan::math::add(
                                stan::math::multiply(X_agd_contrast,
                                  beta_tilde), offset_agd_contrast)) : 
              stan::math::eval(
                stan::math::multiply(X_agd_contrast, beta_tilde))),
              "assigning variable eta_agd_contrast_bar");
          }
          current_statement__ = 87;
          if (class_effects) {
            current_statement__ = 85;
            for (int i = 1; i <= ni_agd_contrast; ++i) {
              current_statement__ = 80;
              if ((stan::math::primitive_value(
                     stan::math::logical_gt(
                       stan::model::rvalue(agd_contrast_trt,
                         "agd_contrast_trt", stan::model::index_uni(i)), 1))
                  &&
                  stan::math::primitive_value(
                    stan::model::rvalue(which_CE, "which_CE",
                      stan::model::index_uni(
                        (stan::model::rvalue(agd_contrast_trt,
                           "agd_contrast_trt", stan::model::index_uni(i)) -
                        1)))))) {
                current_statement__ = 78;
                stan::model::assign(eta_agd_contrast_bar,
                  (stan::model::rvalue(eta_agd_contrast_bar,
                     "eta_agd_contrast_bar", stan::model::index_uni(i)) +
                  stan::model::rvalue(f_class, "f_class",
                    stan::model::index_uni(
                      stan::model::rvalue(which_fclass, "which_fclass",
                        stan::model::index_uni(
                          (stan::model::rvalue(agd_contrast_trt,
                             "agd_contrast_trt", stan::model::index_uni(i)) -
                          1)))))), "assigning variable eta_agd_contrast_bar",
                  stan::model::index_uni(i));
              }
              current_statement__ = 83;
              if ((stan::math::primitive_value(
                     stan::math::logical_gt(
                       stan::model::rvalue(agd_contrast_trt_b,
                         "agd_contrast_trt_b", stan::model::index_uni(i)), 1))
                  &&
                  stan::math::primitive_value(
                    stan::model::rvalue(which_CE, "which_CE",
                      stan::model::index_uni(
                        (stan::model::rvalue(agd_contrast_trt_b,
                           "agd_contrast_trt_b", stan::model::index_uni(i)) -
                        1)))))) {
                current_statement__ = 81;
                stan::model::assign(eta_agd_contrast_bar,
                  (stan::model::rvalue(eta_agd_contrast_bar,
                     "eta_agd_contrast_bar", stan::model::index_uni(i)) -
                  stan::model::rvalue(f_class, "f_class",
                    stan::model::index_uni(
                      stan::model::rvalue(which_fclass, "which_fclass",
                        stan::model::index_uni(
                          (stan::model::rvalue(agd_contrast_trt_b,
                             "agd_contrast_trt_b", stan::model::index_uni(i))
                          - 1)))))),
                  "assigning variable eta_agd_contrast_bar",
                  stan::model::index_uni(i));
              }
            }
          }
        }
      }
      current_statement__ = 123;
      if (stan::math::logical_eq(link, 1)) {
        current_statement__ = 122;
        stan::model::assign(theta_ipd, stan::math::exp(eta_ipd),
          "assigning variable theta_ipd");
      }
      current_statement__ = 188;
      if (ni_agd_arm) {
        current_statement__ = 124;
        stan::math::validate_non_negative_index("eta_agd_arm_noRE",
          "nint_max * ni_agd_arm", (nint_max * ni_agd_arm));
        Eigen::Matrix<local_scalar_t__,-1,1> eta_agd_arm_noRE =
          Eigen::Matrix<local_scalar_t__,-1,1>::Constant((nint_max *
            ni_agd_arm), DUMMY_VAR__);
        current_statement__ = 125;
        stan::model::assign(eta_agd_arm_noRE,
          (has_offset ? stan::math::eval(
                          stan::math::add(
                            stan::math::multiply(X_agd_arm, beta_tilde),
                            offset_agd_arm)) : stan::math::eval(
                                                 stan::math::multiply(
                                                   X_agd_arm, beta_tilde))),
          "assigning variable eta_agd_arm_noRE");
        current_statement__ = 128;
        if (stan::math::logical_gt(brmr_n_col, 0)) {
          current_statement__ = 126;
          stan::model::assign(eta_agd_arm_noRE,
            stan::math::add(stan::model::deep_copy(eta_agd_arm_noRE),
              stan::math::elt_multiply(
                stan::math::subtract(
                  stan::math::subtract(
                    stan::math::multiply(
                      stan::model::rvalue(X_agd_arm, "X_agd_arm",
                        stan::model::index_omni(),
                        stan::model::index_min_max(1, totns)), mu), xbar_mu),
                  1),
                stan::math::multiply(
                  stan::model::rvalue(X_agd_arm, "X_agd_arm",
                    stan::model::index_omni(),
                    stan::model::index_multi(brmr_col)),
                  stan::model::rvalue(beta_tilde, "beta_tilde",
                    stan::model::index_multi(brmr_col))))),
            "assigning variable eta_agd_arm_noRE");
        }
        current_statement__ = 186;
        if (stan::math::logical_gt(nint_max, 1)) {
          current_statement__ = 162;
          if (class_effects) {
            current_statement__ = 160;
            for (int i = 1; i <= ni_agd_arm; ++i) {
              current_statement__ = 158;
              if ((stan::math::primitive_value(
                     stan::math::logical_gt(
                       stan::model::rvalue(agd_arm_trt, "agd_arm_trt",
                         stan::model::index_uni(i)), 1))
                  &&
                  stan::math::primitive_value(
                    stan::model::rvalue(which_CE, "which_CE",
                      stan::model::index_uni(
                        (stan::model::rvalue(agd_arm_trt, "agd_arm_trt",
                           stan::model::index_uni(i)) - 1)))))) {
                current_statement__ = 156;
                stan::model::assign(eta_agd_arm_noRE,
                  stan::math::add(
                    stan::model::deep_copy(
                      stan::model::rvalue(eta_agd_arm_noRE,
                        "eta_agd_arm_noRE",
                        stan::model::index_min_max((1 + ((i - 1) *
                          nint_max)), (((i - 1) * nint_max) + nint)))),
                    stan::model::rvalue(f_class, "f_class",
                      stan::model::index_uni(
                        stan::model::rvalue(which_fclass, "which_fclass",
                          stan::model::index_uni(
                            (stan::model::rvalue(agd_arm_trt, "agd_arm_trt",
                               stan::model::index_uni(i)) - 1)))))),
                  "assigning variable eta_agd_arm_noRE",
                  stan::model::index_min_max((1 + ((i - 1) * nint_max)), (((i
                    - 1) * nint_max) + nint)));
              }
            }
          }
          current_statement__ = 184;
          if (RE) {
            current_statement__ = 179;
            if (stan::math::logical_eq(link, 1)) {
              current_statement__ = 177;
              for (int i = 1; i <= ni_agd_arm; ++i) {
                current_statement__ = 175;
                if (stan::model::rvalue(which_RE, "which_RE",
                      stan::model::index_uni((narm_ipd + i)))) {
                  current_statement__ = 174;
                  stan::model::assign(theta_agd_arm_ii,
                    stan::math::exp(
                      stan::math::add(
                        stan::model::rvalue(eta_agd_arm_noRE,
                          "eta_agd_arm_noRE",
                          stan::model::index_min_max((1 + ((i - 1) *
                            nint_max)), (((i - 1) * nint_max) + nint))),
                        stan::model::rvalue(f_delta, "f_delta",
                          stan::model::index_uni(
                            stan::model::rvalue(which_RE, "which_RE",
                              stan::model::index_uni((narm_ipd + i))))))),
                    "assigning variable theta_agd_arm_ii",
                    stan::model::index_min_max((1 + ((i - 1) * nint)), (i *
                      nint)));
                } else {
                  current_statement__ = 173;
                  stan::model::assign(theta_agd_arm_ii,
                    stan::math::exp(
                      stan::model::rvalue(eta_agd_arm_noRE,
                        "eta_agd_arm_noRE",
                        stan::model::index_min_max((1 + ((i - 1) *
                          nint_max)), (((i - 1) * nint_max) + nint)))),
                    "assigning variable theta_agd_arm_ii",
                    stan::model::index_min_max((1 + ((i - 1) * nint)), (i *
                      nint)));
                }
              }
            }
            current_statement__ = 182;
            for (int i = 1; i <= ni_agd_arm; ++i) {
              current_statement__ = 180;
              stan::model::assign(theta_agd_arm_bar,
                stan::math::mean(
                  stan::model::rvalue(theta_agd_arm_ii, "theta_agd_arm_ii",
                    stan::model::index_min_max((1 + ((i - 1) * nint)), (i *
                      nint)))), "assigning variable theta_agd_arm_bar",
                stan::model::index_uni(i));
            }
          } else {
            current_statement__ = 168;
            if (stan::math::logical_eq(link, 1)) {
              current_statement__ = 166;
              if (stan::math::logical_eq(nint, nint_max)) {
                current_statement__ = 165;
                stan::model::assign(theta_agd_arm_ii,
                  stan::math::exp(eta_agd_arm_noRE),
                  "assigning variable theta_agd_arm_ii");
              } else {
                current_statement__ = 164;
                for (int i = 1; i <= ni_agd_arm; ++i) {
                  current_statement__ = 163;
                  stan::model::assign(theta_agd_arm_ii,
                    stan::math::exp(
                      stan::model::rvalue(eta_agd_arm_noRE,
                        "eta_agd_arm_noRE",
                        stan::model::index_min_max((1 + ((i - 1) *
                          nint_max)), (((i - 1) * nint_max) + nint)))),
                    "assigning variable theta_agd_arm_ii",
                    stan::model::index_min_max((1 + ((i - 1) * nint)), (i *
                      nint)));
                }
              }
            }
            current_statement__ = 171;
            for (int i = 1; i <= ni_agd_arm; ++i) {
              current_statement__ = 169;
              stan::model::assign(theta_agd_arm_bar,
                stan::math::mean(
                  stan::model::rvalue(theta_agd_arm_ii, "theta_agd_arm_ii",
                    stan::model::index_min_max((1 + ((i - 1) * nint)), (i *
                      nint)))), "assigning variable theta_agd_arm_bar",
                stan::model::index_uni(i));
            }
          }
        } else {
          current_statement__ = 154;
          if (RE) {
            current_statement__ = 145;
            if (class_effects) {
              current_statement__ = 143;
              for (int i = 1; i <= ni_agd_arm; ++i) {
                current_statement__ = 141;
                if ((stan::math::primitive_value(
                       stan::math::logical_gt(
                         stan::model::rvalue(agd_arm_trt, "agd_arm_trt",
                           stan::model::index_uni(i)), 1))
                    &&
                    stan::math::primitive_value(
                      stan::model::rvalue(which_CE, "which_CE",
                        stan::model::index_uni(
                          (stan::model::rvalue(agd_arm_trt, "agd_arm_trt",
                             stan::model::index_uni(i)) - 1)))))) {
                  current_statement__ = 139;
                  stan::model::assign(eta_agd_arm_noRE,
                    (stan::model::rvalue(eta_agd_arm_noRE,
                       "eta_agd_arm_noRE", stan::model::index_uni(i)) +
                    stan::model::rvalue(f_class, "f_class",
                      stan::model::index_uni(
                        stan::model::rvalue(which_fclass, "which_fclass",
                          stan::model::index_uni(
                            (stan::model::rvalue(agd_arm_trt, "agd_arm_trt",
                               stan::model::index_uni(i)) - 1)))))),
                    "assigning variable eta_agd_arm_noRE",
                    stan::model::index_uni(i));
                }
              }
            }
            current_statement__ = 152;
            if (stan::math::logical_eq(link, 1)) {
              current_statement__ = 150;
              for (int i = 1; i <= ni_agd_arm; ++i) {
                current_statement__ = 148;
                if (stan::model::rvalue(which_RE, "which_RE",
                      stan::model::index_uni((narm_ipd + i)))) {
                  current_statement__ = 147;
                  stan::model::assign(theta_agd_arm_bar,
                    stan::math::exp(
                      (stan::model::rvalue(eta_agd_arm_noRE,
                         "eta_agd_arm_noRE", stan::model::index_uni(i)) +
                      stan::model::rvalue(f_delta, "f_delta",
                        stan::model::index_uni(
                          stan::model::rvalue(which_RE, "which_RE",
                            stan::model::index_uni((narm_ipd + i))))))),
                    "assigning variable theta_agd_arm_bar",
                    stan::model::index_uni(i));
                } else {
                  current_statement__ = 146;
                  stan::model::assign(theta_agd_arm_bar,
                    stan::math::exp(
                      stan::model::rvalue(eta_agd_arm_noRE,
                        "eta_agd_arm_noRE", stan::model::index_uni(i))),
                    "assigning variable theta_agd_arm_bar",
                    stan::model::index_uni(i));
                }
              }
            }
          } else {
            current_statement__ = 135;
            if (class_effects) {
              current_statement__ = 133;
              for (int i = 1; i <= ni_agd_arm; ++i) {
                current_statement__ = 131;
                if ((stan::math::primitive_value(
                       stan::math::logical_gt(
                         stan::model::rvalue(agd_arm_trt, "agd_arm_trt",
                           stan::model::index_uni(i)), 1))
                    &&
                    stan::math::primitive_value(
                      stan::model::rvalue(which_CE, "which_CE",
                        stan::model::index_uni(
                          (stan::model::rvalue(agd_arm_trt, "agd_arm_trt",
                             stan::model::index_uni(i)) - 1)))))) {
                  current_statement__ = 129;
                  stan::model::assign(eta_agd_arm_noRE,
                    (stan::model::rvalue(eta_agd_arm_noRE,
                       "eta_agd_arm_noRE", stan::model::index_uni(i)) +
                    stan::model::rvalue(f_class, "f_class",
                      stan::model::index_uni(
                        stan::model::rvalue(which_fclass, "which_fclass",
                          stan::model::index_uni(
                            (stan::model::rvalue(agd_arm_trt, "agd_arm_trt",
                               stan::model::index_uni(i)) - 1)))))),
                    "assigning variable eta_agd_arm_noRE",
                    stan::model::index_uni(i));
                }
              }
            }
            current_statement__ = 137;
            if (stan::math::logical_eq(link, 1)) {
              current_statement__ = 136;
              stan::model::assign(theta_agd_arm_bar,
                stan::math::exp(eta_agd_arm_noRE),
                "assigning variable theta_agd_arm_bar");
            }
          }
        }
      }
      current_statement__ = 189;
      stan::model::assign(E_eta_ipd, stan::math::add(eta_ipd, ipd_logE),
        "assigning variable E_eta_ipd");
      current_statement__ = 190;
      stan::model::assign(E_theta_agd_arm,
        stan::math::elt_multiply(theta_agd_arm_bar, agd_arm_E),
        "assigning variable E_theta_agd_arm");
      current_statement__ = 8;
      stan::math::check_greater_or_equal(function__, "E_theta_agd_arm",
        E_theta_agd_arm, 0);
      {
        current_statement__ = 242;
        prior_select_lp<propto__>(mu, prior_intercept_dist,
          prior_intercept_location, prior_intercept_scale,
          prior_intercept_df, lp__, lp_accum__, pstream__);
        current_statement__ = 248;
        if (stan::math::logical_eq(class_effects, 0)) {
          current_statement__ = 246;
          prior_select_lp<propto__>(d, prior_trt_dist, prior_trt_location,
            prior_trt_scale, prior_trt_df, lp__, lp_accum__, pstream__);
        } else {
          current_statement__ = 243;
          prior_select_lp<propto__>(class_mean, prior_class_mean_dist,
            prior_class_mean_location, prior_class_mean_scale,
            prior_class_mean_df, lp__, lp_accum__, pstream__);
          current_statement__ = 244;
          prior_select_lp<propto__>(class_sd, prior_class_sd_dist,
            prior_class_sd_location, prior_class_sd_scale, prior_class_sd_df,
            lp__, lp_accum__, pstream__);
        }
        current_statement__ = 249;
        prior_select_lp<propto__>(beta, prior_reg_dist, prior_reg_location,
          prior_reg_scale, prior_reg_df, lp__, lp_accum__, pstream__);
        current_statement__ = 250;
        prior_select_lp<propto__>(omega, prior_trt_dist, prior_trt_location,
          prior_trt_scale, prior_trt_df, lp__, lp_accum__, pstream__);
        current_statement__ = 268;
        if (RE) {
          current_statement__ = 266;
          if (stan::math::logical_eq(prior_het_type, 1)) {
            current_statement__ = 264;
            prior_select_lp<propto__>(tau, prior_het_dist,
              prior_het_location, prior_het_scale, prior_het_df, lp__,
              lp_accum__, pstream__);
          } else {
            current_statement__ = 251;
            stan::math::validate_non_negative_index("tau_t", "RE ? 1 : 0",
              (RE ? 1 : 0));
            Eigen::Matrix<local_scalar_t__,-1,1> tau_t =
              Eigen::Matrix<local_scalar_t__,-1,1>::Constant((RE ? 1 : 0),
                DUMMY_VAR__);
            current_statement__ = 260;
            if (stan::math::logical_eq(prior_het_type, 2)) {
              current_statement__ = 257;
              stan::model::assign(tau_t,
                stan::math::pow(
                  stan::model::rvalue(tau, "tau", stan::model::index_uni(1)),
                  2), "assigning variable tau_t", stan::model::index_uni(1));
              current_statement__ = 258;
              lp_accum__.add(stan::math::log(tau));
            } else {
              current_statement__ = 256;
              if (stan::math::logical_eq(prior_het_type, 3)) {
                current_statement__ = 253;
                stan::model::assign(tau_t,
                  stan::math::pow(
                    stan::model::rvalue(tau, "tau", stan::model::index_uni(1)),
                    -2), "assigning variable tau_t",
                  stan::model::index_uni(1));
                current_statement__ = 254;
                lp_accum__.add(stan::math::multiply(-3, stan::math::log(tau)));
              }
            }
            current_statement__ = 261;
            prior_select_lp<propto__>(tau_t, prior_het_dist,
              prior_het_location, prior_het_scale, prior_het_df, lp__,
              lp_accum__, pstream__);
          }
        }
        current_statement__ = 269;
        lp_accum__.add(stan::math::std_normal_lpdf<propto__>(u_delta));
        current_statement__ = 272;
        if (ni_agd_contrast) {
          current_statement__ = 270;
          lp_accum__.add(stan::math::multi_normal_lpdf<propto__>(
                           agd_contrast_y, eta_agd_contrast_bar,
                           agd_contrast_Sigma));
        }
        current_statement__ = 281;
        if (class_effects) {
          current_statement__ = 279;
          for (int t = 1; t <= (nt - 1); ++t) {
            current_statement__ = 277;
            if (stan::math::logical_eq(
                  stan::model::rvalue(which_CE, "which_CE",
                    stan::model::index_uni(t)), 0)) {
              current_statement__ = 275;
              prior_select2_lp<propto__>(
                stan::model::rvalue(d, "d", stan::model::index_uni(t)),
                prior_trt_dist, prior_trt_location, prior_trt_scale,
                prior_trt_df, lp__, lp_accum__, pstream__);
            } else {
              current_statement__ = 273;
              lp_accum__.add(stan::math::std_normal_lpdf<propto__>(
                               stan::model::rvalue(allbeta, "allbeta",
                                 stan::model::index_uni((totns + t)))));
            }
          }
        }
        current_statement__ = 282;
        lp_accum__.add(stan::math::std_normal_lpdf<propto__>(z_class));
        current_statement__ = 285;
        if (stan::math::logical_eq(link, 1)) {
          current_statement__ = 283;
          lp_accum__.add(stan::math::poisson_log_lpmf<propto__>(ipd_r,
                           E_eta_ipd));
        }
        current_statement__ = 286;
        lp_accum__.add(stan::math::poisson_lpmf<propto__>(agd_arm_r,
                         E_theta_agd_arm));
      }
    } 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_poisson_namespace::write_array";
    // suppress unused var warning
    (void) function__;
    try {
      Eigen::Matrix<double,-1,1> beta_tilde =
        Eigen::Matrix<double,-1,1>::Constant(nX,
          std::numeric_limits<double>::quiet_NaN());
      current_statement__ = 1;
      beta_tilde = in__.template read<
                     Eigen::Matrix<local_scalar_t__,-1,1>>(nX);
      Eigen::Matrix<double,-1,1> u_delta =
        Eigen::Matrix<double,-1,1>::Constant(n_delta,
          std::numeric_limits<double>::quiet_NaN());
      current_statement__ = 2;
      u_delta = in__.template read<
                  Eigen::Matrix<local_scalar_t__,-1,1>>(n_delta);
      Eigen::Matrix<double,-1,1> tau =
        Eigen::Matrix<double,-1,1>::Constant(tau_1dim__,
          std::numeric_limits<double>::quiet_NaN());
      current_statement__ = 3;
      tau = in__.template read_constrain_lb<
              Eigen::Matrix<local_scalar_t__,-1,1>, jacobian__>(0, lp__,
              tau_1dim__);
      Eigen::Matrix<double,-1,1> class_mean =
        Eigen::Matrix<double,-1,1>::Constant(class_mean_1dim__,
          std::numeric_limits<double>::quiet_NaN());
      current_statement__ = 4;
      class_mean = in__.template read<
                     Eigen::Matrix<local_scalar_t__,-1,1>>(class_mean_1dim__);
      Eigen::Matrix<double,-1,1> class_sd =
        Eigen::Matrix<double,-1,1>::Constant(class_sd_1dim__,
          std::numeric_limits<double>::quiet_NaN());
      current_statement__ = 5;
      class_sd = in__.template read_constrain_lb<
                   Eigen::Matrix<local_scalar_t__,-1,1>, jacobian__>(0, lp__,
                   class_sd_1dim__);
      Eigen::Matrix<double,-1,1> z_class =
        Eigen::Matrix<double,-1,1>::Constant(z_class_1dim__,
          std::numeric_limits<double>::quiet_NaN());
      current_statement__ = 6;
      z_class = in__.template read<
                  Eigen::Matrix<local_scalar_t__,-1,1>>(z_class_1dim__);
      Eigen::Matrix<double,-1,1> E_eta_ipd =
        Eigen::Matrix<double,-1,1>::Constant(ni_ipd,
          std::numeric_limits<double>::quiet_NaN());
      Eigen::Matrix<double,-1,1> E_theta_agd_arm =
        Eigen::Matrix<double,-1,1>::Constant(ni_agd_arm,
          std::numeric_limits<double>::quiet_NaN());
      Eigen::Matrix<double,-1,1> theta_ipd =
        Eigen::Matrix<double,-1,1>::Constant(ni_ipd,
          std::numeric_limits<double>::quiet_NaN());
      Eigen::Matrix<double,-1,1> theta_agd_arm_ii =
        Eigen::Matrix<double,-1,1>::Constant(theta_agd_arm_ii_1dim__,
          std::numeric_limits<double>::quiet_NaN());
      Eigen::Matrix<double,-1,1> theta_agd_arm_bar =
        Eigen::Matrix<double,-1,1>::Constant(ni_agd_arm,
          std::numeric_limits<double>::quiet_NaN());
      Eigen::Matrix<double,-1,1> eta_ipd =
        Eigen::Matrix<double,-1,1>::Constant(ni_ipd,
          std::numeric_limits<double>::quiet_NaN());
      Eigen::Matrix<double,-1,1> f_delta =
        Eigen::Matrix<double,-1,1>::Constant(n_delta,
          std::numeric_limits<double>::quiet_NaN());
      Eigen::Matrix<double,-1,1> f_class =
        Eigen::Matrix<double,-1,1>::Constant(f_class_1dim__,
          std::numeric_limits<double>::quiet_NaN());
      Eigen::Matrix<double,-1,1> allbeta =
        Eigen::Matrix<double,-1,1>::Constant(nX,
          std::numeric_limits<double>::quiet_NaN());
      Eigen::Matrix<double,-1,1> mu =
        Eigen::Matrix<double,-1,1>::Constant(totns,
          std::numeric_limits<double>::quiet_NaN());
      Eigen::Matrix<double,-1,1> d =
        Eigen::Matrix<double,-1,1>::Constant(d_1dim__,
          std::numeric_limits<double>::quiet_NaN());
      Eigen::Matrix<double,-1,1> omega =
        Eigen::Matrix<double,-1,1>::Constant(nodesplit,
          std::numeric_limits<double>::quiet_NaN());
      Eigen::Matrix<double,-1,1> beta =
        Eigen::Matrix<double,-1,1>::Constant(beta_1dim__,
          std::numeric_limits<double>::quiet_NaN());
      Eigen::Matrix<double,-1,1> eta_agd_contrast_ii =
        Eigen::Matrix<double,-1,1>::Constant(eta_agd_contrast_ii_1dim__,
          std::numeric_limits<double>::quiet_NaN());
      Eigen::Matrix<double,-1,1> eta_agd_contrast_bar =
        Eigen::Matrix<double,-1,1>::Constant(ni_agd_contrast,
          std::numeric_limits<double>::quiet_NaN());
      out__.write(beta_tilde);
      out__.write(u_delta);
      out__.write(tau);
      out__.write(class_mean);
      out__.write(class_sd);
      out__.write(z_class);
      if (stan::math::logical_negation(
            (stan::math::primitive_value(emit_transformed_parameters__) ||
            stan::math::primitive_value(emit_generated_quantities__)))) {
        return ;
      }
      current_statement__ = 13;
      stan::model::assign(f_delta,
        (RE ? stan::math::eval(
                (RE_sparse ? stan::math::eval(
                               stan::math::multiply(
                                 stan::model::rvalue(tau, "tau",
                                   stan::model::index_uni(1)),
                                 stan::math::csr_matrix_times_vector(n_delta,
                                   n_delta, RE_L_w, RE_L_v, RE_L_u, u_delta))) : 
                stan::math::eval(
                  stan::math::multiply(
                    stan::math::multiply(
                      stan::model::rvalue(tau, "tau",
                        stan::model::index_uni(1)), RE_L), u_delta)))) : 
        stan::math::eval(u_delta)), "assigning variable f_delta");
      current_statement__ = 15;
      stan::model::assign(allbeta,
        (QR ? stan::math::eval(stan::math::multiply(R_inv, beta_tilde)) : 
        stan::math::eval(beta_tilde)), "assigning variable allbeta");
      current_statement__ = 17;
      stan::model::assign(d,
        stan::model::rvalue(allbeta, "allbeta",
          stan::model::index_min_max((totns + 1), ((totns + nt) - 1))),
        "assigning variable d");
      current_statement__ = 32;
      if (totns) {
        current_statement__ = 30;
        stan::model::assign(mu,
          stan::model::rvalue(allbeta, "allbeta",
            stan::model::index_min_max(1, totns)), "assigning variable mu");
      }
      current_statement__ = 35;
      if ((((nX - totns) - (nt - 1)) - nodesplit)) {
        current_statement__ = 33;
        stan::model::assign(beta,
          stan::model::rvalue(allbeta, "allbeta",
            stan::model::index_min(((totns + nt) + nodesplit))),
          "assigning variable beta");
      }
      current_statement__ = 38;
      if (nodesplit) {
        current_statement__ = 36;
        stan::model::assign(omega,
          stan::model::rvalue(allbeta, "allbeta",
            stan::model::index_uni((totns + nt))),
          "assigning variable omega", stan::model::index_uni(1));
      }
      current_statement__ = 42;
      if (class_effects) {
        current_statement__ = 39;
        stan::model::assign(f_class,
          stan::math::add(
            stan::math::subtract(
              stan::model::rvalue(class_mean, "class_mean",
                stan::model::index_multi(
                  stan::model::rvalue(which_CE, "which_CE",
                    stan::model::index_multi(which_class_trt)))),
              stan::model::rvalue(d, "d",
                stan::model::index_multi(which_class_trt))),
            stan::math::elt_multiply(
              stan::model::rvalue(class_sd, "class_sd",
                stan::model::index_multi(
                  stan::model::rvalue(which_CE_sd, "which_CE_sd",
                    stan::model::index_multi(which_class_trt)))), z_class)),
          "assigning variable f_class");
        current_statement__ = 40;
        stan::model::assign(d,
          stan::math::add(
            stan::model::rvalue(class_mean, "class_mean",
              stan::model::index_multi(
                stan::model::rvalue(which_CE, "which_CE",
                  stan::model::index_multi(which_class_trt)))),
            stan::math::elt_multiply(
              stan::model::rvalue(class_sd, "class_sd",
                stan::model::index_multi(
                  stan::model::rvalue(which_CE_sd, "which_CE_sd",
                    stan::model::index_multi(which_class_trt)))), z_class)),
          "assigning variable d", stan::model::index_multi(which_class_trt));
      }
      current_statement__ = 66;
      if (ni_ipd) {
        current_statement__ = 54;
        if (RE) {
          current_statement__ = 45;
          stan::math::validate_non_negative_index("eta_ipd_noRE", "ni_ipd",
            ni_ipd);
          Eigen::Matrix<double,-1,1> eta_ipd_noRE =
            Eigen::Matrix<double,-1,1>::Constant(ni_ipd,
              std::numeric_limits<double>::quiet_NaN());
          current_statement__ = 46;
          stan::model::assign(eta_ipd_noRE,
            (has_offset ? stan::math::eval(
                            stan::math::add(
                              stan::math::multiply(X_ipd, beta_tilde),
                              offset_ipd)) : stan::math::eval(
                                               stan::math::multiply(X_ipd,
                                                 beta_tilde))),
            "assigning variable eta_ipd_noRE");
          current_statement__ = 51;
          for (int i = 1; i <= ni_ipd; ++i) {
            current_statement__ = 49;
            if (stan::model::rvalue(which_RE, "which_RE",
                  stan::model::index_uni(
                    stan::model::rvalue(ipd_arm, "ipd_arm",
                      stan::model::index_uni(i))))) {
              current_statement__ = 48;
              stan::model::assign(eta_ipd,
                (stan::model::rvalue(eta_ipd_noRE, "eta_ipd_noRE",
                   stan::model::index_uni(i)) +
                stan::model::rvalue(f_delta, "f_delta",
                  stan::model::index_uni(
                    stan::model::rvalue(which_RE, "which_RE",
                      stan::model::index_uni(
                        stan::model::rvalue(ipd_arm, "ipd_arm",
                          stan::model::index_uni(i))))))),
                "assigning variable eta_ipd", stan::model::index_uni(i));
            } else {
              current_statement__ = 47;
              stan::model::assign(eta_ipd,
                stan::model::rvalue(eta_ipd_noRE, "eta_ipd_noRE",
                  stan::model::index_uni(i)), "assigning variable eta_ipd",
                stan::model::index_uni(i));
            }
          }
        } else {
          current_statement__ = 43;
          stan::model::assign(eta_ipd,
            (has_offset ? stan::math::eval(
                            stan::math::add(
                              stan::math::multiply(X_ipd, beta_tilde),
                              offset_ipd)) : stan::math::eval(
                                               stan::math::multiply(X_ipd,
                                                 beta_tilde))),
            "assigning variable eta_ipd");
        }
        current_statement__ = 57;
        if (stan::math::logical_gt(brmr_n_col, 0)) {
          current_statement__ = 55;
          stan::model::assign(eta_ipd,
            stan::math::add(stan::model::deep_copy(eta_ipd),
              stan::math::elt_multiply(
                stan::math::subtract(
                  stan::math::subtract(
                    stan::math::multiply(
                      stan::model::rvalue(X_ipd, "X_ipd",
                        stan::model::index_omni(),
                        stan::model::index_min_max(1, totns)), mu), xbar_mu),
                  1),
                stan::math::multiply(
                  stan::model::rvalue(X_ipd, "X_ipd",
                    stan::model::index_omni(),
                    stan::model::index_multi(brmr_col)),
                  stan::model::rvalue(beta_tilde, "beta_tilde",
                    stan::model::index_multi(brmr_col))))),
            "assigning variable eta_ipd");
        }
        current_statement__ = 64;
        if (class_effects) {
          current_statement__ = 62;
          for (int i = 1; i <= ni_ipd; ++i) {
            current_statement__ = 60;
            if ((stan::math::primitive_value(
                   stan::math::logical_gt(
                     stan::model::rvalue(ipd_trt, "ipd_trt",
                       stan::model::index_uni(
                         stan::model::rvalue(ipd_arm, "ipd_arm",
                           stan::model::index_uni(i)))), 1))
                &&
                stan::math::primitive_value(
                  stan::model::rvalue(which_CE, "which_CE",
                    stan::model::index_uni(
                      (stan::model::rvalue(ipd_trt, "ipd_trt",
                         stan::model::index_uni(
                           stan::model::rvalue(ipd_arm, "ipd_arm",
                             stan::model::index_uni(i)))) - 1)))))) {
              current_statement__ = 58;
              stan::model::assign(eta_ipd,
                (stan::model::rvalue(eta_ipd, "eta_ipd",
                   stan::model::index_uni(i)) +
                stan::model::rvalue(f_class, "f_class",
                  stan::model::index_uni(
                    stan::model::rvalue(which_fclass, "which_fclass",
                      stan::model::index_uni(
                        (stan::model::rvalue(ipd_trt, "ipd_trt",
                           stan::model::index_uni(
                             stan::model::rvalue(ipd_arm, "ipd_arm",
                               stan::model::index_uni(i)))) - 1)))))),
                "assigning variable eta_ipd", stan::model::index_uni(i));
            }
          }
        }
      }
      current_statement__ = 121;
      if (ni_agd_contrast) {
        current_statement__ = 119;
        if (stan::math::logical_gt(nint_max, 1)) {
          current_statement__ = 89;
          stan::math::validate_non_negative_index("eta_agd_contrast_noRE",
            "nint_max * ni_agd_contrast", (nint_max * ni_agd_contrast));
          Eigen::Matrix<double,-1,1> eta_agd_contrast_noRE =
            Eigen::Matrix<double,-1,1>::Constant((nint_max *
              ni_agd_contrast), std::numeric_limits<double>::quiet_NaN());
          current_statement__ = 90;
          stan::model::assign(eta_agd_contrast_noRE,
            (has_offset ? stan::math::eval(
                            stan::math::add(
                              stan::math::multiply(X_agd_contrast, beta_tilde),
                              offset_agd_contrast)) : stan::math::eval(
                                                        stan::math::multiply(
                                                          X_agd_contrast,
                                                          beta_tilde))),
            "assigning variable eta_agd_contrast_noRE");
          current_statement__ = 100;
          if (class_effects) {
            current_statement__ = 98;
            for (int i = 1; i <= ni_agd_arm; ++i) {
              current_statement__ = 93;
              if ((stan::math::primitive_value(
                     stan::math::logical_gt(
                       stan::model::rvalue(agd_contrast_trt,
                         "agd_contrast_trt", stan::model::index_uni(i)), 1))
                  &&
                  stan::math::primitive_value(
                    stan::model::rvalue(which_CE, "which_CE",
                      stan::model::index_uni(
                        (stan::model::rvalue(agd_contrast_trt,
                           "agd_contrast_trt", stan::model::index_uni(i)) -
                        1)))))) {
                current_statement__ = 91;
                stan::model::assign(eta_agd_contrast_noRE,
                  stan::math::add(
                    stan::model::deep_copy(
                      stan::model::rvalue(eta_agd_contrast_noRE,
                        "eta_agd_contrast_noRE",
                        stan::model::index_min_max((1 + ((i - 1) *
                          nint_max)), (((i - 1) * nint_max) + nint)))),
                    stan::model::rvalue(f_class, "f_class",
                      stan::model::index_uni(
                        stan::model::rvalue(which_fclass, "which_fclass",
                          stan::model::index_uni(
                            (stan::model::rvalue(agd_contrast_trt,
                               "agd_contrast_trt", stan::model::index_uni(i))
                            - 1)))))),
                  "assigning variable eta_agd_contrast_noRE",
                  stan::model::index_min_max((1 + ((i - 1) * nint_max)), (((i
                    - 1) * nint_max) + nint)));
              }
              current_statement__ = 96;
              if ((stan::math::primitive_value(
                     stan::math::logical_gt(
                       stan::model::rvalue(agd_contrast_trt_b,
                         "agd_contrast_trt_b", stan::model::index_uni(i)), 1))
                  &&
                  stan::math::primitive_value(
                    stan::model::rvalue(which_CE, "which_CE",
                      stan::model::index_uni(
                        (stan::model::rvalue(agd_contrast_trt_b,
                           "agd_contrast_trt_b", stan::model::index_uni(i)) -
                        1)))))) {
                current_statement__ = 94;
                stan::model::assign(eta_agd_contrast_noRE,
                  stan::math::subtract(
                    stan::model::deep_copy(
                      stan::model::rvalue(eta_agd_contrast_noRE,
                        "eta_agd_contrast_noRE",
                        stan::model::index_min_max((1 + ((i - 1) *
                          nint_max)), (((i - 1) * nint_max) + nint)))),
                    stan::model::rvalue(f_class, "f_class",
                      stan::model::index_uni(
                        stan::model::rvalue(which_fclass, "which_fclass",
                          stan::model::index_uni(
                            (stan::model::rvalue(agd_contrast_trt_b,
                               "agd_contrast_trt_b",
                               stan::model::index_uni(i)) - 1)))))),
                  "assigning variable eta_agd_contrast_noRE",
                  stan::model::index_min_max((1 + ((i - 1) * nint_max)), (((i
                    - 1) * nint_max) + nint)));
              }
            }
          }
          current_statement__ = 117;
          if (RE) {
            current_statement__ = 115;
            for (int i = 1; i <= ni_agd_contrast; ++i) {
              current_statement__ = 112;
              if (stan::model::rvalue(which_RE, "which_RE",
                    stan::model::index_uni(((narm_ipd + narm_agd_arm) + i)))) {
                current_statement__ = 111;
                stan::model::assign(eta_agd_contrast_ii,
                  stan::math::add(
                    stan::model::rvalue(eta_agd_contrast_noRE,
                      "eta_agd_contrast_noRE",
                      stan::model::index_min_max((1 + ((i - 1) * nint_max)),
                        (((i - 1) * nint_max) + nint))),
                    stan::model::rvalue(f_delta, "f_delta",
                      stan::model::index_uni(
                        stan::model::rvalue(which_RE, "which_RE",
                          stan::model::index_uni(((narm_ipd + narm_agd_arm) +
                            i)))))),
                  "assigning variable eta_agd_contrast_ii",
                  stan::model::index_min_max((1 + ((i - 1) * nint)), (i *
                    nint)));
              } else {
                current_statement__ = 110;
                stan::model::assign(eta_agd_contrast_ii,
                  stan::model::rvalue(eta_agd_contrast_noRE,
                    "eta_agd_contrast_noRE",
                    stan::model::index_min_max((1 + ((i - 1) * nint_max)),
                      (((i - 1) * nint_max) + nint))),
                  "assigning variable eta_agd_contrast_ii",
                  stan::model::index_min_max((1 + ((i - 1) * nint)), (i *
                    nint)));
              }
              current_statement__ = 113;
              stan::model::assign(eta_agd_contrast_bar,
                stan::math::mean(
                  stan::model::rvalue(eta_agd_contrast_ii,
                    "eta_agd_contrast_ii",
                    stan::model::index_min_max((1 + ((i - 1) * nint)), (i *
                      nint)))), "assigning variable eta_agd_contrast_bar",
                stan::model::index_uni(i));
            }
          } else {
            current_statement__ = 105;
            if (stan::math::logical_eq(nint, nint_max)) {
              current_statement__ = 104;
              stan::model::assign(eta_agd_contrast_ii, eta_agd_contrast_noRE,
                "assigning variable eta_agd_contrast_ii");
            } else {
              current_statement__ = 103;
              for (int i = 1; i <= ni_agd_contrast; ++i) {
                current_statement__ = 101;
                stan::model::assign(eta_agd_contrast_ii,
                  stan::model::rvalue(eta_agd_contrast_noRE,
                    "eta_agd_contrast_noRE",
                    stan::model::index_min_max((1 + ((i - 1) * nint_max)),
                      (((i - 1) * nint_max) + nint))),
                  "assigning variable eta_agd_contrast_ii",
                  stan::model::index_min_max((1 + ((i - 1) * nint)), (i *
                    nint)));
              }
            }
            current_statement__ = 108;
            for (int i = 1; i <= ni_agd_contrast; ++i) {
              current_statement__ = 106;
              stan::model::assign(eta_agd_contrast_bar,
                stan::math::mean(
                  stan::model::rvalue(eta_agd_contrast_ii,
                    "eta_agd_contrast_ii",
                    stan::model::index_min_max((1 + ((i - 1) * nint)), (i *
                      nint)))), "assigning variable eta_agd_contrast_bar",
                stan::model::index_uni(i));
            }
          }
        } else {
          current_statement__ = 77;
          if (RE) {
            current_statement__ = 69;
            stan::math::validate_non_negative_index("eta_agd_contrast_noRE",
              "nint * ni_agd_contrast", (nint * ni_agd_contrast));
            Eigen::Matrix<double,-1,1> eta_agd_contrast_noRE =
              Eigen::Matrix<double,-1,1>::Constant((nint * ni_agd_contrast),
                std::numeric_limits<double>::quiet_NaN());
            current_statement__ = 70;
            stan::model::assign(eta_agd_contrast_noRE,
              (has_offset ? stan::math::eval(
                              stan::math::add(
                                stan::math::multiply(X_agd_contrast,
                                  beta_tilde), offset_agd_contrast)) : 
              stan::math::eval(
                stan::math::multiply(X_agd_contrast, beta_tilde))),
              "assigning variable eta_agd_contrast_noRE");
            current_statement__ = 75;
            for (int i = 1; i <= ni_agd_contrast; ++i) {
              current_statement__ = 73;
              if (stan::model::rvalue(which_RE, "which_RE",
                    stan::model::index_uni(((narm_ipd + narm_agd_arm) + i)))) {
                current_statement__ = 72;
                stan::model::assign(eta_agd_contrast_bar,
                  (stan::model::rvalue(eta_agd_contrast_noRE,
                     "eta_agd_contrast_noRE", stan::model::index_uni(i)) +
                  stan::model::rvalue(f_delta, "f_delta",
                    stan::model::index_uni(
                      stan::model::rvalue(which_RE, "which_RE",
                        stan::model::index_uni(((narm_ipd + narm_agd_arm) +
                          i)))))), "assigning variable eta_agd_contrast_bar",
                  stan::model::index_uni(i));
              } else {
                current_statement__ = 71;
                stan::model::assign(eta_agd_contrast_bar,
                  stan::model::rvalue(eta_agd_contrast_noRE,
                    "eta_agd_contrast_noRE", stan::model::index_uni(i)),
                  "assigning variable eta_agd_contrast_bar",
                  stan::model::index_uni(i));
              }
            }
          } else {
            current_statement__ = 67;
            stan::model::assign(eta_agd_contrast_bar,
              (has_offset ? stan::math::eval(
                              stan::math::add(
                                stan::math::multiply(X_agd_contrast,
                                  beta_tilde), offset_agd_contrast)) : 
              stan::math::eval(
                stan::math::multiply(X_agd_contrast, beta_tilde))),
              "assigning variable eta_agd_contrast_bar");
          }
          current_statement__ = 87;
          if (class_effects) {
            current_statement__ = 85;
            for (int i = 1; i <= ni_agd_contrast; ++i) {
              current_statement__ = 80;
              if ((stan::math::primitive_value(
                     stan::math::logical_gt(
                       stan::model::rvalue(agd_contrast_trt,
                         "agd_contrast_trt", stan::model::index_uni(i)), 1))
                  &&
                  stan::math::primitive_value(
                    stan::model::rvalue(which_CE, "which_CE",
                      stan::model::index_uni(
                        (stan::model::rvalue(agd_contrast_trt,
                           "agd_contrast_trt", stan::model::index_uni(i)) -
                        1)))))) {
                current_statement__ = 78;
                stan::model::assign(eta_agd_contrast_bar,
                  (stan::model::rvalue(eta_agd_contrast_bar,
                     "eta_agd_contrast_bar", stan::model::index_uni(i)) +
                  stan::model::rvalue(f_class, "f_class",
                    stan::model::index_uni(
                      stan::model::rvalue(which_fclass, "which_fclass",
                        stan::model::index_uni(
                          (stan::model::rvalue(agd_contrast_trt,
                             "agd_contrast_trt", stan::model::index_uni(i)) -
                          1)))))), "assigning variable eta_agd_contrast_bar",
                  stan::model::index_uni(i));
              }
              current_statement__ = 83;
              if ((stan::math::primitive_value(
                     stan::math::logical_gt(
                       stan::model::rvalue(agd_contrast_trt_b,
                         "agd_contrast_trt_b", stan::model::index_uni(i)), 1))
                  &&
                  stan::math::primitive_value(
                    stan::model::rvalue(which_CE, "which_CE",
                      stan::model::index_uni(
                        (stan::model::rvalue(agd_contrast_trt_b,
                           "agd_contrast_trt_b", stan::model::index_uni(i)) -
                        1)))))) {
                current_statement__ = 81;
                stan::model::assign(eta_agd_contrast_bar,
                  (stan::model::rvalue(eta_agd_contrast_bar,
                     "eta_agd_contrast_bar", stan::model::index_uni(i)) -
                  stan::model::rvalue(f_class, "f_class",
                    stan::model::index_uni(
                      stan::model::rvalue(which_fclass, "which_fclass",
                        stan::model::index_uni(
                          (stan::model::rvalue(agd_contrast_trt_b,
                             "agd_contrast_trt_b", stan::model::index_uni(i))
                          - 1)))))),
                  "assigning variable eta_agd_contrast_bar",
                  stan::model::index_uni(i));
              }
            }
          }
        }
      }
      current_statement__ = 123;
      if (stan::math::logical_eq(link, 1)) {
        current_statement__ = 122;
        stan::model::assign(theta_ipd, stan::math::exp(eta_ipd),
          "assigning variable theta_ipd");
      }
      current_statement__ = 188;
      if (ni_agd_arm) {
        current_statement__ = 124;
        stan::math::validate_non_negative_index("eta_agd_arm_noRE",
          "nint_max * ni_agd_arm", (nint_max * ni_agd_arm));
        Eigen::Matrix<double,-1,1> eta_agd_arm_noRE =
          Eigen::Matrix<double,-1,1>::Constant((nint_max * ni_agd_arm),
            std::numeric_limits<double>::quiet_NaN());
        current_statement__ = 125;
        stan::model::assign(eta_agd_arm_noRE,
          (has_offset ? stan::math::eval(
                          stan::math::add(
                            stan::math::multiply(X_agd_arm, beta_tilde),
                            offset_agd_arm)) : stan::math::eval(
                                                 stan::math::multiply(
                                                   X_agd_arm, beta_tilde))),
          "assigning variable eta_agd_arm_noRE");
        current_statement__ = 128;
        if (stan::math::logical_gt(brmr_n_col, 0)) {
          current_statement__ = 126;
          stan::model::assign(eta_agd_arm_noRE,
            stan::math::add(stan::model::deep_copy(eta_agd_arm_noRE),
              stan::math::elt_multiply(
                stan::math::subtract(
                  stan::math::subtract(
                    stan::math::multiply(
                      stan::model::rvalue(X_agd_arm, "X_agd_arm",
                        stan::model::index_omni(),
                        stan::model::index_min_max(1, totns)), mu), xbar_mu),
                  1),
                stan::math::multiply(
                  stan::model::rvalue(X_agd_arm, "X_agd_arm",
                    stan::model::index_omni(),
                    stan::model::index_multi(brmr_col)),
                  stan::model::rvalue(beta_tilde, "beta_tilde",
                    stan::model::index_multi(brmr_col))))),
            "assigning variable eta_agd_arm_noRE");
        }
        current_statement__ = 186;
        if (stan::math::logical_gt(nint_max, 1)) {
          current_statement__ = 162;
          if (class_effects) {
            current_statement__ = 160;
            for (int i = 1; i <= ni_agd_arm; ++i) {
              current_statement__ = 158;
              if ((stan::math::primitive_value(
                     stan::math::logical_gt(
                       stan::model::rvalue(agd_arm_trt, "agd_arm_trt",
                         stan::model::index_uni(i)), 1))
                  &&
                  stan::math::primitive_value(
                    stan::model::rvalue(which_CE, "which_CE",
                      stan::model::index_uni(
                        (stan::model::rvalue(agd_arm_trt, "agd_arm_trt",
                           stan::model::index_uni(i)) - 1)))))) {
                current_statement__ = 156;
                stan::model::assign(eta_agd_arm_noRE,
                  stan::math::add(
                    stan::model::deep_copy(
                      stan::model::rvalue(eta_agd_arm_noRE,
                        "eta_agd_arm_noRE",
                        stan::model::index_min_max((1 + ((i - 1) *
                          nint_max)), (((i - 1) * nint_max) + nint)))),
                    stan::model::rvalue(f_class, "f_class",
                      stan::model::index_uni(
                        stan::model::rvalue(which_fclass, "which_fclass",
                          stan::model::index_uni(
                            (stan::model::rvalue(agd_arm_trt, "agd_arm_trt",
                               stan::model::index_uni(i)) - 1)))))),
                  "assigning variable eta_agd_arm_noRE",
                  stan::model::index_min_max((1 + ((i - 1) * nint_max)), (((i
                    - 1) * nint_max) + nint)));
              }
            }
          }
          current_statement__ = 184;
          if (RE) {
            current_statement__ = 179;
            if (stan::math::logical_eq(link, 1)) {
              current_statement__ = 177;
              for (int i = 1; i <= ni_agd_arm; ++i) {
                current_statement__ = 175;
                if (stan::model::rvalue(which_RE, "which_RE",
                      stan::model::index_uni((narm_ipd + i)))) {
                  current_statement__ = 174;
                  stan::model::assign(theta_agd_arm_ii,
                    stan::math::exp(
                      stan::math::add(
                        stan::model::rvalue(eta_agd_arm_noRE,
                          "eta_agd_arm_noRE",
                          stan::model::index_min_max((1 + ((i - 1) *
                            nint_max)), (((i - 1) * nint_max) + nint))),
                        stan::model::rvalue(f_delta, "f_delta",
                          stan::model::index_uni(
                            stan::model::rvalue(which_RE, "which_RE",
                              stan::model::index_uni((narm_ipd + i))))))),
                    "assigning variable theta_agd_arm_ii",
                    stan::model::index_min_max((1 + ((i - 1) * nint)), (i *
                      nint)));
                } else {
                  current_statement__ = 173;
                  stan::model::assign(theta_agd_arm_ii,
                    stan::math::exp(
                      stan::model::rvalue(eta_agd_arm_noRE,
                        "eta_agd_arm_noRE",
                        stan::model::index_min_max((1 + ((i - 1) *
                          nint_max)), (((i - 1) * nint_max) + nint)))),
                    "assigning variable theta_agd_arm_ii",
                    stan::model::index_min_max((1 + ((i - 1) * nint)), (i *
                      nint)));
                }
              }
            }
            current_statement__ = 182;
            for (int i = 1; i <= ni_agd_arm; ++i) {
              current_statement__ = 180;
              stan::model::assign(theta_agd_arm_bar,
                stan::math::mean(
                  stan::model::rvalue(theta_agd_arm_ii, "theta_agd_arm_ii",
                    stan::model::index_min_max((1 + ((i - 1) * nint)), (i *
                      nint)))), "assigning variable theta_agd_arm_bar",
                stan::model::index_uni(i));
            }
          } else {
            current_statement__ = 168;
            if (stan::math::logical_eq(link, 1)) {
              current_statement__ = 166;
              if (stan::math::logical_eq(nint, nint_max)) {
                current_statement__ = 165;
                stan::model::assign(theta_agd_arm_ii,
                  stan::math::exp(eta_agd_arm_noRE),
                  "assigning variable theta_agd_arm_ii");
              } else {
                current_statement__ = 164;
                for (int i = 1; i <= ni_agd_arm; ++i) {
                  current_statement__ = 163;
                  stan::model::assign(theta_agd_arm_ii,
                    stan::math::exp(
                      stan::model::rvalue(eta_agd_arm_noRE,
                        "eta_agd_arm_noRE",
                        stan::model::index_min_max((1 + ((i - 1) *
                          nint_max)), (((i - 1) * nint_max) + nint)))),
                    "assigning variable theta_agd_arm_ii",
                    stan::model::index_min_max((1 + ((i - 1) * nint)), (i *
                      nint)));
                }
              }
            }
            current_statement__ = 171;
            for (int i = 1; i <= ni_agd_arm; ++i) {
              current_statement__ = 169;
              stan::model::assign(theta_agd_arm_bar,
                stan::math::mean(
                  stan::model::rvalue(theta_agd_arm_ii, "theta_agd_arm_ii",
                    stan::model::index_min_max((1 + ((i - 1) * nint)), (i *
                      nint)))), "assigning variable theta_agd_arm_bar",
                stan::model::index_uni(i));
            }
          }
        } else {
          current_statement__ = 154;
          if (RE) {
            current_statement__ = 145;
            if (class_effects) {
              current_statement__ = 143;
              for (int i = 1; i <= ni_agd_arm; ++i) {
                current_statement__ = 141;
                if ((stan::math::primitive_value(
                       stan::math::logical_gt(
                         stan::model::rvalue(agd_arm_trt, "agd_arm_trt",
                           stan::model::index_uni(i)), 1))
                    &&
                    stan::math::primitive_value(
                      stan::model::rvalue(which_CE, "which_CE",
                        stan::model::index_uni(
                          (stan::model::rvalue(agd_arm_trt, "agd_arm_trt",
                             stan::model::index_uni(i)) - 1)))))) {
                  current_statement__ = 139;
                  stan::model::assign(eta_agd_arm_noRE,
                    (stan::model::rvalue(eta_agd_arm_noRE,
                       "eta_agd_arm_noRE", stan::model::index_uni(i)) +
                    stan::model::rvalue(f_class, "f_class",
                      stan::model::index_uni(
                        stan::model::rvalue(which_fclass, "which_fclass",
                          stan::model::index_uni(
                            (stan::model::rvalue(agd_arm_trt, "agd_arm_trt",
                               stan::model::index_uni(i)) - 1)))))),
                    "assigning variable eta_agd_arm_noRE",
                    stan::model::index_uni(i));
                }
              }
            }
            current_statement__ = 152;
            if (stan::math::logical_eq(link, 1)) {
              current_statement__ = 150;
              for (int i = 1; i <= ni_agd_arm; ++i) {
                current_statement__ = 148;
                if (stan::model::rvalue(which_RE, "which_RE",
                      stan::model::index_uni((narm_ipd + i)))) {
                  current_statement__ = 147;
                  stan::model::assign(theta_agd_arm_bar,
                    stan::math::exp(
                      (stan::model::rvalue(eta_agd_arm_noRE,
                         "eta_agd_arm_noRE", stan::model::index_uni(i)) +
                      stan::model::rvalue(f_delta, "f_delta",
                        stan::model::index_uni(
                          stan::model::rvalue(which_RE, "which_RE",
                            stan::model::index_uni((narm_ipd + i))))))),
                    "assigning variable theta_agd_arm_bar",
                    stan::model::index_uni(i));
                } else {
                  current_statement__ = 146;
                  stan::model::assign(theta_agd_arm_bar,
                    stan::math::exp(
                      stan::model::rvalue(eta_agd_arm_noRE,
                        "eta_agd_arm_noRE", stan::model::index_uni(i))),
                    "assigning variable theta_agd_arm_bar",
                    stan::model::index_uni(i));
                }
              }
            }
          } else {
            current_statement__ = 135;
            if (class_effects) {
              current_statement__ = 133;
              for (int i = 1; i <= ni_agd_arm; ++i) {
                current_statement__ = 131;
                if ((stan::math::primitive_value(
                       stan::math::logical_gt(
                         stan::model::rvalue(agd_arm_trt, "agd_arm_trt",
                           stan::model::index_uni(i)), 1))
                    &&
                    stan::math::primitive_value(
                      stan::model::rvalue(which_CE, "which_CE",
                        stan::model::index_uni(
                          (stan::model::rvalue(agd_arm_trt, "agd_arm_trt",
                             stan::model::index_uni(i)) - 1)))))) {
                  current_statement__ = 129;
                  stan::model::assign(eta_agd_arm_noRE,
                    (stan::model::rvalue(eta_agd_arm_noRE,
                       "eta_agd_arm_noRE", stan::model::index_uni(i)) +
                    stan::model::rvalue(f_class, "f_class",
                      stan::model::index_uni(
                        stan::model::rvalue(which_fclass, "which_fclass",
                          stan::model::index_uni(
                            (stan::model::rvalue(agd_arm_trt, "agd_arm_trt",
                               stan::model::index_uni(i)) - 1)))))),
                    "assigning variable eta_agd_arm_noRE",
                    stan::model::index_uni(i));
                }
              }
            }
            current_statement__ = 137;
            if (stan::math::logical_eq(link, 1)) {
              current_statement__ = 136;
              stan::model::assign(theta_agd_arm_bar,
                stan::math::exp(eta_agd_arm_noRE),
                "assigning variable theta_agd_arm_bar");
            }
          }
        }
      }
      current_statement__ = 189;
      stan::model::assign(E_eta_ipd, stan::math::add(eta_ipd, ipd_logE),
        "assigning variable E_eta_ipd");
      current_statement__ = 190;
      stan::model::assign(E_theta_agd_arm,
        stan::math::elt_multiply(theta_agd_arm_bar, agd_arm_E),
        "assigning variable E_theta_agd_arm");
      current_statement__ = 8;
      stan::math::check_greater_or_equal(function__, "E_theta_agd_arm",
        E_theta_agd_arm, 0);
      if (emit_transformed_parameters__) {
        out__.write(E_eta_ipd);
        out__.write(E_theta_agd_arm);
        out__.write(theta_ipd);
        out__.write(theta_agd_arm_ii);
        out__.write(theta_agd_arm_bar);
        out__.write(eta_ipd);
        out__.write(f_delta);
        out__.write(f_class);
        out__.write(allbeta);
        out__.write(mu);
        out__.write(d);
        out__.write(omega);
        out__.write(beta);
        out__.write(eta_agd_contrast_ii);
        out__.write(eta_agd_contrast_bar);
      }
      if (stan::math::logical_negation(emit_generated_quantities__)) {
        return ;
      }
      Eigen::Matrix<double,-1,1> fitted_ipd =
        Eigen::Matrix<double,-1,1>::Constant(ni_ipd,
          std::numeric_limits<double>::quiet_NaN());
      Eigen::Matrix<double,-1,1> fitted_agd_arm =
        Eigen::Matrix<double,-1,1>::Constant(ni_agd_arm,
          std::numeric_limits<double>::quiet_NaN());
      Eigen::Matrix<double,-1,1> theta_bar_cum_agd_arm =
        Eigen::Matrix<double,-1,1>::Constant(theta_bar_cum_agd_arm_1dim__,
          std::numeric_limits<double>::quiet_NaN());
      Eigen::Matrix<double,-1,1> log_lik =
        Eigen::Matrix<double,-1,1>::Constant(log_lik_1dim__,
          std::numeric_limits<double>::quiet_NaN());
      Eigen::Matrix<double,-1,1> resdev =
        Eigen::Matrix<double,-1,1>::Constant(resdev_1dim__,
          std::numeric_limits<double>::quiet_NaN());
      Eigen::Matrix<double,-1,1> fitted_agd_contrast =
        Eigen::Matrix<double,-1,1>::Constant(ni_agd_contrast,
          std::numeric_limits<double>::quiet_NaN());
      Eigen::Matrix<double,-1,1> theta_bar_cum_agd_contrast =
        Eigen::Matrix<double,-1,1>::Constant(theta_bar_cum_agd_contrast_1dim__,
          std::numeric_limits<double>::quiet_NaN());
      Eigen::Matrix<double,-1,1> delta =
        Eigen::Matrix<double,-1,1>::Constant(n_delta,
          std::numeric_limits<double>::quiet_NaN());
      current_statement__ = 207;
      if (RE) {
        int s = std::numeric_limits<int>::min();
        current_statement__ = 191;
        s = 1;
        current_statement__ = 197;
        for (int i = 1; i <= (narm_ipd + narm_agd_arm); ++i) {
          current_statement__ = 195;
          if (stan::model::rvalue(which_RE, "which_RE",
                stan::model::index_uni(i))) {
            current_statement__ = 192;
            stan::model::assign(delta,
              ((stan::math::logical_gt(
                  stan::model::rvalue(trt, "trt", stan::model::index_uni(i)),
                  1) ? stan::model::rvalue(d, "d",
                         stan::model::index_uni(
                           (stan::model::rvalue(trt, "trt",
                              stan::model::index_uni(i)) - 1))) : 0) +
              (stan::model::rvalue(which_RE, "which_RE",
                 stan::model::index_uni(i)) ? stan::model::rvalue(f_delta,
                                                "f_delta",
                                                stan::model::index_uni(
                                                  stan::model::rvalue(
                                                    which_RE, "which_RE",
                                                    stan::model::index_uni(i)))) : 0)),
              "assigning variable delta", stan::model::index_uni(s));
            current_statement__ = 193;
            s = (s + 1);
          }
        }
        current_statement__ = 205;
        for (int i = 1; i <= ni_agd_contrast; ++i) {
          current_statement__ = 203;
          if (stan::model::rvalue(which_RE, "which_RE",
                stan::model::index_uni(((narm_ipd + narm_agd_arm) + i)))) {
            current_statement__ = 198;
            stan::model::assign(delta,
              ((stan::math::logical_gt(
                  stan::model::rvalue(trt, "trt",
                    stan::model::index_uni(((narm_ipd + narm_agd_arm) + i))),
                  1) ? stan::model::rvalue(d, "d",
                         stan::model::index_uni(
                           (stan::model::rvalue(trt, "trt",
                              stan::model::index_uni(((narm_ipd +
                                narm_agd_arm) + i))) - 1))) : 0) +
              (stan::model::rvalue(which_RE, "which_RE",
                 stan::model::index_uni(((narm_ipd + narm_agd_arm) + i))) ? 
              stan::model::rvalue(f_delta, "f_delta",
                stan::model::index_uni(
                  stan::model::rvalue(which_RE, "which_RE",
                    stan::model::index_uni(((narm_ipd + narm_agd_arm) + i))))) : 0)),
              "assigning variable delta", stan::model::index_uni(s));
            current_statement__ = 200;
            if (stan::math::logical_gt(
                  stan::model::rvalue(agd_contrast_trt_b,
                    "agd_contrast_trt_b", stan::model::index_uni(i)), 1)) {
              current_statement__ = 199;
              stan::model::assign(delta,
                (stan::model::rvalue(delta, "delta",
                   stan::model::index_uni(s)) -
                stan::model::rvalue(d, "d",
                  stan::model::index_uni(
                    (stan::model::rvalue(agd_contrast_trt_b,
                       "agd_contrast_trt_b", stan::model::index_uni(i)) - 1)))),
                "assigning variable delta", stan::model::index_uni(s));
            }
            current_statement__ = 201;
            s = (s + 1);
          }
        }
      }
      current_statement__ = 212;
      for (int i = 1; i <= ni_agd_contrast; ++i) {
        current_statement__ = 210;
        for (int j = 1; j <= n_int_thin; ++j) {
          current_statement__ = 208;
          stan::model::assign(theta_bar_cum_agd_contrast,
            stan::math::mean(
              stan::model::rvalue(eta_agd_contrast_ii, "eta_agd_contrast_ii",
                stan::model::index_min_max((1 + ((i - 1) * nint)), (((i - 1)
                  * nint) + (j * int_thin))))),
            "assigning variable theta_bar_cum_agd_contrast",
            stan::model::index_uni((((i - 1) * n_int_thin) + j)));
        }
      }
      current_statement__ = 213;
      stan::model::assign(fitted_agd_contrast, eta_agd_contrast_bar,
        "assigning variable fitted_agd_contrast");
      {
        int a = std::numeric_limits<int>::min();
        current_statement__ = 214;
        a = 0;
        int nc = std::numeric_limits<int>::min();
        current_statement__ = 221;
        for (int s = 1; s <= ns_agd_contrast; ++s) {
          current_statement__ = 216;
          nc = stan::model::rvalue(nc_agd_contrast, "nc_agd_contrast",
                 stan::model::index_uni(s));
          current_statement__ = 217;
          stan::model::assign(log_lik,
            stan::math::multi_normal_lpdf<false>(
              stan::model::rvalue(agd_contrast_y, "agd_contrast_y",
                stan::model::index_min_max((a + 1), (a + nc))),
              stan::model::rvalue(eta_agd_contrast_bar,
                "eta_agd_contrast_bar",
                stan::model::index_min_max((a + 1), (a + nc))),
              stan::model::rvalue(agd_contrast_Sigma, "agd_contrast_Sigma",
                stan::model::index_min_max((a + 1), (a + nc)),
                stan::model::index_min_max((a + 1), (a + nc)))),
            "assigning variable log_lik",
            stan::model::index_uni(((ni_ipd + ni_agd_arm) + s)));
          current_statement__ = 218;
          stan::model::assign(resdev,
            stan::math::quad_form(
              stan::model::rvalue(inv_Sigma, "inv_Sigma",
                stan::model::index_min_max((a + 1), (a + nc)),
                stan::model::index_min_max((a + 1), (a + nc))),
              stan::math::subtract(
                stan::model::rvalue(agd_contrast_y, "agd_contrast_y",
                  stan::model::index_min_max((a + 1), (a + nc))),
                stan::model::rvalue(eta_agd_contrast_bar,
                  "eta_agd_contrast_bar",
                  stan::model::index_min_max((a + 1), (a + nc))))),
            "assigning variable resdev",
            stan::model::index_uni(((ni_ipd + ni_agd_arm) + s)));
          current_statement__ = 219;
          a = (a + nc);
        }
      }
      current_statement__ = 227;
      for (int i = 1; i <= ni_agd_arm; ++i) {
        current_statement__ = 225;
        for (int j = 1; j <= n_int_thin; ++j) {
          current_statement__ = 223;
          stan::model::assign(theta_bar_cum_agd_arm,
            stan::math::mean(
              stan::model::rvalue(theta_agd_arm_ii, "theta_agd_arm_ii",
                stan::model::index_min_max((1 + ((i - 1) * nint)), (((i - 1)
                  * nint) + (j * int_thin))))),
            "assigning variable theta_bar_cum_agd_arm",
            stan::model::index_uni((((i - 1) * n_int_thin) + j)));
        }
      }
      current_statement__ = 236;
      if (stan::math::logical_eq(link, 1)) {
        current_statement__ = 228;
        stan::math::validate_non_negative_index("E_theta_ipd", "ni_ipd",
          ni_ipd);
        Eigen::Matrix<double,-1,1> E_theta_ipd =
          Eigen::Matrix<double,-1,1>::Constant(ni_ipd,
            std::numeric_limits<double>::quiet_NaN());
        current_statement__ = 229;
        stan::model::assign(E_theta_ipd, stan::math::exp(E_eta_ipd),
          "assigning variable E_theta_ipd");
        current_statement__ = 234;
        for (int i = 1; i <= ni_ipd; ++i) {
          current_statement__ = 230;
          stan::model::assign(log_lik,
            stan::math::poisson_log_lpmf<false>(
              stan::model::rvalue(ipd_r, "ipd_r", stan::model::index_uni(i)),
              stan::model::rvalue(E_eta_ipd, "E_eta_ipd",
                stan::model::index_uni(i))), "assigning variable log_lik",
            stan::model::index_uni(i));
          current_statement__ = 231;
          stan::model::assign(resdev, (2 *
            ((stan::model::rvalue(E_theta_ipd, "E_theta_ipd",
                stan::model::index_uni(i)) -
            stan::model::rvalue(ipd_r, "ipd_r", stan::model::index_uni(i))) +
            stan::math::multiply_log(
              stan::model::rvalue(ipd_r, "ipd_r", stan::model::index_uni(i)),
              (stan::model::rvalue(ipd_r, "ipd_r", stan::model::index_uni(i))
              /
              stan::model::rvalue(E_theta_ipd, "E_theta_ipd",
                stan::model::index_uni(i)))))), "assigning variable resdev",
            stan::model::index_uni(i));
          current_statement__ = 232;
          stan::model::assign(fitted_ipd,
            stan::model::rvalue(E_theta_ipd, "E_theta_ipd",
              stan::model::index_uni(i)), "assigning variable fitted_ipd",
            stan::model::index_uni(i));
        }
      }
      current_statement__ = 241;
      for (int i = 1; i <= ni_agd_arm; ++i) {
        current_statement__ = 237;
        stan::model::assign(log_lik,
          stan::math::poisson_lpmf<false>(
            stan::model::rvalue(agd_arm_r, "agd_arm_r",
              stan::model::index_uni(i)),
            stan::model::rvalue(E_theta_agd_arm, "E_theta_agd_arm",
              stan::model::index_uni(i))), "assigning variable log_lik",
          stan::model::index_uni((ni_ipd + i)));
        current_statement__ = 238;
        stan::model::assign(resdev, (2 *
          ((stan::model::rvalue(E_theta_agd_arm, "E_theta_agd_arm",
              stan::model::index_uni(i)) -
          stan::model::rvalue(agd_arm_r, "agd_arm_r",
            stan::model::index_uni(i))) +
          stan::math::multiply_log(
            stan::model::rvalue(agd_arm_r, "agd_arm_r",
              stan::model::index_uni(i)),
            (stan::model::rvalue(agd_arm_r, "agd_arm_r",
               stan::model::index_uni(i)) /
            stan::model::rvalue(E_theta_agd_arm, "E_theta_agd_arm",
              stan::model::index_uni(i)))))), "assigning variable resdev",
          stan::model::index_uni((ni_ipd + i)));
        current_statement__ = 239;
        stan::model::assign(fitted_agd_arm,
          stan::model::rvalue(E_theta_agd_arm, "E_theta_agd_arm",
            stan::model::index_uni(i)), "assigning variable fitted_agd_arm",
          stan::model::index_uni(i));
      }
      out__.write(fitted_ipd);
      out__.write(fitted_agd_arm);
      out__.write(theta_bar_cum_agd_arm);
      out__.write(log_lik);
      out__.write(resdev);
      out__.write(fitted_agd_contrast);
      out__.write(theta_bar_cum_agd_contrast);
      out__.write(delta);
    } 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;
      Eigen::Matrix<local_scalar_t__,-1,1> beta_tilde =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(nX, DUMMY_VAR__);
      current_statement__ = 1;
      stan::model::assign(beta_tilde,
        in__.read<Eigen::Matrix<local_scalar_t__,-1,1>>(nX),
        "assigning variable beta_tilde");
      out__.write(beta_tilde);
      Eigen::Matrix<local_scalar_t__,-1,1> u_delta =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(n_delta, DUMMY_VAR__);
      current_statement__ = 2;
      stan::model::assign(u_delta,
        in__.read<Eigen::Matrix<local_scalar_t__,-1,1>>(n_delta),
        "assigning variable u_delta");
      out__.write(u_delta);
      Eigen::Matrix<local_scalar_t__,-1,1> tau =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(tau_1dim__,
          DUMMY_VAR__);
      current_statement__ = 3;
      stan::model::assign(tau,
        in__.read<Eigen::Matrix<local_scalar_t__,-1,1>>(tau_1dim__),
        "assigning variable tau");
      out__.write_free_lb(0, tau);
      Eigen::Matrix<local_scalar_t__,-1,1> class_mean =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(class_mean_1dim__,
          DUMMY_VAR__);
      current_statement__ = 4;
      stan::model::assign(class_mean,
        in__.read<Eigen::Matrix<local_scalar_t__,-1,1>>(class_mean_1dim__),
        "assigning variable class_mean");
      out__.write(class_mean);
      Eigen::Matrix<local_scalar_t__,-1,1> class_sd =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(class_sd_1dim__,
          DUMMY_VAR__);
      current_statement__ = 5;
      stan::model::assign(class_sd,
        in__.read<Eigen::Matrix<local_scalar_t__,-1,1>>(class_sd_1dim__),
        "assigning variable class_sd");
      out__.write_free_lb(0, class_sd);
      Eigen::Matrix<local_scalar_t__,-1,1> z_class =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(z_class_1dim__,
          DUMMY_VAR__);
      current_statement__ = 6;
      stan::model::assign(z_class,
        in__.read<Eigen::Matrix<local_scalar_t__,-1,1>>(z_class_1dim__),
        "assigning variable z_class");
      out__.write(z_class);
    } 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", "beta_tilde",
        "double", std::vector<size_t>{static_cast<size_t>(nX)});
      current_statement__ = 2;
      context__.validate_dims("parameter initialization", "u_delta",
        "double", std::vector<size_t>{static_cast<size_t>(n_delta)});
      current_statement__ = 3;
      context__.validate_dims("parameter initialization", "tau", "double",
        std::vector<size_t>{static_cast<size_t>(tau_1dim__)});
      current_statement__ = 4;
      context__.validate_dims("parameter initialization", "class_mean",
        "double",
        std::vector<size_t>{static_cast<size_t>(class_mean_1dim__)});
      current_statement__ = 5;
      context__.validate_dims("parameter initialization", "class_sd",
        "double", std::vector<size_t>{static_cast<size_t>(class_sd_1dim__)});
      current_statement__ = 6;
      context__.validate_dims("parameter initialization", "z_class",
        "double", std::vector<size_t>{static_cast<size_t>(z_class_1dim__)});
      int pos__ = std::numeric_limits<int>::min();
      pos__ = 1;
      Eigen::Matrix<local_scalar_t__,-1,1> beta_tilde =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(nX, DUMMY_VAR__);
      {
        std::vector<local_scalar_t__> beta_tilde_flat__;
        current_statement__ = 1;
        beta_tilde_flat__ = context__.vals_r("beta_tilde");
        current_statement__ = 1;
        pos__ = 1;
        current_statement__ = 1;
        for (int sym1__ = 1; sym1__ <= nX; ++sym1__) {
          current_statement__ = 1;
          stan::model::assign(beta_tilde, beta_tilde_flat__[(pos__ - 1)],
            "assigning variable beta_tilde", stan::model::index_uni(sym1__));
          current_statement__ = 1;
          pos__ = (pos__ + 1);
        }
      }
      out__.write(beta_tilde);
      Eigen::Matrix<local_scalar_t__,-1,1> u_delta =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(n_delta, DUMMY_VAR__);
      {
        std::vector<local_scalar_t__> u_delta_flat__;
        current_statement__ = 2;
        u_delta_flat__ = context__.vals_r("u_delta");
        current_statement__ = 2;
        pos__ = 1;
        current_statement__ = 2;
        for (int sym1__ = 1; sym1__ <= n_delta; ++sym1__) {
          current_statement__ = 2;
          stan::model::assign(u_delta, u_delta_flat__[(pos__ - 1)],
            "assigning variable u_delta", stan::model::index_uni(sym1__));
          current_statement__ = 2;
          pos__ = (pos__ + 1);
        }
      }
      out__.write(u_delta);
      Eigen::Matrix<local_scalar_t__,-1,1> tau =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(tau_1dim__,
          DUMMY_VAR__);
      {
        std::vector<local_scalar_t__> tau_flat__;
        current_statement__ = 3;
        tau_flat__ = context__.vals_r("tau");
        current_statement__ = 3;
        pos__ = 1;
        current_statement__ = 3;
        for (int sym1__ = 1; sym1__ <= tau_1dim__; ++sym1__) {
          current_statement__ = 3;
          stan::model::assign(tau, tau_flat__[(pos__ - 1)],
            "assigning variable tau", stan::model::index_uni(sym1__));
          current_statement__ = 3;
          pos__ = (pos__ + 1);
        }
      }
      out__.write_free_lb(0, tau);
      Eigen::Matrix<local_scalar_t__,-1,1> class_mean =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(class_mean_1dim__,
          DUMMY_VAR__);
      {
        std::vector<local_scalar_t__> class_mean_flat__;
        current_statement__ = 4;
        class_mean_flat__ = context__.vals_r("class_mean");
        current_statement__ = 4;
        pos__ = 1;
        current_statement__ = 4;
        for (int sym1__ = 1; sym1__ <= class_mean_1dim__; ++sym1__) {
          current_statement__ = 4;
          stan::model::assign(class_mean, class_mean_flat__[(pos__ - 1)],
            "assigning variable class_mean", stan::model::index_uni(sym1__));
          current_statement__ = 4;
          pos__ = (pos__ + 1);
        }
      }
      out__.write(class_mean);
      Eigen::Matrix<local_scalar_t__,-1,1> class_sd =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(class_sd_1dim__,
          DUMMY_VAR__);
      {
        std::vector<local_scalar_t__> class_sd_flat__;
        current_statement__ = 5;
        class_sd_flat__ = context__.vals_r("class_sd");
        current_statement__ = 5;
        pos__ = 1;
        current_statement__ = 5;
        for (int sym1__ = 1; sym1__ <= class_sd_1dim__; ++sym1__) {
          current_statement__ = 5;
          stan::model::assign(class_sd, class_sd_flat__[(pos__ - 1)],
            "assigning variable class_sd", stan::model::index_uni(sym1__));
          current_statement__ = 5;
          pos__ = (pos__ + 1);
        }
      }
      out__.write_free_lb(0, class_sd);
      Eigen::Matrix<local_scalar_t__,-1,1> z_class =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(z_class_1dim__,
          DUMMY_VAR__);
      {
        std::vector<local_scalar_t__> z_class_flat__;
        current_statement__ = 6;
        z_class_flat__ = context__.vals_r("z_class");
        current_statement__ = 6;
        pos__ = 1;
        current_statement__ = 6;
        for (int sym1__ = 1; sym1__ <= z_class_1dim__; ++sym1__) {
          current_statement__ = 6;
          stan::model::assign(z_class, z_class_flat__[(pos__ - 1)],
            "assigning variable z_class", stan::model::index_uni(sym1__));
          current_statement__ = 6;
          pos__ = (pos__ + 1);
        }
      }
      out__.write(z_class);
    } 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>{"beta_tilde", "u_delta", "tau",
                "class_mean", "class_sd", "z_class"};
    if (emit_transformed_parameters__) {
      std::vector<std::string>
        temp{"E_eta_ipd", "E_theta_agd_arm", "theta_ipd", "theta_agd_arm_ii",
             "theta_agd_arm_bar", "eta_ipd", "f_delta", "f_class", "allbeta",
             "mu", "d", "omega", "beta", "eta_agd_contrast_ii",
             "eta_agd_contrast_bar"};
      names__.reserve(names__.size() + temp.size());
      names__.insert(names__.end(), temp.begin(), temp.end());
    }
    if (emit_generated_quantities__) {
      std::vector<std::string>
        temp{"fitted_ipd", "fitted_agd_arm", "theta_bar_cum_agd_arm",
             "log_lik", "resdev", "fitted_agd_contrast",
             "theta_bar_cum_agd_contrast", "delta"};
      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>(
                                                                    nX)},
                std::vector<size_t>{static_cast<size_t>(n_delta)},
                std::vector<size_t>{static_cast<size_t>(tau_1dim__)},
                std::vector<size_t>{static_cast<size_t>(class_mean_1dim__)},
                std::vector<size_t>{static_cast<size_t>(class_sd_1dim__)},
                std::vector<size_t>{static_cast<size_t>(z_class_1dim__)}};
    if (emit_transformed_parameters__) {
      std::vector<std::vector<size_t>>
        temp{std::vector<size_t>{static_cast<size_t>(ni_ipd)},
             std::vector<size_t>{static_cast<size_t>(ni_agd_arm)},
             std::vector<size_t>{static_cast<size_t>(ni_ipd)},
             std::vector<size_t>{static_cast<size_t>(theta_agd_arm_ii_1dim__)},
             std::vector<size_t>{static_cast<size_t>(ni_agd_arm)},
             std::vector<size_t>{static_cast<size_t>(ni_ipd)},
             std::vector<size_t>{static_cast<size_t>(n_delta)},
             std::vector<size_t>{static_cast<size_t>(f_class_1dim__)},
             std::vector<size_t>{static_cast<size_t>(nX)},
             std::vector<size_t>{static_cast<size_t>(totns)},
             std::vector<size_t>{static_cast<size_t>(d_1dim__)},
             std::vector<size_t>{static_cast<size_t>(nodesplit)},
             std::vector<size_t>{static_cast<size_t>(beta_1dim__)},
             std::vector<size_t>{static_cast<size_t>(
                                   eta_agd_contrast_ii_1dim__)},
             std::vector<size_t>{static_cast<size_t>(ni_agd_contrast)}};
      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>{static_cast<size_t>(ni_ipd)},
             std::vector<size_t>{static_cast<size_t>(ni_agd_arm)},
             std::vector<size_t>{static_cast<size_t>(
                                   theta_bar_cum_agd_arm_1dim__)},
             std::vector<size_t>{static_cast<size_t>(log_lik_1dim__)},
             std::vector<size_t>{static_cast<size_t>(resdev_1dim__)},
             std::vector<size_t>{static_cast<size_t>(ni_agd_contrast)},
             std::vector<size_t>{static_cast<size_t>(
                                   theta_bar_cum_agd_contrast_1dim__)},
             std::vector<size_t>{static_cast<size_t>(n_delta)}};
      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__ <= nX; ++sym1__) {
      param_names__.emplace_back(std::string() + "beta_tilde" + '.' +
        std::to_string(sym1__));
    }
    for (int sym1__ = 1; sym1__ <= n_delta; ++sym1__) {
      param_names__.emplace_back(std::string() + "u_delta" + '.' +
        std::to_string(sym1__));
    }
    for (int sym1__ = 1; sym1__ <= tau_1dim__; ++sym1__) {
      param_names__.emplace_back(std::string() + "tau" + '.' +
        std::to_string(sym1__));
    }
    for (int sym1__ = 1; sym1__ <= class_mean_1dim__; ++sym1__) {
      param_names__.emplace_back(std::string() + "class_mean" + '.' +
        std::to_string(sym1__));
    }
    for (int sym1__ = 1; sym1__ <= class_sd_1dim__; ++sym1__) {
      param_names__.emplace_back(std::string() + "class_sd" + '.' +
        std::to_string(sym1__));
    }
    for (int sym1__ = 1; sym1__ <= z_class_1dim__; ++sym1__) {
      param_names__.emplace_back(std::string() + "z_class" + '.' +
        std::to_string(sym1__));
    }
    if (emit_transformed_parameters__) {
      for (int sym1__ = 1; sym1__ <= ni_ipd; ++sym1__) {
        param_names__.emplace_back(std::string() + "E_eta_ipd" + '.' +
          std::to_string(sym1__));
      }
      for (int sym1__ = 1; sym1__ <= ni_agd_arm; ++sym1__) {
        param_names__.emplace_back(std::string() + "E_theta_agd_arm" + '.' +
          std::to_string(sym1__));
      }
      for (int sym1__ = 1; sym1__ <= ni_ipd; ++sym1__) {
        param_names__.emplace_back(std::string() + "theta_ipd" + '.' +
          std::to_string(sym1__));
      }
      for (int sym1__ = 1; sym1__ <= theta_agd_arm_ii_1dim__; ++sym1__) {
        param_names__.emplace_back(std::string() + "theta_agd_arm_ii" + '.' +
          std::to_string(sym1__));
      }
      for (int sym1__ = 1; sym1__ <= ni_agd_arm; ++sym1__) {
        param_names__.emplace_back(std::string() + "theta_agd_arm_bar" + '.'
          + std::to_string(sym1__));
      }
      for (int sym1__ = 1; sym1__ <= ni_ipd; ++sym1__) {
        param_names__.emplace_back(std::string() + "eta_ipd" + '.' +
          std::to_string(sym1__));
      }
      for (int sym1__ = 1; sym1__ <= n_delta; ++sym1__) {
        param_names__.emplace_back(std::string() + "f_delta" + '.' +
          std::to_string(sym1__));
      }
      for (int sym1__ = 1; sym1__ <= f_class_1dim__; ++sym1__) {
        param_names__.emplace_back(std::string() + "f_class" + '.' +
          std::to_string(sym1__));
      }
      for (int sym1__ = 1; sym1__ <= nX; ++sym1__) {
        param_names__.emplace_back(std::string() + "allbeta" + '.' +
          std::to_string(sym1__));
      }
      for (int sym1__ = 1; sym1__ <= totns; ++sym1__) {
        param_names__.emplace_back(std::string() + "mu" + '.' +
          std::to_string(sym1__));
      }
      for (int sym1__ = 1; sym1__ <= d_1dim__; ++sym1__) {
        param_names__.emplace_back(std::string() + "d" + '.' +
          std::to_string(sym1__));
      }
      for (int sym1__ = 1; sym1__ <= nodesplit; ++sym1__) {
        param_names__.emplace_back(std::string() + "omega" + '.' +
          std::to_string(sym1__));
      }
      for (int sym1__ = 1; sym1__ <= beta_1dim__; ++sym1__) {
        param_names__.emplace_back(std::string() + "beta" + '.' +
          std::to_string(sym1__));
      }
      for (int sym1__ = 1; sym1__ <= eta_agd_contrast_ii_1dim__; ++sym1__) {
        param_names__.emplace_back(std::string() + "eta_agd_contrast_ii" +
          '.' + std::to_string(sym1__));
      }
      for (int sym1__ = 1; sym1__ <= ni_agd_contrast; ++sym1__) {
        param_names__.emplace_back(std::string() + "eta_agd_contrast_bar" +
          '.' + std::to_string(sym1__));
      }
    }
    if (emit_generated_quantities__) {
      for (int sym1__ = 1; sym1__ <= ni_ipd; ++sym1__) {
        param_names__.emplace_back(std::string() + "fitted_ipd" + '.' +
          std::to_string(sym1__));
      }
      for (int sym1__ = 1; sym1__ <= ni_agd_arm; ++sym1__) {
        param_names__.emplace_back(std::string() + "fitted_agd_arm" + '.' +
          std::to_string(sym1__));
      }
      for (int sym1__ = 1; sym1__ <= theta_bar_cum_agd_arm_1dim__; ++sym1__) {
        param_names__.emplace_back(std::string() + "theta_bar_cum_agd_arm" +
          '.' + std::to_string(sym1__));
      }
      for (int sym1__ = 1; sym1__ <= log_lik_1dim__; ++sym1__) {
        param_names__.emplace_back(std::string() + "log_lik" + '.' +
          std::to_string(sym1__));
      }
      for (int sym1__ = 1; sym1__ <= resdev_1dim__; ++sym1__) {
        param_names__.emplace_back(std::string() + "resdev" + '.' +
          std::to_string(sym1__));
      }
      for (int sym1__ = 1; sym1__ <= ni_agd_contrast; ++sym1__) {
        param_names__.emplace_back(std::string() + "fitted_agd_contrast" +
          '.' + std::to_string(sym1__));
      }
      for (int sym1__ = 1; sym1__ <=
           theta_bar_cum_agd_contrast_1dim__; ++sym1__) {
        param_names__.emplace_back(std::string() +
          "theta_bar_cum_agd_contrast" + '.' + std::to_string(sym1__));
      }
      for (int sym1__ = 1; sym1__ <= n_delta; ++sym1__) {
        param_names__.emplace_back(std::string() + "delta" + '.' +
          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__ <= nX; ++sym1__) {
      param_names__.emplace_back(std::string() + "beta_tilde" + '.' +
        std::to_string(sym1__));
    }
    for (int sym1__ = 1; sym1__ <= n_delta; ++sym1__) {
      param_names__.emplace_back(std::string() + "u_delta" + '.' +
        std::to_string(sym1__));
    }
    for (int sym1__ = 1; sym1__ <= tau_1dim__; ++sym1__) {
      param_names__.emplace_back(std::string() + "tau" + '.' +
        std::to_string(sym1__));
    }
    for (int sym1__ = 1; sym1__ <= class_mean_1dim__; ++sym1__) {
      param_names__.emplace_back(std::string() + "class_mean" + '.' +
        std::to_string(sym1__));
    }
    for (int sym1__ = 1; sym1__ <= class_sd_1dim__; ++sym1__) {
      param_names__.emplace_back(std::string() + "class_sd" + '.' +
        std::to_string(sym1__));
    }
    for (int sym1__ = 1; sym1__ <= z_class_1dim__; ++sym1__) {
      param_names__.emplace_back(std::string() + "z_class" + '.' +
        std::to_string(sym1__));
    }
    if (emit_transformed_parameters__) {
      for (int sym1__ = 1; sym1__ <= ni_ipd; ++sym1__) {
        param_names__.emplace_back(std::string() + "E_eta_ipd" + '.' +
          std::to_string(sym1__));
      }
      for (int sym1__ = 1; sym1__ <= ni_agd_arm; ++sym1__) {
        param_names__.emplace_back(std::string() + "E_theta_agd_arm" + '.' +
          std::to_string(sym1__));
      }
      for (int sym1__ = 1; sym1__ <= ni_ipd; ++sym1__) {
        param_names__.emplace_back(std::string() + "theta_ipd" + '.' +
          std::to_string(sym1__));
      }
      for (int sym1__ = 1; sym1__ <= theta_agd_arm_ii_1dim__; ++sym1__) {
        param_names__.emplace_back(std::string() + "theta_agd_arm_ii" + '.' +
          std::to_string(sym1__));
      }
      for (int sym1__ = 1; sym1__ <= ni_agd_arm; ++sym1__) {
        param_names__.emplace_back(std::string() + "theta_agd_arm_bar" + '.'
          + std::to_string(sym1__));
      }
      for (int sym1__ = 1; sym1__ <= ni_ipd; ++sym1__) {
        param_names__.emplace_back(std::string() + "eta_ipd" + '.' +
          std::to_string(sym1__));
      }
      for (int sym1__ = 1; sym1__ <= n_delta; ++sym1__) {
        param_names__.emplace_back(std::string() + "f_delta" + '.' +
          std::to_string(sym1__));
      }
      for (int sym1__ = 1; sym1__ <= f_class_1dim__; ++sym1__) {
        param_names__.emplace_back(std::string() + "f_class" + '.' +
          std::to_string(sym1__));
      }
      for (int sym1__ = 1; sym1__ <= nX; ++sym1__) {
        param_names__.emplace_back(std::string() + "allbeta" + '.' +
          std::to_string(sym1__));
      }
      for (int sym1__ = 1; sym1__ <= totns; ++sym1__) {
        param_names__.emplace_back(std::string() + "mu" + '.' +
          std::to_string(sym1__));
      }
      for (int sym1__ = 1; sym1__ <= d_1dim__; ++sym1__) {
        param_names__.emplace_back(std::string() + "d" + '.' +
          std::to_string(sym1__));
      }
      for (int sym1__ = 1; sym1__ <= nodesplit; ++sym1__) {
        param_names__.emplace_back(std::string() + "omega" + '.' +
          std::to_string(sym1__));
      }
      for (int sym1__ = 1; sym1__ <= beta_1dim__; ++sym1__) {
        param_names__.emplace_back(std::string() + "beta" + '.' +
          std::to_string(sym1__));
      }
      for (int sym1__ = 1; sym1__ <= eta_agd_contrast_ii_1dim__; ++sym1__) {
        param_names__.emplace_back(std::string() + "eta_agd_contrast_ii" +
          '.' + std::to_string(sym1__));
      }
      for (int sym1__ = 1; sym1__ <= ni_agd_contrast; ++sym1__) {
        param_names__.emplace_back(std::string() + "eta_agd_contrast_bar" +
          '.' + std::to_string(sym1__));
      }
    }
    if (emit_generated_quantities__) {
      for (int sym1__ = 1; sym1__ <= ni_ipd; ++sym1__) {
        param_names__.emplace_back(std::string() + "fitted_ipd" + '.' +
          std::to_string(sym1__));
      }
      for (int sym1__ = 1; sym1__ <= ni_agd_arm; ++sym1__) {
        param_names__.emplace_back(std::string() + "fitted_agd_arm" + '.' +
          std::to_string(sym1__));
      }
      for (int sym1__ = 1; sym1__ <= theta_bar_cum_agd_arm_1dim__; ++sym1__) {
        param_names__.emplace_back(std::string() + "theta_bar_cum_agd_arm" +
          '.' + std::to_string(sym1__));
      }
      for (int sym1__ = 1; sym1__ <= log_lik_1dim__; ++sym1__) {
        param_names__.emplace_back(std::string() + "log_lik" + '.' +
          std::to_string(sym1__));
      }
      for (int sym1__ = 1; sym1__ <= resdev_1dim__; ++sym1__) {
        param_names__.emplace_back(std::string() + "resdev" + '.' +
          std::to_string(sym1__));
      }
      for (int sym1__ = 1; sym1__ <= ni_agd_contrast; ++sym1__) {
        param_names__.emplace_back(std::string() + "fitted_agd_contrast" +
          '.' + std::to_string(sym1__));
      }
      for (int sym1__ = 1; sym1__ <=
           theta_bar_cum_agd_contrast_1dim__; ++sym1__) {
        param_names__.emplace_back(std::string() +
          "theta_bar_cum_agd_contrast" + '.' + std::to_string(sym1__));
      }
      for (int sym1__ = 1; sym1__ <= n_delta; ++sym1__) {
        param_names__.emplace_back(std::string() + "delta" + '.' +
          std::to_string(sym1__));
      }
    }
  }
  inline std::string get_constrained_sizedtypes() const {
    return std::string("[{\"name\":\"beta_tilde\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(nX) + "},\"block\":\"parameters\"},{\"name\":\"u_delta\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(n_delta) + "},\"block\":\"parameters\"},{\"name\":\"tau\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(tau_1dim__) + "},\"block\":\"parameters\"},{\"name\":\"class_mean\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(class_mean_1dim__) + "},\"block\":\"parameters\"},{\"name\":\"class_sd\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(class_sd_1dim__) + "},\"block\":\"parameters\"},{\"name\":\"z_class\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(z_class_1dim__) + "},\"block\":\"parameters\"},{\"name\":\"E_eta_ipd\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(ni_ipd) + "},\"block\":\"transformed_parameters\"},{\"name\":\"E_theta_agd_arm\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(ni_agd_arm) + "},\"block\":\"transformed_parameters\"},{\"name\":\"theta_ipd\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(ni_ipd) + "},\"block\":\"transformed_parameters\"},{\"name\":\"theta_agd_arm_ii\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(theta_agd_arm_ii_1dim__) + "},\"block\":\"transformed_parameters\"},{\"name\":\"theta_agd_arm_bar\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(ni_agd_arm) + "},\"block\":\"transformed_parameters\"},{\"name\":\"eta_ipd\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(ni_ipd) + "},\"block\":\"transformed_parameters\"},{\"name\":\"f_delta\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(n_delta) + "},\"block\":\"transformed_parameters\"},{\"name\":\"f_class\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(f_class_1dim__) + "},\"block\":\"transformed_parameters\"},{\"name\":\"allbeta\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(nX) + "},\"block\":\"transformed_parameters\"},{\"name\":\"mu\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(totns) + "},\"block\":\"transformed_parameters\"},{\"name\":\"d\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(d_1dim__) + "},\"block\":\"transformed_parameters\"},{\"name\":\"omega\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(nodesplit) + "},\"block\":\"transformed_parameters\"},{\"name\":\"beta\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(beta_1dim__) + "},\"block\":\"transformed_parameters\"},{\"name\":\"eta_agd_contrast_ii\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(eta_agd_contrast_ii_1dim__) + "},\"block\":\"transformed_parameters\"},{\"name\":\"eta_agd_contrast_bar\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(ni_agd_contrast) + "},\"block\":\"transformed_parameters\"},{\"name\":\"fitted_ipd\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(ni_ipd) + "},\"block\":\"generated_quantities\"},{\"name\":\"fitted_agd_arm\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(ni_agd_arm) + "},\"block\":\"generated_quantities\"},{\"name\":\"theta_bar_cum_agd_arm\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(theta_bar_cum_agd_arm_1dim__) + "},\"block\":\"generated_quantities\"},{\"name\":\"log_lik\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(log_lik_1dim__) + "},\"block\":\"generated_quantities\"},{\"name\":\"resdev\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(resdev_1dim__) + "},\"block\":\"generated_quantities\"},{\"name\":\"fitted_agd_contrast\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(ni_agd_contrast) + "},\"block\":\"generated_quantities\"},{\"name\":\"theta_bar_cum_agd_contrast\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(theta_bar_cum_agd_contrast_1dim__) + "},\"block\":\"generated_quantities\"},{\"name\":\"delta\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(n_delta) + "},\"block\":\"generated_quantities\"}]");
  }
  inline std::string get_unconstrained_sizedtypes() const {
    return std::string("[{\"name\":\"beta_tilde\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(nX) + "},\"block\":\"parameters\"},{\"name\":\"u_delta\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(n_delta) + "},\"block\":\"parameters\"},{\"name\":\"tau\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(tau_1dim__) + "},\"block\":\"parameters\"},{\"name\":\"class_mean\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(class_mean_1dim__) + "},\"block\":\"parameters\"},{\"name\":\"class_sd\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(class_sd_1dim__) + "},\"block\":\"parameters\"},{\"name\":\"z_class\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(z_class_1dim__) + "},\"block\":\"parameters\"},{\"name\":\"E_eta_ipd\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(ni_ipd) + "},\"block\":\"transformed_parameters\"},{\"name\":\"E_theta_agd_arm\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(ni_agd_arm) + "},\"block\":\"transformed_parameters\"},{\"name\":\"theta_ipd\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(ni_ipd) + "},\"block\":\"transformed_parameters\"},{\"name\":\"theta_agd_arm_ii\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(theta_agd_arm_ii_1dim__) + "},\"block\":\"transformed_parameters\"},{\"name\":\"theta_agd_arm_bar\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(ni_agd_arm) + "},\"block\":\"transformed_parameters\"},{\"name\":\"eta_ipd\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(ni_ipd) + "},\"block\":\"transformed_parameters\"},{\"name\":\"f_delta\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(n_delta) + "},\"block\":\"transformed_parameters\"},{\"name\":\"f_class\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(f_class_1dim__) + "},\"block\":\"transformed_parameters\"},{\"name\":\"allbeta\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(nX) + "},\"block\":\"transformed_parameters\"},{\"name\":\"mu\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(totns) + "},\"block\":\"transformed_parameters\"},{\"name\":\"d\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(d_1dim__) + "},\"block\":\"transformed_parameters\"},{\"name\":\"omega\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(nodesplit) + "},\"block\":\"transformed_parameters\"},{\"name\":\"beta\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(beta_1dim__) + "},\"block\":\"transformed_parameters\"},{\"name\":\"eta_agd_contrast_ii\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(eta_agd_contrast_ii_1dim__) + "},\"block\":\"transformed_parameters\"},{\"name\":\"eta_agd_contrast_bar\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(ni_agd_contrast) + "},\"block\":\"transformed_parameters\"},{\"name\":\"fitted_ipd\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(ni_ipd) + "},\"block\":\"generated_quantities\"},{\"name\":\"fitted_agd_arm\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(ni_agd_arm) + "},\"block\":\"generated_quantities\"},{\"name\":\"theta_bar_cum_agd_arm\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(theta_bar_cum_agd_arm_1dim__) + "},\"block\":\"generated_quantities\"},{\"name\":\"log_lik\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(log_lik_1dim__) + "},\"block\":\"generated_quantities\"},{\"name\":\"resdev\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(resdev_1dim__) + "},\"block\":\"generated_quantities\"},{\"name\":\"fitted_agd_contrast\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(ni_agd_contrast) + "},\"block\":\"generated_quantities\"},{\"name\":\"theta_bar_cum_agd_contrast\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(theta_bar_cum_agd_contrast_1dim__) + "},\"block\":\"generated_quantities\"},{\"name\":\"delta\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(n_delta) + "},\"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__ = (((((nX + n_delta) + tau_1dim__) +
      class_mean_1dim__) + class_sd_1dim__) + z_class_1dim__);
    const size_t num_transformed = emit_transformed_parameters *
      (((((((((((((((ni_ipd + ni_agd_arm) + ni_ipd) +
      theta_agd_arm_ii_1dim__) + ni_agd_arm) + ni_ipd) + n_delta) +
      f_class_1dim__) + nX) + totns) + d_1dim__) + nodesplit) + beta_1dim__)
      + eta_agd_contrast_ii_1dim__) + ni_agd_contrast));
    const size_t num_gen_quantities = emit_generated_quantities *
      ((((((((ni_ipd + ni_agd_arm) + theta_bar_cum_agd_arm_1dim__) +
      log_lik_1dim__) + resdev_1dim__) + ni_agd_contrast) +
      theta_bar_cum_agd_contrast_1dim__) + n_delta));
    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__ = (((((nX + n_delta) + tau_1dim__) +
      class_mean_1dim__) + class_sd_1dim__) + z_class_1dim__);
    const size_t num_transformed = emit_transformed_parameters *
      (((((((((((((((ni_ipd + ni_agd_arm) + ni_ipd) +
      theta_agd_arm_ii_1dim__) + ni_agd_arm) + ni_ipd) + n_delta) +
      f_class_1dim__) + nX) + totns) + d_1dim__) + nodesplit) + beta_1dim__)
      + eta_agd_contrast_ii_1dim__) + ni_agd_contrast));
    const size_t num_gen_quantities = emit_generated_quantities *
      ((((((((ni_ipd + ni_agd_arm) + theta_bar_cum_agd_arm_1dim__) +
      log_lik_1dim__) + resdev_1dim__) + ni_agd_contrast) +
      theta_bar_cum_agd_contrast_1dim__) + n_delta));
    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_poisson_namespace::model_poisson;
#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_poisson_namespace::profiles__;
}
#endif
#endif
