* using log directory 'd:/RCompile/CRANincoming/R-devel/mvgam.Rcheck' * using R version 4.4.0 beta (2024-04-15 r86425 ucrt) * using platform: x86_64-w64-mingw32 * R was compiled by gcc.exe (GCC) 13.2.0 GNU Fortran (GCC) 13.2.0 * running under: Windows Server 2022 x64 (build 20348) * using session charset: UTF-8 * checking for file 'mvgam/DESCRIPTION' ... OK * this is package 'mvgam' version '1.1.0' * package encoding: UTF-8 * checking CRAN incoming feasibility ... NOTE Maintainer: 'Nicholas J Clark ' New submission Possibly misspelled words in DESCRIPTION: GAMs (10:33) MCMC (11:112) Suggests or Enhances not in mainstream repositories: cmdstanr Package has a VignetteBuilder field but no prebuilt vignette index. Package CITATION file contains call(s) to old-style personList() or as.personList(). Please use c() on person objects instead. Package CITATION file contains call(s) to old-style citEntry(). Please use bibentry() instead. The Description field contains . Please write DOIs as . Size of tarball: 10060528 bytes * checking package namespace information ... OK * checking package dependencies ... NOTE Package suggested but not available for checking: 'cmdstanr' * checking if this is a source package ... OK * checking if there is a namespace ... OK * checking for hidden files and directories ... OK * checking for portable file names ... OK * checking whether package 'mvgam' can be installed ... OK * used C++ compiler: 'g++.exe (GCC) 13.2.0' * checking installed package size ... OK * checking package directory ... OK * checking for future file timestamps ... OK * checking DESCRIPTION meta-information ... OK * checking top-level files ... NOTE Non-standard files/directories found at top level: 'desktop.ini' 'misc' * checking for left-over files ... OK * checking index information ... OK * checking package subdirectories ... OK * checking code files for non-ASCII characters ... OK * checking R files for syntax errors ... OK * checking whether the package can be loaded ... OK * checking whether the package can be loaded with stated dependencies ... OK * checking whether the package can be unloaded cleanly ... OK * checking whether the namespace can be loaded with stated dependencies ... OK * checking whether the namespace can be unloaded cleanly ... OK * checking loading without being on the library search path ... OK * checking whether startup messages can be suppressed ... OK * checking use of S3 registration ... OK * checking dependencies in R code ... OK * checking S3 generic/method consistency ... OK * checking replacement functions ... OK * checking foreign function calls ... OK * checking R code for possible problems ... [41s] OK * checking Rd files ... OK * checking Rd metadata ... OK * checking Rd line widths ... OK * checking Rd cross-references ... NOTE Unknown package 'cmdstanr' in Rd xrefs * checking for missing documentation entries ... OK * checking for code/documentation mismatches ... OK * checking Rd \usage sections ... OK * checking Rd contents ... OK * checking for unstated dependencies in examples ... OK * checking contents of 'data' directory ... OK * checking data for non-ASCII characters ... OK * checking LazyData ... OK * checking data for ASCII and uncompressed saves ... OK * checking R/sysdata.rda ... OK * checking line endings in C/C++/Fortran sources/headers ... OK * checking use of PKG_*FLAGS in Makefiles ... OK * checking use of SHLIB_OPENMP_*FLAGS in Makefiles ... OK * checking pragmas in C/C++ headers and code ... OK * checking compilation flags used ... OK * checking compiled code ... OK * checking files in 'vignettes' ... WARNING Files in the 'vignettes' directory but no files in 'inst/doc': 'SS_model.svg' 'data_in_mvgam.Rmd' 'forecast_evaluation.Rmd' 'mvgam_overview.Rmd' 'nmixtures.Rmd' 'shared_states.Rmd' 'time_varying_effects.Rmd' 'trend_formulas.Rmd' * checking examples ... [15s] OK * checking for unstated dependencies in 'tests' ... OK * checking tests ... [52s] ERROR Running 'mvgam_examples.R' Running 'testthat.R' [44s] Running the tests in 'tests/mvgam_examples.R' failed. Complete output: > # Small mvgam examples for testing post-fitting functions such as > # predict, forecast, hindcast etc... > library(mvgam) Loading required package: mgcv Loading required package: nlme This is mgcv 1.9-1. For overview type 'help("mgcv-package")'. Loading required package: Rcpp Loading required package: brms Loading 'brms' package (version 2.21.0). Useful instructions can be found by typing help('brms'). A more detailed introduction to the package is available through vignette('brms_overview'). Attaching package: 'brms' The following objects are masked from 'package:mgcv': s, t2 The following object is masked from 'package:stats': ar Loading required package: marginaleffects Loading required package: insight Welcome to mvgam. Please cite as: Clark, NJ, and Wells, K. 2022. Dynamic Generalized Additive Models (DGAMs) for forecasting discrete ecological time series. Methods in Ecology and Evolution, 2022, https://doi.org/10.1111/2041-210X.13974 > set.seed(1234) > mvgam_examp_dat <- sim_mvgam(family = gaussian(), + T = 40, + prop_missing = 0.1) > > # Univariate process without trend_formula > mvgam_example1 <- mvgam(y ~ s(season, k = 5), + trend_model = 'RW', + family = gaussian(), + data = mvgam_examp_dat$data_train, + burnin = 300, + samples = 30, + chains = 1) Using rstan as the backend Compiling the Stan program... TRANSLATING MODEL '' FROM Stan CODE TO C++ CODE NOW. OS: x86_64, mingw32; rstan: 2.32.6; Rcpp: 1.0.12; inline: 0.3.19 >> setting environment variables: PKG_LIBS = "D:/RCompile/CRANpkg/lib/4.4/rstan/lib/x64/libStanServices.a" -L"D:/RCompile/CRANpkg/lib/4.4/StanHeaders/libs/x64" -lStanHeaders -L"D:/RCompile/CRANpkg/lib/4.4/RcppParallel/lib/x64" -ltbb -LD:/RCompile/CRANpkg/lib/4.4/RcppParallel/lib/x64 -ltbb -ltbbmalloc PKG_CPPFLAGS = -I"D:/RCompile/CRANpkg/lib/4.4/Rcpp/include/" -I"D:/temp/RtmpS2djg3/RLIBS_226843aebc96/RcppEigen/include/" -I"D:/temp/RtmpS2djg3/RLIBS_226843aebc96/RcppEigen/include/unsupported" -I"D:/temp/RtmpS2djg3/RLIBS_226843aebc96/BH/include" -I"D:/RCompile/CRANpkg/lib/4.4/StanHeaders/include/src/" -I"D:/RCompile/CRANpkg/lib/4.4/StanHeaders/include/" -I"D:/RCompile/CRANpkg/lib/4.4/RcppParallel/include/" -DRCPP_PARALLEL_USE_TBB=1 -I"D:/RCompile/CRANpkg/lib/4.4/rstan/include" -DEIGEN_NO_DEBUG -DBOOST_DISABLE_ASSERTS -DBOOST_PENDING_INTEGER_LOG2_HPP -DSTAN_THREADS -DUSE_STANC3 -DSTRICT_R_HEADERS -DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION -D_HAS_AUTO_PTR_ETC=0 -include "D:/RCompile/CRANpkg/lib/4.4/StanHeaders/include/stan/math/prim/fun/Eigen.hpp" -std=c++1y >> Program source : 1 : 2 : // includes from the plugin 3 : // [[Rcpp::plugins(cpp14)]] 4 : 5 : 6 : // user includes 7 : #include 8 : using namespace Rcpp; 9 : #ifndef MODELS_HPP 10 : #define MODELS_HPP 11 : #define STAN__SERVICES__COMMAND_HPP 12 : #include 13 : #ifndef USE_STANC3 14 : #define USE_STANC3 15 : #endif 16 : // Code generated by stanc v2.32.2 17 : #include 18 : namespace model1f1d41f703a3e__namespace { 19 : using stan::model::model_base_crtp; 20 : using namespace stan::math; 21 : stan::math::profile_map profiles__; 22 : static constexpr std::array locations_array__ = 23 : {" (found before start of program)", 24 : " (in 'string', line 33, column 0 to column 24)", 25 : " (in 'string', line 35, column 0 to column 36)", 26 : " (in 'string', line 37, column 0 to column 32)", 27 : " (in 'string', line 39, column 0 to column 26)", 28 : " (in 'string', line 41, column 0 to column 29)", 29 : " (in 'string', line 45, column 0 to column 20)", 30 : " (in 'string', line 76, column 0 to column 22)", 31 : " (in 'string', line 77, column 0 to column 34)", 32 : " (in 'string', line 78, column 0 to column 24)", 33 : " (in 'string', line 79, column 0 to column 17)", 34 : " (in 'string', line 80, column 0 to column 21)", 35 : " (in 'string', line 81, column 0 to column 30)", 36 : " (in 'string', line 46, column 0 to column 36)", 37 : " (in 'string', line 82, column 0 to column 18)", 38 : " (in 'string', line 84, column 0 to column 29)", 39 : " (in 'string', line 83, column 22 to line 85, column 1)", 40 : " (in 'string', line 83, column 0 to line 85, column 1)", 41 : " (in 'string', line 87, column 0 to column 12)", 42 : " (in 'string', line 89, column 0 to column 51)", 43 : " (in 'string', line 88, column 22 to line 90, column 1)", 44 : " (in 'string', line 88, column 0 to line 90, column 1)", 45 : " (in 'string', line 92, column 0 to column 50)", 46 : " (in 'string', line 93, column 0 to column 63)", 47 : " (in 'string', line 91, column 20 to line 94, column 1)", 48 : " (in 'string', line 91, column 0 to line 94, column 1)", 49 : " (in 'string', line 50, column 0 to column 34)", 50 : " (in 'string', line 52, column 0 to column 92)", 51 : " (in 'string', line 54, column 0 to column 23)", 52 : " (in 'string', line 56, column 0 to column 29)", 53 : " (in 'string', line 58, column 0 to column 40)", 54 : " (in 'string', line 60, column 0 to column 54)", 55 : " (in 'string', line 59, column 20 to line 61, column 1)", 56 : " (in 'string', line 59, column 0 to line 61, column 1)", 57 : " (in 'string', line 63, column 0 to column 33)", 58 : " (in 'string', line 66, column 7 to column 19)", 59 : " (in 'string', line 66, column 0 to column 33)", 60 : " (in 'string', line 67, column 7 to column 19)", 61 : " (in 'string', line 67, column 0 to column 36)", 62 : " (in 'string', line 68, column 0 to column 42)", 63 : " (in 'string', line 69, column 0 to column 49)", 64 : " (in 'string', line 70, column 0 to line 72, column 16)", 65 : " (in 'string', line 64, column 0 to line 73, column 1)", 66 : " (in 'string', line 17, column 0 to column 23)", 67 : " (in 'string', line 18, column 0 to column 15)", 68 : " (in 'string', line 19, column 0 to column 18)", 69 : " (in 'string', line 20, column 0 to column 22)", 70 : " (in 'string', line 21, column 0 to column 23)", 71 : " (in 'string', line 22, column 7 to column 16)", 72 : " (in 'string', line 22, column 0 to column 23)", 73 : " (in 'string', line 23, column 7 to column 16)", 74 : " (in 'string', line 23, column 18 to column 27)", 75 : " (in 'string', line 23, column 0 to column 31)", 76 : " (in 'string', line 24, column 20 to column 21)", 77 : " (in 'string', line 24, column 23 to column 31)", 78 : " (in 'string', line 24, column 0 to column 33)", 79 : " (in 'string', line 25, column 0 to column 15)", 80 : " (in 'string', line 26, column 0 to column 26)", 81 : " (in 'string', line 27, column 7 to column 19)", 82 : " (in 'string', line 27, column 0 to column 29)", 83 : " (in 'string', line 28, column 7 to column 19)", 84 : " (in 'string', line 28, column 21 to column 30)", 85 : " (in 'string', line 28, column 0 to column 40)", 86 : " (in 'string', line 29, column 21 to column 33)", 87 : " (in 'string', line 29, column 0 to column 35)", 88 : " (in 'string', line 33, column 7 to column 16)", 89 : " (in 'string', line 35, column 16 to column 24)", 90 : " (in 'string', line 37, column 16 to column 24)", 91 : " (in 'string', line 39, column 7 to column 8)", 92 : " (in 'string', line 39, column 10 to column 18)", 93 : " (in 'string', line 41, column 16 to column 20)", 94 : " (in 'string', line 45, column 7 to column 16)", 95 : " (in 'string', line 76, column 7 to column 16)", 96 : " (in 'string', line 77, column 7 to column 8)", 97 : " (in 'string', line 77, column 10 to column 18)", 98 : " (in 'string', line 78, column 7 to column 8)", 99 : " (in 'string', line 78, column 10 to column 18)", 100 : " (in 'string', line 79, column 7 to column 11)", 101 : " (in 'string', line 80, column 7 to column 15)", 102 : " (in 'string', line 81, column 6 to column 7)", 103 : " (in 'string', line 81, column 9 to column 17)", 104 : " (in 'string', line 4, column 0 to column 16)", 105 : " (in 'string', line 5, column 7 to column 12)", 106 : " (in 'string', line 5, column 0 to column 16)", 107 : " (in 'string', line 6, column 0 to column 12)", 108 : " (in 'string', line 9, column 0 to column 14)", 109 : " (in 'string', line 10, column 0 to column 9)", 110 : " (in 'string', line 8, column 15 to line 11, column 1)", 111 : " (in 'string', line 8, column 0 to line 11, column 1)", 112 : " (in 'string', line 7, column 15 to line 12, column 1)", 113 : " (in 'string', line 7, column 0 to line 12, column 1)", 114 : " (in 'string', line 13, column 0 to column 9)", 115 : " (in 'string', line 3, column 33 to line 14, column 1)"}; 116 : template , 118 : stan::is_vt_not_complex>* = nullptr> 119 : Eigen::Matrix>,-1,1> 120 : rep_each(const T0__& x_arg__, const int& K, std::ostream* pstream__); 121 : template , 123 : stan::is_vt_not_complex>*> 124 : Eigen::Matrix>,-1,1> 125 : rep_each(const T0__& x_arg__, const int& K, std::ostream* pstream__) { 126 : using local_scalar_t__ = stan::promote_args_t>; 127 : int current_statement__ = 0; 128 : const auto& x = stan::math::to_ref(x_arg__); 129 : static constexpr bool propto__ = true; 130 : // suppress unused var warning 131 : (void) propto__; 132 : local_scalar_t__ DUMMY_VAR__(std::numeric_limits::quiet_NaN()); 133 : // suppress unused var warning 134 : (void) DUMMY_VAR__; 135 : try { 136 : int N = std::numeric_limits::min(); 137 : current_statement__ = 81; 138 : N = stan::math::rows(x); 139 : current_statement__ = 82; 140 : stan::math::validate_non_negative_index("y", "N * K", (N * K)); 141 : Eigen::Matrix y = 142 : Eigen::Matrix::Constant((N * K), DUMMY_VAR__); 143 : int pos = std::numeric_limits::min(); 144 : current_statement__ = 84; 145 : pos = 1; 146 : current_statement__ = 90; 147 : for (int n = 1; n <= N; ++n) { 148 : current_statement__ = 88; 149 : for (int k = 1; k <= K; ++k) { 150 : current_statement__ = 85; 151 : stan::model::assign(y, 152 : stan::model::rvalue(x, "x", stan::model::index_uni(n)), 153 : "assigning variable y", stan::model::index_uni(pos)); 154 : current_statement__ = 86; 155 : pos = (pos + 1); 156 : } 157 : } 158 : current_statement__ = 91; 159 : return y; 160 : } catch (const std::exception& e) { 161 : stan::lang::rethrow_located(e, locations_array__[current_statement__]); 162 : } 163 : } 164 : class model1f1d41f703a3e_ final : public model_base_crtp { 165 : private: 166 : int total_obs; 167 : int n; 168 : int n_sp; 169 : int n_series; 170 : int num_basis; 171 : Eigen::Matrix zero_data__; 172 : Eigen::Matrix X_data__; 173 : std::vector> ytimes; 174 : Eigen::Matrix S1_data__; 175 : int n_nonmissing; 176 : Eigen::Matrix flat_ys_data__; 177 : Eigen::Matrix flat_xs_data__; 178 : std::vector obs_ind; 179 : Eigen::Map> zero{nullptr, 0}; 180 : Eigen::Map> X{nullptr, 0, 0}; 181 : Eigen::Map> S1{nullptr, 0, 0}; 182 : Eigen::Map> flat_ys{nullptr, 0}; 183 : Eigen::Map> flat_xs{nullptr, 0, 0}; 184 : public: 185 : ~model1f1d41f703a3e_() {} 186 : model1f1d41f703a3e_(stan::io::var_context& context__, unsigned int 187 : random_seed__ = 0, std::ostream* pstream__ = nullptr) 188 : : model_base_crtp(0) { 189 : int current_statement__ = 0; 190 : using local_scalar_t__ = double; 191 : boost::ecuyer1988 base_rng__ = 192 : stan::services::util::create_rng(random_seed__, 0); 193 : // suppress unused var warning 194 : (void) base_rng__; 195 : static constexpr const char* function__ = 196 : "model1f1d41f703a3e__namespace::model1f1d41f703a3e_"; 197 : // suppress unused var warning 198 : (void) function__; 199 : local_scalar_t__ DUMMY_VAR__(std::numeric_limits::quiet_NaN()); 200 : // suppress unused var warning 201 : (void) DUMMY_VAR__; 202 : try { 203 : int pos__ = std::numeric_limits::min(); 204 : pos__ = 1; 205 : current_statement__ = 43; 206 : context__.validate_dims("data initialization", "total_obs", "int", 207 : std::vector{}); 208 : total_obs = std::numeric_limits::min(); 209 : current_statement__ = 43; 210 : total_obs = context__.vals_i("total_obs")[(1 - 1)]; 211 : current_statement__ = 43; 212 : stan::math::check_greater_or_equal(function__, "total_obs", total_obs, 213 : 0); 214 : current_statement__ = 44; 215 : context__.validate_dims("data initialization", "n", "int", 216 : std::vector{}); 217 : n = std::numeric_limits::min(); 218 : current_statement__ = 44; 219 : n = context__.vals_i("n")[(1 - 1)]; 220 : current_statement__ = 44; 221 : stan::math::check_greater_or_equal(function__, "n", n, 0); 222 : current_statement__ = 45; 223 : context__.validate_dims("data initialization", "n_sp", "int", 224 : std::vector{}); 225 : n_sp = std::numeric_limits::min(); 226 : current_statement__ = 45; 227 : n_sp = context__.vals_i("n_sp")[(1 - 1)]; 228 : current_statement__ = 45; 229 : stan::math::check_greater_or_equal(function__, "n_sp", n_sp, 0); 230 : current_statement__ = 46; 231 : context__.validate_dims("data initialization", "n_series", "int", 232 : std::vector{}); 233 : n_series = std::numeric_limits::min(); 234 : current_statement__ = 46; 235 : n_series = context__.vals_i("n_series")[(1 - 1)]; 236 : current_statement__ = 46; 237 : stan::math::check_greater_or_equal(function__, "n_series", n_series, 0); 238 : current_statement__ = 47; 239 : context__.validate_dims("data initialization", "num_basis", "int", 240 : std::vector{}); 241 : num_basis = std::numeric_limits::min(); 242 : current_statement__ = 47; 243 : num_basis = context__.vals_i("num_basis")[(1 - 1)]; 244 : current_statement__ = 47; 245 : stan::math::check_greater_or_equal(function__, "num_basis", num_basis, 246 : 0); 247 : current_statement__ = 48; 248 : stan::math::validate_non_negative_index("zero", "num_basis", num_basis); 249 : current_statement__ = 49; 250 : context__.validate_dims("data initialization", "zero", "double", 251 : std::vector{static_cast(num_basis)}); 252 : zero_data__ = Eigen::Matrix::Constant(num_basis, 253 : std::numeric_limits::quiet_NaN()); 254 : new (&zero) Eigen::Map>(zero_data__.data(), 255 : num_basis); 256 : { 257 : std::vector zero_flat__; 258 : current_statement__ = 49; 259 : zero_flat__ = context__.vals_r("zero"); 260 : current_statement__ = 49; 261 : pos__ = 1; 262 : current_statement__ = 49; 263 : for (int sym1__ = 1; sym1__ <= num_basis; ++sym1__) { 264 : current_statement__ = 49; 265 : stan::model::assign(zero, zero_flat__[(pos__ - 1)], 266 : "assigning variable zero", stan::model::index_uni(sym1__)); 267 : current_statement__ = 49; 268 : pos__ = (pos__ + 1); 269 : } 270 : } 271 : current_statement__ = 50; 272 : stan::math::validate_non_negative_index("X", "total_obs", total_obs); 273 : current_statement__ = 51; 274 : stan::math::validate_non_negative_index("X", "num_basis", num_basis); 275 : current_statement__ = 52; 276 : context__.validate_dims("data initialization", "X", "double", 277 : std::vector{static_cast(total_obs), 278 : static_cast(num_basis)}); 279 : X_data__ = Eigen::Matrix::Constant(total_obs, num_basis, 280 : std::numeric_limits::quiet_NaN()); 281 : new (&X) Eigen::Map>(X_data__.data(), 282 : total_obs, num_basis); 283 : { 284 : std::vector X_flat__; 285 : current_statement__ = 52; 286 : X_flat__ = context__.vals_r("X"); 287 : current_statement__ = 52; 288 : pos__ = 1; 289 : current_statement__ = 52; 290 : for (int sym1__ = 1; sym1__ <= num_basis; ++sym1__) { 291 : current_statement__ = 52; 292 : for (int sym2__ = 1; sym2__ <= total_obs; ++sym2__) { 293 : current_statement__ = 52; 294 : stan::model::assign(X, X_flat__[(pos__ - 1)], 295 : "assigning variable X", stan::model::index_uni(sym2__), 296 : stan::model::index_uni(sym1__)); 297 : current_statement__ = 52; 298 : pos__ = (pos__ + 1); 299 : } 300 : } 301 : } 302 : current_statement__ = 53; 303 : stan::math::validate_non_negative_index("ytimes", "n", n); 304 : current_statement__ = 54; 305 : stan::math::validate_non_negative_index("ytimes", "n_series", n_series); 306 : current_statement__ = 55; 307 : context__.validate_dims("data initialization", "ytimes", "int", 308 : std::vector{static_cast(n), 309 : static_cast(n_series)}); 310 : ytimes = std::vector>(n, 311 : std::vector(n_series, std::numeric_limits::min())); 312 : { 313 : std::vector ytimes_flat__; 314 : current_statement__ = 55; 315 : ytimes_flat__ = context__.vals_i("ytimes"); 316 : current_statement__ = 55; 317 : pos__ = 1; 318 : current_statement__ = 55; 319 : for (int sym1__ = 1; sym1__ <= n_series; ++sym1__) { 320 : current_statement__ = 55; 321 : for (int sym2__ = 1; sym2__ <= n; ++sym2__) { 322 : current_statement__ = 55; 323 : stan::model::assign(ytimes, ytimes_flat__[(pos__ - 1)], 324 : "assigning variable ytimes", stan::model::index_uni(sym2__), 325 : stan::model::index_uni(sym1__)); 326 : current_statement__ = 55; 327 : pos__ = (pos__ + 1); 328 : } 329 : } 330 : } 331 : current_statement__ = 55; 332 : stan::math::check_greater_or_equal(function__, "ytimes", ytimes, 0); 333 : current_statement__ = 56; 334 : context__.validate_dims("data initialization", "S1", "double", 335 : std::vector{static_cast(4), static_cast(8)}); 336 : S1_data__ = Eigen::Matrix::Constant(4, 8, 337 : std::numeric_limits::quiet_NaN()); 338 : new (&S1) Eigen::Map>(S1_data__.data(), 4, 339 : 8); 340 : { 341 : std::vector S1_flat__; 342 : current_statement__ = 56; 343 : S1_flat__ = context__.vals_r("S1"); 344 : current_statement__ = 56; 345 : pos__ = 1; 346 : current_statement__ = 56; 347 : for (int sym1__ = 1; sym1__ <= 8; ++sym1__) { 348 : current_statement__ = 56; 349 : for (int sym2__ = 1; sym2__ <= 4; ++sym2__) { 350 : current_statement__ = 56; 351 : stan::model::assign(S1, S1_flat__[(pos__ - 1)], 352 : "assigning variable S1", stan::model::index_uni(sym2__), 353 : stan::model::index_uni(sym1__)); 354 : current_statement__ = 56; 355 : pos__ = (pos__ + 1); 356 : } 357 : } 358 : } 359 : current_statement__ = 57; 360 : context__.validate_dims("data initialization", "n_nonmissing", "int", 361 : std::vector{}); 362 : n_nonmissing = std::numeric_limits::min(); 363 : current_statement__ = 57; 364 : n_nonmissing = context__.vals_i("n_nonmissing")[(1 - 1)]; 365 : current_statement__ = 57; 366 : stan::math::check_greater_or_equal(function__, "n_nonmissing", 367 : n_nonmissing, 0); 368 : current_statement__ = 58; 369 : stan::math::validate_non_negative_index("flat_ys", "n_nonmissing", 370 : n_nonmissing); 371 : current_statement__ = 59; 372 : context__.validate_dims("data initialization", "flat_ys", "double", 373 : std::vector{static_cast(n_nonmissing)}); 374 : flat_ys_data__ = Eigen::Matrix::Constant(n_nonmissing, 375 : std::numeric_limits::quiet_NaN()); 376 : new (&flat_ys) 377 : Eigen::Map>(flat_ys_data__.data(), 378 : n_nonmissing); 379 : { 380 : std::vector flat_ys_flat__; 381 : current_statement__ = 59; 382 : flat_ys_flat__ = context__.vals_r("flat_ys"); 383 : current_statement__ = 59; 384 : pos__ = 1; 385 : current_statement__ = 59; 386 : for (int sym1__ = 1; sym1__ <= n_nonmissing; ++sym1__) { 387 : current_statement__ = 59; 388 : stan::model::assign(flat_ys, flat_ys_flat__[(pos__ - 1)], 389 : "assigning variable flat_ys", stan::model::index_uni(sym1__)); 390 : current_statement__ = 59; 391 : pos__ = (pos__ + 1); 392 : } 393 : } 394 : current_statement__ = 60; 395 : stan::math::validate_non_negative_index("flat_xs", "n_nonmissing", 396 : n_nonmissing); 397 : current_statement__ = 61; 398 : stan::math::validate_non_negative_index("flat_xs", "num_basis", 399 : num_basis); 400 : current_statement__ = 62; 401 : context__.validate_dims("data initialization", "flat_xs", "double", 402 : std::vector{static_cast(n_nonmissing), 403 : static_cast(num_basis)}); 404 : flat_xs_data__ = Eigen::Matrix::Constant(n_nonmissing, 405 : num_basis, std::numeric_limits::quiet_NaN()); 406 : new (&flat_xs) 407 : Eigen::Map>(flat_xs_data__.data(), 408 : n_nonmissing, num_basis); 409 : { 410 : std::vector flat_xs_flat__; 411 : current_statement__ = 62; 412 : flat_xs_flat__ = context__.vals_r("flat_xs"); 413 : current_statement__ = 62; 414 : pos__ = 1; 415 : current_statement__ = 62; 416 : for (int sym1__ = 1; sym1__ <= num_basis; ++sym1__) { 417 : current_statement__ = 62; 418 : for (int sym2__ = 1; sym2__ <= n_nonmissing; ++sym2__) { 419 : current_statement__ = 62; 420 : stan::model::assign(flat_xs, flat_xs_flat__[(pos__ - 1)], 421 : "assigning variable flat_xs", stan::model::index_uni(sym2__), 422 : stan::model::index_uni(sym1__)); 423 : current_statement__ = 62; 424 : pos__ = (pos__ + 1); 425 : } 426 : } 427 : } 428 : current_statement__ = 63; 429 : stan::math::validate_non_negative_index("obs_ind", "n_nonmissing", 430 : n_nonmissing); 431 : current_statement__ = 64; 432 : context__.validate_dims("data initialization", "obs_ind", "int", 433 : std::vector{static_cast(n_nonmissing)}); 434 : obs_ind = std::vector(n_nonmissing, 435 : std::numeric_limits::min()); 436 : current_statement__ = 64; 437 : obs_ind = context__.vals_i("obs_ind"); 438 : current_statement__ = 64; 439 : stan::math::check_greater_or_equal(function__, "obs_ind", obs_ind, 0); 440 : current_statement__ = 65; 441 : stan::math::validate_non_negative_index("b_raw", "num_basis", num_basis); 442 : current_statement__ = 66; 443 : stan::math::validate_non_negative_index("sigma_obs", "n_series", 444 : n_series); 445 : current_statement__ = 67; 446 : stan::math::validate_non_negative_index("sigma", "n_series", n_series); 447 : current_statement__ = 68; 448 : stan::math::validate_non_negative_index("trend", "n", n); 449 : current_statement__ = 69; 450 : stan::math::validate_non_negative_index("trend", "n_series", n_series); 451 : current_statement__ = 70; 452 : stan::math::validate_non_negative_index("lambda", "n_sp", n_sp); 453 : current_statement__ = 71; 454 : stan::math::validate_non_negative_index("b", "num_basis", num_basis); 455 : current_statement__ = 72; 456 : stan::math::validate_non_negative_index("eta", "total_obs", total_obs); 457 : current_statement__ = 73; 458 : stan::math::validate_non_negative_index("sigma_obs_vec", "n", n); 459 : current_statement__ = 74; 460 : stan::math::validate_non_negative_index("sigma_obs_vec", "n_series", 461 : n_series); 462 : current_statement__ = 75; 463 : stan::math::validate_non_negative_index("mus", "n", n); 464 : current_statement__ = 76; 465 : stan::math::validate_non_negative_index("mus", "n_series", n_series); 466 : current_statement__ = 77; 467 : stan::math::validate_non_negative_index("rho", "n_sp", n_sp); 468 : current_statement__ = 78; 469 : stan::math::validate_non_negative_index("tau", "n_series", n_series); 470 : current_statement__ = 79; 471 : stan::math::validate_non_negative_index("ypred", "n", n); 472 : current_statement__ = 80; 473 : stan::math::validate_non_negative_index("ypred", "n_series", n_series); 474 : } catch (const std::exception& e) { 475 : stan::lang::rethrow_located(e, locations_array__[current_statement__]); 476 : } 477 : num_params_r__ = num_basis + n_series + n_series + (n * n_series) + n_sp; 478 : } 479 : inline std::string model_name() const final { 480 : return "model1f1d41f703a3e_"; 481 : } 482 : inline std::vector model_compile_info() const noexcept { 483 : return std::vector{"stanc_version = stanc3 v2.32.2", 484 : "stancflags = --"}; 485 : } 486 : template * = nullptr, 488 : stan::require_vector_like_vt* = nullptr> 489 : inline stan::scalar_type_t 490 : log_prob_impl(VecR& params_r__, VecI& params_i__, std::ostream* 491 : pstream__ = nullptr) const { 492 : using T__ = stan::scalar_type_t; 493 : using local_scalar_t__ = T__; 494 : T__ lp__(0.0); 495 : stan::math::accumulator lp_accum__; 496 : stan::io::deserializer in__(params_r__, params_i__); 497 : int current_statement__ = 0; 498 : local_scalar_t__ DUMMY_VAR__(std::numeric_limits::quiet_NaN()); 499 : // suppress unused var warning 500 : (void) DUMMY_VAR__; 501 : static constexpr const char* function__ = 502 : "model1f1d41f703a3e__namespace::log_prob"; 503 : // suppress unused var warning 504 : (void) function__; 505 : try { 506 : Eigen::Matrix b_raw = 507 : Eigen::Matrix::Constant(num_basis, 508 : DUMMY_VAR__); 509 : current_statement__ = 1; 510 : b_raw = in__.template read< 511 : Eigen::Matrix>(num_basis); 512 : Eigen::Matrix sigma_obs = 513 : Eigen::Matrix::Constant(n_series, DUMMY_VAR__); 514 : current_statement__ = 2; 515 : sigma_obs = in__.template read_constrain_lb< 516 : Eigen::Matrix, jacobian__>(0, 517 : lp__, n_series); 518 : Eigen::Matrix sigma = 519 : Eigen::Matrix::Constant(n_series, DUMMY_VAR__); 520 : current_statement__ = 3; 521 : sigma = in__.template read_constrain_lb< 522 : Eigen::Matrix, jacobian__>(0, lp__, 523 : n_series); 524 : Eigen::Matrix trend = 525 : Eigen::Matrix::Constant(n, n_series, 526 : DUMMY_VAR__); 527 : current_statement__ = 4; 528 : trend = in__.template read>(n, 529 : n_series); 530 : Eigen::Matrix lambda = 531 : Eigen::Matrix::Constant(n_sp, DUMMY_VAR__); 532 : current_statement__ = 5; 533 : lambda = in__.template read_constrain_lb< 534 : Eigen::Matrix, jacobian__>(0, lp__, 535 : n_sp); 536 : Eigen::Matrix b = 537 : Eigen::Matrix::Constant(num_basis, 538 : DUMMY_VAR__); 539 : current_statement__ = 13; 540 : stan::model::assign(b, 541 : stan::model::rvalue(b_raw, "b_raw", 542 : stan::model::index_min_max(1, num_basis)), "assigning variable b", 543 : stan::model::index_min_max(1, num_basis)); 544 : { 545 : current_statement__ = 26; 546 : lp_accum__.add(stan::math::student_t_lpdf( 547 : stan::model::rvalue(b_raw, "b_raw", 548 : stan::model::index_uni(1)), 3, 0.4, 2.5)); 549 : current_statement__ = 27; 550 : lp_accum__.add(stan::math::multi_normal_prec_lpdf( 551 : stan::model::rvalue(b_raw, "b_raw", 552 : stan::model::index_min_max(2, 5)), 553 : stan::model::rvalue(zero, "zero", 554 : stan::model::index_min_max(2, 5)), 555 : stan::math::add( 556 : stan::math::multiply( 557 : stan::model::rvalue(S1, "S1", 558 : stan::model::index_min_max(1, 4), 559 : stan::model::index_min_max(1, 4)), 560 : stan::model::rvalue(lambda, "lambda", 561 : stan::model::index_uni(1))), 562 : stan::math::multiply( 563 : stan::model::rvalue(S1, "S1", 564 : stan::model::index_min_max(1, 4), 565 : stan::model::index_min_max(5, 8)), 566 : stan::model::rvalue(lambda, "lambda", 567 : stan::model::index_uni(2)))))); 568 : current_statement__ = 28; 569 : lp_accum__.add(stan::math::normal_lpdf(lambda, 5, 30)); 570 : current_statement__ = 29; 571 : lp_accum__.add(stan::math::student_t_lpdf(sigma, 3, 0, 2.5)); 572 : current_statement__ = 30; 573 : lp_accum__.add(stan::math::normal_lpdf( 574 : stan::model::rvalue(trend, "trend", 575 : stan::model::index_uni(1), 576 : stan::model::index_min_max(1, n_series)), 0, sigma)); 577 : current_statement__ = 33; 578 : for (int s = 1; s <= n_series; ++s) { 579 : current_statement__ = 31; 580 : lp_accum__.add(stan::math::normal_lpdf( 581 : stan::model::rvalue(trend, "trend", 582 : stan::model::index_min_max(2, n), 583 : stan::model::index_uni(s)), 584 : stan::model::rvalue(trend, "trend", 585 : stan::model::index_min_max(1, (n - 1)), 586 : stan::model::index_uni(s)), 587 : stan::model::rvalue(sigma, "sigma", 588 : stan::model::index_uni(s)))); 589 : } 590 : current_statement__ = 34; 591 : lp_accum__.add(stan::math::student_t_lpdf(sigma_obs, 3, 0, 592 : 2.5)); 593 : { 594 : current_statement__ = 35; 595 : stan::math::validate_non_negative_index("flat_trends", 596 : "n_nonmissing", n_nonmissing); 597 : Eigen::Matrix flat_trends = 598 : Eigen::Matrix::Constant(n_nonmissing, 599 : DUMMY_VAR__); 600 : current_statement__ = 37; 601 : stan::math::validate_non_negative_index("flat_sigma_obs", 602 : "n_nonmissing", n_nonmissing); 603 : Eigen::Matrix flat_sigma_obs = 604 : Eigen::Matrix::Constant(n_nonmissing, 605 : DUMMY_VAR__); 606 : current_statement__ = 39; 607 : stan::model::assign(flat_trends, 608 : stan::model::rvalue(stan::math::to_vector(trend), 609 : "to_vector(trend)", stan::model::index_multi(obs_ind)), 610 : "assigning variable flat_trends"); 611 : current_statement__ = 40; 612 : stan::model::assign(flat_sigma_obs, 613 : stan::model::rvalue(rep_each(sigma_obs, n, pstream__), 614 : "rep_each(sigma_obs,\nn)", stan::model::index_multi(obs_ind)), 615 : "assigning variable flat_sigma_obs"); 616 : current_statement__ = 41; 617 : lp_accum__.add(stan::math::normal_id_glm_lpdf(flat_ys, 618 : stan::math::append_col(flat_xs, flat_trends), 0.0, 619 : stan::math::append_row(b, 1.0), flat_sigma_obs)); 620 : } 621 : } 622 : } catch (const std::exception& e) { 623 : stan::lang::rethrow_located(e, locations_array__[current_statement__]); 624 : } 625 : lp_accum__.add(lp__); 626 : return lp_accum__.sum(); 627 : } 628 : template * = nullptr, stan::require_vector_like_vt* = nullptr, stan::require_vector_vt* = nullptr> 633 : inline void 634 : write_array_impl(RNG& base_rng__, VecR& params_r__, VecI& params_i__, 635 : VecVar& vars__, const bool 636 : emit_transformed_parameters__ = true, const bool 637 : emit_generated_quantities__ = true, std::ostream* 638 : pstream__ = nullptr) const { 639 : using local_scalar_t__ = double; 640 : stan::io::deserializer in__(params_r__, params_i__); 641 : stan::io::serializer out__(vars__); 642 : static constexpr bool propto__ = true; 643 : // suppress unused var warning 644 : (void) propto__; 645 : double lp__ = 0.0; 646 : // suppress unused var warning 647 : (void) lp__; 648 : int current_statement__ = 0; 649 : stan::math::accumulator lp_accum__; 650 : local_scalar_t__ DUMMY_VAR__(std::numeric_limits::quiet_NaN()); 651 : // suppress unused var warning 652 : (void) DUMMY_VAR__; 653 : constexpr bool jacobian__ = false; 654 : static constexpr const char* function__ = 655 : "model1f1d41f703a3e__namespace::write_array"; 656 : // suppress unused var warning 657 : (void) function__; 658 : try { 659 : Eigen::Matrix b_raw = 660 : Eigen::Matrix::Constant(num_basis, 661 : std::numeric_limits::quiet_NaN()); 662 : current_statement__ = 1; 663 : b_raw = in__.template read< 664 : Eigen::Matrix>(num_basis); 665 : Eigen::Matrix sigma_obs = 666 : Eigen::Matrix::Constant(n_series, 667 : std::numeric_limits::quiet_NaN()); 668 : current_statement__ = 2; 669 : sigma_obs = in__.template read_constrain_lb< 670 : Eigen::Matrix, jacobian__>(0, 671 : lp__, n_series); 672 : Eigen::Matrix sigma = 673 : Eigen::Matrix::Constant(n_series, 674 : std::numeric_limits::quiet_NaN()); 675 : current_statement__ = 3; 676 : sigma = in__.template read_constrain_lb< 677 : Eigen::Matrix, jacobian__>(0, lp__, 678 : n_series); 679 : Eigen::Matrix trend = 680 : Eigen::Matrix::Constant(n, n_series, 681 : std::numeric_limits::quiet_NaN()); 682 : current_statement__ = 4; 683 : trend = in__.template read>(n, 684 : n_series); 685 : Eigen::Matrix lambda = 686 : Eigen::Matrix::Constant(n_sp, 687 : std::numeric_limits::quiet_NaN()); 688 : current_statement__ = 5; 689 : lambda = in__.template read_constrain_lb< 690 : Eigen::Matrix, jacobian__>(0, lp__, 691 : n_sp); 692 : Eigen::Matrix b = 693 : Eigen::Matrix::Constant(num_basis, 694 : std::numeric_limits::quiet_NaN()); 695 : out__.write(b_raw); 696 : out__.write(sigma_obs); 697 : out__.write(sigma); 698 : out__.write(trend); 699 : out__.write(lambda); 700 : if (stan::math::logical_negation( 701 : (stan::math::primitive_value(emit_transformed_parameters__) || 702 : stan::math::primitive_value(emit_generated_quantities__)))) { 703 : return ; 704 : } 705 : current_statement__ = 13; 706 : stan::model::assign(b, 707 : stan::model::rvalue(b_raw, "b_raw", 708 : stan::model::index_min_max(1, num_basis)), "assigning variable b", 709 : stan::model::index_min_max(1, num_basis)); 710 : if (emit_transformed_parameters__) { 711 : out__.write(b); 712 : } 713 : if (stan::math::logical_negation(emit_generated_quantities__)) { 714 : return ; 715 : } 716 : Eigen::Matrix eta = 717 : Eigen::Matrix::Constant(total_obs, 718 : std::numeric_limits::quiet_NaN()); 719 : Eigen::Matrix sigma_obs_vec = 720 : Eigen::Matrix::Constant(n, n_series, 721 : std::numeric_limits::quiet_NaN()); 722 : Eigen::Matrix mus = 723 : Eigen::Matrix::Constant(n, n_series, 724 : std::numeric_limits::quiet_NaN()); 725 : Eigen::Matrix rho = 726 : Eigen::Matrix::Constant(n_sp, 727 : std::numeric_limits::quiet_NaN()); 728 : Eigen::Matrix tau = 729 : Eigen::Matrix::Constant(n_series, 730 : std::numeric_limits::quiet_NaN()); 731 : std::vector> ypred = 732 : std::vector>(n, 733 : std::vector(n_series, 734 : std::numeric_limits::quiet_NaN())); 735 : current_statement__ = 14; 736 : stan::model::assign(rho, stan::math::log(lambda), 737 : "assigning variable rho"); 738 : current_statement__ = 17; 739 : for (int s = 1; s <= n_series; ++s) { 740 : current_statement__ = 15; 741 : stan::model::assign(tau, 742 : stan::math::pow( 743 : stan::model::rvalue(sigma, "sigma", stan::model::index_uni(s)), 744 : -2.0), "assigning variable tau", stan::model::index_uni(s)); 745 : } 746 : current_statement__ = 18; 747 : stan::model::assign(eta, stan::math::multiply(X, b), 748 : "assigning variable eta"); 749 : current_statement__ = 21; 750 : for (int s = 1; s <= n_series; ++s) { 751 : current_statement__ = 19; 752 : stan::model::assign(sigma_obs_vec, 753 : stan::math::rep_vector( 754 : stan::model::rvalue(sigma_obs, "sigma_obs", 755 : stan::model::index_uni(s)), n), 756 : "assigning variable sigma_obs_vec", 757 : stan::model::index_min_max(1, n), stan::model::index_uni(s)); 758 : } 759 : current_statement__ = 25; 760 : for (int s = 1; s <= n_series; ++s) { 761 : current_statement__ = 22; 762 : stan::model::assign(mus, 763 : stan::math::add( 764 : stan::model::rvalue(eta, "eta", 765 : stan::model::index_multi( 766 : stan::model::rvalue(ytimes, "ytimes", 767 : stan::model::index_min_max(1, n), stan::model::index_uni(s)))), 768 : stan::model::rvalue(trend, "trend", 769 : stan::model::index_min_max(1, n), stan::model::index_uni(s))), 770 : "assigning variable mus", stan::model::index_min_max(1, n), 771 : stan::model::index_uni(s)); 772 : current_statement__ = 23; 773 : stan::model::assign(ypred, 774 : stan::math::normal_rng( 775 : stan::model::rvalue(mus, "mus", stan::model::index_min_max(1, n), 776 : stan::model::index_uni(s)), 777 : stan::model::rvalue(sigma_obs_vec, "sigma_obs_vec", 778 : stan::model::index_min_max(1, n), stan::model::index_uni(s)), 779 : base_rng__), "assigning variable ypred", 780 : stan::model::index_min_max(1, n), stan::model::index_uni(s)); 781 : } 782 : out__.write(eta); 783 : out__.write(sigma_obs_vec); 784 : out__.write(mus); 785 : out__.write(rho); 786 : out__.write(tau); 787 : for (int sym1__ = 1; sym1__ <= n_series; ++sym1__) { 788 : for (int sym2__ = 1; sym2__ <= n; ++sym2__) { 789 : out__.write(ypred[(sym2__ - 1)][(sym1__ - 1)]); 790 : } 791 : } 792 : } catch (const std::exception& e) { 793 : stan::lang::rethrow_located(e, locations_array__[current_statement__]); 794 : } 795 : } 796 : template * = nullptr, 798 : stan::require_vector_like_vt* = nullptr> 799 : inline void 800 : unconstrain_array_impl(const VecVar& params_r__, const VecI& params_i__, 801 : VecVar& vars__, std::ostream* pstream__ = nullptr) const { 802 : using local_scalar_t__ = double; 803 : stan::io::deserializer in__(params_r__, params_i__); 804 : stan::io::serializer out__(vars__); 805 : int current_statement__ = 0; 806 : local_scalar_t__ DUMMY_VAR__(std::numeric_limits::quiet_NaN()); 807 : // suppress unused var warning 808 : (void) DUMMY_VAR__; 809 : try { 810 : int pos__ = std::numeric_limits::min(); 811 : pos__ = 1; 812 : Eigen::Matrix b_raw = 813 : Eigen::Matrix::Constant(num_basis, 814 : DUMMY_VAR__); 815 : current_statement__ = 1; 816 : stan::model::assign(b_raw, 817 : in__.read>(num_basis), 818 : "assigning variable b_raw"); 819 : out__.write(b_raw); 820 : Eigen::Matrix sigma_obs = 821 : Eigen::Matrix::Constant(n_series, DUMMY_VAR__); 822 : current_statement__ = 2; 823 : stan::model::assign(sigma_obs, 824 : in__.read>(n_series), 825 : "assigning variable sigma_obs"); 826 : out__.write_free_lb(0, sigma_obs); 827 : Eigen::Matrix sigma = 828 : Eigen::Matrix::Constant(n_series, DUMMY_VAR__); 829 : current_statement__ = 3; 830 : stan::model::assign(sigma, 831 : in__.read>(n_series), 832 : "assigning variable sigma"); 833 : out__.write_free_lb(0, sigma); 834 : Eigen::Matrix trend = 835 : Eigen::Matrix::Constant(n, n_series, 836 : DUMMY_VAR__); 837 : current_statement__ = 4; 838 : stan::model::assign(trend, 839 : in__.read>(n, n_series), 840 : "assigning variable trend"); 841 : out__.write(trend); 842 : Eigen::Matrix lambda = 843 : Eigen::Matrix::Constant(n_sp, DUMMY_VAR__); 844 : current_statement__ = 5; 845 : stan::model::assign(lambda, 846 : in__.read>(n_sp), 847 : "assigning variable lambda"); 848 : out__.write_free_lb(0, lambda); 849 : } catch (const std::exception& e) { 850 : stan::lang::rethrow_located(e, locations_array__[current_statement__]); 851 : } 852 : } 853 : template * = nullptr> 854 : inline void 855 : transform_inits_impl(const stan::io::var_context& context__, VecVar& 856 : vars__, std::ostream* pstream__ = nullptr) const { 857 : using local_scalar_t__ = double; 858 : stan::io::serializer out__(vars__); 859 : int current_statement__ = 0; 860 : local_scalar_t__ DUMMY_VAR__(std::numeric_limits::quiet_NaN()); 861 : // suppress unused var warning 862 : (void) DUMMY_VAR__; 863 : try { 864 : current_statement__ = 1; 865 : context__.validate_dims("parameter initialization", "b_raw", "double", 866 : std::vector{static_cast(num_basis)}); 867 : current_statement__ = 2; 868 : context__.validate_dims("parameter initialization", "sigma_obs", 869 : "double", std::vector{static_cast(n_series)}); 870 : current_statement__ = 3; 871 : context__.validate_dims("parameter initialization", "sigma", "double", 872 : std::vector{static_cast(n_series)}); 873 : current_statement__ = 4; 874 : context__.validate_dims("parameter initialization", "trend", "double", 875 : std::vector{static_cast(n), 876 : static_cast(n_series)}); 877 : current_statement__ = 5; 878 : context__.validate_dims("parameter initialization", "lambda", "double", 879 : std::vector{static_cast(n_sp)}); 880 : int pos__ = std::numeric_limits::min(); 881 : pos__ = 1; 882 : Eigen::Matrix b_raw = 883 : Eigen::Matrix::Constant(num_basis, 884 : DUMMY_VAR__); 885 : { 886 : std::vector b_raw_flat__; 887 : current_statement__ = 1; 888 : b_raw_flat__ = context__.vals_r("b_raw"); 889 : current_statement__ = 1; 890 : pos__ = 1; 891 : current_statement__ = 1; 892 : for (int sym1__ = 1; sym1__ <= num_basis; ++sym1__) { 893 : current_statement__ = 1; 894 : stan::model::assign(b_raw, b_raw_flat__[(pos__ - 1)], 895 : "assigning variable b_raw", stan::model::index_uni(sym1__)); 896 : current_statement__ = 1; 897 : pos__ = (pos__ + 1); 898 : } 899 : } 900 : out__.write(b_raw); 901 : Eigen::Matrix sigma_obs = 902 : Eigen::Matrix::Constant(n_series, DUMMY_VAR__); 903 : { 904 : std::vector sigma_obs_flat__; 905 : current_statement__ = 2; 906 : sigma_obs_flat__ = context__.vals_r("sigma_obs"); 907 : current_statement__ = 2; 908 : pos__ = 1; 909 : current_statement__ = 2; 910 : for (int sym1__ = 1; sym1__ <= n_series; ++sym1__) { 911 : current_statement__ = 2; 912 : stan::model::assign(sigma_obs, sigma_obs_flat__[(pos__ - 1)], 913 : "assigning variable sigma_obs", stan::model::index_uni(sym1__)); 914 : current_statement__ = 2; 915 : pos__ = (pos__ + 1); 916 : } 917 : } 918 : out__.write_free_lb(0, sigma_obs); 919 : Eigen::Matrix sigma = 920 : Eigen::Matrix::Constant(n_series, DUMMY_VAR__); 921 : { 922 : std::vector sigma_flat__; 923 : current_statement__ = 3; 924 : sigma_flat__ = context__.vals_r("sigma"); 925 : current_statement__ = 3; 926 : pos__ = 1; 927 : current_statement__ = 3; 928 : for (int sym1__ = 1; sym1__ <= n_series; ++sym1__) { 929 : current_statement__ = 3; 930 : stan::model::assign(sigma, sigma_flat__[(pos__ - 1)], 931 : "assigning variable sigma", stan::model::index_uni(sym1__)); 932 : current_statement__ = 3; 933 : pos__ = (pos__ + 1); 934 : } 935 : } 936 : out__.write_free_lb(0, sigma); 937 : Eigen::Matrix trend = 938 : Eigen::Matrix::Constant(n, n_series, 939 : DUMMY_VAR__); 940 : { 941 : std::vector trend_flat__; 942 : current_statement__ = 4; 943 : trend_flat__ = context__.vals_r("trend"); 944 : current_statement__ = 4; 945 : pos__ = 1; 946 : current_statement__ = 4; 947 : for (int sym1__ = 1; sym1__ <= n_series; ++sym1__) { 948 : current_statement__ = 4; 949 : for (int sym2__ = 1; sym2__ <= n; ++sym2__) { 950 : current_statement__ = 4; 951 : stan::model::assign(trend, trend_flat__[(pos__ - 1)], 952 : "assigning variable trend", stan::model::index_uni(sym2__), 953 : stan::model::index_uni(sym1__)); 954 : current_statement__ = 4; 955 : pos__ = (pos__ + 1); 956 : } 957 : } 958 : } 959 : out__.write(trend); 960 : Eigen::Matrix lambda = 961 : Eigen::Matrix::Constant(n_sp, DUMMY_VAR__); 962 : { 963 : std::vector lambda_flat__; 964 : current_statement__ = 5; 965 : lambda_flat__ = context__.vals_r("lambda"); 966 : current_statement__ = 5; 967 : pos__ = 1; 968 : current_statement__ = 5; 969 : for (int sym1__ = 1; sym1__ <= n_sp; ++sym1__) { 970 : current_statement__ = 5; 971 : stan::model::assign(lambda, lambda_flat__[(pos__ - 1)], 972 : "assigning variable lambda", stan::model::index_uni(sym1__)); 973 : current_statement__ = 5; 974 : pos__ = (pos__ + 1); 975 : } 976 : } 977 : out__.write_free_lb(0, lambda); 978 : } catch (const std::exception& e) { 979 : stan::lang::rethrow_located(e, locations_array__[current_statement__]); 980 : } 981 : } 982 : inline void 983 : get_param_names(std::vector& names__, const bool 984 : emit_transformed_parameters__ = true, const bool 985 : emit_generated_quantities__ = true) const { 986 : names__ = std::vector{"b_raw", "sigma_obs", "sigma", 987 : "trend", "lambda"}; 988 : if (emit_transformed_parameters__) { 989 : std::vector temp{"b"}; 990 : names__.reserve(names__.size() + temp.size()); 991 : names__.insert(names__.end(), temp.begin(), temp.end()); 992 : } 993 : if (emit_generated_quantities__) { 994 : std::vector 995 : temp{"eta", "sigma_obs_vec", "mus", "rho", "tau", "ypred"}; 996 : names__.reserve(names__.size() + temp.size()); 997 : names__.insert(names__.end(), temp.begin(), temp.end()); 998 : } 999 : } 1000 : inline void 1001 : get_dims(std::vector>& dimss__, const bool 1002 : emit_transformed_parameters__ = true, const bool 1003 : emit_generated_quantities__ = true) const { 1004 : dimss__ = std::vector>{std::vector{static_cast< 1005 : size_t>( 1006 : num_basis)}, 1007 : std::vector{static_cast(n_series)}, 1008 : std::vector{static_cast(n_series)}, 1009 : std::vector{static_cast(n), 1010 : static_cast(n_series)}, 1011 : std::vector{static_cast(n_sp)}}; 1012 : if (emit_transformed_parameters__) { 1013 : std::vector> 1014 : temp{std::vector{static_cast(num_basis)}}; 1015 : dimss__.reserve(dimss__.size() + temp.size()); 1016 : dimss__.insert(dimss__.end(), temp.begin(), temp.end()); 1017 : } 1018 : if (emit_generated_quantities__) { 1019 : std::vector> 1020 : temp{std::vector{static_cast(total_obs)}, 1021 : std::vector{static_cast(n), 1022 : static_cast(n_series)}, 1023 : std::vector{static_cast(n), 1024 : static_cast(n_series)}, 1025 : std::vector{static_cast(n_sp)}, 1026 : std::vector{static_cast(n_series)}, 1027 : std::vector{static_cast(n), 1028 : static_cast(n_series)}}; 1029 : dimss__.reserve(dimss__.size() + temp.size()); 1030 : dimss__.insert(dimss__.end(), temp.begin(), temp.end()); 1031 : } 1032 : } 1033 : inline void 1034 : constrained_param_names(std::vector& param_names__, bool 1035 : emit_transformed_parameters__ = true, bool 1036 : emit_generated_quantities__ = true) const final { 1037 : for (int sym1__ = 1; sym1__ <= num_basis; ++sym1__) { 1038 : param_names__.emplace_back(std::string() + "b_raw" + '.' + 1039 : std::to_string(sym1__)); 1040 : } 1041 : for (int sym1__ = 1; sym1__ <= n_series; ++sym1__) { 1042 : param_names__.emplace_back(std::string() + "sigma_obs" + '.' + 1043 : std::to_string(sym1__)); 1044 : } 1045 : for (int sym1__ = 1; sym1__ <= n_series; ++sym1__) { 1046 : param_names__.emplace_back(std::string() + "sigma" + '.' + 1047 : std::to_string(sym1__)); 1048 : } 1049 : for (int sym1__ = 1; sym1__ <= n_series; ++sym1__) { 1050 : for (int sym2__ = 1; sym2__ <= n; ++sym2__) { 1051 : param_names__.emplace_back(std::string() + "trend" + '.' + 1052 : std::to_string(sym2__) + '.' + std::to_string(sym1__)); 1053 : } 1054 : } 1055 : for (int sym1__ = 1; sym1__ <= n_sp; ++sym1__) { 1056 : param_names__.emplace_back(std::string() + "lambda" + '.' + 1057 : std::to_string(sym1__)); 1058 : } 1059 : if (emit_transformed_parameters__) { 1060 : for (int sym1__ = 1; sym1__ <= num_basis; ++sym1__) { 1061 : param_names__.emplace_back(std::string() + "b" + '.' + 1062 : std::to_string(sym1__)); 1063 : } 1064 : } 1065 : if (emit_generated_quantities__) { 1066 : for (int sym1__ = 1; sym1__ <= total_obs; ++sym1__) { 1067 : param_names__.emplace_back(std::string() + "eta" + '.' + 1068 : std::to_string(sym1__)); 1069 : } 1070 : for (int sym1__ = 1; sym1__ <= n_series; ++sym1__) { 1071 : for (int sym2__ = 1; sym2__ <= n; ++sym2__) { 1072 : param_names__.emplace_back(std::string() + "sigma_obs_vec" + '.' + 1073 : std::to_string(sym2__) + '.' + std::to_string(sym1__)); 1074 : } 1075 : } 1076 : for (int sym1__ = 1; sym1__ <= n_series; ++sym1__) { 1077 : for (int sym2__ = 1; sym2__ <= n; ++sym2__) { 1078 : param_names__.emplace_back(std::string() + "mus" + '.' + 1079 : std::to_string(sym2__) + '.' + std::to_string(sym1__)); 1080 : } 1081 : } 1082 : for (int sym1__ = 1; sym1__ <= n_sp; ++sym1__) { 1083 : param_names__.emplace_back(std::string() + "rho" + '.' + 1084 : std::to_string(sym1__)); 1085 : } 1086 : for (int sym1__ = 1; sym1__ <= n_series; ++sym1__) { 1087 : param_names__.emplace_back(std::string() + "tau" + '.' + 1088 : std::to_string(sym1__)); 1089 : } 1090 : for (int sym1__ = 1; sym1__ <= n_series; ++sym1__) { 1091 : for (int sym2__ = 1; sym2__ <= n; ++sym2__) { 1092 : param_names__.emplace_back(std::string() + "ypred" + '.' + 1093 : std::to_string(sym2__) + '.' + std::to_string(sym1__)); 1094 : } 1095 : } 1096 : } 1097 : } 1098 : inline void 1099 : unconstrained_param_names(std::vector& param_names__, bool 1100 : emit_transformed_parameters__ = true, bool 1101 : emit_generated_quantities__ = true) const final { 1102 : for (int sym1__ = 1; sym1__ <= num_basis; ++sym1__) { 1103 : param_names__.emplace_back(std::string() + "b_raw" + '.' + 1104 : std::to_string(sym1__)); 1105 : } 1106 : for (int sym1__ = 1; sym1__ <= n_series; ++sym1__) { 1107 : param_names__.emplace_back(std::string() + "sigma_obs" + '.' + 1108 : std::to_string(sym1__)); 1109 : } 1110 : for (int sym1__ = 1; sym1__ <= n_series; ++sym1__) { 1111 : param_names__.emplace_back(std::string() + "sigma" + '.' + 1112 : std::to_string(sym1__)); 1113 : } 1114 : for (int sym1__ = 1; sym1__ <= n_series; ++sym1__) { 1115 : for (int sym2__ = 1; sym2__ <= n; ++sym2__) { 1116 : param_names__.emplace_back(std::string() + "trend" + '.' + 1117 : std::to_string(sym2__) + '.' + std::to_string(sym1__)); 1118 : } 1119 : } 1120 : for (int sym1__ = 1; sym1__ <= n_sp; ++sym1__) { 1121 : param_names__.emplace_back(std::string() + "lambda" + '.' + 1122 : std::to_string(sym1__)); 1123 : } 1124 : if (emit_transformed_parameters__) { 1125 : for (int sym1__ = 1; sym1__ <= num_basis; ++sym1__) { 1126 : param_names__.emplace_back(std::string() + "b" + '.' + 1127 : std::to_string(sym1__)); 1128 : } 1129 : } 1130 : if (emit_generated_quantities__) { 1131 : for (int sym1__ = 1; sym1__ <= total_obs; ++sym1__) { 1132 : param_names__.emplace_back(std::string() + "eta" + '.' + 1133 : std::to_string(sym1__)); 1134 : } 1135 : for (int sym1__ = 1; sym1__ <= n_series; ++sym1__) { 1136 : for (int sym2__ = 1; sym2__ <= n; ++sym2__) { 1137 : param_names__.emplace_back(std::string() + "sigma_obs_vec" + '.' + 1138 : std::to_string(sym2__) + '.' + std::to_string(sym1__)); 1139 : } 1140 : } 1141 : for (int sym1__ = 1; sym1__ <= n_series; ++sym1__) { 1142 : for (int sym2__ = 1; sym2__ <= n; ++sym2__) { 1143 : param_names__.emplace_back(std::string() + "mus" + '.' + 1144 : std::to_string(sym2__) + '.' + std::to_string(sym1__)); 1145 : } 1146 : } 1147 : for (int sym1__ = 1; sym1__ <= n_sp; ++sym1__) { 1148 : param_names__.emplace_back(std::string() + "rho" + '.' + 1149 : std::to_string(sym1__)); 1150 : } 1151 : for (int sym1__ = 1; sym1__ <= n_series; ++sym1__) { 1152 : param_names__.emplace_back(std::string() + "tau" + '.' + 1153 : std::to_string(sym1__)); 1154 : } 1155 : for (int sym1__ = 1; sym1__ <= n_series; ++sym1__) { 1156 : for (int sym2__ = 1; sym2__ <= n; ++sym2__) { 1157 : param_names__.emplace_back(std::string() + "ypred" + '.' + 1158 : std::to_string(sym2__) + '.' + std::to_string(sym1__)); 1159 : } 1160 : } 1161 : } 1162 : } 1163 : inline std::string get_constrained_sizedtypes() const { 1164 : return std::string("[{\"name\":\"b_raw\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(num_basis) + "},\"block\":\"parameters\"},{\"name\":\"sigma_obs\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(n_series) + "},\"block\":\"parameters\"},{\"name\":\"sigma\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(n_series) + "},\"block\":\"parameters\"},{\"name\":\"trend\",\"type\":{\"name\":\"matrix\",\"rows\":" + std::to_string(n) + ",\"cols\":" + std::to_string(n_series) + "},\"block\":\"parameters\"},{\"name\":\"lambda\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(n_sp) + "},\"block\":\"parameters\"},{\"name\":\"b\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(num_basis) + "},\"block\":\"transformed_parameters\"},{\"name\":\"eta\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(total_obs) + "},\"block\":\"generated_quantities\"},{\"name\":\"sigma_obs_vec\",\"type\":{\"name\":\"matrix\",\"rows\":" + std::to_string(n) + ",\"cols\":" + std::to_string(n_series) + "},\"block\":\"generated_quantities\"},{\"name\":\"mus\",\"type\":{\"name\":\"matrix\",\"rows\":" + std::to_string(n) + ",\"cols\":" + std::to_string(n_series) + "},\"block\":\"generated_quantities\"},{\"name\":\"rho\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(n_sp) + "},\"block\":\"generated_quantities\"},{\"name\":\"tau\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(n_series) + "},\"block\":\"generated_quantities\"},{\"name\":\"ypred\",\"type\":{\"name\":\"array\",\"length\":" + std::to_string(n) + ",\"element_type\":{\"name\":\"array\",\"length\":" + std::to_string(n_series) + ",\"element_type\":{\"name\":\"real\"}}},\"block\":\"generated_quantities\"}]"); 1165 : } 1166 : inline std::string get_unconstrained_sizedtypes() const { 1167 : return std::string("[{\"name\":\"b_raw\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(num_basis) + "},\"block\":\"parameters\"},{\"name\":\"sigma_obs\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(n_series) + "},\"block\":\"parameters\"},{\"name\":\"sigma\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(n_series) + "},\"block\":\"parameters\"},{\"name\":\"trend\",\"type\":{\"name\":\"matrix\",\"rows\":" + std::to_string(n) + ",\"cols\":" + std::to_string(n_series) + "},\"block\":\"parameters\"},{\"name\":\"lambda\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(n_sp) + "},\"block\":\"parameters\"},{\"name\":\"b\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(num_basis) + "},\"block\":\"transformed_parameters\"},{\"name\":\"eta\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(total_obs) + "},\"block\":\"generated_quantities\"},{\"name\":\"sigma_obs_vec\",\"type\":{\"name\":\"matrix\",\"rows\":" + std::to_string(n) + ",\"cols\":" + std::to_string(n_series) + "},\"block\":\"generated_quantities\"},{\"name\":\"mus\",\"type\":{\"name\":\"matrix\",\"rows\":" + std::to_string(n) + ",\"cols\":" + std::to_string(n_series) + "},\"block\":\"generated_quantities\"},{\"name\":\"rho\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(n_sp) + "},\"block\":\"generated_quantities\"},{\"name\":\"tau\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(n_series) + "},\"block\":\"generated_quantities\"},{\"name\":\"ypred\",\"type\":{\"name\":\"array\",\"length\":" + std::to_string(n) + ",\"element_type\":{\"name\":\"array\",\"length\":" + std::to_string(n_series) + ",\"element_type\":{\"name\":\"real\"}}},\"block\":\"generated_quantities\"}]"); 1168 : } 1169 : // Begin method overload boilerplate 1170 : template inline void 1171 : write_array(RNG& base_rng, Eigen::Matrix& params_r, 1172 : Eigen::Matrix& vars, const bool 1173 : emit_transformed_parameters = true, const bool 1174 : emit_generated_quantities = true, std::ostream* 1175 : pstream = nullptr) const { 1176 : const size_t num_params__ = ((((num_basis + n_series) + n_series) + (n * 1177 : n_series)) + n_sp); 1178 : const size_t num_transformed = emit_transformed_parameters * (num_basis); 1179 : const size_t num_gen_quantities = emit_generated_quantities * 1180 : ((((((total_obs + (n * n_series)) + (n * n_series)) + n_sp) + n_series) 1181 : + (n * n_series))); 1182 : const size_t num_to_write = num_params__ + num_transformed + 1183 : num_gen_quantities; 1184 : std::vector params_i; 1185 : vars = Eigen::Matrix::Constant(num_to_write, 1186 : std::numeric_limits::quiet_NaN()); 1187 : write_array_impl(base_rng, params_r, params_i, vars, 1188 : emit_transformed_parameters, emit_generated_quantities, pstream); 1189 : } 1190 : template inline void 1191 : write_array(RNG& base_rng, std::vector& params_r, std::vector& 1192 : params_i, std::vector& vars, bool 1193 : emit_transformed_parameters = true, bool 1194 : emit_generated_quantities = true, std::ostream* 1195 : pstream = nullptr) const { 1196 : const size_t num_params__ = ((((num_basis + n_series) + n_series) + (n * 1197 : n_series)) + n_sp); 1198 : const size_t num_transformed = emit_transformed_parameters * (num_basis); 1199 : const size_t num_gen_quantities = emit_generated_quantities * 1200 : ((((((total_obs + (n * n_series)) + (n * n_series)) + n_sp) + n_series) 1201 : + (n * n_series))); 1202 : const size_t num_to_write = num_params__ + num_transformed + 1203 : num_gen_quantities; 1204 : vars = std::vector(num_to_write, 1205 : std::numeric_limits::quiet_NaN()); 1206 : write_array_impl(base_rng, params_r, params_i, vars, 1207 : emit_transformed_parameters, emit_generated_quantities, pstream); 1208 : } 1209 : template inline T_ 1210 : log_prob(Eigen::Matrix& params_r, std::ostream* pstream = nullptr) const { 1211 : Eigen::Matrix params_i; 1212 : return log_prob_impl(params_r, params_i, pstream); 1213 : } 1214 : template inline T_ 1215 : log_prob(std::vector& params_r, std::vector& params_i, 1216 : std::ostream* pstream = nullptr) const { 1217 : return log_prob_impl(params_r, params_i, pstream); 1218 : } 1219 : inline void 1220 : transform_inits(const stan::io::var_context& context, 1221 : Eigen::Matrix& params_r, std::ostream* 1222 : pstream = nullptr) const final { 1223 : std::vector params_r_vec(params_r.size()); 1224 : std::vector params_i; 1225 : transform_inits(context, params_i, params_r_vec, pstream); 1226 : params_r = Eigen::Map>(params_r_vec.data(), 1227 : params_r_vec.size()); 1228 : } 1229 : inline void 1230 : transform_inits(const stan::io::var_context& context, std::vector& 1231 : params_i, std::vector& vars, std::ostream* 1232 : pstream__ = nullptr) const { 1233 : vars.resize(num_params_r__); 1234 : transform_inits_impl(context, vars, pstream__); 1235 : } 1236 : inline void 1237 : unconstrain_array(const std::vector& params_constrained, 1238 : std::vector& params_unconstrained, std::ostream* 1239 : pstream = nullptr) const { 1240 : const std::vector params_i; 1241 : params_unconstrained = std::vector(num_params_r__, 1242 : std::numeric_limits::quiet_NaN()); 1243 : unconstrain_array_impl(params_constrained, params_i, 1244 : params_unconstrained, pstream); 1245 : } 1246 : inline void 1247 : unconstrain_array(const Eigen::Matrix& params_constrained, 1248 : Eigen::Matrix& params_unconstrained, 1249 : std::ostream* pstream = nullptr) const { 1250 : const std::vector params_i; 1251 : params_unconstrained = Eigen::Matrix::Constant(num_params_r__, 1252 : std::numeric_limits::quiet_NaN()); 1253 : unconstrain_array_impl(params_constrained, params_i, 1254 : params_unconstrained, pstream); 1255 : } 1256 : }; 1257 : } 1258 : using stan_model = model1f1d41f703a3e__namespace::model1f1d41f703a3e_; 1259 : #ifndef USING_R 1260 : // Boilerplate 1261 : stan::model::model_base& 1262 : new_model(stan::io::var_context& data_context, unsigned int seed, 1263 : std::ostream* msg_stream) { 1264 : stan_model* m = new stan_model(data_context, seed, msg_stream); 1265 : return *m; 1266 : } 1267 : stan::math::profile_map& get_stan_profile_data() { 1268 : return model1f1d41f703a3e__namespace::profiles__; 1269 : } 1270 : #endif 1271 : #endif 1272 : 1273 : RCPP_MODULE(stan_fit4model1f1d41f703a3e__mod) { 1274 : class_ >( 1275 : "stan_fit4model1f1d41f703a3e_") 1276 : 1277 : .constructor() 1278 : 1279 : .method( 1280 : "call_sampler", 1281 : &rstan::stan_fit::call_sampler) 1282 : .method( 1283 : "param_names", 1284 : &rstan::stan_fit::param_names) 1285 : .method("param_names_oi", 1286 : &rstan::stan_fit::param_names_oi) 1288 : .method("param_fnames_oi", 1289 : &rstan::stan_fit::param_fnames_oi) 1291 : .method( 1292 : "param_dims", 1293 : &rstan::stan_fit::param_dims) 1294 : .method("param_dims_oi", 1295 : &rstan::stan_fit::param_dims_oi) 1297 : .method("update_param_oi", 1298 : &rstan::stan_fit::update_param_oi) 1300 : .method("param_oi_tidx", 1301 : &rstan::stan_fit::param_oi_tidx) 1303 : .method("grad_log_prob", 1304 : &rstan::stan_fit::grad_log_prob) 1306 : .method("log_prob", 1307 : &rstan::stan_fit::log_prob) 1308 : .method("unconstrain_pars", 1309 : &rstan::stan_fit::unconstrain_pars) 1311 : .method("constrain_pars", 1312 : &rstan::stan_fit::constrain_pars) 1314 : .method( 1315 : "num_pars_unconstrained", 1316 : &rstan::stan_fit::num_pars_unconstrained) 1318 : .method( 1319 : "unconstrained_param_names", 1320 : &rstan::stan_fit< 1321 : stan_model, boost::random::ecuyer1988>::unconstrained_param_names) 1322 : .method( 1323 : "constrained_param_names", 1324 : &rstan::stan_fit::constrained_param_names) 1326 : .method("standalone_gqs", 1327 : &rstan::stan_fit::standalone_gqs); 1329 : } 1330 : 1331 : 1332 : // declarations 1333 : extern "C" { 1334 : SEXP file1f1d43c5f518c( ) ; 1335 : } 1336 : 1337 : // definition 1338 : SEXP file1f1d43c5f518c() { 1339 : return Rcpp::wrap("anon_model"); 1340 : } Error in file(filename, "r", encoding = encoding) : cannot open the connection Calls: local ... eval.parent -> eval -> eval -> eval -> eval -> source -> file In addition: Warning message: In file(filename, "r", encoding = encoding) : cannot open file 'startup.Rs': No such file or directory Execution halted ERROR(s) during compilation: source code errors or compiler configuration errors! Program source: 1: 2: // includes from the plugin 3: // [[Rcpp::plugins(cpp14)]] 4: 5: 6: // user includes 7: #include 8: using namespace Rcpp; 9: #ifndef MODELS_HPP 10: #define MODELS_HPP 11: #define STAN__SERVICES__COMMAND_HPP 12: #include 13: #ifndef USE_STANC3 14: #define USE_STANC3 15: #endif 16: // Code generated by stanc v2.32.2 17: #include 18: namespace model1f1d41f703a3e__namespace { 19: using stan::model::model_base_crtp; 20: using namespace stan::math; 21: stan::math::profile_map profiles__; 22: static constexpr std::array locations_array__ = 23: {" (found before start of program)", 24: " (in 'string', line 33, column 0 to column 24)", 25: " (in 'string', line 35, column 0 to column 36)", 26: " (in 'string', line 37, column 0 to column 32)", 27: " (in 'string', line 39, column 0 to column 26)", 28: " (in 'string', line 41, column 0 to column 29)", 29: " (in 'string', line 45, column 0 to column 20)", 30: " (in 'string', line 76, column 0 to column 22)", 31: " (in 'string', line 77, column 0 to column 34)", 32: " (in 'string', line 78, column 0 to column 24)", 33: " (in 'string', line 79, column 0 to column 17)", 34: " (in 'string', line 80, column 0 to column 21)", 35: " (in 'string', line 81, column 0 to column 30)", 36: " (in 'string', line 46, column 0 to column 36)", 37: " (in 'string', line 82, column 0 to column 18)", 38: " (in 'string', line 84, column 0 to column 29)", 39: " (in 'string', line 83, column 22 to line 85, column 1)", 40: " (in 'string', line 83, column 0 to line 85, column 1)", 41: " (in 'string', line 87, column 0 to column 12)", 42: " (in 'string', line 89, column 0 to column 51)", 43: " (in 'string', line 88, column 22 to line 90, column 1)", 44: " (in 'string', line 88, column 0 to line 90, column 1)", 45: " (in 'string', line 92, column 0 to column 50)", 46: " (in 'string', line 93, column 0 to column 63)", 47: " (in 'string', line 91, column 20 to line 94, column 1)", 48: " (in 'string', line 91, column 0 to line 94, column 1)", 49: " (in 'string', line 50, column 0 to column 34)", 50: " (in 'string', line 52, column 0 to column 92)", 51: " (in 'string', line 54, column 0 to column 23)", 52: " (in 'string', line 56, column 0 to column 29)", 53: " (in 'string', line 58, column 0 to column 40)", 54: " (in 'string', line 60, column 0 to column 54)", 55: " (in 'string', line 59, column 20 to line 61, column 1)", 56: " (in 'string', line 59, column 0 to line 61, column 1)", 57: " (in 'string', line 63, column 0 to column 33)", 58: " (in 'string', line 66, column 7 to column 19)", 59: " (in 'string', line 66, column 0 to column 33)", 60: " (in 'string', line 67, column 7 to column 19)", 61: " (in 'string', line 67, column 0 to column 36)", 62: " (in 'string', line 68, column 0 to column 42)", 63: " (in 'string', line 69, column 0 to column 49)", 64: " (in 'string', line 70, column 0 to line 72, column 16)", 65: " (in 'string', line 64, column 0 to line 73, column 1)", 66: " (in 'string', line 17, column 0 to column 23)", 67: " (in 'string', line 18, column 0 to column 15)", 68: " (in 'string', line 19, column 0 to column 18)", 69: " (in 'string', line 20, column 0 to column 22)", 70: " (in 'string', line 21, column 0 to column 23)", 71: " (in 'string', line 22, column 7 to column 16)", 72: " (in 'string', line 22, column 0 to column 23)", 73: " (in 'string', line 23, column 7 to column 16)", 74: " (in 'string', line 23, column 18 to column 27)", 75: " (in 'string', line 23, column 0 to column 31)", 76: " (in 'string', line 24, column 20 to column 21)", 77: " (in 'string', line 24, column 23 to column 31)", 78: " (in 'string', line 24, column 0 to column 33)", 79: " (in 'string', line 25, column 0 to column 15)", 80: " (in 'string', line 26, column 0 to column 26)", 81: " (in 'string', line 27, column 7 to column 19)", 82: " (in 'string', line 27, column 0 to column 29)", 83: " (in 'string', line 28, column 7 to column 19)", 84: " (in 'string', line 28, column 21 to column 30)", 85: " (in 'string', line 28, column 0 to column 40)", 86: " (in 'string', line 29, column 21 to column 33)", 87: " (in 'string', line 29, column 0 to column 35)", 88: " (in 'string', line 33, column 7 to column 16)", 89: " (in 'string', line 35, column 16 to column 24)", 90: " (in 'string', line 37, column 16 to column 24)", 91: " (in 'string', line 39, column 7 to column 8)", 92: " (in 'string', line 39, column 10 to column 18)", 93: " (in 'string', line 41, column 16 to column 20)", 94: " (in 'string', line 45, column 7 to column 16)", 95: " (in 'string', line 76, column 7 to column 16)", 96: " (in 'string', line 77, column 7 to column 8)", 97: " (in 'string', line 77, column 10 to column 18)", 98: " (in 'string', line 78, column 7 to column 8)", 99: " (in 'string', line 78, column 10 to column 18)", 100: " (in 'string', line 79, column 7 to column 11)", 101: " (in 'string', line 80, column 7 to column 15)", 102: " (in 'string', line 81, column 6 to column 7)", 103: " (in 'string', line 81, column 9 to column 17)", 104: " (in 'string', line 4, column 0 to column 16)", 105: " (in 'string', line 5, column 7 to column 12)", 106: " (in 'string', line 5, column 0 to column 16)", 107: " (in 'string', line 6, column 0 to column 12)", 108: " (in 'string', line 9, column 0 to column 14)", 109: " (in 'string', line 10, column 0 to column 9)", 110: " (in 'string', line 8, column 15 to line 11, column 1)", 111: " (in 'string', line 8, column 0 to line 11, column 1)", 112: " (in 'string', line 7, column 15 to line 12, column 1)", 113: " (in 'string', line 7, column 0 to line 12, column 1)", 114: " (in 'string', line 13, column 0 to column 9)", 115: " (in 'string', line 3, column 33 to line 14, column 1)"}; 116: template , 118: stan::is_vt_not_complex>* = nullptr> 119: Eigen::Matrix>,-1,1> 120: rep_each(const T0__& x_arg__, const int& K, std::ostream* pstream__); 121: template , 123: stan::is_vt_not_complex>*> 124: Eigen::Matrix>,-1,1> 125: rep_each(const T0__& x_arg__, const int& K, std::ostream* pstream__) { 126: using local_scalar_t__ = stan::promote_args_t>; 127: int current_statement__ = 0; 128: const auto& x = stan::math::to_ref(x_arg__); 129: static constexpr bool propto__ = true; 130: // suppress unused var warning 131: (void) propto__; 132: local_scalar_t__ DUMMY_VAR__(std::numeric_limits::quiet_NaN()); 133: // suppress unused var warning 134: (void) DUMMY_VAR__; 135: try { 136: int N = std::numeric_limits::min(); 137: current_statement__ = 81; 138: N = stan::math::rows(x); 139: current_statement__ = 82; 140: stan::math::validate_non_negative_index("y", "N * K", (N * K)); 141: Eigen::Matrix y = 142: Eigen::Matrix::Constant((N * K), DUMMY_VAR__); 143: int pos = std::numeric_limits::min(); 144: current_statement__ = 84; 145: pos = 1; 146: current_statement__ = 90; 147: for (int n = 1; n <= N; ++n) { 148: current_statement__ = 88; 149: for (int k = 1; k <= K; ++k) { 150: current_statement__ = 85; 151: stan::model::assign(y, 152: stan::model::rvalue(x, "x", stan::model::index_uni(n)), 153: "assigning variable y", stan::model::index_uni(pos)); 154: current_statement__ = 86; 155: pos = (pos + 1); 156: } 157: } 158: current_statement__ = 91; 159: return y; 160: } catch (const std::exception& e) { 161: stan::lang::rethrow_located(e, locations_array__[current_statement__]); 162: } 163: } 164: class model1f1d41f703a3e_ final : public model_base_crtp { 165: private: 166: int total_obs; 167: int n; 168: int n_sp; 169: int n_series; 170: int num_basis; 171: Eigen::Matrix zero_data__; 172: Eigen::Matrix X_data__; 173: std::vector> ytimes; 174: Eigen::Matrix S1_data__; 175: int n_nonmissing; 176: Eigen::Matrix flat_ys_data__; 177: Eigen::Matrix flat_xs_data__; 178: std::vector obs_ind; 179: Eigen::Map> zero{nullptr, 0}; 180: Eigen::Map> X{nullptr, 0, 0}; 181: Eigen::Map> S1{nullptr, 0, 0}; 182: Eigen::Map> flat_ys{nullptr, 0}; 183: Eigen::Map> flat_xs{nullptr, 0, 0}; 184: public: 185: ~model1f1d41f703a3e_() {} 186: model1f1d41f703a3e_(stan::io::var_context& context__, unsigned int 187: random_seed__ = 0, std::ostream* pstream__ = nullptr) 188: : model_base_crtp(0) { 189: int current_statement__ = 0; 190: using local_scalar_t__ = double; 191: boost::ecuyer1988 base_rng__ = 192: stan::services::util::create_rng(random_seed__, 0); 193: // suppress unused var warning 194: (void) base_rng__; 195: static constexpr const char* function__ = 196: "model1f1d41f703a3e__namespace::model1f1d41f703a3e_"; 197: // suppress unused var warning 198: (void) function__; 199: local_scalar_t__ DUMMY_VAR__(std::numeric_limits::quiet_NaN()); 200: // suppress unused var warning 201: (void) DUMMY_VAR__; 202: try { 203: int pos__ = std::numeric_limits::min(); 204: pos__ = 1; 205: current_statement__ = 43; 206: context__.validate_dims("data initialization", "total_obs", "int", 207: std::vector{}); 208: total_obs = std::numeric_limits::min(); 209: current_statement__ = 43; 210: total_obs = context__.vals_i("total_obs")[(1 - 1)]; 211: current_statement__ = 43; 212: stan::math::check_greater_or_equal(function__, "total_obs", total_obs, 213: 0); 214: current_statement__ = 44; 215: context__.validate_dims("data initialization", "n", "int", 216: std::vector{}); 217: n = std::numeric_limits::min(); 218: current_statement__ = 44; 219: n = context__.vals_i("n")[(1 - 1)]; 220: current_statement__ = 44; 221: stan::math::check_greater_or_equal(function__, "n", n, 0); 222: current_statement__ = 45; 223: context__.validate_dims("data initialization", "n_sp", "int", 224: std::vector{}); 225: n_sp = std::numeric_limits::min(); 226: current_statement__ = 45; 227: n_sp = context__.vals_i("n_sp")[(1 - 1)]; 228: current_statement__ = 45; 229: stan::math::check_greater_or_equal(function__, "n_sp", n_sp, 0); 230: current_statement__ = 46; 231: context__.validate_dims("data initialization", "n_series", "int", 232: std::vector{}); 233: n_series = std::numeric_limits::min(); 234: current_statement__ = 46; 235: n_series = context__.vals_i("n_series")[(1 - 1)]; 236: current_statement__ = 46; 237: stan::math::check_greater_or_equal(function__, "n_series", n_series, 0); 238: current_statement__ = 47; 239: context__.validate_dims("data initialization", "num_basis", "int", 240: std::vector{}); 241: num_basis = std::numeric_limits::min(); 242: current_statement__ = 47; 243: num_basis = context__.vals_i("num_basis")[(1 - 1)]; 244: current_statement__ = 47; 245: stan::math::check_greater_or_equal(function__, "num_basis", num_basis, 246: 0); 247: current_statement__ = 48; 248: stan::math::validate_non_negative_index("zero", "num_basis", num_basis); 249: current_statement__ = 49; 250: context__.validate_dims("data initialization", "zero", "double", 251: std::vector{static_cast(num_basis)}); 252: zero_data__ = Eigen::Matrix::Constant(num_basis, 253: std::numeric_limits::quiet_NaN()); 254: new (&zero) Eigen::Map>(zero_data__.data(), 255: num_basis); 256: { 257: std::vector zero_flat__; 258: current_statement__ = 49; 259: zero_flat__ = context__.vals_r("zero"); 260: current_statement__ = 49; 261: pos__ = 1; 262: current_statement__ = 49; 263: for (int sym1__ = 1; sym1__ <= num_basis; ++sym1__) { 264: current_statement__ = 49; 265: stan::model::assign(zero, zero_flat__[(pos__ - 1)], 266: "assigning variable zero", stan::model::index_uni(sym1__)); 267: current_statement__ = 49; 268: pos__ = (pos__ + 1); 269: } 270: } 271: current_statement__ = 50; 272: stan::math::validate_non_negative_index("X", "total_obs", total_obs); 273: current_statement__ = 51; 274: stan::math::validate_non_negative_index("X", "num_basis", num_basis); 275: current_statement__ = 52; 276: context__.validate_dims("data initialization", "X", "double", 277: std::vector{static_cast(total_obs), 278: static_cast(num_basis)}); 279: X_data__ = Eigen::Matrix::Constant(total_obs, num_basis, 280: std::numeric_limits::quiet_NaN()); 281: new (&X) Eigen::Map>(X_data__.data(), 282: total_obs, num_basis); 283: { 284: std::vector X_flat__; 285: current_statement__ = 52; 286: X_flat__ = context__.vals_r("X"); 287: current_statement__ = 52; 288: pos__ = 1; 289: current_statement__ = 52; 290: for (int sym1__ = 1; sym1__ <= num_basis; ++sym1__) { 291: current_statement__ = 52; 292: for (int sym2__ = 1; sym2__ <= total_obs; ++sym2__) { 293: current_statement__ = 52; 294: stan::model::assign(X, X_flat__[(pos__ - 1)], 295: "assigning variable X", stan::model::index_uni(sym2__), 296: stan::model::index_uni(sym1__)); 297: current_statement__ = 52; 298: pos__ = (pos__ + 1); 299: } 300: } 301: } 302: current_statement__ = 53; 303: stan::math::validate_non_negative_index("ytimes", "n", n); 304: current_statement__ = 54; 305: stan::math::validate_non_negative_index("ytimes", "n_series", n_series); 306: current_statement__ = 55; 307: context__.validate_dims("data initialization", "ytimes", "int", 308: std::vector{static_cast(n), 309: static_cast(n_series)}); 310: ytimes = std::vector>(n, 311: std::vector(n_series, std::numeric_limits::min())); 312: { 313: std::vector ytimes_flat__; 314: current_statement__ = 55; 315: ytimes_flat__ = context__.vals_i("ytimes"); 316: current_statement__ = 55; 317: pos__ = 1; 318: current_statement__ = 55; 319: for (int sym1__ = 1; sym1__ <= n_series; ++sym1__) { 320: current_statement__ = 55; 321: for (int sym2__ = 1; sym2__ <= n; ++sym2__) { 322: current_statement__ = 55; 323: stan::model::assign(ytimes, ytimes_flat__[(pos__ - 1)], 324: "assigning variable ytimes", stan::model::index_uni(sym2__), 325: stan::model::index_uni(sym1__)); 326: current_statement__ = 55; 327: pos__ = (pos__ + 1); 328: } 329: } 330: } 331: current_statement__ = 55; 332: stan::math::check_greater_or_equal(function__, "ytimes", ytimes, 0); 333: current_statement__ = 56; 334: context__.validate_dims("data initialization", "S1", "double", 335: std::vector{static_cast(4), static_cast(8)}); 336: S1_data__ = Eigen::Matrix::Constant(4, 8, 337: std::numeric_limits::quiet_NaN()); 338: new (&S1) Eigen::Map>(S1_data__.data(), 4, 339: 8); 340: { 341: std::vector S1_flat__; 342: current_statement__ = 56; 343: S1_flat__ = context__.vals_r("S1"); 344: current_statement__ = 56; 345: pos__ = 1; 346: current_statement__ = 56; 347: for (int sym1__ = 1; sym1__ <= 8; ++sym1__) { 348: current_statement__ = 56; 349: for (int sym2__ = 1; sym2__ <= 4; ++sym2__) { 350: current_statement__ = 56; 351: stan::model::assign(S1, S1_flat__[(pos__ - 1)], 352: "assigning variable S1", stan::model::index_uni(sym2__), 353: stan::model::index_uni(sym1__)); 354: current_statement__ = 56; 355: pos__ = (pos__ + 1); 356: } 357: } 358: } 359: current_statement__ = 57; 360: context__.validate_dims("data initialization", "n_nonmissing", "int", 361: std::vector{}); 362: n_nonmissing = std::numeric_limits::min(); 363: current_statement__ = 57; 364: n_nonmissing = context__.vals_i("n_nonmissing")[(1 - 1)]; 365: current_statement__ = 57; 366: stan::math::check_greater_or_equal(function__, "n_nonmissing", 367: n_nonmissing, 0); 368: current_statement__ = 58; 369: stan::math::validate_non_negative_index("flat_ys", "n_nonmissing", 370: n_nonmissing); 371: current_statement__ = 59; 372: context__.validate_dims("data initialization", "flat_ys", "double", 373: std::vector{static_cast(n_nonmissing)}); 374: flat_ys_data__ = Eigen::Matrix::Constant(n_nonmissing, 375: std::numeric_limits::quiet_NaN()); 376: new (&flat_ys) 377: Eigen::Map>(flat_ys_data__.data(), 378: n_nonmissing); 379: { 380: std::vector flat_ys_flat__; 381: current_statement__ = 59; 382: flat_ys_flat__ = context__.vals_r("flat_ys"); 383: current_statement__ = 59; 384: pos__ = 1; 385: current_statement__ = 59; 386: for (int sym1__ = 1; sym1__ <= n_nonmissing; ++sym1__) { 387: current_statement__ = 59; 388: stan::model::assign(flat_ys, flat_ys_flat__[(pos__ - 1)], 389: "assigning variable flat_ys", stan::model::index_uni(sym1__)); 390: current_statement__ = 59; 391: pos__ = (pos__ + 1); 392: } 393: } 394: current_statement__ = 60; 395: stan::math::validate_non_negative_index("flat_xs", "n_nonmissing", 396: n_nonmissing); 397: current_statement__ = 61; 398: stan::math::validate_non_negative_index("flat_xs", "num_basis", 399: num_basis); 400: current_statement__ = 62; 401: context__.validate_dims("data initialization", "flat_xs", "double", 402: std::vector{static_cast(n_nonmissing), 403: static_cast(num_basis)}); 404: flat_xs_data__ = Eigen::Matrix::Constant(n_nonmissing, 405: num_basis, std::numeric_limits::quiet_NaN()); 406: new (&flat_xs) 407: Eigen::Map>(flat_xs_data__.data(), 408: n_nonmissing, num_basis); 409: { 410: std::vector flat_xs_flat__; 411: current_statement__ = 62; 412: flat_xs_flat__ = context__.vals_r("flat_xs"); 413: current_statement__ = 62; 414: pos__ = 1; 415: current_statement__ = 62; 416: for (int sym1__ = 1; sym1__ <= num_basis; ++sym1__) { 417: current_statement__ = 62; 418: for (int sym2__ = 1; sym2__ <= n_nonmissing; ++sym2__) { 419: current_statement__ = 62; 420: stan::model::assign(flat_xs, flat_xs_flat__[(pos__ - 1)], 421: "assigning variable flat_xs", stan::model::index_uni(sym2__), 422: stan::model::index_uni(sym1__)); 423: current_statement__ = 62; 424: pos__ = (pos__ + 1); 425: } 426: } 427: } 428: current_statement__ = 63; 429: stan::math::validate_non_negative_index("obs_ind", "n_nonmissing", 430: n_nonmissing); 431: current_statement__ = 64; 432: context__.validate_dims("data initialization", "obs_ind", "int", 433: std::vector{static_cast(n_nonmissing)}); 434: obs_ind = std::vector(n_nonmissing, 435: std::numeric_limits::min()); 436: current_statement__ = 64; 437: obs_ind = context__.vals_i("obs_ind"); 438: current_statement__ = 64; 439: stan::math::check_greater_or_equal(function__, "obs_ind", obs_ind, 0); 440: current_statement__ = 65; 441: stan::math::validate_non_negative_index("b_raw", "num_basis", num_basis); 442: current_statement__ = 66; 443: stan::math::validate_non_negative_index("sigma_obs", "n_series", 444: n_series); 445: current_statement__ = 67; 446: stan::math::validate_non_negative_index("sigma", "n_series", n_series); 447: current_statement__ = 68; 448: stan::math::validate_non_negative_index("trend", "n", n); 449: current_statement__ = 69; 450: stan::math::validate_non_negative_index("trend", "n_series", n_series); 451: current_statement__ = 70; 452: stan::math::validate_non_negative_index("lambda", "n_sp", n_sp); 453: current_statement__ = 71; 454: stan::math::validate_non_negative_index("b", "num_basis", num_basis); 455: current_statement__ = 72; 456: stan::math::validate_non_negative_index("eta", "total_obs", total_obs); 457: current_statement__ = 73; 458: stan::math::validate_non_negative_index("sigma_obs_vec", "n", n); 459: current_statement__ = 74; 460: stan::math::validate_non_negative_index("sigma_obs_vec", "n_series", 461: n_series); 462: current_statement__ = 75; 463: stan::math::validate_non_negative_index("mus", "n", n); 464: current_statement__ = 76; 465: stan::math::validate_non_negative_index("mus", "n_series", n_series); 466: current_statement__ = 77; 467: stan::math::validate_non_negative_index("rho", "n_sp", n_sp); 468: current_statement__ = 78; 469: stan::math::validate_non_negative_index("tau", "n_series", n_series); 470: current_statement__ = 79; 471: stan::math::validate_non_negative_index("ypred", "n", n); 472: current_statement__ = 80; 473: stan::math::validate_non_negative_index("ypred", "n_series", n_series); 474: } catch (const std::exception& e) { 475: stan::lang::rethrow_located(e, locations_array__[current_statement__]); 476: } 477: num_params_r__ = num_basis + n_series + n_series + (n * n_series) + n_sp; 478: } 479: inline std::string model_name() const final { 480: return "model1f1d41f703a3e_"; 481: } 482: inline std::vector model_compile_info() const noexcept { 483: return std::vector{"stanc_version = stanc3 v2.32.2", 484: "stancflags = --"}; 485: } 486: template * = nullptr, 488: stan::require_vector_like_vt* = nullptr> 489: inline stan::scalar_type_t 490: log_prob_impl(VecR& params_r__, VecI& params_i__, std::ostream* 491: pstream__ = nullptr) const { 492: using T__ = stan::scalar_type_t; 493: using local_scalar_t__ = T__; 494: T__ lp__(0.0); 495: stan::math::accumulator lp_accum__; 496: stan::io::deserializer in__(params_r__, params_i__); 497: int current_statement__ = 0; 498: local_scalar_t__ DUMMY_VAR__(std::numeric_limits::quiet_NaN()); 499: // suppress unused var warning 500: (void) DUMMY_VAR__; 501: static constexpr const char* function__ = 502: "model1f1d41f703a3e__namespace::log_prob"; 503: // suppress unused var warning 504: (void) function__; 505: try { 506: Eigen::Matrix b_raw = 507: Eigen::Matrix::Constant(num_basis, 508: DUMMY_VAR__); 509: current_statement__ = 1; 510: b_raw = in__.template read< 511: Eigen::Matrix>(num_basis); 512: Eigen::Matrix sigma_obs = 513: Eigen::Matrix::Constant(n_series, DUMMY_VAR__); 514: current_statement__ = 2; 515: sigma_obs = in__.template read_constrain_lb< 516: Eigen::Matrix, jacobian__>(0, 517: lp__, n_series); 518: Eigen::Matrix sigma = 519: Eigen::Matrix::Constant(n_series, DUMMY_VAR__); 520: current_statement__ = 3; 521: sigma = in__.template read_constrain_lb< 522: Eigen::Matrix, jacobian__>(0, lp__, 523: n_series); 524: Eigen::Matrix trend = 525: Eigen::Matrix::Constant(n, n_series, 526: DUMMY_VAR__); 527: current_statement__ = 4; 528: trend = in__.template read>(n, 529: n_series); 530: Eigen::Matrix lambda = 531: Eigen::Matrix::Constant(n_sp, DUMMY_VAR__); 532: current_statement__ = 5; 533: lambda = in__.template read_constrain_lb< 534: Eigen::Matrix, jacobian__>(0, lp__, 535: n_sp); 536: Eigen::Matrix b = 537: Eigen::Matrix::Constant(num_basis, 538: DUMMY_VAR__); 539: current_statement__ = 13; 540: stan::model::assign(b, 541: stan::model::rvalue(b_raw, "b_raw", 542: stan::model::index_min_max(1, num_basis)), "assigning variable b", 543: stan::model::index_min_max(1, num_basis)); 544: { 545: current_statement__ = 26; 546: lp_accum__.add(stan::math::student_t_lpdf( 547: stan::model::rvalue(b_raw, "b_raw", 548: stan::model::index_uni(1)), 3, 0.4, 2.5)); 549: current_statement__ = 27; 550: lp_accum__.add(stan::math::multi_normal_prec_lpdf( 551: stan::model::rvalue(b_raw, "b_raw", 552: stan::model::index_min_max(2, 5)), 553: stan::model::rvalue(zero, "zero", 554: stan::model::index_min_max(2, 5)), 555: stan::math::add( 556: stan::math::multiply( 557: stan::model::rvalue(S1, "S1", 558: stan::model::index_min_max(1, 4), 559: stan::model::index_min_max(1, 4)), 560: stan::model::rvalue(lambda, "lambda", 561: stan::model::index_uni(1))), 562: stan::math::multiply( 563: stan::model::rvalue(S1, "S1", 564: stan::model::index_min_max(1, 4), 565: stan::model::index_min_max(5, 8)), 566: stan::model::rvalue(lambda, "lambda", 567: stan::model::index_uni(2)))))); 568: current_statement__ = 28; 569: lp_accum__.add(stan::math::normal_lpdf(lambda, 5, 30)); 570: current_statement__ = 29; 571: lp_accum__.add(stan::math::student_t_lpdf(sigma, 3, 0, 2.5)); 572: current_statement__ = 30; 573: lp_accum__.add(stan::math::normal_lpdf( 574: stan::model::rvalue(trend, "trend", 575: stan::model::index_uni(1), 576: stan::model::index_min_max(1, n_series)), 0, sigma)); 577: current_statement__ = 33; 578: for (int s = 1; s <= n_series; ++s) { 579: current_statement__ = 31; 580: lp_accum__.add(stan::math::normal_lpdf( 581: stan::model::rvalue(trend, "trend", 582: stan::model::index_min_max(2, n), 583: stan::model::index_uni(s)), 584: stan::model::rvalue(trend, "trend", 585: stan::model::index_min_max(1, (n - 1)), 586: stan::model::index_uni(s)), 587: stan::model::rvalue(sigma, "sigma", 588: stan::model::index_uni(s)))); 589: } 590: current_statement__ = 34; 591: lp_accum__.add(stan::math::student_t_lpdf(sigma_obs, 3, 0, 592: 2.5)); 593: { 594: current_statement__ = 35; 595: stan::math::validate_non_negative_index("flat_trends", 596: "n_nonmissing", n_nonmissing); 597: Eigen::Matrix flat_trends = 598: Eigen::Matrix::Constant(n_nonmissing, 599: DUMMY_VAR__); 600: current_statement__ = 37; 601: stan::math::validate_non_negative_index("flat_sigma_obs", 602: "n_nonmissing", n_nonmissing); 603: Eigen::Matrix flat_sigma_obs = 604: Eigen::Matrix::Constant(n_nonmissing, 605: DUMMY_VAR__); 606: current_statement__ = 39; 607: stan::model::assign(flat_trends, 608: stan::model::rvalue(stan::math::to_vector(trend), 609: "to_vector(trend)", stan::model::index_multi(obs_ind)), 610: "assigning variable flat_trends"); 611: current_statement__ = 40; 612: stan::model::assign(flat_sigma_obs, 613: stan::model::rvalue(rep_each(sigma_obs, n, pstream__), 614: "rep_each(sigma_obs,\nn)", stan::model::index_multi(obs_ind)), 615: "assigning variable flat_sigma_obs"); 616: current_statement__ = 41; 617: lp_accum__.add(stan::math::normal_id_glm_lpdf(flat_ys, 618: stan::math::append_col(flat_xs, flat_trends), 0.0, 619: stan::math::append_row(b, 1.0), flat_sigma_obs)); 620: } 621: } 622: } catch (const std::exception& e) { 623: stan::lang::rethrow_located(e, locations_array__[current_statement__]); 624: } 625: lp_accum__.add(lp__); 626: return lp_accum__.sum(); 627: } 628: template * = nullptr, stan::require_vector_like_vt* = nullptr, stan::require_vector_vt* = nullptr> 633: inline void 634: write_array_impl(RNG& base_rng__, VecR& params_r__, VecI& params_i__, 635: VecVar& vars__, const bool 636: emit_transformed_parameters__ = true, const bool 637: emit_generated_quantities__ = true, std::ostream* 638: pstream__ = nullptr) const { 639: using local_scalar_t__ = double; 640: stan::io::deserializer in__(params_r__, params_i__); 641: stan::io::serializer out__(vars__); 642: static constexpr bool propto__ = true; 643: // suppress unused var warning 644: (void) propto__; 645: double lp__ = 0.0; 646: // suppress unused var warning 647: (void) lp__; 648: int current_statement__ = 0; 649: stan::math::accumulator lp_accum__; 650: local_scalar_t__ DUMMY_VAR__(std::numeric_limits::quiet_NaN()); 651: // suppress unused var warning 652: (void) DUMMY_VAR__; 653: constexpr bool jacobian__ = false; 654: static constexpr const char* function__ = 655: "model1f1d41f703a3e__namespace::write_array"; 656: // suppress unused var warning 657: (void) function__; 658: try { 659: Eigen::Matrix b_raw = 660: Eigen::Matrix::Constant(num_basis, 661: std::numeric_limits::quiet_NaN()); 662: current_statement__ = 1; 663: b_raw = in__.template read< 664: Eigen::Matrix>(num_basis); 665: Eigen::Matrix sigma_obs = 666: Eigen::Matrix::Constant(n_series, 667: std::numeric_limits::quiet_NaN()); 668: current_statement__ = 2; 669: sigma_obs = in__.template read_constrain_lb< 670: Eigen::Matrix, jacobian__>(0, 671: lp__, n_series); 672: Eigen::Matrix sigma = 673: Eigen::Matrix::Constant(n_series, 674: std::numeric_limits::quiet_NaN()); 675: current_statement__ = 3; 676: sigma = in__.template read_constrain_lb< 677: Eigen::Matrix, jacobian__>(0, lp__, 678: n_series); 679: Eigen::Matrix trend = 680: Eigen::Matrix::Constant(n, n_series, 681: std::numeric_limits::quiet_NaN()); 682: current_statement__ = 4; 683: trend = in__.template read>(n, 684: n_series); 685: Eigen::Matrix lambda = 686: Eigen::Matrix::Constant(n_sp, 687: std::numeric_limits::quiet_NaN()); 688: current_statement__ = 5; 689: lambda = in__.template read_constrain_lb< 690: Eigen::Matrix, jacobian__>(0, lp__, 691: n_sp); 692: Eigen::Matrix b = 693: Eigen::Matrix::Constant(num_basis, 694: std::numeric_limits::quiet_NaN()); 695: out__.write(b_raw); 696: out__.write(sigma_obs); 697: out__.write(sigma); 698: out__.write(trend); 699: out__.write(lambda); 700: if (stan::math::logical_negation( 701: (stan::math::primitive_value(emit_transformed_parameters__) || 702: stan::math::primitive_value(emit_generated_quantities__)))) { 703: return ; 704: } 705: current_statement__ = 13; 706: stan::model::assign(b, 707: stan::model::rvalue(b_raw, "b_raw", 708: stan::model::index_min_max(1, num_basis)), "assigning variable b", 709: stan::model::index_min_max(1, num_basis)); 710: if (emit_transformed_parameters__) { 711: out__.write(b); 712: } 713: if (stan::math::logical_negation(emit_generated_quantities__)) { 714: return ; 715: } 716: Eigen::Matrix eta = 717: Eigen::Matrix::Constant(total_obs, 718: std::numeric_limits::quiet_NaN()); 719: Eigen::Matrix sigma_obs_vec = 720: Eigen::Matrix::Constant(n, n_series, 721: std::numeric_limits::quiet_NaN()); 722: Eigen::Matrix mus = 723: Eigen::Matrix::Constant(n, n_series, 724: std::numeric_limits::quiet_NaN()); 725: Eigen::Matrix rho = 726: Eigen::Matrix::Constant(n_sp, 727: std::numeric_limits::quiet_NaN()); 728: Eigen::Matrix tau = 729: Eigen::Matrix::Constant(n_series, 730: std::numeric_limits::quiet_NaN()); 731: std::vector> ypred = 732: std::vector>(n, 733: std::vector(n_series, 734: std::numeric_limits::quiet_NaN())); 735: current_statement__ = 14; 736: stan::model::assign(rho, stan::math::log(lambda), 737: "assigning variable rho"); 738: current_statement__ = 17; 739: for (int s = 1; s <= n_series; ++s) { 740: current_statement__ = 15; 741: stan::model::assign(tau, 742: stan::math::pow( 743: stan::model::rvalue(sigma, "sigma", stan::model::index_uni(s)), 744: -2.0), "assigning variable tau", stan::model::index_uni(s)); 745: } 746: current_statement__ = 18; 747: stan::model::assign(eta, stan::math::multiply(X, b), 748: "assigning variable eta"); 749: current_statement__ = 21; 750: for (int s = 1; s <= n_series; ++s) { 751: current_statement__ = 19; 752: stan::model::assign(sigma_obs_vec, 753: stan::math::rep_vector( 754: stan::model::rvalue(sigma_obs, "sigma_obs", 755: stan::model::index_uni(s)), n), 756: "assigning variable sigma_obs_vec", 757: stan::model::index_min_max(1, n), stan::model::index_uni(s)); 758: } 759: current_statement__ = 25; 760: for (int s = 1; s <= n_series; ++s) { 761: current_statement__ = 22; 762: stan::model::assign(mus, 763: stan::math::add( 764: stan::model::rvalue(eta, "eta", 765: stan::model::index_multi( 766: stan::model::rvalue(ytimes, "ytimes", 767: stan::model::index_min_max(1, n), stan::model::index_uni(s)))), 768: stan::model::rvalue(trend, "trend", 769: stan::model::index_min_max(1, n), stan::model::index_uni(s))), 770: "assigning variable mus", stan::model::index_min_max(1, n), 771: stan::model::index_uni(s)); 772: current_statement__ = 23; 773: stan::model::assign(ypred, 774: stan::math::normal_rng( 775: stan::model::rvalue(mus, "mus", stan::model::index_min_max(1, n), 776: stan::model::index_uni(s)), 777: stan::model::rvalue(sigma_obs_vec, "sigma_obs_vec", 778: stan::model::index_min_max(1, n), stan::model::index_uni(s)), 779: base_rng__), "assigning variable ypred", 780: stan::model::index_min_max(1, n), stan::model::index_uni(s)); 781: } 782: out__.write(eta); 783: out__.write(sigma_obs_vec); 784: out__.write(mus); 785: out__.write(rho); 786: out__.write(tau); 787: for (int sym1__ = 1; sym1__ <= n_series; ++sym1__) { 788: for (int sym2__ = 1; sym2__ <= n; ++sym2__) { 789: out__.write(ypred[(sym2__ - 1)][(sym1__ - 1)]); 790: } 791: } 792: } catch (const std::exception& e) { 793: stan::lang::rethrow_located(e, locations_array__[current_statement__]); 794: } 795: } 796: template * = nullptr, 798: stan::require_vector_like_vt* = nullptr> 799: inline void 800: unconstrain_array_impl(const VecVar& params_r__, const VecI& params_i__, 801: VecVar& vars__, std::ostream* pstream__ = nullptr) const { 802: using local_scalar_t__ = double; 803: stan::io::deserializer in__(params_r__, params_i__); 804: stan::io::serializer out__(vars__); 805: int current_statement__ = 0; 806: local_scalar_t__ DUMMY_VAR__(std::numeric_limits::quiet_NaN()); 807: // suppress unused var warning 808: (void) DUMMY_VAR__; 809: try { 810: int pos__ = std::numeric_limits::min(); 811: pos__ = 1; 812: Eigen::Matrix b_raw = 813: Eigen::Matrix::Constant(num_basis, 814: DUMMY_VAR__); 815: current_statement__ = 1; 816: stan::model::assign(b_raw, 817: in__.read>(num_basis), 818: "assigning variable b_raw"); 819: out__.write(b_raw); 820: Eigen::Matrix sigma_obs = 821: Eigen::Matrix::Constant(n_series, DUMMY_VAR__); 822: current_statement__ = 2; 823: stan::model::assign(sigma_obs, 824: in__.read>(n_series), 825: "assigning variable sigma_obs"); 826: out__.write_free_lb(0, sigma_obs); 827: Eigen::Matrix sigma = 828: Eigen::Matrix::Constant(n_series, DUMMY_VAR__); 829: current_statement__ = 3; 830: stan::model::assign(sigma, 831: in__.read>(n_series), 832: "assigning variable sigma"); 833: out__.write_free_lb(0, sigma); 834: Eigen::Matrix trend = 835: Eigen::Matrix::Constant(n, n_series, 836: DUMMY_VAR__); 837: current_statement__ = 4; 838: stan::model::assign(trend, 839: in__.read>(n, n_series), 840: "assigning variable trend"); 841: out__.write(trend); 842: Eigen::Matrix lambda = 843: Eigen::Matrix::Constant(n_sp, DUMMY_VAR__); 844: current_statement__ = 5; 845: stan::model::assign(lambda, 846: in__.read>(n_sp), 847: "assigning variable lambda"); 848: out__.write_free_lb(0, lambda); 849: } catch (const std::exception& e) { 850: stan::lang::rethrow_located(e, locations_array__[current_statement__]); 851: } 852: } 853: template * = nullptr> 854: inline void 855: transform_inits_impl(const stan::io::var_context& context__, VecVar& 856: vars__, std::ostream* pstream__ = nullptr) const { 857: using local_scalar_t__ = double; 858: stan::io::serializer out__(vars__); 859: int current_statement__ = 0; 860: local_scalar_t__ DUMMY_VAR__(std::numeric_limits::quiet_NaN()); 861: // suppress unused var warning 862: (void) DUMMY_VAR__; 863: try { 864: current_statement__ = 1; 865: context__.validate_dims("parameter initialization", "b_raw", "double", 866: std::vector{static_cast(num_basis)}); 867: current_statement__ = 2; 868: context__.validate_dims("parameter initialization", "sigma_obs", 869: "double", std::vector{static_cast(n_series)}); 870: current_statement__ = 3; 871: context__.validate_dims("parameter initialization", "sigma", "double", 872: std::vector{static_cast(n_series)}); 873: current_statement__ = 4; 874: context__.validate_dims("parameter initialization", "trend", "double", 875: std::vector{static_cast(n), 876: static_cast(n_series)}); 877: current_statement__ = 5; 878: context__.validate_dims("parameter initialization", "lambda", "double", 879: std::vector{static_cast(n_sp)}); 880: int pos__ = std::numeric_limits::min(); 881: pos__ = 1; 882: Eigen::Matrix b_raw = 883: Eigen::Matrix::Constant(num_basis, 884: DUMMY_VAR__); 885: { 886: std::vector b_raw_flat__; 887: current_statement__ = 1; 888: b_raw_flat__ = context__.vals_r("b_raw"); 889: current_statement__ = 1; 890: pos__ = 1; 891: current_statement__ = 1; 892: for (int sym1__ = 1; sym1__ <= num_basis; ++sym1__) { 893: current_statement__ = 1; 894: stan::model::assign(b_raw, b_raw_flat__[(pos__ - 1)], 895: "assigning variable b_raw", stan::model::index_uni(sym1__)); 896: current_statement__ = 1; 897: pos__ = (pos__ + 1); 898: } 899: } 900: out__.write(b_raw); 901: Eigen::Matrix sigma_obs = 902: Eigen::Matrix::Constant(n_series, DUMMY_VAR__); 903: { 904: std::vector sigma_obs_flat__; 905: current_statement__ = 2; 906: sigma_obs_flat__ = context__.vals_r("sigma_obs"); 907: current_statement__ = 2; 908: pos__ = 1; 909: current_statement__ = 2; 910: for (int sym1__ = 1; sym1__ <= n_series; ++sym1__) { 911: current_statement__ = 2; 912: stan::model::assign(sigma_obs, sigma_obs_flat__[(pos__ - 1)], 913: "assigning variable sigma_obs", stan::model::index_uni(sym1__)); 914: current_statement__ = 2; 915: pos__ = (pos__ + 1); 916: } 917: } 918: out__.write_free_lb(0, sigma_obs); 919: Eigen::Matrix sigma = 920: Eigen::Matrix::Constant(n_series, DUMMY_VAR__); 921: { 922: std::vector sigma_flat__; 923: current_statement__ = 3; 924: sigma_flat__ = context__.vals_r("sigma"); 925: current_statement__ = 3; 926: pos__ = 1; 927: current_statement__ = 3; 928: for (int sym1__ = 1; sym1__ <= n_series; ++sym1__) { 929: current_statement__ = 3; 930: stan::model::assign(sigma, sigma_flat__[(pos__ - 1)], 931: "assigning variable sigma", stan::model::index_uni(sym1__)); 932: current_statement__ = 3; 933: pos__ = (pos__ + 1); 934: } 935: } 936: out__.write_free_lb(0, sigma); 937: Eigen::Matrix trend = 938: Eigen::Matrix::Constant(n, n_series, 939: DUMMY_VAR__); 940: { 941: std::vector trend_flat__; 942: current_statement__ = 4; 943: trend_flat__ = context__.vals_r("trend"); 944: current_statement__ = 4; 945: pos__ = 1; 946: current_statement__ = 4; 947: for (int sym1__ = 1; sym1__ <= n_series; ++sym1__) { 948: current_statement__ = 4; 949: for (int sym2__ = 1; sym2__ <= n; ++sym2__) { 950: current_statement__ = 4; 951: stan::model::assign(trend, trend_flat__[(pos__ - 1)], 952: "assigning variable trend", stan::model::index_uni(sym2__), 953: stan::model::index_uni(sym1__)); 954: current_statement__ = 4; 955: pos__ = (pos__ + 1); 956: } 957: } 958: } 959: out__.write(trend); 960: Eigen::Matrix lambda = 961: Eigen::Matrix::Constant(n_sp, DUMMY_VAR__); 962: { 963: std::vector lambda_flat__; 964: current_statement__ = 5; 965: lambda_flat__ = context__.vals_r("lambda"); 966: current_statement__ = 5; 967: pos__ = 1; 968: current_statement__ = 5; 969: for (int sym1__ = 1; sym1__ <= n_sp; ++sym1__) { 970: current_statement__ = 5; 971: stan::model::assign(lambda, lambda_flat__[(pos__ - 1)], 972: "assigning variable lambda", stan::model::index_uni(sym1__)); 973: current_statement__ = 5; 974: pos__ = (pos__ + 1); 975: } 976: } 977: out__.write_free_lb(0, lambda); 978: } catch (const std::exception& e) { 979: stan::lang::rethrow_located(e, locations_array__[current_statement__]); 980: } 981: } 982: inline void 983: get_param_names(std::vector& names__, const bool 984: emit_transformed_parameters__ = true, const bool 985: emit_generated_quantities__ = true) const { 986: names__ = std::vector{"b_raw", "sigma_obs", "sigma", 987: "trend", "lambda"}; 988: if (emit_transformed_parameters__) { 989: std::vector temp{"b"}; 990: names__.reserve(names__.size() + temp.size()); 991: names__.insert(names__.end(), temp.begin(), temp.end()); 992: } 993: if (emit_generated_quantities__) { 994: std::vector 995: temp{"eta", "sigma_obs_vec", "mus", "rho", "tau", "ypred"}; 996: names__.reserve(names__.size() + temp.size()); 997: names__.insert(names__.end(), temp.begin(), temp.end()); 998: } 999: } 1000: inline void 1001: get_dims(std::vector>& dimss__, const bool 1002: emit_transformed_parameters__ = true, const bool 1003: emit_generated_quantities__ = true) const { 1004: dimss__ = std::vector>{std::vector{static_cast< 1005: size_t>( 1006: num_basis)}, 1007: std::vector{static_cast(n_series)}, 1008: std::vector{static_cast(n_series)}, 1009: std::vector{static_cast(n), 1010: static_cast(n_series)}, 1011: std::vector{static_cast(n_sp)}}; 1012: if (emit_transformed_parameters__) { 1013: std::vector> 1014: temp{std::vector{static_cast(num_basis)}}; 1015: dimss__.reserve(dimss__.size() + temp.size()); 1016: dimss__.insert(dimss__.end(), temp.begin(), temp.end()); 1017: } 1018: if (emit_generated_quantities__) { 1019: std::vector> 1020: temp{std::vector{static_cast(total_obs)}, 1021: std::vector{static_cast(n), 1022: static_cast(n_series)}, 1023: std::vector{static_cast(n), 1024: static_cast(n_series)}, 1025: std::vector{static_cast(n_sp)}, 1026: std::vector{static_cast(n_series)}, 1027: std::vector{static_cast(n), 1028: static_cast(n_series)}}; 1029: dimss__.reserve(dimss__.size() + temp.size()); 1030: dimss__.insert(dimss__.end(), temp.begin(), temp.end()); 1031: } 1032: } 1033: inline void 1034: constrained_param_names(std::vector& param_names__, bool 1035: emit_transformed_parameters__ = true, bool 1036: emit_generated_quantities__ = true) const final { 1037: for (int sym1__ = 1; sym1__ <= num_basis; ++sym1__) { 1038: param_names__.emplace_back(std::string() + "b_raw" + '.' + 1039: std::to_string(sym1__)); 1040: } 1041: for (int sym1__ = 1; sym1__ <= n_series; ++sym1__) { 1042: param_names__.emplace_back(std::string() + "sigma_obs" + '.' + 1043: std::to_string(sym1__)); 1044: } 1045: for (int sym1__ = 1; sym1__ <= n_series; ++sym1__) { 1046: param_names__.emplace_back(std::string() + "sigma" + '.' + 1047: std::to_string(sym1__)); 1048: } 1049: for (int sym1__ = 1; sym1__ <= n_series; ++sym1__) { 1050: for (int sym2__ = 1; sym2__ <= n; ++sym2__) { 1051: param_names__.emplace_back(std::string() + "trend" + '.' + 1052: std::to_string(sym2__) + '.' + std::to_string(sym1__)); 1053: } 1054: } 1055: for (int sym1__ = 1; sym1__ <= n_sp; ++sym1__) { 1056: param_names__.emplace_back(std::string() + "lambda" + '.' + 1057: std::to_string(sym1__)); 1058: } 1059: if (emit_transformed_parameters__) { 1060: for (int sym1__ = 1; sym1__ <= num_basis; ++sym1__) { 1061: param_names__.emplace_back(std::string() + "b" + '.' + 1062: std::to_string(sym1__)); 1063: } 1064: } 1065: if (emit_generated_quantities__) { 1066: for (int sym1__ = 1; sym1__ <= total_obs; ++sym1__) { 1067: param_names__.emplace_back(std::string() + "eta" + '.' + 1068: std::to_string(sym1__)); 1069: } 1070: for (int sym1__ = 1; sym1__ <= n_series; ++sym1__) { 1071: for (int sym2__ = 1; sym2__ <= n; ++sym2__) { 1072: param_names__.emplace_back(std::string() + "sigma_obs_vec" + '.' + 1073: std::to_string(sym2__) + '.' + std::to_string(sym1__)); 1074: } 1075: } 1076: for (int sym1__ = 1; sym1__ <= n_series; ++sym1__) { 1077: for (int sym2__ = 1; sym2__ <= n; ++sym2__) { 1078: param_names__.emplace_back(std::string() + "mus" + '.' + 1079: std::to_string(sym2__) + '.' + std::to_string(sym1__)); 1080: } 1081: } 1082: for (int sym1__ = 1; sym1__ <= n_sp; ++sym1__) { 1083: param_names__.emplace_back(std::string() + "rho" + '.' + 1084: std::to_string(sym1__)); 1085: } 1086: for (int sym1__ = 1; sym1__ <= n_series; ++sym1__) { 1087: param_names__.emplace_back(std::string() + "tau" + '.' + 1088: std::to_string(sym1__)); 1089: } 1090: for (int sym1__ = 1; sym1__ <= n_series; ++sym1__) { 1091: for (int sym2__ = 1; sym2__ <= n; ++sym2__) { 1092: param_names__.emplace_back(std::string() + "ypred" + '.' + 1093: std::to_string(sym2__) + '.' + std::to_string(sym1__)); 1094: } 1095: } 1096: } 1097: } 1098: inline void 1099: unconstrained_param_names(std::vector& param_names__, bool 1100: emit_transformed_parameters__ = true, bool 1101: emit_generated_quantities__ = true) const final { 1102: for (int sym1__ = 1; sym1__ <= num_basis; ++sym1__) { 1103: param_names__.emplace_back(std::string() + "b_raw" + '.' + 1104: std::to_string(sym1__)); 1105: } 1106: for (int sym1__ = 1; sym1__ <= n_series; ++sym1__) { 1107: param_names__.emplace_back(std::string() + "sigma_obs" + '.' + 1108: std::to_string(sym1__)); 1109: } 1110: for (int sym1__ = 1; sym1__ <= n_series; ++sym1__) { 1111: param_names__.emplace_back(std::string() + "sigma" + '.' + 1112: std::to_string(sym1__)); 1113: } 1114: for (int sym1__ = 1; sym1__ <= n_series; ++sym1__) { 1115: for (int sym2__ = 1; sym2__ <= n; ++sym2__) { 1116: param_names__.emplace_back(std::string() + "trend" + '.' + 1117: std::to_string(sym2__) + '.' + std::to_string(sym1__)); 1118: } 1119: } 1120: for (int sym1__ = 1; sym1__ <= n_sp; ++sym1__) { 1121: param_names__.emplace_back(std::string() + "lambda" + '.' + 1122: std::to_string(sym1__)); 1123: } 1124: if (emit_transformed_parameters__) { 1125: for (int sym1__ = 1; sym1__ <= num_basis; ++sym1__) { 1126: param_names__.emplace_back(std::string() + "b" + '.' + 1127: std::to_string(sym1__)); 1128: } 1129: } 1130: if (emit_generated_quantities__) { 1131: for (int sym1__ = 1; sym1__ <= total_obs; ++sym1__) { 1132: param_names__.emplace_back(std::string() + "eta" + '.' + 1133: std::to_string(sym1__)); 1134: } 1135: for (int sym1__ = 1; sym1__ <= n_series; ++sym1__) { 1136: for (int sym2__ = 1; sym2__ <= n; ++sym2__) { 1137: param_names__.emplace_back(std::string() + "sigma_obs_vec" + '.' + 1138: std::to_string(sym2__) + '.' + std::to_string(sym1__)); 1139: } 1140: } 1141: for (int sym1__ = 1; sym1__ <= n_series; ++sym1__) { 1142: for (int sym2__ = 1; sym2__ <= n; ++sym2__) { 1143: param_names__.emplace_back(std::string() + "mus" + '.' + 1144: std::to_string(sym2__) + '.' + std::to_string(sym1__)); 1145: } 1146: } 1147: for (int sym1__ = 1; sym1__ <= n_sp; ++sym1__) { 1148: param_names__.emplace_back(std::string() + "rho" + '.' + 1149: std::to_string(sym1__)); 1150: } 1151: for (int sym1__ = 1; sym1__ <= n_series; ++sym1__) { 1152: param_names__.emplace_back(std::string() + "tau" + '.' + 1153: std::to_string(sym1__)); 1154: } 1155: for (int sym1__ = 1; sym1__ <= n_series; ++sym1__) { 1156: for (int sym2__ = 1; sym2__ <= n; ++sym2__) { 1157: param_names__.emplace_back(std::string() + "ypred" + '.' + 1158: std::to_string(sym2__) + '.' + std::to_string(sym1__)); 1159: } 1160: } 1161: } 1162: } 1163: inline std::string get_constrained_sizedtypes() const { 1164: return std::string("[{\"name\":\"b_raw\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(num_basis) + "},\"block\":\"parameters\"},{\"name\":\"sigma_obs\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(n_series) + "},\"block\":\"parameters\"},{\"name\":\"sigma\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(n_series) + "},\"block\":\"parameters\"},{\"name\":\"trend\",\"type\":{\"name\":\"matrix\",\"rows\":" + std::to_string(n) + ",\"cols\":" + std::to_string(n_series) + "},\"block\":\"parameters\"},{\"name\":\"lambda\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(n_sp) + "},\"block\":\"parameters\"},{\"name\":\"b\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(num_basis) + "},\"block\":\"transformed_parameters\"},{\"name\":\"eta\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(total_obs) + "},\"block\":\"generated_quantities\"},{\"name\":\"sigma_obs_vec\",\"type\":{\"name\":\"matrix\",\"rows\":" + std::to_string(n) + ",\"cols\":" + std::to_string(n_series) + "},\"block\":\"generated_quantities\"},{\"name\":\"mus\",\"type\":{\"name\":\"matrix\",\"rows\":" + std::to_string(n) + ",\"cols\":" + std::to_string(n_series) + "},\"block\":\"generated_quantities\"},{\"name\":\"rho\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(n_sp) + "},\"block\":\"generated_quantities\"},{\"name\":\"tau\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(n_series) + "},\"block\":\"generated_quantities\"},{\"name\":\"ypred\",\"type\":{\"name\":\"array\",\"length\":" + std::to_string(n) + ",\"element_type\":{\"name\":\"array\",\"length\":" + std::to_string(n_series) + ",\"element_type\":{\"name\":\"real\"}}},\"block\":\"generated_quantities\"}]"); 1165: } 1166: inline std::string get_unconstrained_sizedtypes() const { 1167: return std::string("[{\"name\":\"b_raw\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(num_basis) + "},\"block\":\"parameters\"},{\"name\":\"sigma_obs\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(n_series) + "},\"block\":\"parameters\"},{\"name\":\"sigma\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(n_series) + "},\"block\":\"parameters\"},{\"name\":\"trend\",\"type\":{\"name\":\"matrix\",\"rows\":" + std::to_string(n) + ",\"cols\":" + std::to_string(n_series) + "},\"block\":\"parameters\"},{\"name\":\"lambda\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(n_sp) + "},\"block\":\"parameters\"},{\"name\":\"b\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(num_basis) + "},\"block\":\"transformed_parameters\"},{\"name\":\"eta\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(total_obs) + "},\"block\":\"generated_quantities\"},{\"name\":\"sigma_obs_vec\",\"type\":{\"name\":\"matrix\",\"rows\":" + std::to_string(n) + ",\"cols\":" + std::to_string(n_series) + "},\"block\":\"generated_quantities\"},{\"name\":\"mus\",\"type\":{\"name\":\"matrix\",\"rows\":" + std::to_string(n) + ",\"cols\":" + std::to_string(n_series) + "},\"block\":\"generated_quantities\"},{\"name\":\"rho\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(n_sp) + "},\"block\":\"generated_quantities\"},{\"name\":\"tau\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(n_series) + "},\"block\":\"generated_quantities\"},{\"name\":\"ypred\",\"type\":{\"name\":\"array\",\"length\":" + std::to_string(n) + ",\"element_type\":{\"name\":\"array\",\"length\":" + std::to_string(n_series) + ",\"element_type\":{\"name\":\"real\"}}},\"block\":\"generated_quantities\"}]"); 1168: } 1169: // Begin method overload boilerplate 1170: template inline void 1171: write_array(RNG& base_rng, Eigen::Matrix& params_r, 1172: Eigen::Matrix& vars, const bool 1173: emit_transformed_parameters = true, const bool 1174: emit_generated_quantities = true, std::ostream* 1175: pstream = nullptr) const { 1176: const size_t num_params__ = ((((num_basis + n_series) + n_series) + (n * 1177: n_series)) + n_sp); 1178: const size_t num_transformed = emit_transformed_parameters * (num_basis); 1179: const size_t num_gen_quantities = emit_generated_quantities * 1180: ((((((total_obs + (n * n_series)) + (n * n_series)) + n_sp) + n_series) 1181: + (n * n_series))); 1182: const size_t num_to_write = num_params__ + num_transformed + 1183: num_gen_quantities; 1184: std::vector params_i; 1185: vars = Eigen::Matrix::Constant(num_to_write, 1186: std::numeric_limits::quiet_NaN()); 1187: write_array_impl(base_rng, params_r, params_i, vars, 1188: emit_transformed_parameters, emit_generated_quantities, pstream); 1189: } 1190: template inline void 1191: write_array(RNG& base_rng, std::vector& params_r, std::vector& 1192: params_i, std::vector& vars, bool 1193: emit_transformed_parameters = true, bool 1194: emit_generated_quantities = true, std::ostream* 1195: pstream = nullptr) const { 1196: const size_t num_params__ = ((((num_basis + n_series) + n_series) + (n * 1197: n_series)) + n_sp); 1198: const size_t num_transformed = emit_transformed_parameters * (num_basis); 1199: const size_t num_gen_quantities = emit_generated_quantities * 1200: ((((((total_obs + (n * n_series)) + (n * n_series)) + n_sp) + n_series) 1201: + (n * n_series))); 1202: const size_t num_to_write = num_params__ + num_transformed + 1203: num_gen_quantities; 1204: vars = std::vector(num_to_write, 1205: std::numeric_limits::quiet_NaN()); 1206: write_array_impl(base_rng, params_r, params_i, vars, 1207: emit_transformed_parameters, emit_generated_quantities, pstream); 1208: } 1209: template inline T_ 1210: log_prob(Eigen::Matrix& params_r, std::ostream* pstream = nullptr) const { 1211: Eigen::Matrix params_i; 1212: return log_prob_impl(params_r, params_i, pstream); 1213: } 1214: template inline T_ 1215: log_prob(std::vector& params_r, std::vector& params_i, 1216: std::ostream* pstream = nullptr) const { 1217: return log_prob_impl(params_r, params_i, pstream); 1218: } 1219: inline void 1220: transform_inits(const stan::io::var_context& context, 1221: Eigen::Matrix& params_r, std::ostream* 1222: pstream = nullptr) const final { 1223: std::vector params_r_vec(params_r.size()); 1224: std::vector params_i; 1225: transform_inits(context, params_i, params_r_vec, pstream); 1226: params_r = Eigen::Map>(params_r_vec.data(), 1227: params_r_vec.size()); 1228: } 1229: inline void 1230: transform_inits(const stan::io::var_context& context, std::vector& 1231: params_i, std::vector& vars, std::ostream* 1232: pstream__ = nullptr) const { 1233: vars.resize(num_params_r__); 1234: transform_inits_impl(context, vars, pstream__); 1235: } 1236: inline void 1237: unconstrain_array(const std::vector& params_constrained, 1238: std::vector& params_unconstrained, std::ostream* 1239: pstream = nullptr) const { 1240: const std::vector params_i; 1241: params_unconstrained = std::vector(num_params_r__, 1242: std::numeric_limits::quiet_NaN()); 1243: unconstrain_array_impl(params_constrained, params_i, 1244: params_unconstrained, pstream); 1245: } 1246: inline void 1247: unconstrain_array(const Eigen::Matrix& params_constrained, 1248: Eigen::Matrix& params_unconstrained, 1249: std::ostream* pstream = nullptr) const { 1250: const std::vector params_i; 1251: params_unconstrained = Eigen::Matrix::Constant(num_params_r__, 1252: std::numeric_limits::quiet_NaN()); 1253: unconstrain_array_impl(params_constrained, params_i, 1254: params_unconstrained, pstream); 1255: } 1256: }; 1257: } 1258: using stan_model = model1f1d41f703a3e__namespace::model1f1d41f703a3e_; 1259: #ifndef USING_R 1260: // Boilerplate 1261: stan::model::model_base& 1262: new_model(stan::io::var_context& data_context, unsigned int seed, 1263: std::ostream* msg_stream) { 1264: stan_model* m = new stan_model(data_context, seed, msg_stream); 1265: return *m; 1266: } 1267: stan::math::profile_map& get_stan_profile_data() { 1268: return model1f1d41f703a3e__namespace::profiles__; 1269: } 1270: #endif 1271: #endif 1272: 1273: RCPP_MODULE(stan_fit4model1f1d41f703a3e__mod) { 1274: class_ >( 1275: "stan_fit4model1f1d41f703a3e_") 1276: 1277: .constructor() 1278: 1279: .method( 1280: "call_sampler", 1281: &rstan::stan_fit::call_sampler) 1282: .method( 1283: "param_names", 1284: &rstan::stan_fit::param_names) 1285: .method("param_names_oi", 1286: &rstan::stan_fit::param_names_oi) 1288: .method("param_fnames_oi", 1289: &rstan::stan_fit::param_fnames_oi) 1291: .method( 1292: "param_dims", 1293: &rstan::stan_fit::param_dims) 1294: .method("param_dims_oi", 1295: &rstan::stan_fit::param_dims_oi) 1297: .method("update_param_oi", 1298: &rstan::stan_fit::update_param_oi) 1300: .method("param_oi_tidx", 1301: &rstan::stan_fit::param_oi_tidx) 1303: .method("grad_log_prob", 1304: &rstan::stan_fit::grad_log_prob) 1306: .method("log_prob", 1307: &rstan::stan_fit::log_prob) 1308: .method("unconstrain_pars", 1309: &rstan::stan_fit::unconstrain_pars) 1311: .method("constrain_pars", 1312: &rstan::stan_fit::constrain_pars) 1314: .method( 1315: "num_pars_unconstrained", 1316: &rstan::stan_fit::num_pars_unconstrained) 1318: .method( 1319: "unconstrained_param_names", 1320: &rstan::stan_fit< 1321: stan_model, boost::random::ecuyer1988>::unconstrained_param_names) 1322: .method( 1323: "constrained_param_names", 1324: &rstan::stan_fit::constrained_param_names) 1326: .method("standalone_gqs", 1327: &rstan::stan_fit::standalone_gqs); 1329: } 1330: 1331: 1332: // declarations 1333: extern "C" { 1334: SEXP file1f1d43c5f518c( ) ; 1335: } 1336: 1337: // definition 1338: SEXP file1f1d43c5f518c() { 1339: return Rcpp::wrap("anon_model"); 1340: } Compilation ERROR, function(s)/method(s) not created! Error in compileCode(f, code, language = language, verbose = verbose) : Error in file(filename, "r", encoding = encoding) : cannot open the connectionCalls: local ... eval.parent -> eval -> eval -> eval -> eval -> source -> fileIn addition: Warning message:In file(filename, "r", encoding = encoding) : cannot open file 'startup.Rs': No such file or directoryExecution halted Calls: mvgam ... withr_with_path -> force -> cxxfunction -> compileCode In addition: Warning message: In mvgam(y ~ s(season, k = 5), trend_model = "RW", family = gaussian(), : cmdstanr library not found. Defaulting to rstan Execution halted Running the tests in 'tests/testthat.R' failed. Complete output: > library(testthat) > library(mvgam) Loading required package: mgcv Loading required package: nlme This is mgcv 1.9-1. For overview type 'help("mgcv-package")'. Loading required package: Rcpp Loading required package: brms Loading 'brms' package (version 2.21.0). Useful instructions can be found by typing help('brms'). A more detailed introduction to the package is available through vignette('brms_overview'). Attaching package: 'brms' The following objects are masked from 'package:mgcv': s, t2 The following object is masked from 'package:stats': ar Loading required package: marginaleffects Loading required package: insight Welcome to mvgam. Please cite as: Clark, NJ, and Wells, K. 2022. Dynamic Generalized Additive Models (DGAMs) for forecasting discrete ecological time series. Methods in Ecology and Evolution, 2022, https://doi.org/10.1111/2041-210X.13974 > > test_check("mvgam") [ FAIL 3 | WARN 0 | SKIP 3 | PASS 274 ] ══ Skipped tests (3) ═══════════════════════════════════════════════════════════ • On CRAN (3): 'test-example_processing.R:125:3', 'test-example_processing.R:204:3', 'test-mvgam-methods.R:143:3' ══ Failed tests ════════════════════════════════════════════════════════════════ ── Failure ('test-mvgam_priors.R:166:3'): specified priors appear in the Stan code ── expect_match2(stancode, "vector[n_series] alpha_gp;") is not TRUE `actual`: FALSE `expected`: TRUE ── Failure ('test-mvgam_priors.R:251:3'): priors on gp() effects work properly ── any(...) is not TRUE `actual`: FALSE `expected`: TRUE ── Failure ('test-mvgam_priors.R:257:3'): priors on gp() effects work properly ── any(...) is not TRUE `actual`: FALSE `expected`: TRUE [ FAIL 3 | WARN 0 | SKIP 3 | PASS 274 ] Error: Test failures Execution halted * checking for unstated dependencies in vignettes ... OK * checking package vignettes ... WARNING Directory 'inst/doc' does not exist. Package vignettes without corresponding single PDF/HTML: 'data_in_mvgam.Rmd' 'forecast_evaluation.Rmd' 'mvgam_overview.Rmd' 'nmixtures.Rmd' 'shared_states.Rmd' 'time_varying_effects.Rmd' 'trend_formulas.Rmd' * checking re-building of vignette outputs ... OK * checking PDF version of manual ... [16s] OK * checking HTML version of manual ... [11s] OK * DONE Status: 1 ERROR, 2 WARNINGs, 4 NOTEs