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

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

    disbayes 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 disbayes.  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_disbayes_namespace {
using stan::model::model_base_crtp;
using namespace stan::math;
stan::math::profile_map profiles__;
static constexpr std::array<const char*, 387> locations_array__ =
  {" (found before start of program)",
  " (in 'string', line 152, column 2 to column 47)",
  " (in 'string', line 153, column 2 to column 45)",
  " (in 'string', line 154, column 2 to column 89)",
  " (in 'string', line 155, column 2 to column 40)",
  " (in 'string', line 156, column 2 to column 55)",
  " (in 'string', line 157, column 2 to column 58)",
  " (in 'string', line 158, column 2 to column 32)",
  " (in 'string', line 159, column 2 to column 58)",
  " (in 'string', line 160, column 2 to column 32)",
  " (in 'string', line 161, column 2 to column 46)",
  " (in 'string', line 163, column 2 to column 30)",
  " (in 'string', line 164, column 2 to column 42)",
  " (in 'string', line 167, column 2 to column 27)",
  " (in 'string', line 168, column 2 to column 42)",
  " (in 'string', line 169, column 2 to column 34)",
  " (in 'string', line 170, column 2 to column 47)",
  " (in 'string', line 171, column 2 to column 28)",
  " (in 'string', line 172, column 2 to column 51)",
  " (in 'string', line 173, column 2 to column 40)",
  " (in 'string', line 175, column 2 to column 60)",
  " (in 'string', line 176, column 2 to column 20)",
  " (in 'string', line 177, column 2 to column 33)",
  " (in 'string', line 178, column 2 to column 40)",
  " (in 'string', line 179, column 2 to column 38)",
  " (in 'string', line 180, column 2 to column 46)",
  " (in 'string', line 181, column 2 to column 57)",
  " (in 'string', line 182, column 2 to column 69)",
  " (in 'string', line 183, column 2 to column 30)",
  " (in 'string', line 184, column 2 to column 31)",
  " (in 'string', line 185, column 2 to column 31)",
  " (in 'string', line 367, column 2 to column 23)",
  " (in 'string', line 368, column 2 to column 35)",
  " (in 'string', line 369, column 2 to column 37)",
  " (in 'string', line 370, column 2 to column 32)",
  " (in 'string', line 371, column 2 to column 73)",
  " (in 'string', line 186, column 71 to column 100)",
  " (in 'string', line 186, column 33 to column 65)",
  " (in 'string', line 186, column 2 to column 100)",
  " (in 'string', line 187, column 75 to column 106)",
  " (in 'string', line 187, column 35 to column 69)",
  " (in 'string', line 187, column 2 to column 106)",
  " (in 'string', line 188, column 75 to column 106)",
  " (in 'string', line 188, column 35 to column 69)",
  " (in 'string', line 188, column 2 to column 106)",
  " (in 'string', line 192, column 56 to column 80)",
  " (in 'string', line 192, column 18 to column 50)",
  " (in 'string', line 192, column 2 to column 80)",
  " (in 'string', line 194, column 4 to column 60)",
  " (in 'string', line 193, column 17 to line 195, column 3)",
  " (in 'string', line 193, column 2 to line 195, column 3)",
  " (in 'string', line 203, column 9 to column 35)",
  " (in 'string', line 202, column 9 to column 23)",
  " (in 'string', line 201, column 25 to column 47)",
  " (in 'string', line 201, column 9 to line 202, column 23)",
  " (in 'string', line 199, column 1 to column 21)",
  " (in 'string', line 198, column 6 to line 199, column 21)",
  " (in 'string', line 197, column 19 to line 200, column 5)",
  " (in 'string', line 197, column 4 to line 202, column 23)",
  " (in 'string', line 196, column 17 to line 203, column 3)",
  " (in 'string', line 196, column 2 to line 203, column 35)",
  " (in 'string', line 209, column 9 to column 28)",
  " (in 'string', line 208, column 6 to column 35)",
  " (in 'string', line 207, column 4 to line 209, column 28)",
  " (in 'string', line 206, column 21 to line 210, column 3)",
  " (in 'string', line 206, column 2 to line 210, column 3)",
  " (in 'string', line 224, column 39 to column 51)",
  " (in 'string', line 224, column 16 to column 33)",
  " (in 'string', line 224, column 1 to column 51)",
  " (in 'string', line 223, column 9 to line 225, column 3)",
  " (in 'string', line 215, column 8 to column 26)",
  " (in 'string', line 214, column 28 to line 216, column 7)",
  " (in 'string', line 214, column 6 to line 216, column 7)",
  " (in 'string', line 219, column 13 to column 39)",
  " (in 'string', line 218, column 1 to column 19)",
  " (in 'string', line 217, column 20 to line 219, column 7)",
  " (in 'string', line 217, column 6 to line 219, column 39)",
  " (in 'string', line 221, column 1 to column 26)",
  " (in 'string', line 220, column 27 to line 222, column 7)",
  " (in 'string', line 220, column 6 to line 222, column 7)",
  " (in 'string', line 212, column 21 to line 223, column 3)",
  " (in 'string', line 212, column 2 to line 225, column 3)",
  " (in 'string', line 252, column 6 to column 29)",
  " (in 'string', line 253, column 6 to column 29)",
  " (in 'string', line 254, column 6 to column 29)",
  " (in 'string', line 251, column 22 to line 255, column 5)",
  " (in 'string', line 251, column 4 to line 255, column 5)",
  " (in 'string', line 250, column 9 to line 256, column 3)",
  " (in 'string', line 228, column 4 to column 21)",
  " (in 'string', line 230, column 6 to column 44)",
  " (in 'string', line 229, column 20 to line 231, column 5)",
  " (in 'string', line 229, column 4 to line 231, column 5)",
  " (in 'string', line 235, column 3 to column 47)",
  " (in 'string', line 234, column 18 to line 236, column 2)",
  " (in 'string', line 234, column 1 to line 236, column 2)",
  " (in 'string', line 233, column 22 to line 237, column 7)",
  " (in 'string', line 233, column 6 to line 237, column 7)",
  " (in 'string', line 240, column 1 to column 29)",
  " (in 'string', line 241, column 1 to column 29)",
  " (in 'string', line 242, column 1 to column 29)",
  " (in 'string', line 246, column 3 to column 52)",
  " (in 'string', line 245, column 22 to line 247, column 2)",
  " (in 'string', line 245, column 1 to line 247, column 2)",
  " (in 'string', line 239, column 23 to line 248, column 7)",
  " (in 'string', line 239, column 6 to line 248, column 7)",
  " (in 'string', line 232, column 22 to line 249, column 5)",
  " (in 'string', line 232, column 4 to line 249, column 5)",
  " (in 'string', line 226, column 13 to line 250, column 3)",
  " (in 'string', line 226, column 2 to line 256, column 3)",
  " (in 'string', line 279, column 1 to column 42)",
  " (in 'string', line 280, column 1 to column 45)",
  " (in 'string', line 282, column 3 to column 83)",
  " (in 'string', line 281, column 1 to line 282, column 83)",
  " (in 'string', line 283, column 1 to column 32)",
  " (in 'string', line 284, column 1 to column 30)",
  " (in 'string', line 286, column 3 to column 70)",
  " (in 'string', line 287, column 3 to column 35)",
  " (in 'string', line 289, column 5 to column 26)",
  " (in 'string', line 288, column 3 to line 289, column 26)",
  " (in 'string', line 285, column 11 to line 290, column 2)",
  " (in 'string', line 285, column 1 to line 290, column 2)",
  " (in 'string', line 278, column 24 to line 291, column 7)",
  " (in 'string', line 278, column 6 to line 291, column 7)",
  " (in 'string', line 277, column 11 to line 292, column 5)",
  " (in 'string', line 261, column 3 to column 9)",
  " (in 'string', line 263, column 5 to column 21)",
  " (in 'string', line 264, column 5 to column 69)",
  " (in 'string', line 265, column 5 to column 48)",
  " (in 'string', line 266, column 5 to column 40)",
  " (in 'string', line 262, column 17 to line 267, column 4)",
  " (in 'string', line 262, column 3 to line 267, column 4)",
  " (in 'string', line 260, column 12 to line 268, column 2)",
  " (in 'string', line 260, column 1 to line 268, column 2)",
  " (in 'string', line 270, column 1 to column 56)",
  " (in 'string', line 271, column 1 to column 45)",
  " (in 'string', line 272, column 1 to line 273, column 59)",
  " (in 'string', line 274, column 11 to column 78)",
  " (in 'string', line 274, column 1 to column 78)",
  " (in 'string', line 275, column 1 to column 33)",
  " (in 'string', line 259, column 24 to line 276, column 7)",
  " (in 'string', line 259, column 6 to line 276, column 7)",
  " (in 'string', line 258, column 15 to line 277, column 5)",
  " (in 'string', line 258, column 4 to line 292, column 5)",
  " (in 'string', line 294, column 4 to column 44)",
  " (in 'string', line 257, column 19 to line 295, column 3)",
  " (in 'string', line 257, column 2 to line 295, column 3)",
  " (in 'string', line 373, column 6 to column 76)",
  " (in 'string', line 375, column 1 to column 67)",
  " (in 'string', line 374, column 6 to line 375, column 67)",
  " (in 'string', line 377, column 1 to column 71)",
  " (in 'string', line 376, column 6 to line 377, column 71)",
  " (in 'string', line 379, column 3 to column 69)",
  " (in 'string', line 378, column 6 to line 379, column 69)",
  " (in 'string', line 372, column 20 to line 380, column 3)",
  " (in 'string', line 372, column 2 to line 380, column 3)",
  " (in 'string', line 381, column 2 to column 84)",
  " (in 'string', line 298, column 2 to column 45)",
  " (in 'string', line 299, column 2 to column 62)",
  " (in 'string', line 300, column 2 to column 66)",
  " (in 'string', line 302, column 4 to column 44)",
  " (in 'string', line 301, column 17 to line 303, column 3)",
  " (in 'string', line 301, column 2 to line 303, column 3)",
  " (in 'string', line 319, column 6 to column 50)",
  " (in 'string', line 318, column 21 to line 320, column 5)",
  " (in 'string', line 318, column 4 to line 320, column 5)",
  " (in 'string', line 317, column 7 to line 321, column 3)",
  " (in 'string', line 308, column 1 to column 36)",
  " (in 'string', line 307, column 25 to line 309, column 7)",
  " (in 'string', line 307, column 6 to line 309, column 7)",
  " (in 'string', line 311, column 1 to column 26)",
  " (in 'string', line 310, column 24 to line 312, column 7)",
  " (in 'string', line 310, column 6 to line 312, column 7)",
  " (in 'string', line 306, column 19 to line 313, column 5)",
  " (in 'string', line 306, column 4 to line 313, column 5)",
  " (in 'string', line 315, column 6 to column 41)",
  " (in 'string', line 314, column 4 to line 315, column 41)",
  " (in 'string', line 305, column 18 to line 316, column 3)",
  " (in 'string', line 305, column 2 to line 321, column 3)",
  " (in 'string', line 323, column 4 to column 48)",
  " (in 'string', line 322, column 21 to line 324, column 3)",
  " (in 'string', line 322, column 2 to line 324, column 3)",
  " (in 'string', line 337, column 6 to column 53)",
  " (in 'string', line 336, column 21 to line 338, column 5)",
  " (in 'string', line 336, column 4 to line 338, column 5)",
  " (in 'string', line 335, column 7 to line 339, column 3)",
  " (in 'string', line 327, column 6 to column 46)",
  " (in 'string', line 326, column 23 to line 328, column 5)",
  " (in 'string', line 326, column 4 to line 328, column 5)",
  " (in 'string', line 330, column 6 to column 35)",
  " (in 'string', line 329, column 22 to line 331, column 5)",
  " (in 'string', line 329, column 4 to line 331, column 5)",
  " (in 'string', line 333, column 6 to column 42)",
  " (in 'string', line 332, column 4 to line 333, column 42)",
  " (in 'string', line 325, column 19 to line 334, column 3)",
  " (in 'string', line 325, column 2 to line 339, column 3)",
  " (in 'string', line 354, column 1 to column 48)",
  " (in 'string', line 353, column 23 to line 355, column 7)",
  " (in 'string', line 353, column 6 to line 355, column 7)",
  " (in 'string', line 352, column 9 to line 356, column 5)",
  " (in 'string', line 351, column 26 to column 73)",
  " (in 'string', line 351, column 11 to line 356, column 5)",
  " (in 'string', line 344, column 1 to column 41)",
  " (in 'string', line 343, column 25 to line 345, column 7)",
  " (in 'string', line 343, column 6 to line 345, column 7)",
  " (in 'string', line 347, column 1 to column 30)",
  " (in 'string', line 346, column 24 to line 348, column 7)",
  " (in 'string', line 346, column 6 to line 348, column 7)",
  " (in 'string', line 350, column 1 to column 37)",
  " (in 'string', line 349, column 6 to line 350, column 37)",
  " (in 'string', line 342, column 21 to line 351, column 5)",
  " (in 'string', line 342, column 4 to line 356, column 5)",
  " (in 'string', line 341, column 17 to line 357, column 3)",
  " (in 'string', line 341, column 2 to line 357, column 3)",
  " (in 'string', line 360, column 4 to column 29)",
  " (in 'string', line 359, column 15 to line 361, column 3)",
  " (in 'string', line 359, column 2 to line 361, column 3)",
  " (in 'string', line 363, column 4 to column 28)",
  " (in 'string', line 362, column 16 to line 364, column 3)",
  " (in 'string', line 362, column 2 to line 364, column 3)",
  " (in 'string', line 103, column 2 to column 19)",
  " (in 'string', line 104, column 2 to column 20)",
  " (in 'string', line 105, column 2 to column 16)",
  " (in 'string', line 106, column 2 to column 17)",
  " (in 'string', line 107, column 2 to column 17)",
  " (in 'string', line 108, column 2 to column 16)",
  " (in 'string', line 109, column 2 to column 12)",
  " (in 'string', line 110, column 2 to column 16)",
  " (in 'string', line 111, column 2 to column 20)",
  " (in 'string', line 112, column 2 to column 21)",
  " (in 'string', line 113, column 8 to column 12)",
  " (in 'string', line 113, column 2 to column 36)",
  " (in 'string', line 114, column 8 to column 12)",
  " (in 'string', line 114, column 2 to column 38)",
  " (in 'string', line 115, column 8 to column 12)",
  " (in 'string', line 115, column 2 to column 36)",
  " (in 'string', line 116, column 8 to column 12)",
  " (in 'string', line 116, column 2 to column 38)",
  " (in 'string', line 117, column 8 to column 12)",
  " (in 'string', line 117, column 2 to column 35)",
  " (in 'string', line 118, column 8 to column 12)",
  " (in 'string', line 118, column 2 to column 37)",
  " (in 'string', line 119, column 8 to column 12)",
  " (in 'string', line 119, column 2 to column 35)",
  " (in 'string', line 120, column 8 to column 12)",
  " (in 'string', line 120, column 2 to column 37)",
  " (in 'string', line 121, column 2 to column 19)",
  " (in 'string', line 124, column 2 to column 17)",
  " (in 'string', line 125, column 9 to column 13)",
  " (in 'string', line 125, column 14 to column 15)",
  " (in 'string', line 125, column 2 to column 19)",
  " (in 'string', line 126, column 2 to column 32)",
  " (in 'string', line 128, column 2 to column 20)",
  " (in 'string', line 129, column 2 to column 15)",
  " (in 'string', line 130, column 2 to column 16)",
  " (in 'string', line 131, column 2 to column 12)",
  " (in 'string', line 133, column 2 to column 18)",
  " (in 'string', line 134, column 2 to column 19)",
  " (in 'string', line 138, column 18 to column 22)",
  " (in 'string', line 138, column 23 to column 26)",
  " (in 'string', line 138, column 2 to column 38)",
  " (in 'string', line 139, column 18 to column 22)",
  " (in 'string', line 139, column 23 to column 26)",
  " (in 'string', line 139, column 2 to column 37)",
  " (in 'string', line 140, column 2 to column 35)",
  " (in 'string', line 141, column 2 to column 34)",
  " (in 'string', line 142, column 2 to column 35)",
  " (in 'string', line 144, column 2 to column 18)",
  " (in 'string', line 145, column 2 to column 19)",
  " (in 'string', line 146, column 2 to column 19)",
  " (in 'string', line 147, column 2 to column 32)",
  " (in 'string', line 148, column 2 to column 33)",
  " (in 'string', line 149, column 2 to column 33)",
  " (in 'string', line 152, column 18 to column 37)",
  " (in 'string', line 153, column 18 to column 36)",
  " (in 'string', line 154, column 18 to column 79)",
  " (in 'string', line 155, column 9 to column 33)",
  " (in 'string', line 156, column 18 to column 43)",
  " (in 'string', line 157, column 18 to column 45)",
  " (in 'string', line 158, column 9 to column 21)",
  " (in 'string', line 159, column 18 to column 45)",
  " (in 'string', line 160, column 9 to column 21)",
  " (in 'string', line 161, column 26 to column 35)",
  " (in 'string', line 163, column 9 to column 17)",
  " (in 'string', line 164, column 18 to column 33)",
  " (in 'string', line 167, column 18 to column 22)",
  " (in 'string', line 168, column 18 to column 36)",
  " (in 'string', line 169, column 18 to column 22)",
  " (in 'string', line 169, column 23 to column 28)",
  " (in 'string', line 170, column 26 to column 30)",
  " (in 'string', line 170, column 31 to column 36)",
  " (in 'string', line 171, column 18 to column 22)",
  " (in 'string', line 172, column 26 to column 40)",
  " (in 'string', line 173, column 26 to column 30)",
  " (in 'string', line 175, column 8 to column 26)",
  " (in 'string', line 175, column 27 to column 32)",
  " (in 'string', line 178, column 18 to column 22)",
  " (in 'string', line 178, column 23 to column 28)",
  " (in 'string', line 179, column 8 to column 12)",
  " (in 'string', line 180, column 18 to column 28)",
  " (in 'string', line 180, column 29 to column 38)",
  " (in 'string', line 181, column 8 to column 18)",
  " (in 'string', line 181, column 19 to column 28)",
  " (in 'string', line 181, column 29 to column 34)",
  " (in 'string', line 182, column 8 to column 22)",
  " (in 'string', line 182, column 23 to column 32)",
  " (in 'string', line 182, column 33 to column 38)",
  " (in 'string', line 367, column 9 to column 13)",
  " (in 'string', line 368, column 9 to column 26)",
  " (in 'string', line 369, column 9 to column 27)",
  " (in 'string', line 370, column 9 to column 23)",
  " (in 'string', line 371, column 9 to column 60)",
  " (in 'string', line 11, column 4 to column 23)",
  " (in 'string', line 12, column 4 to column 61)",
  " (in 'string', line 13, column 4 to column 31)",
  " (in 'string', line 14, column 4 to column 31)",
  " (in 'string', line 15, column 4 to column 18)",
  " (in 'string', line 16, column 4 to column 57)",
  " (in 'string', line 17, column 4 to column 23)",
  " (in 'string', line 18, column 4 to column 15)",
  " (in 'string', line 20, column 4 to column 25)",
  " (in 'string', line 21, column 4 to column 54)",
  " (in 'string', line 22, column 4 to column 15)",
  " (in 'string', line 24, column 4 to column 44)",
  " (in 'string', line 25, column 4 to column 51)",
  " (in 'string', line 26, column 4 to column 15)",
  " (in 'string', line 27, column 4 to column 13)",
  " (in 'string', line 10, column 50 to line 28, column 3)",
  " (in 'string', line 31, column 4 to column 19)",
  " (in 'string', line 32, column 4 to column 38)",
  " (in 'string', line 33, column 4 to column 31)",
  " (in 'string', line 34, column 4 to column 31)",
  " (in 'string', line 35, column 4 to column 18)",
  " (in 'string', line 36, column 4 to column 53)",
  " (in 'string', line 37, column 4 to column 15)",
  " (in 'string', line 38, column 4 to column 15)",
  " (in 'string', line 40, column 4 to column 25)",
  " (in 'string', line 41, column 4 to column 50)",
  " (in 'string', line 42, column 4 to column 15)",
  " (in 'string', line 44, column 4 to column 44)",
  " (in 'string', line 45, column 4 to column 51)",
  " (in 'string', line 46, column 4 to column 15)",
  " (in 'string', line 47, column 4 to column 13)",
  " (in 'string', line 30, column 47 to line 48, column 3)",
  " (in 'string', line 51, column 4 to column 18)",
  " (in 'string', line 52, column 4 to column 21)",
  " (in 'string', line 53, column 4 to column 23)",
  " (in 'string', line 54, column 4 to column 38)",
  " (in 'string', line 56, column 4 to column 15)",
  " (in 'string', line 57, column 4 to column 21)",
  " (in 'string', line 58, column 4 to column 25)",
  " (in 'string', line 60, column 4 to column 15)",
  " (in 'string', line 61, column 4 to column 15)",
  " (in 'string', line 62, column 4 to column 15)",
  " (in 'string', line 63, column 4 to column 13)",
  " (in 'string', line 50, column 38 to line 64, column 3)",
  " (in 'string', line 67, column 6 to column 21)",
  " (in 'string', line 70, column 3 to column 20)",
  " (in 'string', line 71, column 19 to column 31)",
  " (in 'string', line 71, column 3 to column 31)",
  " (in 'string', line 72, column 19 to column 31)",
  " (in 'string', line 72, column 3 to column 31)",
  " (in 'string', line 69, column 16 to line 73, column 2)",
  " (in 'string', line 69, column 1 to line 73, column 2)",
  " (in 'string', line 68, column 21 to line 74, column 7)",
  " (in 'string', line 68, column 6 to line 74, column 7)",
  " (in 'string', line 75, column 6 to column 16)",
  " (in 'string', line 66, column 29 to line 76, column 5)",
  " (in 'string', line 79, column 4 to column 18)",
  " (in 'string', line 86, column 1 to column 32)",
  " (in 'string', line 84, column 1 to column 28)",
  " (in 'string', line 83, column 6 to line 86, column 32)",
  " (in 'string', line 82, column 9 to line 87, column 5)",
  " (in 'string', line 81, column 6 to column 35)",
  " (in 'string', line 80, column 4 to line 87, column 5)",
  " (in 'string', line 88, column 4 to column 23)",
  " (in 'string', line 78, column 45 to line 89, column 3)",
  " (in 'string', line 92, column 4 to column 13)",
  " (in 'string', line 97, column 13 to column 21)",
  " (in 'string', line 97, column 11 to column 23)",
  " (in 'string', line 96, column 6 to column 32)",
  " (in 'string', line 95, column 23 to line 97, column 5)",
  " (in 'string', line 95, column 11 to line 97, column 23)",
  " (in 'string', line 94, column 6 to column 36)",
  " (in 'string', line 93, column 16 to line 95, column 5)",
  " (in 'string', line 93, column 4 to line 97, column 23)",
  " (in 'string', line 98, column 4 to column 13)",
  " (in 'string', line 91, column 25 to line 99, column 3)"};
template <typename T0__, typename T1__, typename T2__,
          stan::require_all_t<stan::is_stan_scalar<T0__>,
                              stan::is_stan_scalar<T1__>,
                              stan::is_stan_scalar<T2__>>* = nullptr>
Eigen::Matrix<stan::promote_args_t<T0__, T1__, T2__>,-1,-1>
trans_probs_rem(const T0__& i, const T1__& f, const T2__& r, std::ostream*
                pstream__);
template <typename T0__, typename T1__,
          stan::require_all_t<stan::is_stan_scalar<T0__>,
                              stan::is_stan_scalar<T1__>>* = nullptr>
Eigen::Matrix<stan::promote_args_t<T0__, T1__>,-1,-1>
trans_probs_norem_if(const T0__& i, const T1__& f, std::ostream* pstream__);
template <typename T0__,
          stan::require_all_t<stan::is_stan_scalar<T0__>>* = nullptr>
Eigen::Matrix<stan::promote_args_t<T0__>,-1,-1>
trans_probs_norem_i(const T0__& i, std::ostream* pstream__);
template <typename T0__,
          stan::require_all_t<stan::is_eigen_matrix_dynamic<T0__>,
                              stan::is_vt_not_complex<T0__>>* = nullptr>
Eigen::Matrix<stan::promote_args_t<stan::base_type_t<T0__>>,-1,-1>
defuzz_P(const T0__& P_arg__, std::ostream* pstream__);
template <typename T0__, typename T1__, typename T2__,
          stan::require_all_t<stan::is_stan_scalar<T0__>,
                              stan::is_stan_scalar<T1__>,
                              stan::is_stan_scalar<T2__>>* = nullptr>
Eigen::Matrix<stan::promote_args_t<T0__, T1__, T2__>,-1,-1>
trans_probs(const T0__& i, const T1__& f, const T2__& r, std::ostream*
            pstream__);
template <typename T0__,
          stan::require_all_t<stan::is_stan_scalar<T0__>>* = nullptr>
stan::promote_args_t<T0__> bound_prob(const T0__& x, std::ostream* pstream__);
template <typename T0__, typename T1__, typename T2__,
          stan::require_all_t<stan::is_stan_scalar<T0__>,
                              stan::is_stan_scalar<T1__>,
                              stan::is_stan_scalar<T2__>>*>
Eigen::Matrix<stan::promote_args_t<T0__, T1__, T2__>,-1,-1>
trans_probs_rem(const T0__& i, const T1__& f, const T2__& r, std::ostream*
                pstream__) {
  using local_scalar_t__ = stan::promote_args_t<T0__, T1__, T2__>;
  int current_statement__ = 0;
  static constexpr bool propto__ = true;
  // suppress unused var warning
  (void) propto__;
  local_scalar_t__ DUMMY_VAR__(std::numeric_limits<double>::quiet_NaN());
  // suppress unused var warning
  (void) DUMMY_VAR__;
  try {
    local_scalar_t__ l = DUMMY_VAR__;
    current_statement__ = 311;
    l = ((i + r) + f);
    local_scalar_t__ q = DUMMY_VAR__;
    current_statement__ = 312;
    q = stan::math::sqrt(((((((i * i) + ((2 * i) * r)) - ((2 * i) * f)) + (r
          * r)) + ((2 * f) * r)) + (f * f)));
    local_scalar_t__ w = DUMMY_VAR__;
    current_statement__ = 313;
    w = stan::math::exp((-(l + q) / 2));
    local_scalar_t__ v = DUMMY_VAR__;
    current_statement__ = 314;
    v = stan::math::exp((-(l - q) / 2));
    Eigen::Matrix<local_scalar_t__,-1,-1> P =
      Eigen::Matrix<local_scalar_t__,-1,-1>::Constant(3, 3, DUMMY_VAR__);
    current_statement__ = 316;
    stan::model::assign(P, (((((2 * (v - w)) * (f + r)) + (v * (q - l))) + (w
      * (q + l))) / (2 * q)), "assigning variable P",
      stan::model::index_uni(1), stan::model::index_uni(1));
    current_statement__ = 317;
    stan::model::assign(P, (((v - w) * r) / q), "assigning variable P",
      stan::model::index_uni(2), stan::model::index_uni(1));
    current_statement__ = 318;
    stan::model::assign(P, 0, "assigning variable P",
      stan::model::index_uni(3), stan::model::index_uni(1));
    current_statement__ = 319;
    stan::model::assign(P, ((i * (v - w)) / q), "assigning variable P",
      stan::model::index_uni(1), stan::model::index_uni(2));
    current_statement__ = 320;
    stan::model::assign(P, (-((((2 * (f + r)) - l) * (v - w)) - (q * (v +
      w))) / (2 * q)), "assigning variable P", stan::model::index_uni(2),
      stan::model::index_uni(2));
    current_statement__ = 321;
    stan::model::assign(P, 0, "assigning variable P",
      stan::model::index_uni(3), stan::model::index_uni(2));
    current_statement__ = 322;
    stan::model::assign(P, ((((-l * (v - w)) - (q * (v + w))) / (2 * q)) +
      1), "assigning variable P", stan::model::index_uni(1),
      stan::model::index_uni(3));
    current_statement__ = 323;
    stan::model::assign(P, (((((v - w) * ((2 * f) - l)) - (q * (v + w))) / (2
      * q)) + 1), "assigning variable P", stan::model::index_uni(2),
      stan::model::index_uni(3));
    current_statement__ = 324;
    stan::model::assign(P, 1, "assigning variable P",
      stan::model::index_uni(3), stan::model::index_uni(3));
    current_statement__ = 325;
    return P;
  } catch (const std::exception& e) {
    stan::lang::rethrow_located(e, locations_array__[current_statement__]);
  }
}
template <typename T0__, typename T1__,
          stan::require_all_t<stan::is_stan_scalar<T0__>,
                              stan::is_stan_scalar<T1__>>*>
Eigen::Matrix<stan::promote_args_t<T0__, T1__>,-1,-1>
trans_probs_norem_if(const T0__& i, const T1__& f, std::ostream* pstream__) {
  using local_scalar_t__ = stan::promote_args_t<T0__, T1__>;
  int current_statement__ = 0;
  static constexpr bool propto__ = true;
  // suppress unused var warning
  (void) propto__;
  local_scalar_t__ DUMMY_VAR__(std::numeric_limits<double>::quiet_NaN());
  // suppress unused var warning
  (void) DUMMY_VAR__;
  try {
    local_scalar_t__ l = DUMMY_VAR__;
    current_statement__ = 327;
    l = (i + f);
    local_scalar_t__ q = DUMMY_VAR__;
    current_statement__ = 328;
    q = stan::math::sqrt((((i * i) - ((2 * i) * f)) + (f * f)));
    local_scalar_t__ w = DUMMY_VAR__;
    current_statement__ = 329;
    w = stan::math::exp((-(l + q) / 2));
    local_scalar_t__ v = DUMMY_VAR__;
    current_statement__ = 330;
    v = stan::math::exp((-(l - q) / 2));
    Eigen::Matrix<local_scalar_t__,-1,-1> P =
      Eigen::Matrix<local_scalar_t__,-1,-1>::Constant(3, 3, DUMMY_VAR__);
    current_statement__ = 332;
    stan::model::assign(P, (((((2 * (v - w)) * f) + (v * (q - l))) + (w * (q
      + l))) / (2 * q)), "assigning variable P", stan::model::index_uni(1),
      stan::model::index_uni(1));
    current_statement__ = 333;
    stan::model::assign(P, 0, "assigning variable P",
      stan::model::index_uni(2), stan::model::index_uni(1));
    current_statement__ = 334;
    stan::model::assign(P, 0, "assigning variable P",
      stan::model::index_uni(3), stan::model::index_uni(1));
    current_statement__ = 335;
    stan::model::assign(P, ((i * (v - w)) / q), "assigning variable P",
      stan::model::index_uni(1), stan::model::index_uni(2));
    current_statement__ = 336;
    stan::model::assign(P, (-((((2 * f) - l) * (v - w)) - (q * (v + w))) / (2
      * q)), "assigning variable P", stan::model::index_uni(2),
      stan::model::index_uni(2));
    current_statement__ = 337;
    stan::model::assign(P, 0, "assigning variable P",
      stan::model::index_uni(3), stan::model::index_uni(2));
    current_statement__ = 338;
    stan::model::assign(P, ((((-l * (v - w)) - (q * (v + w))) / (2 * q)) +
      1), "assigning variable P", stan::model::index_uni(1),
      stan::model::index_uni(3));
    current_statement__ = 339;
    stan::model::assign(P, (((((v - w) * ((2 * f) - l)) - (q * (v + w))) / (2
      * q)) + 1), "assigning variable P", stan::model::index_uni(2),
      stan::model::index_uni(3));
    current_statement__ = 340;
    stan::model::assign(P, 1, "assigning variable P",
      stan::model::index_uni(3), stan::model::index_uni(3));
    current_statement__ = 341;
    return P;
  } catch (const std::exception& e) {
    stan::lang::rethrow_located(e, locations_array__[current_statement__]);
  }
}
template <typename T0__, stan::require_all_t<stan::is_stan_scalar<T0__>>*>
Eigen::Matrix<stan::promote_args_t<T0__>,-1,-1>
trans_probs_norem_i(const T0__& i, std::ostream* pstream__) {
  using local_scalar_t__ = stan::promote_args_t<T0__>;
  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 {
    Eigen::Matrix<local_scalar_t__,-1,-1> P =
      Eigen::Matrix<local_scalar_t__,-1,-1>::Constant(3, 3, DUMMY_VAR__);
    current_statement__ = 344;
    stan::model::assign(P, stan::math::exp(-i), "assigning variable P",
      stan::model::index_uni(1), stan::model::index_uni(1));
    current_statement__ = 345;
    stan::model::assign(P, (i * stan::math::exp(-i)), "assigning variable P",
      stan::model::index_uni(1), stan::model::index_uni(2));
    current_statement__ = 346;
    stan::model::assign(P, ((-stan::math::exp(-i) + 1) - (i *
      stan::math::exp(-i))), "assigning variable P",
      stan::model::index_uni(1), stan::model::index_uni(3));
    current_statement__ = 347;
    stan::model::assign(P, 0, "assigning variable P",
      stan::model::index_uni(2), stan::model::index_uni(1));
    current_statement__ = 348;
    stan::model::assign(P, stan::math::exp(-i), "assigning variable P",
      stan::model::index_uni(2), stan::model::index_uni(2));
    current_statement__ = 349;
    stan::model::assign(P, (1 - stan::math::exp(-i)), "assigning variable P",
      stan::model::index_uni(2), stan::model::index_uni(3));
    current_statement__ = 350;
    stan::model::assign(P, 0, "assigning variable P",
      stan::model::index_uni(3), stan::model::index_uni(1));
    current_statement__ = 351;
    stan::model::assign(P, 0, "assigning variable P",
      stan::model::index_uni(3), stan::model::index_uni(2));
    current_statement__ = 352;
    stan::model::assign(P, 1, "assigning variable P",
      stan::model::index_uni(3), stan::model::index_uni(3));
    current_statement__ = 353;
    return P;
  } 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__>>*>
Eigen::Matrix<stan::promote_args_t<stan::base_type_t<T0__>>,-1,-1>
defuzz_P(const T0__& P_arg__, std::ostream* pstream__) {
  using local_scalar_t__ = stan::promote_args_t<stan::base_type_t<T0__>>;
  int current_statement__ = 0;
  const auto& P = stan::math::to_ref(P_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 {
    Eigen::Matrix<local_scalar_t__,-1,-1> Pr =
      Eigen::Matrix<local_scalar_t__,-1,-1>::Constant(3, 3, DUMMY_VAR__);
    current_statement__ = 364;
    for (int r = 1; r <= 3; ++r) {
      current_statement__ = 362;
      for (int s = 1; s <= 3; ++s) {
        current_statement__ = 356;
        stan::model::assign(Pr,
          stan::model::rvalue(P, "P", stan::model::index_uni(r),
            stan::model::index_uni(s)), "assigning variable Pr",
          stan::model::index_uni(r), stan::model::index_uni(s));
        current_statement__ = 358;
        if (stan::math::logical_lt(
              stan::model::rvalue(P, "P", stan::model::index_uni(r),
                stan::model::index_uni(s)), 0)) {
          current_statement__ = 357;
          stan::model::assign(Pr, 0, "assigning variable Pr",
            stan::model::index_uni(r), stan::model::index_uni(s));
        }
        current_statement__ = 360;
        if (stan::math::logical_gt(
              stan::model::rvalue(P, "P", stan::model::index_uni(r),
                stan::model::index_uni(s)), 1)) {
          current_statement__ = 359;
          stan::model::assign(Pr, 1, "assigning variable Pr",
            stan::model::index_uni(r), stan::model::index_uni(s));
        }
      }
    }
    current_statement__ = 365;
    return Pr;
  } catch (const std::exception& e) {
    stan::lang::rethrow_located(e, locations_array__[current_statement__]);
  }
}
template <typename T0__, typename T1__, typename T2__,
          stan::require_all_t<stan::is_stan_scalar<T0__>,
                              stan::is_stan_scalar<T1__>,
                              stan::is_stan_scalar<T2__>>*>
Eigen::Matrix<stan::promote_args_t<T0__, T1__, T2__>,-1,-1>
trans_probs(const T0__& i, const T1__& f, const T2__& r, std::ostream*
            pstream__) {
  using local_scalar_t__ = stan::promote_args_t<T0__, T1__, T2__>;
  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 {
    Eigen::Matrix<local_scalar_t__,-1,-1> P =
      Eigen::Matrix<local_scalar_t__,-1,-1>::Constant(3, 3, DUMMY_VAR__);
    current_statement__ = 373;
    if (stan::math::logical_neq(r, 0)) {
      current_statement__ = 372;
      stan::model::assign(P, trans_probs_rem(i, f, r, pstream__),
        "assigning variable P");
    } else {
      current_statement__ = 370;
      if (stan::math::logical_eq(i, f)) {
        current_statement__ = 369;
        stan::model::assign(P, trans_probs_norem_i(i, pstream__),
          "assigning variable P");
      } else {
        current_statement__ = 368;
        stan::model::assign(P, trans_probs_norem_if(i, f, pstream__),
          "assigning variable P");
      }
    }
    current_statement__ = 374;
    return defuzz_P(P, pstream__);
  } catch (const std::exception& e) {
    stan::lang::rethrow_located(e, locations_array__[current_statement__]);
  }
}
template <typename T0__, stan::require_all_t<stan::is_stan_scalar<T0__>>*>
stan::promote_args_t<T0__> bound_prob(const T0__& x, std::ostream* pstream__) {
  using local_scalar_t__ = stan::promote_args_t<T0__>;
  int current_statement__ = 0;
  static constexpr bool propto__ = true;
  // suppress unused var warning
  (void) propto__;
  local_scalar_t__ DUMMY_VAR__(std::numeric_limits<double>::quiet_NaN());
  // suppress unused var warning
  (void) DUMMY_VAR__;
  try {
    local_scalar_t__ ret = DUMMY_VAR__;
    current_statement__ = 384;
    if (stan::math::logical_gte(x, 1)) {
      current_statement__ = 382;
      ret = (1 - stan::math::machine_precision());
    } else {
      current_statement__ = 381;
      if (stan::math::logical_lte(x, 0)) {
        current_statement__ = 379;
        ret = stan::math::machine_precision();
      } else {
        current_statement__ = 377;
        ret = x;
      }
    }
    current_statement__ = 385;
    return x;
  } catch (const std::exception& e) {
    stan::lang::rethrow_located(e, locations_array__[current_statement__]);
  }
}
#include <stan_meta_header.hpp>
class model_disbayes final : public model_base_crtp<model_disbayes> {
private:
  int inc_supplied;
  int prev_supplied;
  int smooth_cf;
  int smooth_inc;
  int smooth_rem;
  int remission;
  int trend;
  int prev_zero;
  int nage;
  int eqage;
  std::vector<int> mort_num;
  std::vector<int> mort_denom;
  std::vector<int> prev_num;
  std::vector<int> prev_denom;
  std::vector<int> inc_num;
  std::vector<int> inc_denom;
  std::vector<int> rem_num;
  std::vector<int> rem_denom;
  int nyr;
  int K;
  Eigen::Matrix<double,-1,-1> X_data__;
  std::vector<double> sprior;
  int increasing_cf;
  int const_cf;
  int const_rem;
  int nbias;
  int incdata_ind;
  int prevdata_ind;
  Eigen::Matrix<double,-1,-1> inc_trend_data__;
  Eigen::Matrix<double,-1,-1> cf_trend_data__;
  std::vector<double> inc_prior;
  std::vector<double> cf_prior;
  std::vector<double> rem_prior;
  int scf_isfixed;
  int sinc_isfixed;
  int srem_isfixed;
  double lambda_cf_fixed;
  double lambda_inc_fixed;
  double lambda_rem_fixed;
  int inc_par_1dim__;
  int cf_par_1dim__;
  int rem_par_1dim__;
  int beta_1dim__;
  int lambda_cf_1dim__;
  int lambda_inc_1dim__;
  int beta_inc_1dim__;
  int lambda_rem_1dim__;
  int beta_rem_1dim__;
  int bias_loghr_1dim__;
  int cfbase_1dim__;
  int dcf_1dim__;
  int rem_prob_1dim__;
  int state_probs_1dim__;
  int cf_yr_1dim__;
  int cf_yr_2dim__;
  int inc_yr_1dim__;
  int inc_yr_2dim__;
  int state_probs_yr_1dim__;
  int state_probs_yr_2dim__;
  int ll_inc_1dim__;
  int ll_prev_1dim__;
  int ll_rem_1dim__;
  int ll_overall_1dim__;
  Eigen::Map<Eigen::Matrix<double,-1,-1>> X{nullptr, 0, 0};
  Eigen::Map<Eigen::Matrix<double,-1,-1>> inc_trend{nullptr, 0, 0};
  Eigen::Map<Eigen::Matrix<double,-1,-1>> cf_trend{nullptr, 0, 0};
public:
  ~model_disbayes() {}
  model_disbayes(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_disbayes_namespace::model_disbayes";
    // 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__ = 219;
      context__.validate_dims("data initialization", "inc_supplied", "int",
        std::vector<size_t>{});
      inc_supplied = std::numeric_limits<int>::min();
      current_statement__ = 219;
      inc_supplied = context__.vals_i("inc_supplied")[(1 - 1)];
      current_statement__ = 220;
      context__.validate_dims("data initialization", "prev_supplied", "int",
        std::vector<size_t>{});
      prev_supplied = std::numeric_limits<int>::min();
      current_statement__ = 220;
      prev_supplied = context__.vals_i("prev_supplied")[(1 - 1)];
      current_statement__ = 221;
      context__.validate_dims("data initialization", "smooth_cf", "int",
        std::vector<size_t>{});
      smooth_cf = std::numeric_limits<int>::min();
      current_statement__ = 221;
      smooth_cf = context__.vals_i("smooth_cf")[(1 - 1)];
      current_statement__ = 222;
      context__.validate_dims("data initialization", "smooth_inc", "int",
        std::vector<size_t>{});
      smooth_inc = std::numeric_limits<int>::min();
      current_statement__ = 222;
      smooth_inc = context__.vals_i("smooth_inc")[(1 - 1)];
      current_statement__ = 223;
      context__.validate_dims("data initialization", "smooth_rem", "int",
        std::vector<size_t>{});
      smooth_rem = std::numeric_limits<int>::min();
      current_statement__ = 223;
      smooth_rem = context__.vals_i("smooth_rem")[(1 - 1)];
      current_statement__ = 224;
      context__.validate_dims("data initialization", "remission", "int",
        std::vector<size_t>{});
      remission = std::numeric_limits<int>::min();
      current_statement__ = 224;
      remission = context__.vals_i("remission")[(1 - 1)];
      current_statement__ = 225;
      context__.validate_dims("data initialization", "trend", "int",
        std::vector<size_t>{});
      trend = std::numeric_limits<int>::min();
      current_statement__ = 225;
      trend = context__.vals_i("trend")[(1 - 1)];
      current_statement__ = 226;
      context__.validate_dims("data initialization", "prev_zero", "int",
        std::vector<size_t>{});
      prev_zero = std::numeric_limits<int>::min();
      current_statement__ = 226;
      prev_zero = context__.vals_i("prev_zero")[(1 - 1)];
      current_statement__ = 227;
      context__.validate_dims("data initialization", "nage", "int",
        std::vector<size_t>{});
      nage = std::numeric_limits<int>::min();
      current_statement__ = 227;
      nage = context__.vals_i("nage")[(1 - 1)];
      current_statement__ = 227;
      stan::math::check_greater_or_equal(function__, "nage", nage, 0);
      current_statement__ = 228;
      context__.validate_dims("data initialization", "eqage", "int",
        std::vector<size_t>{});
      eqage = std::numeric_limits<int>::min();
      current_statement__ = 228;
      eqage = context__.vals_i("eqage")[(1 - 1)];
      current_statement__ = 228;
      stan::math::check_greater_or_equal(function__, "eqage", eqage, 0);
      current_statement__ = 229;
      stan::math::validate_non_negative_index("mort_num", "nage", nage);
      current_statement__ = 230;
      context__.validate_dims("data initialization", "mort_num", "int",
        std::vector<size_t>{static_cast<size_t>(nage)});
      mort_num = std::vector<int>(nage, std::numeric_limits<int>::min());
      current_statement__ = 230;
      mort_num = context__.vals_i("mort_num");
      current_statement__ = 230;
      stan::math::check_greater_or_equal(function__, "mort_num", mort_num, 0);
      current_statement__ = 231;
      stan::math::validate_non_negative_index("mort_denom", "nage", nage);
      current_statement__ = 232;
      context__.validate_dims("data initialization", "mort_denom", "int",
        std::vector<size_t>{static_cast<size_t>(nage)});
      mort_denom = std::vector<int>(nage, std::numeric_limits<int>::min());
      current_statement__ = 232;
      mort_denom = context__.vals_i("mort_denom");
      current_statement__ = 232;
      stan::math::check_greater_or_equal(function__, "mort_denom",
        mort_denom, 0);
      current_statement__ = 233;
      stan::math::validate_non_negative_index("prev_num", "nage", nage);
      current_statement__ = 234;
      context__.validate_dims("data initialization", "prev_num", "int",
        std::vector<size_t>{static_cast<size_t>(nage)});
      prev_num = std::vector<int>(nage, std::numeric_limits<int>::min());
      current_statement__ = 234;
      prev_num = context__.vals_i("prev_num");
      current_statement__ = 234;
      stan::math::check_greater_or_equal(function__, "prev_num", prev_num, 0);
      current_statement__ = 235;
      stan::math::validate_non_negative_index("prev_denom", "nage", nage);
      current_statement__ = 236;
      context__.validate_dims("data initialization", "prev_denom", "int",
        std::vector<size_t>{static_cast<size_t>(nage)});
      prev_denom = std::vector<int>(nage, std::numeric_limits<int>::min());
      current_statement__ = 236;
      prev_denom = context__.vals_i("prev_denom");
      current_statement__ = 236;
      stan::math::check_greater_or_equal(function__, "prev_denom",
        prev_denom, 0);
      current_statement__ = 237;
      stan::math::validate_non_negative_index("inc_num", "nage", nage);
      current_statement__ = 238;
      context__.validate_dims("data initialization", "inc_num", "int",
        std::vector<size_t>{static_cast<size_t>(nage)});
      inc_num = std::vector<int>(nage, std::numeric_limits<int>::min());
      current_statement__ = 238;
      inc_num = context__.vals_i("inc_num");
      current_statement__ = 238;
      stan::math::check_greater_or_equal(function__, "inc_num", inc_num, 0);
      current_statement__ = 239;
      stan::math::validate_non_negative_index("inc_denom", "nage", nage);
      current_statement__ = 240;
      context__.validate_dims("data initialization", "inc_denom", "int",
        std::vector<size_t>{static_cast<size_t>(nage)});
      inc_denom = std::vector<int>(nage, std::numeric_limits<int>::min());
      current_statement__ = 240;
      inc_denom = context__.vals_i("inc_denom");
      current_statement__ = 240;
      stan::math::check_greater_or_equal(function__, "inc_denom", inc_denom,
        0);
      current_statement__ = 241;
      stan::math::validate_non_negative_index("rem_num", "nage", nage);
      current_statement__ = 242;
      context__.validate_dims("data initialization", "rem_num", "int",
        std::vector<size_t>{static_cast<size_t>(nage)});
      rem_num = std::vector<int>(nage, std::numeric_limits<int>::min());
      current_statement__ = 242;
      rem_num = context__.vals_i("rem_num");
      current_statement__ = 242;
      stan::math::check_greater_or_equal(function__, "rem_num", rem_num, 0);
      current_statement__ = 243;
      stan::math::validate_non_negative_index("rem_denom", "nage", nage);
      current_statement__ = 244;
      context__.validate_dims("data initialization", "rem_denom", "int",
        std::vector<size_t>{static_cast<size_t>(nage)});
      rem_denom = std::vector<int>(nage, std::numeric_limits<int>::min());
      current_statement__ = 244;
      rem_denom = context__.vals_i("rem_denom");
      current_statement__ = 244;
      stan::math::check_greater_or_equal(function__, "rem_denom", rem_denom,
        0);
      current_statement__ = 245;
      context__.validate_dims("data initialization", "nyr", "int",
        std::vector<size_t>{});
      nyr = std::numeric_limits<int>::min();
      current_statement__ = 245;
      nyr = context__.vals_i("nyr")[(1 - 1)];
      current_statement__ = 245;
      stan::math::check_greater_or_equal(function__, "nyr", nyr, 0);
      current_statement__ = 246;
      context__.validate_dims("data initialization", "K", "int",
        std::vector<size_t>{});
      K = std::numeric_limits<int>::min();
      current_statement__ = 246;
      K = context__.vals_i("K")[(1 - 1)];
      current_statement__ = 246;
      stan::math::check_greater_or_equal(function__, "K", K, 0);
      current_statement__ = 247;
      stan::math::validate_non_negative_index("X", "nage", nage);
      current_statement__ = 248;
      stan::math::validate_non_negative_index("X", "K", K);
      current_statement__ = 249;
      context__.validate_dims("data initialization", "X", "double",
        std::vector<size_t>{static_cast<size_t>(nage),
          static_cast<size_t>(K)});
      X_data__ = Eigen::Matrix<double,-1,-1>::Constant(nage, K,
                   std::numeric_limits<double>::quiet_NaN());
      new (&X) Eigen::Map<Eigen::Matrix<double,-1,-1>>(X_data__.data(), nage,
        K);
      {
        std::vector<local_scalar_t__> X_flat__;
        current_statement__ = 249;
        X_flat__ = context__.vals_r("X");
        current_statement__ = 249;
        pos__ = 1;
        current_statement__ = 249;
        for (int sym1__ = 1; sym1__ <= K; ++sym1__) {
          current_statement__ = 249;
          for (int sym2__ = 1; sym2__ <= nage; ++sym2__) {
            current_statement__ = 249;
            stan::model::assign(X, X_flat__[(pos__ - 1)],
              "assigning variable X", stan::model::index_uni(sym2__),
              stan::model::index_uni(sym1__));
            current_statement__ = 249;
            pos__ = (pos__ + 1);
          }
        }
      }
      current_statement__ = 250;
      context__.validate_dims("data initialization", "sprior", "double",
        std::vector<size_t>{static_cast<size_t>(3)});
      sprior = std::vector<double>(3,
                 std::numeric_limits<double>::quiet_NaN());
      current_statement__ = 250;
      sprior = context__.vals_r("sprior");
      current_statement__ = 250;
      stan::math::check_greater_or_equal(function__, "sprior", sprior, 0);
      current_statement__ = 251;
      context__.validate_dims("data initialization", "increasing_cf", "int",
        std::vector<size_t>{});
      increasing_cf = std::numeric_limits<int>::min();
      current_statement__ = 251;
      increasing_cf = context__.vals_i("increasing_cf")[(1 - 1)];
      current_statement__ = 252;
      context__.validate_dims("data initialization", "const_cf", "int",
        std::vector<size_t>{});
      const_cf = std::numeric_limits<int>::min();
      current_statement__ = 252;
      const_cf = context__.vals_i("const_cf")[(1 - 1)];
      current_statement__ = 253;
      context__.validate_dims("data initialization", "const_rem", "int",
        std::vector<size_t>{});
      const_rem = std::numeric_limits<int>::min();
      current_statement__ = 253;
      const_rem = context__.vals_i("const_rem")[(1 - 1)];
      current_statement__ = 254;
      context__.validate_dims("data initialization", "nbias", "int",
        std::vector<size_t>{});
      nbias = std::numeric_limits<int>::min();
      current_statement__ = 254;
      nbias = context__.vals_i("nbias")[(1 - 1)];
      current_statement__ = 255;
      context__.validate_dims("data initialization", "incdata_ind", "int",
        std::vector<size_t>{});
      incdata_ind = std::numeric_limits<int>::min();
      current_statement__ = 255;
      incdata_ind = context__.vals_i("incdata_ind")[(1 - 1)];
      current_statement__ = 256;
      context__.validate_dims("data initialization", "prevdata_ind", "int",
        std::vector<size_t>{});
      prevdata_ind = std::numeric_limits<int>::min();
      current_statement__ = 256;
      prevdata_ind = context__.vals_i("prevdata_ind")[(1 - 1)];
      current_statement__ = 257;
      stan::math::validate_non_negative_index("inc_trend", "nage", nage);
      current_statement__ = 258;
      stan::math::validate_non_negative_index("inc_trend", "nyr", nyr);
      current_statement__ = 259;
      context__.validate_dims("data initialization", "inc_trend", "double",
        std::vector<size_t>{static_cast<size_t>(nage),
          static_cast<size_t>(nyr)});
      inc_trend_data__ = Eigen::Matrix<double,-1,-1>::Constant(nage, nyr,
                           std::numeric_limits<double>::quiet_NaN());
      new (&inc_trend)
        Eigen::Map<Eigen::Matrix<double,-1,-1>>(inc_trend_data__.data(),
        nage, nyr);
      {
        std::vector<local_scalar_t__> inc_trend_flat__;
        current_statement__ = 259;
        inc_trend_flat__ = context__.vals_r("inc_trend");
        current_statement__ = 259;
        pos__ = 1;
        current_statement__ = 259;
        for (int sym1__ = 1; sym1__ <= nyr; ++sym1__) {
          current_statement__ = 259;
          for (int sym2__ = 1; sym2__ <= nage; ++sym2__) {
            current_statement__ = 259;
            stan::model::assign(inc_trend, inc_trend_flat__[(pos__ - 1)],
              "assigning variable inc_trend", stan::model::index_uni(sym2__),
              stan::model::index_uni(sym1__));
            current_statement__ = 259;
            pos__ = (pos__ + 1);
          }
        }
      }
      current_statement__ = 259;
      stan::math::check_greater_or_equal(function__, "inc_trend", inc_trend,
        0);
      current_statement__ = 260;
      stan::math::validate_non_negative_index("cf_trend", "nage", nage);
      current_statement__ = 261;
      stan::math::validate_non_negative_index("cf_trend", "nyr", nyr);
      current_statement__ = 262;
      context__.validate_dims("data initialization", "cf_trend", "double",
        std::vector<size_t>{static_cast<size_t>(nage),
          static_cast<size_t>(nyr)});
      cf_trend_data__ = Eigen::Matrix<double,-1,-1>::Constant(nage, nyr,
                          std::numeric_limits<double>::quiet_NaN());
      new (&cf_trend)
        Eigen::Map<Eigen::Matrix<double,-1,-1>>(cf_trend_data__.data(), nage,
        nyr);
      {
        std::vector<local_scalar_t__> cf_trend_flat__;
        current_statement__ = 262;
        cf_trend_flat__ = context__.vals_r("cf_trend");
        current_statement__ = 262;
        pos__ = 1;
        current_statement__ = 262;
        for (int sym1__ = 1; sym1__ <= nyr; ++sym1__) {
          current_statement__ = 262;
          for (int sym2__ = 1; sym2__ <= nage; ++sym2__) {
            current_statement__ = 262;
            stan::model::assign(cf_trend, cf_trend_flat__[(pos__ - 1)],
              "assigning variable cf_trend", stan::model::index_uni(sym2__),
              stan::model::index_uni(sym1__));
            current_statement__ = 262;
            pos__ = (pos__ + 1);
          }
        }
      }
      current_statement__ = 262;
      stan::math::check_greater_or_equal(function__, "cf_trend", cf_trend, 0);
      current_statement__ = 263;
      context__.validate_dims("data initialization", "inc_prior", "double",
        std::vector<size_t>{static_cast<size_t>(2)});
      inc_prior = std::vector<double>(2,
                    std::numeric_limits<double>::quiet_NaN());
      current_statement__ = 263;
      inc_prior = context__.vals_r("inc_prior");
      current_statement__ = 263;
      stan::math::check_greater_or_equal(function__, "inc_prior", inc_prior,
        0);
      current_statement__ = 264;
      context__.validate_dims("data initialization", "cf_prior", "double",
        std::vector<size_t>{static_cast<size_t>(2)});
      cf_prior = std::vector<double>(2,
                   std::numeric_limits<double>::quiet_NaN());
      current_statement__ = 264;
      cf_prior = context__.vals_r("cf_prior");
      current_statement__ = 264;
      stan::math::check_greater_or_equal(function__, "cf_prior", cf_prior, 0);
      current_statement__ = 265;
      context__.validate_dims("data initialization", "rem_prior", "double",
        std::vector<size_t>{static_cast<size_t>(2)});
      rem_prior = std::vector<double>(2,
                    std::numeric_limits<double>::quiet_NaN());
      current_statement__ = 265;
      rem_prior = context__.vals_r("rem_prior");
      current_statement__ = 265;
      stan::math::check_greater_or_equal(function__, "rem_prior", rem_prior,
        0);
      current_statement__ = 266;
      context__.validate_dims("data initialization", "scf_isfixed", "int",
        std::vector<size_t>{});
      scf_isfixed = std::numeric_limits<int>::min();
      current_statement__ = 266;
      scf_isfixed = context__.vals_i("scf_isfixed")[(1 - 1)];
      current_statement__ = 267;
      context__.validate_dims("data initialization", "sinc_isfixed", "int",
        std::vector<size_t>{});
      sinc_isfixed = std::numeric_limits<int>::min();
      current_statement__ = 267;
      sinc_isfixed = context__.vals_i("sinc_isfixed")[(1 - 1)];
      current_statement__ = 268;
      context__.validate_dims("data initialization", "srem_isfixed", "int",
        std::vector<size_t>{});
      srem_isfixed = std::numeric_limits<int>::min();
      current_statement__ = 268;
      srem_isfixed = context__.vals_i("srem_isfixed")[(1 - 1)];
      current_statement__ = 269;
      context__.validate_dims("data initialization", "lambda_cf_fixed",
        "double", std::vector<size_t>{});
      lambda_cf_fixed = std::numeric_limits<double>::quiet_NaN();
      current_statement__ = 269;
      lambda_cf_fixed = context__.vals_r("lambda_cf_fixed")[(1 - 1)];
      current_statement__ = 269;
      stan::math::check_greater_or_equal(function__, "lambda_cf_fixed",
        lambda_cf_fixed, 0);
      current_statement__ = 270;
      context__.validate_dims("data initialization", "lambda_inc_fixed",
        "double", std::vector<size_t>{});
      lambda_inc_fixed = std::numeric_limits<double>::quiet_NaN();
      current_statement__ = 270;
      lambda_inc_fixed = context__.vals_r("lambda_inc_fixed")[(1 - 1)];
      current_statement__ = 270;
      stan::math::check_greater_or_equal(function__, "lambda_inc_fixed",
        lambda_inc_fixed, 0);
      current_statement__ = 271;
      context__.validate_dims("data initialization", "lambda_rem_fixed",
        "double", std::vector<size_t>{});
      lambda_rem_fixed = std::numeric_limits<double>::quiet_NaN();
      current_statement__ = 271;
      lambda_rem_fixed = context__.vals_r("lambda_rem_fixed")[(1 - 1)];
      current_statement__ = 271;
      stan::math::check_greater_or_equal(function__, "lambda_rem_fixed",
        lambda_rem_fixed, 0);
      current_statement__ = 272;
      inc_par_1dim__ = std::numeric_limits<int>::min();
      current_statement__ = 272;
      inc_par_1dim__ = (nage * (1 - smooth_inc));
      current_statement__ = 272;
      stan::math::validate_non_negative_index("inc_par",
        "nage * (1 - smooth_inc)", inc_par_1dim__);
      current_statement__ = 273;
      cf_par_1dim__ = std::numeric_limits<int>::min();
      current_statement__ = 273;
      cf_par_1dim__ = (nage * (1 - smooth_cf));
      current_statement__ = 273;
      stan::math::validate_non_negative_index("cf_par",
        "nage * (1 - smooth_cf)", cf_par_1dim__);
      current_statement__ = 274;
      rem_par_1dim__ = std::numeric_limits<int>::min();
      current_statement__ = 274;
      rem_par_1dim__ = ((remission * (1 - smooth_rem)) * ((nage * (1 -
        const_rem)) + (1 * const_rem)));
      current_statement__ = 274;
      stan::math::validate_non_negative_index("rem_par",
        "remission * (1 - smooth_rem) * (nage * (1 - const_rem) + 1 * const_rem)",
        rem_par_1dim__);
      current_statement__ = 275;
      beta_1dim__ = std::numeric_limits<int>::min();
      current_statement__ = 275;
      beta_1dim__ = ((K * smooth_cf) * (1 - const_cf));
      current_statement__ = 275;
      stan::math::validate_non_negative_index("beta",
        "K * smooth_cf * (1 - const_cf)", beta_1dim__);
      current_statement__ = 276;
      lambda_cf_1dim__ = std::numeric_limits<int>::min();
      current_statement__ = 276;
      lambda_cf_1dim__ = (smooth_cf * (1 - scf_isfixed));
      current_statement__ = 276;
      stan::math::validate_non_negative_index("lambda_cf",
        "smooth_cf * (1 - scf_isfixed)", lambda_cf_1dim__);
      current_statement__ = 277;
      lambda_inc_1dim__ = std::numeric_limits<int>::min();
      current_statement__ = 277;
      lambda_inc_1dim__ = (smooth_inc * (1 - sinc_isfixed));
      current_statement__ = 277;
      stan::math::validate_non_negative_index("lambda_inc",
        "smooth_inc * (1 - sinc_isfixed)", lambda_inc_1dim__);
      current_statement__ = 278;
      beta_inc_1dim__ = std::numeric_limits<int>::min();
      current_statement__ = 278;
      beta_inc_1dim__ = (K * smooth_inc);
      current_statement__ = 278;
      stan::math::validate_non_negative_index("beta_inc", "K * smooth_inc",
        beta_inc_1dim__);
      current_statement__ = 279;
      lambda_rem_1dim__ = std::numeric_limits<int>::min();
      current_statement__ = 279;
      lambda_rem_1dim__ = (smooth_rem * (1 - srem_isfixed));
      current_statement__ = 279;
      stan::math::validate_non_negative_index("lambda_rem",
        "smooth_rem * (1 - srem_isfixed)", lambda_rem_1dim__);
      current_statement__ = 280;
      beta_rem_1dim__ = std::numeric_limits<int>::min();
      current_statement__ = 280;
      beta_rem_1dim__ = (K * smooth_rem);
      current_statement__ = 280;
      stan::math::validate_non_negative_index("beta_rem", "K * smooth_rem",
        beta_rem_1dim__);
      current_statement__ = 281;
      stan::math::validate_non_negative_index("prevzero", "prev_zero",
        prev_zero);
      current_statement__ = 282;
      bias_loghr_1dim__ = std::numeric_limits<int>::min();
      current_statement__ = 282;
      bias_loghr_1dim__ = stan::math::logical_eq(nbias, 2);
      current_statement__ = 282;
      stan::math::validate_non_negative_index("bias_loghr", "nbias == 2",
        bias_loghr_1dim__);
      current_statement__ = 283;
      cfbase_1dim__ = std::numeric_limits<int>::min();
      current_statement__ = 283;
      cfbase_1dim__ = (1 * increasing_cf);
      current_statement__ = 283;
      stan::math::validate_non_negative_index("cfbase", "1 * increasing_cf",
        cfbase_1dim__);
      current_statement__ = 284;
      stan::math::validate_non_negative_index("cf", "nage", nage);
      current_statement__ = 285;
      dcf_1dim__ = std::numeric_limits<int>::min();
      current_statement__ = 285;
      dcf_1dim__ = (nage * increasing_cf);
      current_statement__ = 285;
      stan::math::validate_non_negative_index("dcf", "nage * increasing_cf",
        dcf_1dim__);
      current_statement__ = 286;
      stan::math::validate_non_negative_index("inc", "nage", nage);
      current_statement__ = 287;
      stan::math::validate_non_negative_index("inc", "nbias", nbias);
      current_statement__ = 288;
      stan::math::validate_non_negative_index("inc_prob", "nage", nage);
      current_statement__ = 289;
      stan::math::validate_non_negative_index("inc_prob", "nbias", nbias);
      current_statement__ = 290;
      stan::math::validate_non_negative_index("rem", "nage", nage);
      current_statement__ = 291;
      rem_prob_1dim__ = std::numeric_limits<int>::min();
      current_statement__ = 291;
      rem_prob_1dim__ = (nage * remission);
      current_statement__ = 291;
      stan::math::validate_non_negative_index("rem_prob", "nage * remission",
        rem_prob_1dim__);
      current_statement__ = 292;
      stan::math::validate_non_negative_index("cf_prob", "nage", nage);
      current_statement__ = 293;
      state_probs_1dim__ = std::numeric_limits<int>::min();
      current_statement__ = 293;
      state_probs_1dim__ = ((nage + 1) * (1 - trend));
      current_statement__ = 293;
      stan::math::validate_non_negative_index("state_probs",
        "(nage + 1) * (1 - trend)", state_probs_1dim__);
      current_statement__ = 294;
      stan::math::validate_non_negative_index("state_probs", "nbias", nbias);
      current_statement__ = 295;
      stan::math::validate_non_negative_index("prev_prob", "nage", nage);
      current_statement__ = 296;
      stan::math::validate_non_negative_index("prev_prob", "nbias", nbias);
      current_statement__ = 297;
      stan::math::validate_non_negative_index("mort_prob", "nage", nage);
      current_statement__ = 298;
      cf_yr_1dim__ = std::numeric_limits<int>::min();
      current_statement__ = 298;
      cf_yr_1dim__ = (nage * trend);
      current_statement__ = 298;
      stan::math::validate_non_negative_index("cf_yr", "nage * trend",
        cf_yr_1dim__);
      current_statement__ = 299;
      cf_yr_2dim__ = std::numeric_limits<int>::min();
      current_statement__ = 299;
      cf_yr_2dim__ = (nyr * trend);
      current_statement__ = 299;
      stan::math::validate_non_negative_index("cf_yr", "nyr * trend",
        cf_yr_2dim__);
      current_statement__ = 300;
      inc_yr_1dim__ = std::numeric_limits<int>::min();
      current_statement__ = 300;
      inc_yr_1dim__ = (nage * trend);
      current_statement__ = 300;
      stan::math::validate_non_negative_index("inc_yr", "nage * trend",
        inc_yr_1dim__);
      current_statement__ = 301;
      inc_yr_2dim__ = std::numeric_limits<int>::min();
      current_statement__ = 301;
      inc_yr_2dim__ = (nyr * trend);
      current_statement__ = 301;
      stan::math::validate_non_negative_index("inc_yr", "nyr * trend",
        inc_yr_2dim__);
      current_statement__ = 302;
      stan::math::validate_non_negative_index("inc_yr", "nbias", nbias);
      current_statement__ = 303;
      state_probs_yr_1dim__ = std::numeric_limits<int>::min();
      current_statement__ = 303;
      state_probs_yr_1dim__ = ((nage + 1) * trend);
      current_statement__ = 303;
      stan::math::validate_non_negative_index("state_probs_yr",
        "(nage + 1) * trend", state_probs_yr_1dim__);
      current_statement__ = 304;
      state_probs_yr_2dim__ = std::numeric_limits<int>::min();
      current_statement__ = 304;
      state_probs_yr_2dim__ = (nyr * trend);
      current_statement__ = 304;
      stan::math::validate_non_negative_index("state_probs_yr",
        "nyr * trend", state_probs_yr_2dim__);
      current_statement__ = 305;
      stan::math::validate_non_negative_index("state_probs_yr", "nbias",
        nbias);
      current_statement__ = 306;
      stan::math::validate_non_negative_index("ll_mort", "nage", nage);
      current_statement__ = 307;
      ll_inc_1dim__ = std::numeric_limits<int>::min();
      current_statement__ = 307;
      ll_inc_1dim__ = (nage * inc_supplied);
      current_statement__ = 307;
      stan::math::validate_non_negative_index("ll_inc",
        "nage * inc_supplied", ll_inc_1dim__);
      current_statement__ = 308;
      ll_prev_1dim__ = std::numeric_limits<int>::min();
      current_statement__ = 308;
      ll_prev_1dim__ = (nage * prev_supplied);
      current_statement__ = 308;
      stan::math::validate_non_negative_index("ll_prev",
        "nage * prev_supplied", ll_prev_1dim__);
      current_statement__ = 309;
      ll_rem_1dim__ = std::numeric_limits<int>::min();
      current_statement__ = 309;
      ll_rem_1dim__ = (nage * remission);
      current_statement__ = 309;
      stan::math::validate_non_negative_index("ll_rem", "nage * remission",
        ll_rem_1dim__);
      current_statement__ = 310;
      ll_overall_1dim__ = std::numeric_limits<int>::min();
      current_statement__ = 310;
      ll_overall_1dim__ = (nage * (((1 + inc_supplied) + prev_supplied) +
        remission));
      current_statement__ = 310;
      stan::math::validate_non_negative_index("ll_overall",
        "nage * (1 + inc_supplied + prev_supplied + remission)",
        ll_overall_1dim__);
    } catch (const std::exception& e) {
      stan::lang::rethrow_located(e, locations_array__[current_statement__]);
    }
    num_params_r__ = inc_par_1dim__ + cf_par_1dim__ + rem_par_1dim__ +
      beta_1dim__ + lambda_cf_1dim__ + lambda_inc_1dim__ + beta_inc_1dim__ +
      lambda_rem_1dim__ + beta_rem_1dim__ + prev_zero + bias_loghr_1dim__ +
      cfbase_1dim__;
  }
  inline std::string model_name() const final {
    return "model_disbayes";
  }
  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_disbayes_namespace::log_prob";
    // suppress unused var warning
    (void) function__;
    try {
      Eigen::Matrix<local_scalar_t__,-1,1> inc_par =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(inc_par_1dim__,
          DUMMY_VAR__);
      current_statement__ = 1;
      inc_par = in__.template read_constrain_lb<
                  Eigen::Matrix<local_scalar_t__,-1,1>, jacobian__>(0, lp__,
                  inc_par_1dim__);
      Eigen::Matrix<local_scalar_t__,-1,1> cf_par =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(cf_par_1dim__,
          DUMMY_VAR__);
      current_statement__ = 2;
      cf_par = in__.template read_constrain_lb<
                 Eigen::Matrix<local_scalar_t__,-1,1>, jacobian__>(0, lp__,
                 cf_par_1dim__);
      Eigen::Matrix<local_scalar_t__,-1,1> rem_par =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(rem_par_1dim__,
          DUMMY_VAR__);
      current_statement__ = 3;
      rem_par = in__.template read_constrain_lb<
                  Eigen::Matrix<local_scalar_t__,-1,1>, jacobian__>(0, lp__,
                  rem_par_1dim__);
      Eigen::Matrix<local_scalar_t__,-1,1> beta =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(beta_1dim__,
          DUMMY_VAR__);
      current_statement__ = 4;
      beta = in__.template read<
               Eigen::Matrix<local_scalar_t__,-1,1>>(beta_1dim__);
      Eigen::Matrix<local_scalar_t__,-1,1> lambda_cf =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(lambda_cf_1dim__,
          DUMMY_VAR__);
      current_statement__ = 5;
      lambda_cf = in__.template read_constrain_lb<
                    Eigen::Matrix<local_scalar_t__,-1,1>, jacobian__>(0,
                    lp__, lambda_cf_1dim__);
      Eigen::Matrix<local_scalar_t__,-1,1> lambda_inc =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(lambda_inc_1dim__,
          DUMMY_VAR__);
      current_statement__ = 6;
      lambda_inc = in__.template read_constrain_lb<
                     Eigen::Matrix<local_scalar_t__,-1,1>, jacobian__>(0,
                     lp__, lambda_inc_1dim__);
      Eigen::Matrix<local_scalar_t__,-1,1> beta_inc =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(beta_inc_1dim__,
          DUMMY_VAR__);
      current_statement__ = 7;
      beta_inc = in__.template read<
                   Eigen::Matrix<local_scalar_t__,-1,1>>(beta_inc_1dim__);
      Eigen::Matrix<local_scalar_t__,-1,1> lambda_rem =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(lambda_rem_1dim__,
          DUMMY_VAR__);
      current_statement__ = 8;
      lambda_rem = in__.template read_constrain_lb<
                     Eigen::Matrix<local_scalar_t__,-1,1>, jacobian__>(0,
                     lp__, lambda_rem_1dim__);
      Eigen::Matrix<local_scalar_t__,-1,1> beta_rem =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(beta_rem_1dim__,
          DUMMY_VAR__);
      current_statement__ = 9;
      beta_rem = in__.template read<
                   Eigen::Matrix<local_scalar_t__,-1,1>>(beta_rem_1dim__);
      Eigen::Matrix<local_scalar_t__,-1,1> prevzero =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(prev_zero,
          DUMMY_VAR__);
      current_statement__ = 10;
      prevzero = in__.template read_constrain_lub<
                   Eigen::Matrix<local_scalar_t__,-1,1>, jacobian__>(0, 1,
                   lp__, prev_zero);
      Eigen::Matrix<local_scalar_t__,-1,1> bias_loghr =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(bias_loghr_1dim__,
          DUMMY_VAR__);
      current_statement__ = 11;
      bias_loghr = in__.template read<
                     Eigen::Matrix<local_scalar_t__,-1,1>>(bias_loghr_1dim__);
      Eigen::Matrix<local_scalar_t__,-1,1> cfbase =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(cfbase_1dim__,
          DUMMY_VAR__);
      current_statement__ = 12;
      cfbase = in__.template read_constrain_lb<
                 Eigen::Matrix<local_scalar_t__,-1,1>, jacobian__>(0, lp__,
                 cfbase_1dim__);
      Eigen::Matrix<local_scalar_t__,-1,1> cf =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(nage, DUMMY_VAR__);
      Eigen::Matrix<local_scalar_t__,-1,1> dcf =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(dcf_1dim__,
          DUMMY_VAR__);
      Eigen::Matrix<local_scalar_t__,-1,-1> inc =
        Eigen::Matrix<local_scalar_t__,-1,-1>::Constant(nage, nbias,
          DUMMY_VAR__);
      Eigen::Matrix<local_scalar_t__,-1,-1> inc_prob =
        Eigen::Matrix<local_scalar_t__,-1,-1>::Constant(nage, nbias,
          DUMMY_VAR__);
      Eigen::Matrix<local_scalar_t__,-1,1> rem =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(nage, DUMMY_VAR__);
      Eigen::Matrix<local_scalar_t__,-1,1> rem_prob =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(rem_prob_1dim__,
          DUMMY_VAR__);
      Eigen::Matrix<local_scalar_t__,-1,1> cf_prob =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(nage, DUMMY_VAR__);
      std::vector<std::vector<Eigen::Matrix<local_scalar_t__,1,-1>>>
        state_probs =
        std::vector<std::vector<Eigen::Matrix<local_scalar_t__,1,-1>>>(state_probs_1dim__,
          std::vector<Eigen::Matrix<local_scalar_t__,1,-1>>(nbias,
            Eigen::Matrix<local_scalar_t__,1,-1>::Constant(3, DUMMY_VAR__)));
      Eigen::Matrix<local_scalar_t__,1,-1> tmp =
        Eigen::Matrix<local_scalar_t__,1,-1>::Constant(3, DUMMY_VAR__);
      Eigen::Matrix<local_scalar_t__,-1,-1> P =
        Eigen::Matrix<local_scalar_t__,-1,-1>::Constant(3, 3, DUMMY_VAR__);
      Eigen::Matrix<local_scalar_t__,-1,-1> prev_prob =
        Eigen::Matrix<local_scalar_t__,-1,-1>::Constant(nage, nbias,
          DUMMY_VAR__);
      std::vector<local_scalar_t__> mort_prob =
        std::vector<local_scalar_t__>(nage, DUMMY_VAR__);
      Eigen::Matrix<local_scalar_t__,-1,-1> cf_yr =
        Eigen::Matrix<local_scalar_t__,-1,-1>::Constant(cf_yr_1dim__,
          cf_yr_2dim__, DUMMY_VAR__);
      std::vector<std::vector<std::vector<local_scalar_t__>>> inc_yr =
        std::vector<std::vector<std::vector<local_scalar_t__>>>(inc_yr_1dim__,
          std::vector<std::vector<local_scalar_t__>>(inc_yr_2dim__,
            std::vector<local_scalar_t__>(nbias, DUMMY_VAR__)));
      std::vector<
        std::vector<std::vector<Eigen::Matrix<local_scalar_t__,1,-1>>>>
        state_probs_yr =
        std::vector<
          std::vector<std::vector<Eigen::Matrix<local_scalar_t__,1,-1>>>>(state_probs_yr_1dim__,
          std::vector<std::vector<Eigen::Matrix<local_scalar_t__,1,-1>>>(state_probs_yr_2dim__,
            std::vector<Eigen::Matrix<local_scalar_t__,1,-1>>(nbias,
              Eigen::Matrix<local_scalar_t__,1,-1>::Constant(3, DUMMY_VAR__))));
      local_scalar_t__ lambda_cf_use = DUMMY_VAR__;
      local_scalar_t__ lambda_inc_use = DUMMY_VAR__;
      local_scalar_t__ lambda_rem_use = DUMMY_VAR__;
      current_statement__ = 38;
      if ((stan::math::primitive_value(scf_isfixed) ||
          stan::math::primitive_value(stan::math::logical_negation(smooth_cf)))) {
        current_statement__ = 37;
        lambda_cf_use = lambda_cf_fixed;
      } else {
        current_statement__ = 36;
        lambda_cf_use = stan::model::rvalue(lambda_cf, "lambda_cf",
                          stan::model::index_uni(1));
      }
      current_statement__ = 41;
      if ((stan::math::primitive_value(sinc_isfixed) ||
          stan::math::primitive_value(
            stan::math::logical_negation(smooth_inc)))) {
        current_statement__ = 40;
        lambda_inc_use = lambda_inc_fixed;
      } else {
        current_statement__ = 39;
        lambda_inc_use = stan::model::rvalue(lambda_inc, "lambda_inc",
                           stan::model::index_uni(1));
      }
      current_statement__ = 44;
      if ((stan::math::primitive_value(srem_isfixed) ||
          stan::math::primitive_value(
            stan::math::logical_negation(smooth_rem)))) {
        current_statement__ = 43;
        lambda_rem_use = lambda_rem_fixed;
      } else {
        current_statement__ = 42;
        lambda_rem_use = stan::model::rvalue(lambda_rem, "lambda_rem",
                           stan::model::index_uni(1));
      }
      current_statement__ = 47;
      if (smooth_inc) {
        current_statement__ = 46;
        stan::model::assign(inc,
          stan::math::exp(stan::math::multiply(X, beta_inc)),
          "assigning variable inc", stan::model::index_min_max(1, nage),
          stan::model::index_uni(1));
      } else {
        current_statement__ = 45;
        stan::model::assign(inc, inc_par, "assigning variable inc",
          stan::model::index_min_max(1, nage), stan::model::index_uni(1));
      }
      current_statement__ = 50;
      if (stan::math::logical_gt(nbias, 1)) {
        current_statement__ = 48;
        stan::model::assign(inc,
          stan::math::exp(
            stan::math::add(
              stan::math::log(
                stan::model::deep_copy(
                  stan::model::rvalue(inc, "inc",
                    stan::model::index_min_max(1, nage),
                    stan::model::index_uni(1)))),
              stan::model::rvalue(bias_loghr, "bias_loghr",
                stan::model::index_uni(1)))), "assigning variable inc",
          stan::model::index_min_max(1, nage), stan::model::index_uni(2));
      }
      current_statement__ = 60;
      if (remission) {
        current_statement__ = 58;
        if (const_rem) {
          current_statement__ = 56;
          for (int a = 1; a <= nage; ++a) {
            current_statement__ = 55;
            stan::model::assign(rem,
              stan::model::rvalue(rem_par, "rem_par",
                stan::model::index_uni(1)), "assigning variable rem",
              stan::model::index_uni(a));
          }
        } else {
          current_statement__ = 54;
          if (smooth_rem) {
            current_statement__ = 53;
            stan::model::assign(rem,
              stan::math::exp(stan::math::multiply(X, beta_rem)),
              "assigning variable rem");
          } else {
            current_statement__ = 52;
            stan::model::assign(rem, rem_par, "assigning variable rem");
          }
        }
      } else {
        current_statement__ = 51;
        stan::model::assign(rem, stan::math::rep_vector(0, nage),
          "assigning variable rem");
      }
      current_statement__ = 65;
      for (int k = 1; k <= nbias; ++k) {
        current_statement__ = 63;
        if ((stan::math::primitive_value(
               stan::math::logical_gt(
                 stan::model::rvalue(prev_denom, "prev_denom",
                   stan::model::index_uni(1)), 0))
            &&
            stan::math::primitive_value(
              (stan::math::primitive_value(
                 stan::math::logical_gt(
                   stan::model::rvalue(prev_num, "prev_num",
                     stan::model::index_uni(1)), 0)) ||
              stan::math::primitive_value(prev_zero))))) {
          current_statement__ = 62;
          stan::model::assign(prev_prob,
            stan::model::rvalue(prevzero, "prevzero",
              stan::model::index_uni(1)), "assigning variable prev_prob",
            stan::model::index_uni(1), stan::model::index_uni(k));
        } else {
          current_statement__ = 61;
          stan::model::assign(prev_prob, 0, "assigning variable prev_prob",
            stan::model::index_uni(1), stan::model::index_uni(k));
        }
      }
      current_statement__ = 81;
      if (increasing_cf) {
        current_statement__ = 72;
        for (int a = 1; a <= (eqage - 1); ++a) {
          current_statement__ = 70;
          stan::model::assign(cf,
            stan::model::rvalue(cfbase, "cfbase", stan::model::index_uni(1)),
            "assigning variable cf", stan::model::index_uni(a));
        }
        current_statement__ = 76;
        if (stan::math::logical_negation(const_cf)) {
          current_statement__ = 74;
          stan::model::assign(dcf,
            stan::math::exp(stan::math::multiply(X, beta)),
            "assigning variable dcf");
        } else {
          current_statement__ = 73;
          stan::model::assign(dcf, stan::math::rep_vector(0, nage),
            "assigning variable dcf");
        }
        current_statement__ = 79;
        for (int a = eqage; a <= nage; ++a) {
          current_statement__ = 77;
          stan::model::assign(cf,
            (stan::model::rvalue(cf, "cf", stan::model::index_uni((a - 1))) +
            stan::model::rvalue(dcf, "dcf", stan::model::index_uni(a))),
            "assigning variable cf", stan::model::index_uni(a));
        }
      } else {
        current_statement__ = 68;
        if (smooth_cf) {
          current_statement__ = 67;
          stan::model::assign(cf,
            stan::math::exp(stan::math::multiply(X, beta)),
            "assigning variable cf");
        } else {
          current_statement__ = 66;
          stan::model::assign(cf, cf_par, "assigning variable cf");
        }
      }
      current_statement__ = 108;
      if (trend) {
        current_statement__ = 88;
        stan::model::assign(cf,
          stan::math::exp(stan::math::multiply(X, beta)),
          "assigning variable cf");
        current_statement__ = 91;
        for (int b = 1; b <= nyr; ++b) {
          current_statement__ = 89;
          stan::model::assign(cf_yr,
            stan::math::elt_multiply(cf,
              stan::model::rvalue(cf_trend, "cf_trend",
                stan::model::index_omni(), stan::model::index_uni(b))),
            "assigning variable cf_yr", stan::model::index_min_max(1, nage),
            stan::model::index_uni(b));
        }
        current_statement__ = 106;
        for (int k = 1; k <= nbias; ++k) {
          current_statement__ = 96;
          for (int b = 1; b <= nyr; ++b) {
            current_statement__ = 94;
            for (int a = 1; a <= nage; ++a) {
              current_statement__ = 92;
              stan::model::assign(inc_yr,
                (stan::model::rvalue(inc, "inc", stan::model::index_uni(a),
                   stan::model::index_uni(k)) *
                stan::model::rvalue(inc_trend, "inc_trend",
                  stan::model::index_uni(a), stan::model::index_uni(b))),
                "assigning variable inc_yr", stan::model::index_uni(a),
                stan::model::index_uni(b), stan::model::index_uni(k));
            }
          }
          current_statement__ = 104;
          for (int b = 1; b <= nyr; ++b) {
            current_statement__ = 97;
            stan::model::assign(state_probs_yr, 1,
              "assigning variable state_probs_yr", stan::model::index_uni(1),
              stan::model::index_uni(b), stan::model::index_uni(k),
              stan::model::index_uni(1));
            current_statement__ = 98;
            stan::model::assign(state_probs_yr, 0,
              "assigning variable state_probs_yr", stan::model::index_uni(1),
              stan::model::index_uni(b), stan::model::index_uni(k),
              stan::model::index_uni(2));
            current_statement__ = 99;
            stan::model::assign(state_probs_yr, 0,
              "assigning variable state_probs_yr", stan::model::index_uni(1),
              stan::model::index_uni(b), stan::model::index_uni(k),
              stan::model::index_uni(3));
            current_statement__ = 102;
            for (int a = 2; a <= (nage + 1); ++a) {
              current_statement__ = 100;
              stan::model::assign(state_probs_yr,
                stan::math::rep_row_vector(0, 3),
                "assigning variable state_probs_yr",
                stan::model::index_uni(a), stan::model::index_uni(b),
                stan::model::index_uni(k), stan::model::index_min_max(1, 3));
            }
          }
        }
      } else {
        current_statement__ = 86;
        for (int k = 1; k <= nbias; ++k) {
          current_statement__ = 82;
          stan::model::assign(state_probs, 1,
            "assigning variable state_probs", stan::model::index_uni(1),
            stan::model::index_uni(k), stan::model::index_uni(1));
          current_statement__ = 83;
          stan::model::assign(state_probs, 0,
            "assigning variable state_probs", stan::model::index_uni(1),
            stan::model::index_uni(k), stan::model::index_uni(2));
          current_statement__ = 84;
          stan::model::assign(state_probs, 0,
            "assigning variable state_probs", stan::model::index_uni(1),
            stan::model::index_uni(k), stan::model::index_uni(3));
        }
      }
      current_statement__ = 145;
      for (int a = 1; a <= nage; ++a) {
        current_statement__ = 142;
        if (trend) {
          current_statement__ = 140;
          for (int k = 1; k <= nbias; ++k) {
            current_statement__ = 132;
            if (stan::math::logical_gt(a, 1)) {
              int y = std::numeric_limits<int>::min();
              current_statement__ = 130;
              for (int b = 2; b <= a; ++b) {
                current_statement__ = 125;
                y = ((nyr - a) + b);
                current_statement__ = 126;
                stan::model::assign(P,
                  trans_probs(
                    stan::model::rvalue(inc_yr, "inc_yr",
                      stan::model::index_uni((b - 1)),
                      stan::model::index_uni((y - 1)),
                      stan::model::index_uni(k)),
                    stan::model::rvalue(cf_yr, "cf_yr",
                      stan::model::index_uni((b - 1)),
                      stan::model::index_uni((y - 1))),
                    stan::model::rvalue(rem, "rem",
                      stan::model::index_uni((b - 1))), pstream__),
                  "assigning variable P");
                current_statement__ = 127;
                stan::model::assign(tmp,
                  stan::math::multiply(
                    stan::model::rvalue(state_probs_yr, "state_probs_yr",
                      stan::model::index_uni((b - 1)),
                      stan::model::index_uni((y - 1)),
                      stan::model::index_uni(k),
                      stan::model::index_min_max(1, 3)), P),
                  "assigning variable tmp");
                current_statement__ = 128;
                stan::model::assign(state_probs_yr, tmp,
                  "assigning variable state_probs_yr",
                  stan::model::index_uni(b), stan::model::index_uni(y),
                  stan::model::index_uni(k), stan::model::index_min_max(1, 3));
              }
            }
            current_statement__ = 133;
            stan::model::assign(P,
              trans_probs(
                stan::model::rvalue(inc_yr, "inc_yr",
                  stan::model::index_uni(a), stan::model::index_uni(nyr),
                  stan::model::index_uni(k)),
                stan::model::rvalue(cf_yr, "cf_yr",
                  stan::model::index_uni(a), stan::model::index_uni(nyr)),
                stan::model::rvalue(rem, "rem", stan::model::index_uni(a)),
                pstream__), "assigning variable P");
            current_statement__ = 134;
            stan::model::assign(inc_prob,
              bound_prob(
                (stan::model::rvalue(P, "P", stan::model::index_uni(1),
                   stan::model::index_uni(2)) +
                stan::model::rvalue(P, "P", stan::model::index_uni(1),
                  stan::model::index_uni(3))), pstream__),
              "assigning variable inc_prob", stan::model::index_uni(a),
              stan::model::index_uni(k));
            current_statement__ = 135;
            stan::model::assign(prev_prob,
              (stan::model::rvalue(state_probs_yr, "state_probs_yr",
                 stan::model::index_uni(a), stan::model::index_uni(nyr),
                 stan::model::index_uni(k), stan::model::index_uni(2)) /
              (stan::model::rvalue(state_probs_yr, "state_probs_yr",
                 stan::model::index_uni(a), stan::model::index_uni(nyr),
                 stan::model::index_uni(k), stan::model::index_uni(1)) +
              stan::model::rvalue(state_probs_yr, "state_probs_yr",
                stan::model::index_uni(a), stan::model::index_uni(nyr),
                stan::model::index_uni(k), stan::model::index_uni(2)))),
              "assigning variable prev_prob", stan::model::index_uni(a),
              stan::model::index_uni(k));
            current_statement__ = 137;
            if (stan::math::logical_eq(k, 1)) {
              current_statement__ = 136;
              stan::model::assign(mort_prob,
                ((stan::model::rvalue(P, "P", stan::model::index_uni(1),
                    stan::model::index_uni(3)) * (1 -
                stan::model::rvalue(prev_prob, "prev_prob",
                  stan::model::index_uni(a), stan::model::index_uni(1)))) +
                (stan::model::rvalue(P, "P", stan::model::index_uni(2),
                   stan::model::index_uni(3)) *
                stan::model::rvalue(prev_prob, "prev_prob",
                  stan::model::index_uni(a), stan::model::index_uni(1)))),
                "assigning variable mort_prob", stan::model::index_uni(a));
            }
            current_statement__ = 138;
            stan::model::assign(cf_prob,
              bound_prob(
                stan::model::rvalue(P, "P", stan::model::index_uni(2),
                  stan::model::index_uni(3)), pstream__),
              "assigning variable cf_prob", stan::model::index_uni(a));
          }
        } else {
          current_statement__ = 122;
          for (int k = 1; k <= nbias; ++k) {
            current_statement__ = 109;
            stan::model::assign(P,
              trans_probs(
                stan::model::rvalue(inc, "inc", stan::model::index_uni(a),
                  stan::model::index_uni(k)),
                stan::model::rvalue(cf, "cf", stan::model::index_uni(a)),
                stan::model::rvalue(rem, "rem", stan::model::index_uni(a)),
                pstream__), "assigning variable P");
            current_statement__ = 110;
            stan::model::assign(inc_prob,
              bound_prob(
                (stan::model::rvalue(P, "P", stan::model::index_uni(1),
                   stan::model::index_uni(2)) +
                stan::model::rvalue(P, "P", stan::model::index_uni(1),
                  stan::model::index_uni(3))), pstream__),
              "assigning variable inc_prob", stan::model::index_uni(a),
              stan::model::index_uni(k));
            current_statement__ = 112;
            if (stan::math::logical_gt(a, 1)) {
              current_statement__ = 111;
              stan::model::assign(prev_prob,
                (stan::model::rvalue(state_probs, "state_probs",
                   stan::model::index_uni(a), stan::model::index_uni(k),
                   stan::model::index_uni(2)) /
                (stan::model::rvalue(state_probs, "state_probs",
                   stan::model::index_uni(a), stan::model::index_uni(k),
                   stan::model::index_uni(1)) +
                stan::model::rvalue(state_probs, "state_probs",
                  stan::model::index_uni(a), stan::model::index_uni(k),
                  stan::model::index_uni(2)))),
                "assigning variable prev_prob", stan::model::index_uni(a),
                stan::model::index_uni(k));
            }
            current_statement__ = 113;
            stan::model::assign(tmp,
              stan::math::multiply(
                stan::model::rvalue(state_probs, "state_probs",
                  stan::model::index_uni(a), stan::model::index_uni(k),
                  stan::model::index_min_max(1, 3)), P),
              "assigning variable tmp");
            current_statement__ = 114;
            stan::model::assign(state_probs, tmp,
              "assigning variable state_probs",
              stan::model::index_uni((a + 1)), stan::model::index_uni(k),
              stan::model::index_min_max(1, 3));
            current_statement__ = 120;
            if (stan::math::logical_eq(k, 1)) {
              current_statement__ = 115;
              stan::model::assign(mort_prob,
                ((stan::model::rvalue(P, "P", stan::model::index_uni(1),
                    stan::model::index_uni(3)) * (1 -
                stan::model::rvalue(prev_prob, "prev_prob",
                  stan::model::index_uni(a), stan::model::index_uni(1)))) +
                (stan::model::rvalue(P, "P", stan::model::index_uni(2),
                   stan::model::index_uni(3)) *
                stan::model::rvalue(prev_prob, "prev_prob",
                  stan::model::index_uni(a), stan::model::index_uni(1)))),
                "assigning variable mort_prob", stan::model::index_uni(a));
              current_statement__ = 116;
              stan::model::assign(cf_prob,
                bound_prob(
                  stan::model::rvalue(P, "P", stan::model::index_uni(2),
                    stan::model::index_uni(3)), pstream__),
                "assigning variable cf_prob", stan::model::index_uni(a));
              current_statement__ = 118;
              if (remission) {
                current_statement__ = 117;
                stan::model::assign(rem_prob,
                  stan::model::rvalue(P, "P", stan::model::index_uni(2),
                    stan::model::index_uni(1)),
                  "assigning variable rem_prob", stan::model::index_uni(a));
              }
            }
          }
        }
        current_statement__ = 143;
        stan::model::assign(mort_prob,
          bound_prob(
            stan::model::rvalue(mort_prob, "mort_prob",
              stan::model::index_uni(a)), pstream__),
          "assigning variable mort_prob", stan::model::index_uni(a));
      }
      current_statement__ = 13;
      stan::math::check_greater_or_equal(function__, "cf", cf, 0);
      current_statement__ = 14;
      stan::math::check_greater_or_equal(function__, "dcf", dcf, 0);
      current_statement__ = 15;
      stan::math::check_greater_or_equal(function__, "inc", inc, 0);
      current_statement__ = 16;
      stan::math::check_greater_or_equal(function__, "inc_prob", inc_prob, 0);
      current_statement__ = 16;
      stan::math::check_less_or_equal(function__, "inc_prob", inc_prob, 1);
      current_statement__ = 17;
      stan::math::check_greater_or_equal(function__, "rem", rem, 0);
      current_statement__ = 18;
      stan::math::check_greater_or_equal(function__, "rem_prob", rem_prob, 0);
      current_statement__ = 18;
      stan::math::check_less_or_equal(function__, "rem_prob", rem_prob, 1);
      current_statement__ = 19;
      stan::math::check_greater_or_equal(function__, "cf_prob", cf_prob, 0);
      current_statement__ = 19;
      stan::math::check_less_or_equal(function__, "cf_prob", cf_prob, 1);
      current_statement__ = 22;
      stan::math::check_greater_or_equal(function__, "P", P, 0);
      current_statement__ = 22;
      stan::math::check_less_or_equal(function__, "P", P, 1);
      current_statement__ = 23;
      stan::math::check_greater_or_equal(function__, "prev_prob", prev_prob,
        0);
      current_statement__ = 24;
      stan::math::check_greater_or_equal(function__, "mort_prob", mort_prob,
        0);
      current_statement__ = 25;
      stan::math::check_greater_or_equal(function__, "cf_yr", cf_yr, 0);
      current_statement__ = 26;
      stan::math::check_greater_or_equal(function__, "inc_yr", inc_yr, 0);
      current_statement__ = 28;
      stan::math::check_greater_or_equal(function__, "lambda_cf_use",
        lambda_cf_use, 0);
      current_statement__ = 29;
      stan::math::check_greater_or_equal(function__, "lambda_inc_use",
        lambda_inc_use, 0);
      current_statement__ = 30;
      stan::math::check_greater_or_equal(function__, "lambda_rem_use",
        lambda_rem_use, 0);
      {
        current_statement__ = 156;
        lp_accum__.add(stan::math::binomial_lpmf<propto__>(mort_num,
                         mort_denom, mort_prob));
        current_statement__ = 157;
        lp_accum__.add(stan::math::binomial_lpmf<propto__>(inc_num,
                         inc_denom,
                         stan::model::rvalue(inc_prob, "inc_prob",
                           stan::model::index_min_max(1, nage),
                           stan::model::index_uni(incdata_ind))));
        current_statement__ = 158;
        lp_accum__.add(stan::math::binomial_lpmf<propto__>(prev_num,
                         prev_denom,
                         stan::model::rvalue(prev_prob, "prev_prob",
                           stan::model::index_min_max(1, nage),
                           stan::model::index_uni(prevdata_ind))));
        current_statement__ = 161;
        if (remission) {
          current_statement__ = 159;
          lp_accum__.add(stan::math::binomial_lpmf<propto__>(rem_num,
                           rem_denom, rem_prob));
        }
        current_statement__ = 177;
        if (smooth_cf) {
          current_statement__ = 173;
          if (stan::math::logical_negation(const_cf)) {
            current_statement__ = 168;
            for (int i = 1; i <= (K - 2); ++i) {
              current_statement__ = 166;
              lp_accum__.add(stan::math::normal_lpdf<propto__>(
                               stan::model::rvalue(beta, "beta",
                                 stan::model::index_uni(i)), 0, lambda_cf_use));
            }
            current_statement__ = 171;
            for (int i = (K - 1); i <= K; ++i) {
              current_statement__ = 169;
              lp_accum__.add(stan::math::normal_lpdf<propto__>(
                               stan::model::rvalue(beta, "beta",
                                 stan::model::index_uni(i)), 0, 100));
            }
          }
          current_statement__ = 175;
          if (stan::math::logical_negation(scf_isfixed)) {
            current_statement__ = 174;
            lp_accum__.add(stan::math::gamma_lpdf<propto__>(
                             stan::model::rvalue(lambda_cf, "lambda_cf",
                               stan::model::index_uni(1)), 2,
                             stan::model::rvalue(sprior, "sprior",
                               stan::model::index_uni(2))));
          }
        } else {
          current_statement__ = 164;
          for (int a = 1; a <= nage; ++a) {
            current_statement__ = 162;
            lp_accum__.add(stan::math::gamma_lpdf<propto__>(
                             stan::model::rvalue(cf_par, "cf_par",
                               stan::model::index_uni(a)),
                             stan::model::rvalue(cf_prior, "cf_prior",
                               stan::model::index_uni(1)),
                             stan::model::rvalue(cf_prior, "cf_prior",
                               stan::model::index_uni(2))));
          }
        }
        current_statement__ = 180;
        if (increasing_cf) {
          current_statement__ = 178;
          lp_accum__.add(stan::math::gamma_lpdf<propto__>(
                           stan::model::rvalue(cfbase, "cfbase",
                             stan::model::index_uni(1)),
                           stan::model::rvalue(cf_prior, "cf_prior",
                             stan::model::index_uni(1)),
                           stan::model::rvalue(cf_prior, "cf_prior",
                             stan::model::index_uni(2))));
        }
        current_statement__ = 194;
        if (smooth_inc) {
          current_statement__ = 187;
          for (int i = 1; i <= (K - 2); ++i) {
            current_statement__ = 185;
            lp_accum__.add(stan::math::normal_lpdf<propto__>(
                             stan::model::rvalue(beta_inc, "beta_inc",
                               stan::model::index_uni(i)), 0, lambda_inc_use));
          }
          current_statement__ = 190;
          for (int i = (K - 1); i <= K; ++i) {
            current_statement__ = 188;
            lp_accum__.add(stan::math::normal_lpdf<propto__>(
                             stan::model::rvalue(beta_inc, "beta_inc",
                               stan::model::index_uni(i)), 0, 100));
          }
          current_statement__ = 192;
          if (stan::math::logical_negation(sinc_isfixed)) {
            current_statement__ = 191;
            lp_accum__.add(stan::math::gamma_lpdf<propto__>(
                             stan::model::rvalue(lambda_inc, "lambda_inc",
                               stan::model::index_uni(1)), 2,
                             stan::model::rvalue(sprior, "sprior",
                               stan::model::index_uni(1))));
          }
        } else {
          current_statement__ = 183;
          for (int a = 1; a <= nage; ++a) {
            current_statement__ = 181;
            lp_accum__.add(stan::math::gamma_lpdf<propto__>(
                             stan::model::rvalue(inc_par, "inc_par",
                               stan::model::index_uni(a)),
                             stan::model::rvalue(inc_prior, "inc_prior",
                               stan::model::index_uni(1)),
                             stan::model::rvalue(inc_prior, "inc_prior",
                               stan::model::index_uni(2))));
          }
        }
        current_statement__ = 212;
        if (remission) {
          current_statement__ = 210;
          if (smooth_rem) {
            current_statement__ = 203;
            for (int i = 1; i <= (K - 2); ++i) {
              current_statement__ = 201;
              lp_accum__.add(stan::math::normal_lpdf<propto__>(
                               stan::model::rvalue(beta_rem, "beta_rem",
                                 stan::model::index_uni(i)), 0,
                               lambda_rem_use));
            }
            current_statement__ = 206;
            for (int i = (K - 1); i <= K; ++i) {
              current_statement__ = 204;
              lp_accum__.add(stan::math::normal_lpdf<propto__>(
                               stan::model::rvalue(beta_rem, "beta_rem",
                                 stan::model::index_uni(i)), 0, 100));
            }
            current_statement__ = 208;
            if (stan::math::logical_negation(srem_isfixed)) {
              current_statement__ = 207;
              lp_accum__.add(stan::math::gamma_lpdf<propto__>(
                               stan::model::rvalue(lambda_rem, "lambda_rem",
                                 stan::model::index_uni(1)), 2,
                               stan::model::rvalue(sprior, "sprior",
                                 stan::model::index_uni(3))));
            }
          } else {
            current_statement__ = 200;
            if (const_rem) {
              current_statement__ = 199;
              lp_accum__.add(stan::math::gamma_lpdf<propto__>(
                               stan::model::rvalue(rem_par, "rem_par",
                                 stan::model::index_uni(1)),
                               stan::model::rvalue(rem_prior, "rem_prior",
                                 stan::model::index_uni(1)),
                               stan::model::rvalue(rem_prior, "rem_prior",
                                 stan::model::index_uni(2))));
            } else {
              current_statement__ = 197;
              for (int a = 1; a <= nage; ++a) {
                current_statement__ = 195;
                lp_accum__.add(stan::math::gamma_lpdf<propto__>(
                                 stan::model::rvalue(rem_par, "rem_par",
                                   stan::model::index_uni(a)),
                                 stan::model::rvalue(rem_prior, "rem_prior",
                                   stan::model::index_uni(1)),
                                 stan::model::rvalue(rem_prior, "rem_prior",
                                   stan::model::index_uni(2))));
              }
            }
          }
        }
        current_statement__ = 215;
        if (stan::math::logical_eq(nbias, 2)) {
          current_statement__ = 213;
          lp_accum__.add(stan::math::normal_lpdf<propto__>(bias_loghr, 0, 1));
        }
        current_statement__ = 218;
        if (prev_zero) {
          current_statement__ = 216;
          lp_accum__.add(stan::math::beta_lpdf<propto__>(
                           stan::model::rvalue(prevzero, "prevzero",
                             stan::model::index_uni(1)), 2, 2));
        }
      }
    } 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_disbayes_namespace::write_array";
    // suppress unused var warning
    (void) function__;
    try {
      Eigen::Matrix<double,-1,1> inc_par =
        Eigen::Matrix<double,-1,1>::Constant(inc_par_1dim__,
          std::numeric_limits<double>::quiet_NaN());
      current_statement__ = 1;
      inc_par = in__.template read_constrain_lb<
                  Eigen::Matrix<local_scalar_t__,-1,1>, jacobian__>(0, lp__,
                  inc_par_1dim__);
      Eigen::Matrix<double,-1,1> cf_par =
        Eigen::Matrix<double,-1,1>::Constant(cf_par_1dim__,
          std::numeric_limits<double>::quiet_NaN());
      current_statement__ = 2;
      cf_par = in__.template read_constrain_lb<
                 Eigen::Matrix<local_scalar_t__,-1,1>, jacobian__>(0, lp__,
                 cf_par_1dim__);
      Eigen::Matrix<double,-1,1> rem_par =
        Eigen::Matrix<double,-1,1>::Constant(rem_par_1dim__,
          std::numeric_limits<double>::quiet_NaN());
      current_statement__ = 3;
      rem_par = in__.template read_constrain_lb<
                  Eigen::Matrix<local_scalar_t__,-1,1>, jacobian__>(0, lp__,
                  rem_par_1dim__);
      Eigen::Matrix<double,-1,1> beta =
        Eigen::Matrix<double,-1,1>::Constant(beta_1dim__,
          std::numeric_limits<double>::quiet_NaN());
      current_statement__ = 4;
      beta = in__.template read<
               Eigen::Matrix<local_scalar_t__,-1,1>>(beta_1dim__);
      Eigen::Matrix<double,-1,1> lambda_cf =
        Eigen::Matrix<double,-1,1>::Constant(lambda_cf_1dim__,
          std::numeric_limits<double>::quiet_NaN());
      current_statement__ = 5;
      lambda_cf = in__.template read_constrain_lb<
                    Eigen::Matrix<local_scalar_t__,-1,1>, jacobian__>(0,
                    lp__, lambda_cf_1dim__);
      Eigen::Matrix<double,-1,1> lambda_inc =
        Eigen::Matrix<double,-1,1>::Constant(lambda_inc_1dim__,
          std::numeric_limits<double>::quiet_NaN());
      current_statement__ = 6;
      lambda_inc = in__.template read_constrain_lb<
                     Eigen::Matrix<local_scalar_t__,-1,1>, jacobian__>(0,
                     lp__, lambda_inc_1dim__);
      Eigen::Matrix<double,-1,1> beta_inc =
        Eigen::Matrix<double,-1,1>::Constant(beta_inc_1dim__,
          std::numeric_limits<double>::quiet_NaN());
      current_statement__ = 7;
      beta_inc = in__.template read<
                   Eigen::Matrix<local_scalar_t__,-1,1>>(beta_inc_1dim__);
      Eigen::Matrix<double,-1,1> lambda_rem =
        Eigen::Matrix<double,-1,1>::Constant(lambda_rem_1dim__,
          std::numeric_limits<double>::quiet_NaN());
      current_statement__ = 8;
      lambda_rem = in__.template read_constrain_lb<
                     Eigen::Matrix<local_scalar_t__,-1,1>, jacobian__>(0,
                     lp__, lambda_rem_1dim__);
      Eigen::Matrix<double,-1,1> beta_rem =
        Eigen::Matrix<double,-1,1>::Constant(beta_rem_1dim__,
          std::numeric_limits<double>::quiet_NaN());
      current_statement__ = 9;
      beta_rem = in__.template read<
                   Eigen::Matrix<local_scalar_t__,-1,1>>(beta_rem_1dim__);
      Eigen::Matrix<double,-1,1> prevzero =
        Eigen::Matrix<double,-1,1>::Constant(prev_zero,
          std::numeric_limits<double>::quiet_NaN());
      current_statement__ = 10;
      prevzero = in__.template read_constrain_lub<
                   Eigen::Matrix<local_scalar_t__,-1,1>, jacobian__>(0, 1,
                   lp__, prev_zero);
      Eigen::Matrix<double,-1,1> bias_loghr =
        Eigen::Matrix<double,-1,1>::Constant(bias_loghr_1dim__,
          std::numeric_limits<double>::quiet_NaN());
      current_statement__ = 11;
      bias_loghr = in__.template read<
                     Eigen::Matrix<local_scalar_t__,-1,1>>(bias_loghr_1dim__);
      Eigen::Matrix<double,-1,1> cfbase =
        Eigen::Matrix<double,-1,1>::Constant(cfbase_1dim__,
          std::numeric_limits<double>::quiet_NaN());
      current_statement__ = 12;
      cfbase = in__.template read_constrain_lb<
                 Eigen::Matrix<local_scalar_t__,-1,1>, jacobian__>(0, lp__,
                 cfbase_1dim__);
      Eigen::Matrix<double,-1,1> cf =
        Eigen::Matrix<double,-1,1>::Constant(nage,
          std::numeric_limits<double>::quiet_NaN());
      Eigen::Matrix<double,-1,1> dcf =
        Eigen::Matrix<double,-1,1>::Constant(dcf_1dim__,
          std::numeric_limits<double>::quiet_NaN());
      Eigen::Matrix<double,-1,-1> inc =
        Eigen::Matrix<double,-1,-1>::Constant(nage, nbias,
          std::numeric_limits<double>::quiet_NaN());
      Eigen::Matrix<double,-1,-1> inc_prob =
        Eigen::Matrix<double,-1,-1>::Constant(nage, nbias,
          std::numeric_limits<double>::quiet_NaN());
      Eigen::Matrix<double,-1,1> rem =
        Eigen::Matrix<double,-1,1>::Constant(nage,
          std::numeric_limits<double>::quiet_NaN());
      Eigen::Matrix<double,-1,1> rem_prob =
        Eigen::Matrix<double,-1,1>::Constant(rem_prob_1dim__,
          std::numeric_limits<double>::quiet_NaN());
      Eigen::Matrix<double,-1,1> cf_prob =
        Eigen::Matrix<double,-1,1>::Constant(nage,
          std::numeric_limits<double>::quiet_NaN());
      std::vector<std::vector<Eigen::Matrix<double,1,-1>>> state_probs =
        std::vector<std::vector<Eigen::Matrix<double,1,-1>>>(state_probs_1dim__,
          std::vector<Eigen::Matrix<double,1,-1>>(nbias,
            Eigen::Matrix<double,1,-1>::Constant(3,
              std::numeric_limits<double>::quiet_NaN())));
      Eigen::Matrix<double,1,-1> tmp =
        Eigen::Matrix<double,1,-1>::Constant(3,
          std::numeric_limits<double>::quiet_NaN());
      Eigen::Matrix<double,-1,-1> P =
        Eigen::Matrix<double,-1,-1>::Constant(3, 3,
          std::numeric_limits<double>::quiet_NaN());
      Eigen::Matrix<double,-1,-1> prev_prob =
        Eigen::Matrix<double,-1,-1>::Constant(nage, nbias,
          std::numeric_limits<double>::quiet_NaN());
      std::vector<double> mort_prob =
        std::vector<double>(nage, std::numeric_limits<double>::quiet_NaN());
      Eigen::Matrix<double,-1,-1> cf_yr =
        Eigen::Matrix<double,-1,-1>::Constant(cf_yr_1dim__, cf_yr_2dim__,
          std::numeric_limits<double>::quiet_NaN());
      std::vector<std::vector<std::vector<double>>> inc_yr =
        std::vector<std::vector<std::vector<double>>>(inc_yr_1dim__,
          std::vector<std::vector<double>>(inc_yr_2dim__,
            std::vector<double>(nbias,
              std::numeric_limits<double>::quiet_NaN())));
      std::vector<std::vector<std::vector<Eigen::Matrix<double,1,-1>>>>
        state_probs_yr =
        std::vector<std::vector<std::vector<Eigen::Matrix<double,1,-1>>>>(state_probs_yr_1dim__,
          std::vector<std::vector<Eigen::Matrix<double,1,-1>>>(state_probs_yr_2dim__,
            std::vector<Eigen::Matrix<double,1,-1>>(nbias,
              Eigen::Matrix<double,1,-1>::Constant(3,
                std::numeric_limits<double>::quiet_NaN()))));
      double lambda_cf_use = std::numeric_limits<double>::quiet_NaN();
      double lambda_inc_use = std::numeric_limits<double>::quiet_NaN();
      double lambda_rem_use = std::numeric_limits<double>::quiet_NaN();
      out__.write(inc_par);
      out__.write(cf_par);
      out__.write(rem_par);
      out__.write(beta);
      out__.write(lambda_cf);
      out__.write(lambda_inc);
      out__.write(beta_inc);
      out__.write(lambda_rem);
      out__.write(beta_rem);
      out__.write(prevzero);
      out__.write(bias_loghr);
      out__.write(cfbase);
      if (stan::math::logical_negation(
            (stan::math::primitive_value(emit_transformed_parameters__) ||
            stan::math::primitive_value(emit_generated_quantities__)))) {
        return ;
      }
      current_statement__ = 38;
      if ((stan::math::primitive_value(scf_isfixed) ||
          stan::math::primitive_value(stan::math::logical_negation(smooth_cf)))) {
        current_statement__ = 37;
        lambda_cf_use = lambda_cf_fixed;
      } else {
        current_statement__ = 36;
        lambda_cf_use = stan::model::rvalue(lambda_cf, "lambda_cf",
                          stan::model::index_uni(1));
      }
      current_statement__ = 41;
      if ((stan::math::primitive_value(sinc_isfixed) ||
          stan::math::primitive_value(
            stan::math::logical_negation(smooth_inc)))) {
        current_statement__ = 40;
        lambda_inc_use = lambda_inc_fixed;
      } else {
        current_statement__ = 39;
        lambda_inc_use = stan::model::rvalue(lambda_inc, "lambda_inc",
                           stan::model::index_uni(1));
      }
      current_statement__ = 44;
      if ((stan::math::primitive_value(srem_isfixed) ||
          stan::math::primitive_value(
            stan::math::logical_negation(smooth_rem)))) {
        current_statement__ = 43;
        lambda_rem_use = lambda_rem_fixed;
      } else {
        current_statement__ = 42;
        lambda_rem_use = stan::model::rvalue(lambda_rem, "lambda_rem",
                           stan::model::index_uni(1));
      }
      current_statement__ = 47;
      if (smooth_inc) {
        current_statement__ = 46;
        stan::model::assign(inc,
          stan::math::exp(stan::math::multiply(X, beta_inc)),
          "assigning variable inc", stan::model::index_min_max(1, nage),
          stan::model::index_uni(1));
      } else {
        current_statement__ = 45;
        stan::model::assign(inc, inc_par, "assigning variable inc",
          stan::model::index_min_max(1, nage), stan::model::index_uni(1));
      }
      current_statement__ = 50;
      if (stan::math::logical_gt(nbias, 1)) {
        current_statement__ = 48;
        stan::model::assign(inc,
          stan::math::exp(
            stan::math::add(
              stan::math::log(
                stan::model::deep_copy(
                  stan::model::rvalue(inc, "inc",
                    stan::model::index_min_max(1, nage),
                    stan::model::index_uni(1)))),
              stan::model::rvalue(bias_loghr, "bias_loghr",
                stan::model::index_uni(1)))), "assigning variable inc",
          stan::model::index_min_max(1, nage), stan::model::index_uni(2));
      }
      current_statement__ = 60;
      if (remission) {
        current_statement__ = 58;
        if (const_rem) {
          current_statement__ = 56;
          for (int a = 1; a <= nage; ++a) {
            current_statement__ = 55;
            stan::model::assign(rem,
              stan::model::rvalue(rem_par, "rem_par",
                stan::model::index_uni(1)), "assigning variable rem",
              stan::model::index_uni(a));
          }
        } else {
          current_statement__ = 54;
          if (smooth_rem) {
            current_statement__ = 53;
            stan::model::assign(rem,
              stan::math::exp(stan::math::multiply(X, beta_rem)),
              "assigning variable rem");
          } else {
            current_statement__ = 52;
            stan::model::assign(rem, rem_par, "assigning variable rem");
          }
        }
      } else {
        current_statement__ = 51;
        stan::model::assign(rem, stan::math::rep_vector(0, nage),
          "assigning variable rem");
      }
      current_statement__ = 65;
      for (int k = 1; k <= nbias; ++k) {
        current_statement__ = 63;
        if ((stan::math::primitive_value(
               stan::math::logical_gt(
                 stan::model::rvalue(prev_denom, "prev_denom",
                   stan::model::index_uni(1)), 0))
            &&
            stan::math::primitive_value(
              (stan::math::primitive_value(
                 stan::math::logical_gt(
                   stan::model::rvalue(prev_num, "prev_num",
                     stan::model::index_uni(1)), 0)) ||
              stan::math::primitive_value(prev_zero))))) {
          current_statement__ = 62;
          stan::model::assign(prev_prob,
            stan::model::rvalue(prevzero, "prevzero",
              stan::model::index_uni(1)), "assigning variable prev_prob",
            stan::model::index_uni(1), stan::model::index_uni(k));
        } else {
          current_statement__ = 61;
          stan::model::assign(prev_prob, 0, "assigning variable prev_prob",
            stan::model::index_uni(1), stan::model::index_uni(k));
        }
      }
      current_statement__ = 81;
      if (increasing_cf) {
        current_statement__ = 72;
        for (int a = 1; a <= (eqage - 1); ++a) {
          current_statement__ = 70;
          stan::model::assign(cf,
            stan::model::rvalue(cfbase, "cfbase", stan::model::index_uni(1)),
            "assigning variable cf", stan::model::index_uni(a));
        }
        current_statement__ = 76;
        if (stan::math::logical_negation(const_cf)) {
          current_statement__ = 74;
          stan::model::assign(dcf,
            stan::math::exp(stan::math::multiply(X, beta)),
            "assigning variable dcf");
        } else {
          current_statement__ = 73;
          stan::model::assign(dcf, stan::math::rep_vector(0, nage),
            "assigning variable dcf");
        }
        current_statement__ = 79;
        for (int a = eqage; a <= nage; ++a) {
          current_statement__ = 77;
          stan::model::assign(cf,
            (stan::model::rvalue(cf, "cf", stan::model::index_uni((a - 1))) +
            stan::model::rvalue(dcf, "dcf", stan::model::index_uni(a))),
            "assigning variable cf", stan::model::index_uni(a));
        }
      } else {
        current_statement__ = 68;
        if (smooth_cf) {
          current_statement__ = 67;
          stan::model::assign(cf,
            stan::math::exp(stan::math::multiply(X, beta)),
            "assigning variable cf");
        } else {
          current_statement__ = 66;
          stan::model::assign(cf, cf_par, "assigning variable cf");
        }
      }
      current_statement__ = 108;
      if (trend) {
        current_statement__ = 88;
        stan::model::assign(cf,
          stan::math::exp(stan::math::multiply(X, beta)),
          "assigning variable cf");
        current_statement__ = 91;
        for (int b = 1; b <= nyr; ++b) {
          current_statement__ = 89;
          stan::model::assign(cf_yr,
            stan::math::elt_multiply(cf,
              stan::model::rvalue(cf_trend, "cf_trend",
                stan::model::index_omni(), stan::model::index_uni(b))),
            "assigning variable cf_yr", stan::model::index_min_max(1, nage),
            stan::model::index_uni(b));
        }
        current_statement__ = 106;
        for (int k = 1; k <= nbias; ++k) {
          current_statement__ = 96;
          for (int b = 1; b <= nyr; ++b) {
            current_statement__ = 94;
            for (int a = 1; a <= nage; ++a) {
              current_statement__ = 92;
              stan::model::assign(inc_yr,
                (stan::model::rvalue(inc, "inc", stan::model::index_uni(a),
                   stan::model::index_uni(k)) *
                stan::model::rvalue(inc_trend, "inc_trend",
                  stan::model::index_uni(a), stan::model::index_uni(b))),
                "assigning variable inc_yr", stan::model::index_uni(a),
                stan::model::index_uni(b), stan::model::index_uni(k));
            }
          }
          current_statement__ = 104;
          for (int b = 1; b <= nyr; ++b) {
            current_statement__ = 97;
            stan::model::assign(state_probs_yr, 1,
              "assigning variable state_probs_yr", stan::model::index_uni(1),
              stan::model::index_uni(b), stan::model::index_uni(k),
              stan::model::index_uni(1));
            current_statement__ = 98;
            stan::model::assign(state_probs_yr, 0,
              "assigning variable state_probs_yr", stan::model::index_uni(1),
              stan::model::index_uni(b), stan::model::index_uni(k),
              stan::model::index_uni(2));
            current_statement__ = 99;
            stan::model::assign(state_probs_yr, 0,
              "assigning variable state_probs_yr", stan::model::index_uni(1),
              stan::model::index_uni(b), stan::model::index_uni(k),
              stan::model::index_uni(3));
            current_statement__ = 102;
            for (int a = 2; a <= (nage + 1); ++a) {
              current_statement__ = 100;
              stan::model::assign(state_probs_yr,
                stan::math::rep_row_vector(0, 3),
                "assigning variable state_probs_yr",
                stan::model::index_uni(a), stan::model::index_uni(b),
                stan::model::index_uni(k), stan::model::index_min_max(1, 3));
            }
          }
        }
      } else {
        current_statement__ = 86;
        for (int k = 1; k <= nbias; ++k) {
          current_statement__ = 82;
          stan::model::assign(state_probs, 1,
            "assigning variable state_probs", stan::model::index_uni(1),
            stan::model::index_uni(k), stan::model::index_uni(1));
          current_statement__ = 83;
          stan::model::assign(state_probs, 0,
            "assigning variable state_probs", stan::model::index_uni(1),
            stan::model::index_uni(k), stan::model::index_uni(2));
          current_statement__ = 84;
          stan::model::assign(state_probs, 0,
            "assigning variable state_probs", stan::model::index_uni(1),
            stan::model::index_uni(k), stan::model::index_uni(3));
        }
      }
      current_statement__ = 145;
      for (int a = 1; a <= nage; ++a) {
        current_statement__ = 142;
        if (trend) {
          current_statement__ = 140;
          for (int k = 1; k <= nbias; ++k) {
            current_statement__ = 132;
            if (stan::math::logical_gt(a, 1)) {
              int y = std::numeric_limits<int>::min();
              current_statement__ = 130;
              for (int b = 2; b <= a; ++b) {
                current_statement__ = 125;
                y = ((nyr - a) + b);
                current_statement__ = 126;
                stan::model::assign(P,
                  trans_probs(
                    stan::model::rvalue(inc_yr, "inc_yr",
                      stan::model::index_uni((b - 1)),
                      stan::model::index_uni((y - 1)),
                      stan::model::index_uni(k)),
                    stan::model::rvalue(cf_yr, "cf_yr",
                      stan::model::index_uni((b - 1)),
                      stan::model::index_uni((y - 1))),
                    stan::model::rvalue(rem, "rem",
                      stan::model::index_uni((b - 1))), pstream__),
                  "assigning variable P");
                current_statement__ = 127;
                stan::model::assign(tmp,
                  stan::math::multiply(
                    stan::model::rvalue(state_probs_yr, "state_probs_yr",
                      stan::model::index_uni((b - 1)),
                      stan::model::index_uni((y - 1)),
                      stan::model::index_uni(k),
                      stan::model::index_min_max(1, 3)), P),
                  "assigning variable tmp");
                current_statement__ = 128;
                stan::model::assign(state_probs_yr, tmp,
                  "assigning variable state_probs_yr",
                  stan::model::index_uni(b), stan::model::index_uni(y),
                  stan::model::index_uni(k), stan::model::index_min_max(1, 3));
              }
            }
            current_statement__ = 133;
            stan::model::assign(P,
              trans_probs(
                stan::model::rvalue(inc_yr, "inc_yr",
                  stan::model::index_uni(a), stan::model::index_uni(nyr),
                  stan::model::index_uni(k)),
                stan::model::rvalue(cf_yr, "cf_yr",
                  stan::model::index_uni(a), stan::model::index_uni(nyr)),
                stan::model::rvalue(rem, "rem", stan::model::index_uni(a)),
                pstream__), "assigning variable P");
            current_statement__ = 134;
            stan::model::assign(inc_prob,
              bound_prob(
                (stan::model::rvalue(P, "P", stan::model::index_uni(1),
                   stan::model::index_uni(2)) +
                stan::model::rvalue(P, "P", stan::model::index_uni(1),
                  stan::model::index_uni(3))), pstream__),
              "assigning variable inc_prob", stan::model::index_uni(a),
              stan::model::index_uni(k));
            current_statement__ = 135;
            stan::model::assign(prev_prob,
              (stan::model::rvalue(state_probs_yr, "state_probs_yr",
                 stan::model::index_uni(a), stan::model::index_uni(nyr),
                 stan::model::index_uni(k), stan::model::index_uni(2)) /
              (stan::model::rvalue(state_probs_yr, "state_probs_yr",
                 stan::model::index_uni(a), stan::model::index_uni(nyr),
                 stan::model::index_uni(k), stan::model::index_uni(1)) +
              stan::model::rvalue(state_probs_yr, "state_probs_yr",
                stan::model::index_uni(a), stan::model::index_uni(nyr),
                stan::model::index_uni(k), stan::model::index_uni(2)))),
              "assigning variable prev_prob", stan::model::index_uni(a),
              stan::model::index_uni(k));
            current_statement__ = 137;
            if (stan::math::logical_eq(k, 1)) {
              current_statement__ = 136;
              stan::model::assign(mort_prob,
                ((stan::model::rvalue(P, "P", stan::model::index_uni(1),
                    stan::model::index_uni(3)) * (1 -
                stan::model::rvalue(prev_prob, "prev_prob",
                  stan::model::index_uni(a), stan::model::index_uni(1)))) +
                (stan::model::rvalue(P, "P", stan::model::index_uni(2),
                   stan::model::index_uni(3)) *
                stan::model::rvalue(prev_prob, "prev_prob",
                  stan::model::index_uni(a), stan::model::index_uni(1)))),
                "assigning variable mort_prob", stan::model::index_uni(a));
            }
            current_statement__ = 138;
            stan::model::assign(cf_prob,
              bound_prob(
                stan::model::rvalue(P, "P", stan::model::index_uni(2),
                  stan::model::index_uni(3)), pstream__),
              "assigning variable cf_prob", stan::model::index_uni(a));
          }
        } else {
          current_statement__ = 122;
          for (int k = 1; k <= nbias; ++k) {
            current_statement__ = 109;
            stan::model::assign(P,
              trans_probs(
                stan::model::rvalue(inc, "inc", stan::model::index_uni(a),
                  stan::model::index_uni(k)),
                stan::model::rvalue(cf, "cf", stan::model::index_uni(a)),
                stan::model::rvalue(rem, "rem", stan::model::index_uni(a)),
                pstream__), "assigning variable P");
            current_statement__ = 110;
            stan::model::assign(inc_prob,
              bound_prob(
                (stan::model::rvalue(P, "P", stan::model::index_uni(1),
                   stan::model::index_uni(2)) +
                stan::model::rvalue(P, "P", stan::model::index_uni(1),
                  stan::model::index_uni(3))), pstream__),
              "assigning variable inc_prob", stan::model::index_uni(a),
              stan::model::index_uni(k));
            current_statement__ = 112;
            if (stan::math::logical_gt(a, 1)) {
              current_statement__ = 111;
              stan::model::assign(prev_prob,
                (stan::model::rvalue(state_probs, "state_probs",
                   stan::model::index_uni(a), stan::model::index_uni(k),
                   stan::model::index_uni(2)) /
                (stan::model::rvalue(state_probs, "state_probs",
                   stan::model::index_uni(a), stan::model::index_uni(k),
                   stan::model::index_uni(1)) +
                stan::model::rvalue(state_probs, "state_probs",
                  stan::model::index_uni(a), stan::model::index_uni(k),
                  stan::model::index_uni(2)))),
                "assigning variable prev_prob", stan::model::index_uni(a),
                stan::model::index_uni(k));
            }
            current_statement__ = 113;
            stan::model::assign(tmp,
              stan::math::multiply(
                stan::model::rvalue(state_probs, "state_probs",
                  stan::model::index_uni(a), stan::model::index_uni(k),
                  stan::model::index_min_max(1, 3)), P),
              "assigning variable tmp");
            current_statement__ = 114;
            stan::model::assign(state_probs, tmp,
              "assigning variable state_probs",
              stan::model::index_uni((a + 1)), stan::model::index_uni(k),
              stan::model::index_min_max(1, 3));
            current_statement__ = 120;
            if (stan::math::logical_eq(k, 1)) {
              current_statement__ = 115;
              stan::model::assign(mort_prob,
                ((stan::model::rvalue(P, "P", stan::model::index_uni(1),
                    stan::model::index_uni(3)) * (1 -
                stan::model::rvalue(prev_prob, "prev_prob",
                  stan::model::index_uni(a), stan::model::index_uni(1)))) +
                (stan::model::rvalue(P, "P", stan::model::index_uni(2),
                   stan::model::index_uni(3)) *
                stan::model::rvalue(prev_prob, "prev_prob",
                  stan::model::index_uni(a), stan::model::index_uni(1)))),
                "assigning variable mort_prob", stan::model::index_uni(a));
              current_statement__ = 116;
              stan::model::assign(cf_prob,
                bound_prob(
                  stan::model::rvalue(P, "P", stan::model::index_uni(2),
                    stan::model::index_uni(3)), pstream__),
                "assigning variable cf_prob", stan::model::index_uni(a));
              current_statement__ = 118;
              if (remission) {
                current_statement__ = 117;
                stan::model::assign(rem_prob,
                  stan::model::rvalue(P, "P", stan::model::index_uni(2),
                    stan::model::index_uni(1)),
                  "assigning variable rem_prob", stan::model::index_uni(a));
              }
            }
          }
        }
        current_statement__ = 143;
        stan::model::assign(mort_prob,
          bound_prob(
            stan::model::rvalue(mort_prob, "mort_prob",
              stan::model::index_uni(a)), pstream__),
          "assigning variable mort_prob", stan::model::index_uni(a));
      }
      current_statement__ = 13;
      stan::math::check_greater_or_equal(function__, "cf", cf, 0);
      current_statement__ = 14;
      stan::math::check_greater_or_equal(function__, "dcf", dcf, 0);
      current_statement__ = 15;
      stan::math::check_greater_or_equal(function__, "inc", inc, 0);
      current_statement__ = 16;
      stan::math::check_greater_or_equal(function__, "inc_prob", inc_prob, 0);
      current_statement__ = 16;
      stan::math::check_less_or_equal(function__, "inc_prob", inc_prob, 1);
      current_statement__ = 17;
      stan::math::check_greater_or_equal(function__, "rem", rem, 0);
      current_statement__ = 18;
      stan::math::check_greater_or_equal(function__, "rem_prob", rem_prob, 0);
      current_statement__ = 18;
      stan::math::check_less_or_equal(function__, "rem_prob", rem_prob, 1);
      current_statement__ = 19;
      stan::math::check_greater_or_equal(function__, "cf_prob", cf_prob, 0);
      current_statement__ = 19;
      stan::math::check_less_or_equal(function__, "cf_prob", cf_prob, 1);
      current_statement__ = 22;
      stan::math::check_greater_or_equal(function__, "P", P, 0);
      current_statement__ = 22;
      stan::math::check_less_or_equal(function__, "P", P, 1);
      current_statement__ = 23;
      stan::math::check_greater_or_equal(function__, "prev_prob", prev_prob,
        0);
      current_statement__ = 24;
      stan::math::check_greater_or_equal(function__, "mort_prob", mort_prob,
        0);
      current_statement__ = 25;
      stan::math::check_greater_or_equal(function__, "cf_yr", cf_yr, 0);
      current_statement__ = 26;
      stan::math::check_greater_or_equal(function__, "inc_yr", inc_yr, 0);
      current_statement__ = 28;
      stan::math::check_greater_or_equal(function__, "lambda_cf_use",
        lambda_cf_use, 0);
      current_statement__ = 29;
      stan::math::check_greater_or_equal(function__, "lambda_inc_use",
        lambda_inc_use, 0);
      current_statement__ = 30;
      stan::math::check_greater_or_equal(function__, "lambda_rem_use",
        lambda_rem_use, 0);
      if (emit_transformed_parameters__) {
        out__.write(cf);
        out__.write(dcf);
        out__.write(inc);
        out__.write(inc_prob);
        out__.write(rem);
        out__.write(rem_prob);
        out__.write(cf_prob);
        for (int sym1__ = 1; sym1__ <= 3; ++sym1__) {
          for (int sym2__ = 1; sym2__ <= nbias; ++sym2__) {
            for (int sym3__ = 1; sym3__ <= state_probs_1dim__; ++sym3__) {
              out__.write(state_probs[(sym3__ - 1)][(sym2__ - 1)][(sym1__ -
                1)]);
            }
          }
        }
        out__.write(tmp);
        out__.write(P);
        out__.write(prev_prob);
        out__.write(mort_prob);
        out__.write(cf_yr);
        for (int sym1__ = 1; sym1__ <= nbias; ++sym1__) {
          for (int sym2__ = 1; sym2__ <= inc_yr_2dim__; ++sym2__) {
            for (int sym3__ = 1; sym3__ <= inc_yr_1dim__; ++sym3__) {
              out__.write(inc_yr[(sym3__ - 1)][(sym2__ - 1)][(sym1__ - 1)]);
            }
          }
        }
        for (int sym1__ = 1; sym1__ <= 3; ++sym1__) {
          for (int sym2__ = 1; sym2__ <= nbias; ++sym2__) {
            for (int sym3__ = 1; sym3__ <= state_probs_yr_2dim__; ++sym3__) {
              for (int sym4__ = 1; sym4__ <= state_probs_yr_1dim__; ++sym4__) {
                out__.write(state_probs_yr[(sym4__ - 1)][(sym3__ -
                  1)][(sym2__ - 1)][(sym1__ - 1)]);
              }
            }
          }
        }
        out__.write(lambda_cf_use);
        out__.write(lambda_inc_use);
        out__.write(lambda_rem_use);
      }
      if (stan::math::logical_negation(emit_generated_quantities__)) {
        return ;
      }
      Eigen::Matrix<double,-1,1> ll_mort =
        Eigen::Matrix<double,-1,1>::Constant(nage,
          std::numeric_limits<double>::quiet_NaN());
      Eigen::Matrix<double,-1,1> ll_inc =
        Eigen::Matrix<double,-1,1>::Constant(ll_inc_1dim__,
          std::numeric_limits<double>::quiet_NaN());
      Eigen::Matrix<double,-1,1> ll_prev =
        Eigen::Matrix<double,-1,1>::Constant(ll_prev_1dim__,
          std::numeric_limits<double>::quiet_NaN());
      Eigen::Matrix<double,-1,1> ll_rem =
        Eigen::Matrix<double,-1,1>::Constant(ll_rem_1dim__,
          std::numeric_limits<double>::quiet_NaN());
      Eigen::Matrix<double,-1,1> ll_overall =
        Eigen::Matrix<double,-1,1>::Constant(ll_overall_1dim__,
          std::numeric_limits<double>::quiet_NaN());
      current_statement__ = 154;
      for (int a = 1; a <= nage; ++a) {
        current_statement__ = 146;
        stan::model::assign(ll_mort,
          stan::math::binomial_lpmf<false>(
            stan::model::rvalue(mort_num, "mort_num",
              stan::model::index_uni(a)),
            stan::model::rvalue(mort_denom, "mort_denom",
              stan::model::index_uni(a)),
            stan::model::rvalue(mort_prob, "mort_prob",
              stan::model::index_uni(a))), "assigning variable ll_mort",
          stan::model::index_uni(a));
        current_statement__ = 148;
        if (inc_supplied) {
          current_statement__ = 147;
          stan::model::assign(ll_inc,
            stan::math::binomial_lpmf<false>(
              stan::model::rvalue(inc_num, "inc_num",
                stan::model::index_uni(a)),
              stan::model::rvalue(inc_denom, "inc_denom",
                stan::model::index_uni(a)),
              stan::model::rvalue(inc_prob, "inc_prob",
                stan::model::index_uni(a))), "assigning variable ll_inc",
            stan::model::index_uni(a));
        }
        current_statement__ = 150;
        if (prev_supplied) {
          current_statement__ = 149;
          stan::model::assign(ll_prev,
            stan::math::binomial_lpmf<false>(
              stan::model::rvalue(prev_num, "prev_num",
                stan::model::index_uni(a)),
              stan::model::rvalue(prev_denom, "prev_denom",
                stan::model::index_uni(a)),
              stan::model::rvalue(prev_prob, "prev_prob",
                stan::model::index_uni(a))), "assigning variable ll_prev",
            stan::model::index_uni(a));
        }
        current_statement__ = 152;
        if (remission) {
          current_statement__ = 151;
          stan::model::assign(ll_rem,
            stan::math::binomial_lpmf<false>(
              stan::model::rvalue(rem_num, "rem_num",
                stan::model::index_uni(a)),
              stan::model::rvalue(rem_denom, "rem_denom",
                stan::model::index_uni(a)),
              stan::model::rvalue(rem_prob, "rem_prob",
                stan::model::index_uni(a))), "assigning variable ll_rem",
            stan::model::index_uni(a));
        }
      }
      current_statement__ = 155;
      stan::model::assign(ll_overall,
        stan::math::append_row(ll_mort,
          stan::math::append_row(ll_inc,
            stan::math::append_row(ll_prev, ll_rem))),
        "assigning variable ll_overall");
      out__.write(ll_mort);
      out__.write(ll_inc);
      out__.write(ll_prev);
      out__.write(ll_rem);
      out__.write(ll_overall);
    } 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> inc_par =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(inc_par_1dim__,
          DUMMY_VAR__);
      current_statement__ = 1;
      stan::model::assign(inc_par,
        in__.read<Eigen::Matrix<local_scalar_t__,-1,1>>(inc_par_1dim__),
        "assigning variable inc_par");
      out__.write_free_lb(0, inc_par);
      Eigen::Matrix<local_scalar_t__,-1,1> cf_par =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(cf_par_1dim__,
          DUMMY_VAR__);
      current_statement__ = 2;
      stan::model::assign(cf_par,
        in__.read<Eigen::Matrix<local_scalar_t__,-1,1>>(cf_par_1dim__),
        "assigning variable cf_par");
      out__.write_free_lb(0, cf_par);
      Eigen::Matrix<local_scalar_t__,-1,1> rem_par =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(rem_par_1dim__,
          DUMMY_VAR__);
      current_statement__ = 3;
      stan::model::assign(rem_par,
        in__.read<Eigen::Matrix<local_scalar_t__,-1,1>>(rem_par_1dim__),
        "assigning variable rem_par");
      out__.write_free_lb(0, rem_par);
      Eigen::Matrix<local_scalar_t__,-1,1> beta =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(beta_1dim__,
          DUMMY_VAR__);
      current_statement__ = 4;
      stan::model::assign(beta,
        in__.read<Eigen::Matrix<local_scalar_t__,-1,1>>(beta_1dim__),
        "assigning variable beta");
      out__.write(beta);
      Eigen::Matrix<local_scalar_t__,-1,1> lambda_cf =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(lambda_cf_1dim__,
          DUMMY_VAR__);
      current_statement__ = 5;
      stan::model::assign(lambda_cf,
        in__.read<Eigen::Matrix<local_scalar_t__,-1,1>>(lambda_cf_1dim__),
        "assigning variable lambda_cf");
      out__.write_free_lb(0, lambda_cf);
      Eigen::Matrix<local_scalar_t__,-1,1> lambda_inc =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(lambda_inc_1dim__,
          DUMMY_VAR__);
      current_statement__ = 6;
      stan::model::assign(lambda_inc,
        in__.read<Eigen::Matrix<local_scalar_t__,-1,1>>(lambda_inc_1dim__),
        "assigning variable lambda_inc");
      out__.write_free_lb(0, lambda_inc);
      Eigen::Matrix<local_scalar_t__,-1,1> beta_inc =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(beta_inc_1dim__,
          DUMMY_VAR__);
      current_statement__ = 7;
      stan::model::assign(beta_inc,
        in__.read<Eigen::Matrix<local_scalar_t__,-1,1>>(beta_inc_1dim__),
        "assigning variable beta_inc");
      out__.write(beta_inc);
      Eigen::Matrix<local_scalar_t__,-1,1> lambda_rem =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(lambda_rem_1dim__,
          DUMMY_VAR__);
      current_statement__ = 8;
      stan::model::assign(lambda_rem,
        in__.read<Eigen::Matrix<local_scalar_t__,-1,1>>(lambda_rem_1dim__),
        "assigning variable lambda_rem");
      out__.write_free_lb(0, lambda_rem);
      Eigen::Matrix<local_scalar_t__,-1,1> beta_rem =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(beta_rem_1dim__,
          DUMMY_VAR__);
      current_statement__ = 9;
      stan::model::assign(beta_rem,
        in__.read<Eigen::Matrix<local_scalar_t__,-1,1>>(beta_rem_1dim__),
        "assigning variable beta_rem");
      out__.write(beta_rem);
      Eigen::Matrix<local_scalar_t__,-1,1> prevzero =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(prev_zero,
          DUMMY_VAR__);
      current_statement__ = 10;
      stan::model::assign(prevzero,
        in__.read<Eigen::Matrix<local_scalar_t__,-1,1>>(prev_zero),
        "assigning variable prevzero");
      out__.write_free_lub(0, 1, prevzero);
      Eigen::Matrix<local_scalar_t__,-1,1> bias_loghr =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(bias_loghr_1dim__,
          DUMMY_VAR__);
      current_statement__ = 11;
      stan::model::assign(bias_loghr,
        in__.read<Eigen::Matrix<local_scalar_t__,-1,1>>(bias_loghr_1dim__),
        "assigning variable bias_loghr");
      out__.write(bias_loghr);
      Eigen::Matrix<local_scalar_t__,-1,1> cfbase =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(cfbase_1dim__,
          DUMMY_VAR__);
      current_statement__ = 12;
      stan::model::assign(cfbase,
        in__.read<Eigen::Matrix<local_scalar_t__,-1,1>>(cfbase_1dim__),
        "assigning variable cfbase");
      out__.write_free_lb(0, cfbase);
    } 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", "inc_par",
        "double", std::vector<size_t>{static_cast<size_t>(inc_par_1dim__)});
      current_statement__ = 2;
      context__.validate_dims("parameter initialization", "cf_par", "double",
        std::vector<size_t>{static_cast<size_t>(cf_par_1dim__)});
      current_statement__ = 3;
      context__.validate_dims("parameter initialization", "rem_par",
        "double", std::vector<size_t>{static_cast<size_t>(rem_par_1dim__)});
      current_statement__ = 4;
      context__.validate_dims("parameter initialization", "beta", "double",
        std::vector<size_t>{static_cast<size_t>(beta_1dim__)});
      current_statement__ = 5;
      context__.validate_dims("parameter initialization", "lambda_cf",
        "double", std::vector<size_t>{static_cast<size_t>(lambda_cf_1dim__)});
      current_statement__ = 6;
      context__.validate_dims("parameter initialization", "lambda_inc",
        "double",
        std::vector<size_t>{static_cast<size_t>(lambda_inc_1dim__)});
      current_statement__ = 7;
      context__.validate_dims("parameter initialization", "beta_inc",
        "double", std::vector<size_t>{static_cast<size_t>(beta_inc_1dim__)});
      current_statement__ = 8;
      context__.validate_dims("parameter initialization", "lambda_rem",
        "double",
        std::vector<size_t>{static_cast<size_t>(lambda_rem_1dim__)});
      current_statement__ = 9;
      context__.validate_dims("parameter initialization", "beta_rem",
        "double", std::vector<size_t>{static_cast<size_t>(beta_rem_1dim__)});
      current_statement__ = 10;
      context__.validate_dims("parameter initialization", "prevzero",
        "double", std::vector<size_t>{static_cast<size_t>(prev_zero)});
      current_statement__ = 11;
      context__.validate_dims("parameter initialization", "bias_loghr",
        "double",
        std::vector<size_t>{static_cast<size_t>(bias_loghr_1dim__)});
      current_statement__ = 12;
      context__.validate_dims("parameter initialization", "cfbase", "double",
        std::vector<size_t>{static_cast<size_t>(cfbase_1dim__)});
      int pos__ = std::numeric_limits<int>::min();
      pos__ = 1;
      Eigen::Matrix<local_scalar_t__,-1,1> inc_par =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(inc_par_1dim__,
          DUMMY_VAR__);
      {
        std::vector<local_scalar_t__> inc_par_flat__;
        current_statement__ = 1;
        inc_par_flat__ = context__.vals_r("inc_par");
        current_statement__ = 1;
        pos__ = 1;
        current_statement__ = 1;
        for (int sym1__ = 1; sym1__ <= inc_par_1dim__; ++sym1__) {
          current_statement__ = 1;
          stan::model::assign(inc_par, inc_par_flat__[(pos__ - 1)],
            "assigning variable inc_par", stan::model::index_uni(sym1__));
          current_statement__ = 1;
          pos__ = (pos__ + 1);
        }
      }
      out__.write_free_lb(0, inc_par);
      Eigen::Matrix<local_scalar_t__,-1,1> cf_par =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(cf_par_1dim__,
          DUMMY_VAR__);
      {
        std::vector<local_scalar_t__> cf_par_flat__;
        current_statement__ = 2;
        cf_par_flat__ = context__.vals_r("cf_par");
        current_statement__ = 2;
        pos__ = 1;
        current_statement__ = 2;
        for (int sym1__ = 1; sym1__ <= cf_par_1dim__; ++sym1__) {
          current_statement__ = 2;
          stan::model::assign(cf_par, cf_par_flat__[(pos__ - 1)],
            "assigning variable cf_par", stan::model::index_uni(sym1__));
          current_statement__ = 2;
          pos__ = (pos__ + 1);
        }
      }
      out__.write_free_lb(0, cf_par);
      Eigen::Matrix<local_scalar_t__,-1,1> rem_par =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(rem_par_1dim__,
          DUMMY_VAR__);
      {
        std::vector<local_scalar_t__> rem_par_flat__;
        current_statement__ = 3;
        rem_par_flat__ = context__.vals_r("rem_par");
        current_statement__ = 3;
        pos__ = 1;
        current_statement__ = 3;
        for (int sym1__ = 1; sym1__ <= rem_par_1dim__; ++sym1__) {
          current_statement__ = 3;
          stan::model::assign(rem_par, rem_par_flat__[(pos__ - 1)],
            "assigning variable rem_par", stan::model::index_uni(sym1__));
          current_statement__ = 3;
          pos__ = (pos__ + 1);
        }
      }
      out__.write_free_lb(0, rem_par);
      Eigen::Matrix<local_scalar_t__,-1,1> beta =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(beta_1dim__,
          DUMMY_VAR__);
      {
        std::vector<local_scalar_t__> beta_flat__;
        current_statement__ = 4;
        beta_flat__ = context__.vals_r("beta");
        current_statement__ = 4;
        pos__ = 1;
        current_statement__ = 4;
        for (int sym1__ = 1; sym1__ <= beta_1dim__; ++sym1__) {
          current_statement__ = 4;
          stan::model::assign(beta, beta_flat__[(pos__ - 1)],
            "assigning variable beta", stan::model::index_uni(sym1__));
          current_statement__ = 4;
          pos__ = (pos__ + 1);
        }
      }
      out__.write(beta);
      Eigen::Matrix<local_scalar_t__,-1,1> lambda_cf =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(lambda_cf_1dim__,
          DUMMY_VAR__);
      {
        std::vector<local_scalar_t__> lambda_cf_flat__;
        current_statement__ = 5;
        lambda_cf_flat__ = context__.vals_r("lambda_cf");
        current_statement__ = 5;
        pos__ = 1;
        current_statement__ = 5;
        for (int sym1__ = 1; sym1__ <= lambda_cf_1dim__; ++sym1__) {
          current_statement__ = 5;
          stan::model::assign(lambda_cf, lambda_cf_flat__[(pos__ - 1)],
            "assigning variable lambda_cf", stan::model::index_uni(sym1__));
          current_statement__ = 5;
          pos__ = (pos__ + 1);
        }
      }
      out__.write_free_lb(0, lambda_cf);
      Eigen::Matrix<local_scalar_t__,-1,1> lambda_inc =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(lambda_inc_1dim__,
          DUMMY_VAR__);
      {
        std::vector<local_scalar_t__> lambda_inc_flat__;
        current_statement__ = 6;
        lambda_inc_flat__ = context__.vals_r("lambda_inc");
        current_statement__ = 6;
        pos__ = 1;
        current_statement__ = 6;
        for (int sym1__ = 1; sym1__ <= lambda_inc_1dim__; ++sym1__) {
          current_statement__ = 6;
          stan::model::assign(lambda_inc, lambda_inc_flat__[(pos__ - 1)],
            "assigning variable lambda_inc", stan::model::index_uni(sym1__));
          current_statement__ = 6;
          pos__ = (pos__ + 1);
        }
      }
      out__.write_free_lb(0, lambda_inc);
      Eigen::Matrix<local_scalar_t__,-1,1> beta_inc =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(beta_inc_1dim__,
          DUMMY_VAR__);
      {
        std::vector<local_scalar_t__> beta_inc_flat__;
        current_statement__ = 7;
        beta_inc_flat__ = context__.vals_r("beta_inc");
        current_statement__ = 7;
        pos__ = 1;
        current_statement__ = 7;
        for (int sym1__ = 1; sym1__ <= beta_inc_1dim__; ++sym1__) {
          current_statement__ = 7;
          stan::model::assign(beta_inc, beta_inc_flat__[(pos__ - 1)],
            "assigning variable beta_inc", stan::model::index_uni(sym1__));
          current_statement__ = 7;
          pos__ = (pos__ + 1);
        }
      }
      out__.write(beta_inc);
      Eigen::Matrix<local_scalar_t__,-1,1> lambda_rem =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(lambda_rem_1dim__,
          DUMMY_VAR__);
      {
        std::vector<local_scalar_t__> lambda_rem_flat__;
        current_statement__ = 8;
        lambda_rem_flat__ = context__.vals_r("lambda_rem");
        current_statement__ = 8;
        pos__ = 1;
        current_statement__ = 8;
        for (int sym1__ = 1; sym1__ <= lambda_rem_1dim__; ++sym1__) {
          current_statement__ = 8;
          stan::model::assign(lambda_rem, lambda_rem_flat__[(pos__ - 1)],
            "assigning variable lambda_rem", stan::model::index_uni(sym1__));
          current_statement__ = 8;
          pos__ = (pos__ + 1);
        }
      }
      out__.write_free_lb(0, lambda_rem);
      Eigen::Matrix<local_scalar_t__,-1,1> beta_rem =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(beta_rem_1dim__,
          DUMMY_VAR__);
      {
        std::vector<local_scalar_t__> beta_rem_flat__;
        current_statement__ = 9;
        beta_rem_flat__ = context__.vals_r("beta_rem");
        current_statement__ = 9;
        pos__ = 1;
        current_statement__ = 9;
        for (int sym1__ = 1; sym1__ <= beta_rem_1dim__; ++sym1__) {
          current_statement__ = 9;
          stan::model::assign(beta_rem, beta_rem_flat__[(pos__ - 1)],
            "assigning variable beta_rem", stan::model::index_uni(sym1__));
          current_statement__ = 9;
          pos__ = (pos__ + 1);
        }
      }
      out__.write(beta_rem);
      Eigen::Matrix<local_scalar_t__,-1,1> prevzero =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(prev_zero,
          DUMMY_VAR__);
      {
        std::vector<local_scalar_t__> prevzero_flat__;
        current_statement__ = 10;
        prevzero_flat__ = context__.vals_r("prevzero");
        current_statement__ = 10;
        pos__ = 1;
        current_statement__ = 10;
        for (int sym1__ = 1; sym1__ <= prev_zero; ++sym1__) {
          current_statement__ = 10;
          stan::model::assign(prevzero, prevzero_flat__[(pos__ - 1)],
            "assigning variable prevzero", stan::model::index_uni(sym1__));
          current_statement__ = 10;
          pos__ = (pos__ + 1);
        }
      }
      out__.write_free_lub(0, 1, prevzero);
      Eigen::Matrix<local_scalar_t__,-1,1> bias_loghr =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(bias_loghr_1dim__,
          DUMMY_VAR__);
      {
        std::vector<local_scalar_t__> bias_loghr_flat__;
        current_statement__ = 11;
        bias_loghr_flat__ = context__.vals_r("bias_loghr");
        current_statement__ = 11;
        pos__ = 1;
        current_statement__ = 11;
        for (int sym1__ = 1; sym1__ <= bias_loghr_1dim__; ++sym1__) {
          current_statement__ = 11;
          stan::model::assign(bias_loghr, bias_loghr_flat__[(pos__ - 1)],
            "assigning variable bias_loghr", stan::model::index_uni(sym1__));
          current_statement__ = 11;
          pos__ = (pos__ + 1);
        }
      }
      out__.write(bias_loghr);
      Eigen::Matrix<local_scalar_t__,-1,1> cfbase =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(cfbase_1dim__,
          DUMMY_VAR__);
      {
        std::vector<local_scalar_t__> cfbase_flat__;
        current_statement__ = 12;
        cfbase_flat__ = context__.vals_r("cfbase");
        current_statement__ = 12;
        pos__ = 1;
        current_statement__ = 12;
        for (int sym1__ = 1; sym1__ <= cfbase_1dim__; ++sym1__) {
          current_statement__ = 12;
          stan::model::assign(cfbase, cfbase_flat__[(pos__ - 1)],
            "assigning variable cfbase", stan::model::index_uni(sym1__));
          current_statement__ = 12;
          pos__ = (pos__ + 1);
        }
      }
      out__.write_free_lb(0, cfbase);
    } 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>{"inc_par", "cf_par", "rem_par",
                "beta", "lambda_cf", "lambda_inc", "beta_inc", "lambda_rem",
                "beta_rem", "prevzero", "bias_loghr", "cfbase"};
    if (emit_transformed_parameters__) {
      std::vector<std::string>
        temp{"cf", "dcf", "inc", "inc_prob", "rem", "rem_prob", "cf_prob",
             "state_probs", "tmp", "P", "prev_prob", "mort_prob", "cf_yr",
             "inc_yr", "state_probs_yr", "lambda_cf_use", "lambda_inc_use",
             "lambda_rem_use"};
      names__.reserve(names__.size() + temp.size());
      names__.insert(names__.end(), temp.begin(), temp.end());
    }
    if (emit_generated_quantities__) {
      std::vector<std::string>
        temp{"ll_mort", "ll_inc", "ll_prev", "ll_rem", "ll_overall"};
      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>(
                                                                    inc_par_1dim__)},
                std::vector<size_t>{static_cast<size_t>(cf_par_1dim__)},
                std::vector<size_t>{static_cast<size_t>(rem_par_1dim__)},
                std::vector<size_t>{static_cast<size_t>(beta_1dim__)},
                std::vector<size_t>{static_cast<size_t>(lambda_cf_1dim__)},
                std::vector<size_t>{static_cast<size_t>(lambda_inc_1dim__)},
                std::vector<size_t>{static_cast<size_t>(beta_inc_1dim__)},
                std::vector<size_t>{static_cast<size_t>(lambda_rem_1dim__)},
                std::vector<size_t>{static_cast<size_t>(beta_rem_1dim__)},
                std::vector<size_t>{static_cast<size_t>(prev_zero)},
                std::vector<size_t>{static_cast<size_t>(bias_loghr_1dim__)},
                std::vector<size_t>{static_cast<size_t>(cfbase_1dim__)}};
    if (emit_transformed_parameters__) {
      std::vector<std::vector<size_t>>
        temp{std::vector<size_t>{static_cast<size_t>(nage)},
             std::vector<size_t>{static_cast<size_t>(dcf_1dim__)},
             std::vector<size_t>{static_cast<size_t>(nage),
               static_cast<size_t>(nbias)},
             std::vector<size_t>{static_cast<size_t>(nage),
               static_cast<size_t>(nbias)},
             std::vector<size_t>{static_cast<size_t>(nage)},
             std::vector<size_t>{static_cast<size_t>(rem_prob_1dim__)},
             std::vector<size_t>{static_cast<size_t>(nage)},
             std::vector<size_t>{static_cast<size_t>(state_probs_1dim__),
               static_cast<size_t>(nbias), static_cast<size_t>(3)},
             std::vector<size_t>{static_cast<size_t>(3)},
             std::vector<size_t>{static_cast<size_t>(3),
               static_cast<size_t>(3)},
             std::vector<size_t>{static_cast<size_t>(nage),
               static_cast<size_t>(nbias)},
             std::vector<size_t>{static_cast<size_t>(nage)},
             std::vector<size_t>{static_cast<size_t>(cf_yr_1dim__),
               static_cast<size_t>(cf_yr_2dim__)},
             std::vector<size_t>{static_cast<size_t>(inc_yr_1dim__),
               static_cast<size_t>(inc_yr_2dim__),
               static_cast<size_t>(nbias)},
             std::vector<size_t>{static_cast<size_t>(state_probs_yr_1dim__),
               static_cast<size_t>(state_probs_yr_2dim__),
               static_cast<size_t>(nbias), static_cast<size_t>(3)},
             std::vector<size_t>{}, std::vector<size_t>{},
             std::vector<size_t>{}};
      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>(nage)},
             std::vector<size_t>{static_cast<size_t>(ll_inc_1dim__)},
             std::vector<size_t>{static_cast<size_t>(ll_prev_1dim__)},
             std::vector<size_t>{static_cast<size_t>(ll_rem_1dim__)},
             std::vector<size_t>{static_cast<size_t>(ll_overall_1dim__)}};
      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__ <= inc_par_1dim__; ++sym1__) {
      param_names__.emplace_back(std::string() + "inc_par" + '.' +
        std::to_string(sym1__));
    }
    for (int sym1__ = 1; sym1__ <= cf_par_1dim__; ++sym1__) {
      param_names__.emplace_back(std::string() + "cf_par" + '.' +
        std::to_string(sym1__));
    }
    for (int sym1__ = 1; sym1__ <= rem_par_1dim__; ++sym1__) {
      param_names__.emplace_back(std::string() + "rem_par" + '.' +
        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__ <= lambda_cf_1dim__; ++sym1__) {
      param_names__.emplace_back(std::string() + "lambda_cf" + '.' +
        std::to_string(sym1__));
    }
    for (int sym1__ = 1; sym1__ <= lambda_inc_1dim__; ++sym1__) {
      param_names__.emplace_back(std::string() + "lambda_inc" + '.' +
        std::to_string(sym1__));
    }
    for (int sym1__ = 1; sym1__ <= beta_inc_1dim__; ++sym1__) {
      param_names__.emplace_back(std::string() + "beta_inc" + '.' +
        std::to_string(sym1__));
    }
    for (int sym1__ = 1; sym1__ <= lambda_rem_1dim__; ++sym1__) {
      param_names__.emplace_back(std::string() + "lambda_rem" + '.' +
        std::to_string(sym1__));
    }
    for (int sym1__ = 1; sym1__ <= beta_rem_1dim__; ++sym1__) {
      param_names__.emplace_back(std::string() + "beta_rem" + '.' +
        std::to_string(sym1__));
    }
    for (int sym1__ = 1; sym1__ <= prev_zero; ++sym1__) {
      param_names__.emplace_back(std::string() + "prevzero" + '.' +
        std::to_string(sym1__));
    }
    for (int sym1__ = 1; sym1__ <= bias_loghr_1dim__; ++sym1__) {
      param_names__.emplace_back(std::string() + "bias_loghr" + '.' +
        std::to_string(sym1__));
    }
    for (int sym1__ = 1; sym1__ <= cfbase_1dim__; ++sym1__) {
      param_names__.emplace_back(std::string() + "cfbase" + '.' +
        std::to_string(sym1__));
    }
    if (emit_transformed_parameters__) {
      for (int sym1__ = 1; sym1__ <= nage; ++sym1__) {
        param_names__.emplace_back(std::string() + "cf" + '.' +
          std::to_string(sym1__));
      }
      for (int sym1__ = 1; sym1__ <= dcf_1dim__; ++sym1__) {
        param_names__.emplace_back(std::string() + "dcf" + '.' +
          std::to_string(sym1__));
      }
      for (int sym1__ = 1; sym1__ <= nbias; ++sym1__) {
        for (int sym2__ = 1; sym2__ <= nage; ++sym2__) {
          param_names__.emplace_back(std::string() + "inc" + '.' +
            std::to_string(sym2__) + '.' + std::to_string(sym1__));
        }
      }
      for (int sym1__ = 1; sym1__ <= nbias; ++sym1__) {
        for (int sym2__ = 1; sym2__ <= nage; ++sym2__) {
          param_names__.emplace_back(std::string() + "inc_prob" + '.' +
            std::to_string(sym2__) + '.' + std::to_string(sym1__));
        }
      }
      for (int sym1__ = 1; sym1__ <= nage; ++sym1__) {
        param_names__.emplace_back(std::string() + "rem" + '.' +
          std::to_string(sym1__));
      }
      for (int sym1__ = 1; sym1__ <= rem_prob_1dim__; ++sym1__) {
        param_names__.emplace_back(std::string() + "rem_prob" + '.' +
          std::to_string(sym1__));
      }
      for (int sym1__ = 1; sym1__ <= nage; ++sym1__) {
        param_names__.emplace_back(std::string() + "cf_prob" + '.' +
          std::to_string(sym1__));
      }
      for (int sym1__ = 1; sym1__ <= 3; ++sym1__) {
        for (int sym2__ = 1; sym2__ <= nbias; ++sym2__) {
          for (int sym3__ = 1; sym3__ <= state_probs_1dim__; ++sym3__) {
            param_names__.emplace_back(std::string() + "state_probs" + '.' +
              std::to_string(sym3__) + '.' + std::to_string(sym2__) + '.' +
              std::to_string(sym1__));
          }
        }
      }
      for (int sym1__ = 1; sym1__ <= 3; ++sym1__) {
        param_names__.emplace_back(std::string() + "tmp" + '.' +
          std::to_string(sym1__));
      }
      for (int sym1__ = 1; sym1__ <= 3; ++sym1__) {
        for (int sym2__ = 1; sym2__ <= 3; ++sym2__) {
          param_names__.emplace_back(std::string() + "P" + '.' +
            std::to_string(sym2__) + '.' + std::to_string(sym1__));
        }
      }
      for (int sym1__ = 1; sym1__ <= nbias; ++sym1__) {
        for (int sym2__ = 1; sym2__ <= nage; ++sym2__) {
          param_names__.emplace_back(std::string() + "prev_prob" + '.' +
            std::to_string(sym2__) + '.' + std::to_string(sym1__));
        }
      }
      for (int sym1__ = 1; sym1__ <= nage; ++sym1__) {
        param_names__.emplace_back(std::string() + "mort_prob" + '.' +
          std::to_string(sym1__));
      }
      for (int sym1__ = 1; sym1__ <= cf_yr_2dim__; ++sym1__) {
        for (int sym2__ = 1; sym2__ <= cf_yr_1dim__; ++sym2__) {
          param_names__.emplace_back(std::string() + "cf_yr" + '.' +
            std::to_string(sym2__) + '.' + std::to_string(sym1__));
        }
      }
      for (int sym1__ = 1; sym1__ <= nbias; ++sym1__) {
        for (int sym2__ = 1; sym2__ <= inc_yr_2dim__; ++sym2__) {
          for (int sym3__ = 1; sym3__ <= inc_yr_1dim__; ++sym3__) {
            param_names__.emplace_back(std::string() + "inc_yr" + '.' +
              std::to_string(sym3__) + '.' + std::to_string(sym2__) + '.' +
              std::to_string(sym1__));
          }
        }
      }
      for (int sym1__ = 1; sym1__ <= 3; ++sym1__) {
        for (int sym2__ = 1; sym2__ <= nbias; ++sym2__) {
          for (int sym3__ = 1; sym3__ <= state_probs_yr_2dim__; ++sym3__) {
            for (int sym4__ = 1; sym4__ <= state_probs_yr_1dim__; ++sym4__) {
              param_names__.emplace_back(std::string() + "state_probs_yr" +
                '.' + std::to_string(sym4__) + '.' + std::to_string(sym3__) +
                '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__));
            }
          }
        }
      }
      param_names__.emplace_back(std::string() + "lambda_cf_use");
      param_names__.emplace_back(std::string() + "lambda_inc_use");
      param_names__.emplace_back(std::string() + "lambda_rem_use");
    }
    if (emit_generated_quantities__) {
      for (int sym1__ = 1; sym1__ <= nage; ++sym1__) {
        param_names__.emplace_back(std::string() + "ll_mort" + '.' +
          std::to_string(sym1__));
      }
      for (int sym1__ = 1; sym1__ <= ll_inc_1dim__; ++sym1__) {
        param_names__.emplace_back(std::string() + "ll_inc" + '.' +
          std::to_string(sym1__));
      }
      for (int sym1__ = 1; sym1__ <= ll_prev_1dim__; ++sym1__) {
        param_names__.emplace_back(std::string() + "ll_prev" + '.' +
          std::to_string(sym1__));
      }
      for (int sym1__ = 1; sym1__ <= ll_rem_1dim__; ++sym1__) {
        param_names__.emplace_back(std::string() + "ll_rem" + '.' +
          std::to_string(sym1__));
      }
      for (int sym1__ = 1; sym1__ <= ll_overall_1dim__; ++sym1__) {
        param_names__.emplace_back(std::string() + "ll_overall" + '.' +
          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__ <= inc_par_1dim__; ++sym1__) {
      param_names__.emplace_back(std::string() + "inc_par" + '.' +
        std::to_string(sym1__));
    }
    for (int sym1__ = 1; sym1__ <= cf_par_1dim__; ++sym1__) {
      param_names__.emplace_back(std::string() + "cf_par" + '.' +
        std::to_string(sym1__));
    }
    for (int sym1__ = 1; sym1__ <= rem_par_1dim__; ++sym1__) {
      param_names__.emplace_back(std::string() + "rem_par" + '.' +
        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__ <= lambda_cf_1dim__; ++sym1__) {
      param_names__.emplace_back(std::string() + "lambda_cf" + '.' +
        std::to_string(sym1__));
    }
    for (int sym1__ = 1; sym1__ <= lambda_inc_1dim__; ++sym1__) {
      param_names__.emplace_back(std::string() + "lambda_inc" + '.' +
        std::to_string(sym1__));
    }
    for (int sym1__ = 1; sym1__ <= beta_inc_1dim__; ++sym1__) {
      param_names__.emplace_back(std::string() + "beta_inc" + '.' +
        std::to_string(sym1__));
    }
    for (int sym1__ = 1; sym1__ <= lambda_rem_1dim__; ++sym1__) {
      param_names__.emplace_back(std::string() + "lambda_rem" + '.' +
        std::to_string(sym1__));
    }
    for (int sym1__ = 1; sym1__ <= beta_rem_1dim__; ++sym1__) {
      param_names__.emplace_back(std::string() + "beta_rem" + '.' +
        std::to_string(sym1__));
    }
    for (int sym1__ = 1; sym1__ <= prev_zero; ++sym1__) {
      param_names__.emplace_back(std::string() + "prevzero" + '.' +
        std::to_string(sym1__));
    }
    for (int sym1__ = 1; sym1__ <= bias_loghr_1dim__; ++sym1__) {
      param_names__.emplace_back(std::string() + "bias_loghr" + '.' +
        std::to_string(sym1__));
    }
    for (int sym1__ = 1; sym1__ <= cfbase_1dim__; ++sym1__) {
      param_names__.emplace_back(std::string() + "cfbase" + '.' +
        std::to_string(sym1__));
    }
    if (emit_transformed_parameters__) {
      for (int sym1__ = 1; sym1__ <= nage; ++sym1__) {
        param_names__.emplace_back(std::string() + "cf" + '.' +
          std::to_string(sym1__));
      }
      for (int sym1__ = 1; sym1__ <= dcf_1dim__; ++sym1__) {
        param_names__.emplace_back(std::string() + "dcf" + '.' +
          std::to_string(sym1__));
      }
      for (int sym1__ = 1; sym1__ <= nbias; ++sym1__) {
        for (int sym2__ = 1; sym2__ <= nage; ++sym2__) {
          param_names__.emplace_back(std::string() + "inc" + '.' +
            std::to_string(sym2__) + '.' + std::to_string(sym1__));
        }
      }
      for (int sym1__ = 1; sym1__ <= nbias; ++sym1__) {
        for (int sym2__ = 1; sym2__ <= nage; ++sym2__) {
          param_names__.emplace_back(std::string() + "inc_prob" + '.' +
            std::to_string(sym2__) + '.' + std::to_string(sym1__));
        }
      }
      for (int sym1__ = 1; sym1__ <= nage; ++sym1__) {
        param_names__.emplace_back(std::string() + "rem" + '.' +
          std::to_string(sym1__));
      }
      for (int sym1__ = 1; sym1__ <= rem_prob_1dim__; ++sym1__) {
        param_names__.emplace_back(std::string() + "rem_prob" + '.' +
          std::to_string(sym1__));
      }
      for (int sym1__ = 1; sym1__ <= nage; ++sym1__) {
        param_names__.emplace_back(std::string() + "cf_prob" + '.' +
          std::to_string(sym1__));
      }
      for (int sym1__ = 1; sym1__ <= 3; ++sym1__) {
        for (int sym2__ = 1; sym2__ <= nbias; ++sym2__) {
          for (int sym3__ = 1; sym3__ <= state_probs_1dim__; ++sym3__) {
            param_names__.emplace_back(std::string() + "state_probs" + '.' +
              std::to_string(sym3__) + '.' + std::to_string(sym2__) + '.' +
              std::to_string(sym1__));
          }
        }
      }
      for (int sym1__ = 1; sym1__ <= 3; ++sym1__) {
        param_names__.emplace_back(std::string() + "tmp" + '.' +
          std::to_string(sym1__));
      }
      for (int sym1__ = 1; sym1__ <= 3; ++sym1__) {
        for (int sym2__ = 1; sym2__ <= 3; ++sym2__) {
          param_names__.emplace_back(std::string() + "P" + '.' +
            std::to_string(sym2__) + '.' + std::to_string(sym1__));
        }
      }
      for (int sym1__ = 1; sym1__ <= nbias; ++sym1__) {
        for (int sym2__ = 1; sym2__ <= nage; ++sym2__) {
          param_names__.emplace_back(std::string() + "prev_prob" + '.' +
            std::to_string(sym2__) + '.' + std::to_string(sym1__));
        }
      }
      for (int sym1__ = 1; sym1__ <= nage; ++sym1__) {
        param_names__.emplace_back(std::string() + "mort_prob" + '.' +
          std::to_string(sym1__));
      }
      for (int sym1__ = 1; sym1__ <= cf_yr_2dim__; ++sym1__) {
        for (int sym2__ = 1; sym2__ <= cf_yr_1dim__; ++sym2__) {
          param_names__.emplace_back(std::string() + "cf_yr" + '.' +
            std::to_string(sym2__) + '.' + std::to_string(sym1__));
        }
      }
      for (int sym1__ = 1; sym1__ <= nbias; ++sym1__) {
        for (int sym2__ = 1; sym2__ <= inc_yr_2dim__; ++sym2__) {
          for (int sym3__ = 1; sym3__ <= inc_yr_1dim__; ++sym3__) {
            param_names__.emplace_back(std::string() + "inc_yr" + '.' +
              std::to_string(sym3__) + '.' + std::to_string(sym2__) + '.' +
              std::to_string(sym1__));
          }
        }
      }
      for (int sym1__ = 1; sym1__ <= 3; ++sym1__) {
        for (int sym2__ = 1; sym2__ <= nbias; ++sym2__) {
          for (int sym3__ = 1; sym3__ <= state_probs_yr_2dim__; ++sym3__) {
            for (int sym4__ = 1; sym4__ <= state_probs_yr_1dim__; ++sym4__) {
              param_names__.emplace_back(std::string() + "state_probs_yr" +
                '.' + std::to_string(sym4__) + '.' + std::to_string(sym3__) +
                '.' + std::to_string(sym2__) + '.' + std::to_string(sym1__));
            }
          }
        }
      }
      param_names__.emplace_back(std::string() + "lambda_cf_use");
      param_names__.emplace_back(std::string() + "lambda_inc_use");
      param_names__.emplace_back(std::string() + "lambda_rem_use");
    }
    if (emit_generated_quantities__) {
      for (int sym1__ = 1; sym1__ <= nage; ++sym1__) {
        param_names__.emplace_back(std::string() + "ll_mort" + '.' +
          std::to_string(sym1__));
      }
      for (int sym1__ = 1; sym1__ <= ll_inc_1dim__; ++sym1__) {
        param_names__.emplace_back(std::string() + "ll_inc" + '.' +
          std::to_string(sym1__));
      }
      for (int sym1__ = 1; sym1__ <= ll_prev_1dim__; ++sym1__) {
        param_names__.emplace_back(std::string() + "ll_prev" + '.' +
          std::to_string(sym1__));
      }
      for (int sym1__ = 1; sym1__ <= ll_rem_1dim__; ++sym1__) {
        param_names__.emplace_back(std::string() + "ll_rem" + '.' +
          std::to_string(sym1__));
      }
      for (int sym1__ = 1; sym1__ <= ll_overall_1dim__; ++sym1__) {
        param_names__.emplace_back(std::string() + "ll_overall" + '.' +
          std::to_string(sym1__));
      }
    }
  }
  inline std::string get_constrained_sizedtypes() const {
    return std::string("[{\"name\":\"inc_par\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(inc_par_1dim__) + "},\"block\":\"parameters\"},{\"name\":\"cf_par\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(cf_par_1dim__) + "},\"block\":\"parameters\"},{\"name\":\"rem_par\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(rem_par_1dim__) + "},\"block\":\"parameters\"},{\"name\":\"beta\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(beta_1dim__) + "},\"block\":\"parameters\"},{\"name\":\"lambda_cf\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(lambda_cf_1dim__) + "},\"block\":\"parameters\"},{\"name\":\"lambda_inc\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(lambda_inc_1dim__) + "},\"block\":\"parameters\"},{\"name\":\"beta_inc\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(beta_inc_1dim__) + "},\"block\":\"parameters\"},{\"name\":\"lambda_rem\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(lambda_rem_1dim__) + "},\"block\":\"parameters\"},{\"name\":\"beta_rem\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(beta_rem_1dim__) + "},\"block\":\"parameters\"},{\"name\":\"prevzero\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(prev_zero) + "},\"block\":\"parameters\"},{\"name\":\"bias_loghr\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(bias_loghr_1dim__) + "},\"block\":\"parameters\"},{\"name\":\"cfbase\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(cfbase_1dim__) + "},\"block\":\"parameters\"},{\"name\":\"cf\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(nage) + "},\"block\":\"transformed_parameters\"},{\"name\":\"dcf\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(dcf_1dim__) + "},\"block\":\"transformed_parameters\"},{\"name\":\"inc\",\"type\":{\"name\":\"matrix\",\"rows\":" + std::to_string(nage) + ",\"cols\":" + std::to_string(nbias) + "},\"block\":\"transformed_parameters\"},{\"name\":\"inc_prob\",\"type\":{\"name\":\"matrix\",\"rows\":" + std::to_string(nage) + ",\"cols\":" + std::to_string(nbias) + "},\"block\":\"transformed_parameters\"},{\"name\":\"rem\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(nage) + "},\"block\":\"transformed_parameters\"},{\"name\":\"rem_prob\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(rem_prob_1dim__) + "},\"block\":\"transformed_parameters\"},{\"name\":\"cf_prob\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(nage) + "},\"block\":\"transformed_parameters\"},{\"name\":\"state_probs\",\"type\":{\"name\":\"array\",\"length\":" + std::to_string(state_probs_1dim__) + ",\"element_type\":{\"name\":\"array\",\"length\":" + std::to_string(nbias) + ",\"element_type\":{\"name\":\"vector\",\"length\":" + std::to_string(3) + "}}},\"block\":\"transformed_parameters\"},{\"name\":\"tmp\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(3) + "},\"block\":\"transformed_parameters\"},{\"name\":\"P\",\"type\":{\"name\":\"matrix\",\"rows\":" + std::to_string(3) + ",\"cols\":" + std::to_string(3) + "},\"block\":\"transformed_parameters\"},{\"name\":\"prev_prob\",\"type\":{\"name\":\"matrix\",\"rows\":" + std::to_string(nage) + ",\"cols\":" + std::to_string(nbias) + "},\"block\":\"transformed_parameters\"},{\"name\":\"mort_prob\",\"type\":{\"name\":\"array\",\"length\":" + std::to_string(nage) + ",\"element_type\":{\"name\":\"real\"}},\"block\":\"transformed_parameters\"},{\"name\":\"cf_yr\",\"type\":{\"name\":\"matrix\",\"rows\":" + std::to_string(cf_yr_1dim__) + ",\"cols\":" + std::to_string(cf_yr_2dim__) + "},\"block\":\"transformed_parameters\"},{\"name\":\"inc_yr\",\"type\":{\"name\":\"array\",\"length\":" + std::to_string(inc_yr_1dim__) + ",\"element_type\":{\"name\":\"array\",\"length\":" + std::to_string(inc_yr_2dim__) + ",\"element_type\":{\"name\":\"array\",\"length\":" + std::to_string(nbias) + ",\"element_type\":{\"name\":\"real\"}}}},\"block\":\"transformed_parameters\"},{\"name\":\"state_probs_yr\",\"type\":{\"name\":\"array\",\"length\":" + std::to_string(state_probs_yr_1dim__) + ",\"element_type\":{\"name\":\"array\",\"length\":" + std::to_string(state_probs_yr_2dim__) + ",\"element_type\":{\"name\":\"array\",\"length\":" + std::to_string(nbias) + ",\"element_type\":{\"name\":\"vector\",\"length\":" + std::to_string(3) + "}}}},\"block\":\"transformed_parameters\"},{\"name\":\"lambda_cf_use\",\"type\":{\"name\":\"real\"},\"block\":\"transformed_parameters\"},{\"name\":\"lambda_inc_use\",\"type\":{\"name\":\"real\"},\"block\":\"transformed_parameters\"},{\"name\":\"lambda_rem_use\",\"type\":{\"name\":\"real\"},\"block\":\"transformed_parameters\"},{\"name\":\"ll_mort\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(nage) + "},\"block\":\"generated_quantities\"},{\"name\":\"ll_inc\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(ll_inc_1dim__) + "},\"block\":\"generated_quantities\"},{\"name\":\"ll_prev\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(ll_prev_1dim__) + "},\"block\":\"generated_quantities\"},{\"name\":\"ll_rem\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(ll_rem_1dim__) + "},\"block\":\"generated_quantities\"},{\"name\":\"ll_overall\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(ll_overall_1dim__) + "},\"block\":\"generated_quantities\"}]");
  }
  inline std::string get_unconstrained_sizedtypes() const {
    return std::string("[{\"name\":\"inc_par\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(inc_par_1dim__) + "},\"block\":\"parameters\"},{\"name\":\"cf_par\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(cf_par_1dim__) + "},\"block\":\"parameters\"},{\"name\":\"rem_par\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(rem_par_1dim__) + "},\"block\":\"parameters\"},{\"name\":\"beta\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(beta_1dim__) + "},\"block\":\"parameters\"},{\"name\":\"lambda_cf\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(lambda_cf_1dim__) + "},\"block\":\"parameters\"},{\"name\":\"lambda_inc\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(lambda_inc_1dim__) + "},\"block\":\"parameters\"},{\"name\":\"beta_inc\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(beta_inc_1dim__) + "},\"block\":\"parameters\"},{\"name\":\"lambda_rem\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(lambda_rem_1dim__) + "},\"block\":\"parameters\"},{\"name\":\"beta_rem\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(beta_rem_1dim__) + "},\"block\":\"parameters\"},{\"name\":\"prevzero\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(prev_zero) + "},\"block\":\"parameters\"},{\"name\":\"bias_loghr\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(bias_loghr_1dim__) + "},\"block\":\"parameters\"},{\"name\":\"cfbase\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(cfbase_1dim__) + "},\"block\":\"parameters\"},{\"name\":\"cf\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(nage) + "},\"block\":\"transformed_parameters\"},{\"name\":\"dcf\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(dcf_1dim__) + "},\"block\":\"transformed_parameters\"},{\"name\":\"inc\",\"type\":{\"name\":\"matrix\",\"rows\":" + std::to_string(nage) + ",\"cols\":" + std::to_string(nbias) + "},\"block\":\"transformed_parameters\"},{\"name\":\"inc_prob\",\"type\":{\"name\":\"matrix\",\"rows\":" + std::to_string(nage) + ",\"cols\":" + std::to_string(nbias) + "},\"block\":\"transformed_parameters\"},{\"name\":\"rem\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(nage) + "},\"block\":\"transformed_parameters\"},{\"name\":\"rem_prob\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(rem_prob_1dim__) + "},\"block\":\"transformed_parameters\"},{\"name\":\"cf_prob\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(nage) + "},\"block\":\"transformed_parameters\"},{\"name\":\"state_probs\",\"type\":{\"name\":\"array\",\"length\":" + std::to_string(state_probs_1dim__) + ",\"element_type\":{\"name\":\"array\",\"length\":" + std::to_string(nbias) + ",\"element_type\":{\"name\":\"vector\",\"length\":" + std::to_string(3) + "}}},\"block\":\"transformed_parameters\"},{\"name\":\"tmp\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(3) + "},\"block\":\"transformed_parameters\"},{\"name\":\"P\",\"type\":{\"name\":\"matrix\",\"rows\":" + std::to_string(3) + ",\"cols\":" + std::to_string(3) + "},\"block\":\"transformed_parameters\"},{\"name\":\"prev_prob\",\"type\":{\"name\":\"matrix\",\"rows\":" + std::to_string(nage) + ",\"cols\":" + std::to_string(nbias) + "},\"block\":\"transformed_parameters\"},{\"name\":\"mort_prob\",\"type\":{\"name\":\"array\",\"length\":" + std::to_string(nage) + ",\"element_type\":{\"name\":\"real\"}},\"block\":\"transformed_parameters\"},{\"name\":\"cf_yr\",\"type\":{\"name\":\"matrix\",\"rows\":" + std::to_string(cf_yr_1dim__) + ",\"cols\":" + std::to_string(cf_yr_2dim__) + "},\"block\":\"transformed_parameters\"},{\"name\":\"inc_yr\",\"type\":{\"name\":\"array\",\"length\":" + std::to_string(inc_yr_1dim__) + ",\"element_type\":{\"name\":\"array\",\"length\":" + std::to_string(inc_yr_2dim__) + ",\"element_type\":{\"name\":\"array\",\"length\":" + std::to_string(nbias) + ",\"element_type\":{\"name\":\"real\"}}}},\"block\":\"transformed_parameters\"},{\"name\":\"state_probs_yr\",\"type\":{\"name\":\"array\",\"length\":" + std::to_string(state_probs_yr_1dim__) + ",\"element_type\":{\"name\":\"array\",\"length\":" + std::to_string(state_probs_yr_2dim__) + ",\"element_type\":{\"name\":\"array\",\"length\":" + std::to_string(nbias) + ",\"element_type\":{\"name\":\"vector\",\"length\":" + std::to_string(3) + "}}}},\"block\":\"transformed_parameters\"},{\"name\":\"lambda_cf_use\",\"type\":{\"name\":\"real\"},\"block\":\"transformed_parameters\"},{\"name\":\"lambda_inc_use\",\"type\":{\"name\":\"real\"},\"block\":\"transformed_parameters\"},{\"name\":\"lambda_rem_use\",\"type\":{\"name\":\"real\"},\"block\":\"transformed_parameters\"},{\"name\":\"ll_mort\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(nage) + "},\"block\":\"generated_quantities\"},{\"name\":\"ll_inc\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(ll_inc_1dim__) + "},\"block\":\"generated_quantities\"},{\"name\":\"ll_prev\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(ll_prev_1dim__) + "},\"block\":\"generated_quantities\"},{\"name\":\"ll_rem\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(ll_rem_1dim__) + "},\"block\":\"generated_quantities\"},{\"name\":\"ll_overall\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(ll_overall_1dim__) + "},\"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__ = (((((((((((inc_par_1dim__ + cf_par_1dim__) +
      rem_par_1dim__) + beta_1dim__) + lambda_cf_1dim__) + lambda_inc_1dim__)
      + beta_inc_1dim__) + lambda_rem_1dim__) + beta_rem_1dim__) + prev_zero)
      + bias_loghr_1dim__) + cfbase_1dim__);
    const size_t num_transformed = emit_transformed_parameters *
      ((((((((((((((((((nage + dcf_1dim__) + (nage * nbias)) + (nage *
      nbias)) + nage) + rem_prob_1dim__) + nage) + ((state_probs_1dim__ *
      nbias) * 3)) + 3) + (3 * 3)) + (nage * nbias)) + nage) + (cf_yr_1dim__
      * cf_yr_2dim__)) + ((inc_yr_1dim__ * inc_yr_2dim__) * nbias)) +
      (((state_probs_yr_1dim__ * state_probs_yr_2dim__) * nbias) * 3)) + 1) +
      1) + 1));
    const size_t num_gen_quantities = emit_generated_quantities * (((((nage +
      ll_inc_1dim__) + ll_prev_1dim__) + ll_rem_1dim__) + ll_overall_1dim__));
    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__ = (((((((((((inc_par_1dim__ + cf_par_1dim__) +
      rem_par_1dim__) + beta_1dim__) + lambda_cf_1dim__) + lambda_inc_1dim__)
      + beta_inc_1dim__) + lambda_rem_1dim__) + beta_rem_1dim__) + prev_zero)
      + bias_loghr_1dim__) + cfbase_1dim__);
    const size_t num_transformed = emit_transformed_parameters *
      ((((((((((((((((((nage + dcf_1dim__) + (nage * nbias)) + (nage *
      nbias)) + nage) + rem_prob_1dim__) + nage) + ((state_probs_1dim__ *
      nbias) * 3)) + 3) + (3 * 3)) + (nage * nbias)) + nage) + (cf_yr_1dim__
      * cf_yr_2dim__)) + ((inc_yr_1dim__ * inc_yr_2dim__) * nbias)) +
      (((state_probs_yr_1dim__ * state_probs_yr_2dim__) * nbias) * 3)) + 1) +
      1) + 1));
    const size_t num_gen_quantities = emit_generated_quantities * (((((nage +
      ll_inc_1dim__) + ll_prev_1dim__) + ll_rem_1dim__) + ll_overall_1dim__));
    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_disbayes_namespace::model_disbayes;
#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_disbayes_namespace::profiles__;
}
#endif
#endif
