luisgruber / bayesianVARs

MCMC estimation of Bayesian Vectorautoregressions
https://luisgruber.github.io/bayesianVARs/
GNU General Public License v3.0
6 stars 3 forks source link

Build error: `bvar_cpp.cpp: error: 'stochvol' was not declared in this scope` #3

Closed barracuda156 closed 8 months ago

barracuda156 commented 8 months ago

Something is wrong here:

/opt/local/bin/g++-mp-13 -std=gnu++17 -I"/opt/local/Library/Frameworks/R.framework/Resources/include" -DNDEBUG  -I'/opt/local/Library/Frameworks/R.framework/Versions/4.3/Resources/library/factorstochvol/include' -I'/opt/local/Library/Frameworks/R.framework/Versions/4.3/Resources/library/Rcpp/include' -I'/opt/local/Library/Frameworks/R.framework/Versions/4.3/Resources/library/RcppArmadillo/include' -I'/opt/local/Library/Frameworks/R.framework/Versions/4.3/Resources/library/RcppProgress/include' -I'/opt/local/Library/Frameworks/R.framework/Versions/4.3/Resources/library/stochvol/include' -isystem/opt/local/include/LegacySupport -I/opt/local/include    -fPIC  -pipe -Os -arch ppc  -c RcppExports.cpp -o RcppExports.o
/opt/local/bin/g++-mp-13 -std=gnu++17 -I"/opt/local/Library/Frameworks/R.framework/Resources/include" -DNDEBUG  -I'/opt/local/Library/Frameworks/R.framework/Versions/4.3/Resources/library/factorstochvol/include' -I'/opt/local/Library/Frameworks/R.framework/Versions/4.3/Resources/library/Rcpp/include' -I'/opt/local/Library/Frameworks/R.framework/Versions/4.3/Resources/library/RcppArmadillo/include' -I'/opt/local/Library/Frameworks/R.framework/Versions/4.3/Resources/library/RcppProgress/include' -I'/opt/local/Library/Frameworks/R.framework/Versions/4.3/Resources/library/stochvol/include' -isystem/opt/local/include/LegacySupport -I/opt/local/include    -fPIC  -pipe -Os -arch ppc  -c bvar_cpp.cpp -o bvar_cpp.o
bvar_cpp.cpp: In function 'Rcpp::List bvar_cpp(const arma::mat&, const arma::mat&, const int&, const int&, const int&, const int&, const int&, const int&, const std::string&, const int&, arma::vec, arma::mat&, Rcpp::List, Rcpp::List, Rcpp::List, const arma::imat&, const arma::ivec&, const bool&, const double&, const double&, const bool&)':
bvar_cpp.cpp:342:15: error: 'stochvol' was not declared in this scope
  342 |   std::vector<stochvol::PriorSpec> prior_specs(M+factors);
      |               ^~~~~~~~
bvar_cpp.cpp:342:34: error: template argument 1 is invalid
  342 |   std::vector<stochvol::PriorSpec> prior_specs(M+factors);
      |                                  ^
bvar_cpp.cpp:342:34: error: template argument 2 is invalid
bvar_cpp.cpp:347:20: error: invalid types 'int[int]' for array subscript
  347 |         prior_specs[j] = {
      |                    ^
bvar_cpp.cpp:348:34: error: 'stochvol' is not a class, namespace, or enumeration
  348 |           (sv_priorh0(j) <= 0) ? stochvol::PriorSpec::Latent0() : stochvol::PriorSpec::Latent0(stochvol::PriorSpec::Constant(sv_priorh0(j))), // ? : conditional statement, similar to if else
      |                                  ^~~~~~~~
bvar_cpp.cpp:348:67: error: 'stochvol' is not a class, namespace, or enumeration
  348 |           (sv_priorh0(j) <= 0) ? stochvol::PriorSpec::Latent0() : stochvol::PriorSpec::Latent0(stochvol::PriorSpec::Constant(sv_priorh0(j))), // ? : conditional statement, similar to if else
      |                                                                   ^~~~~~~~
bvar_cpp.cpp:348:96: error: 'stochvol' is not a class, namespace, or enumeration
  348 |           (sv_priorh0(j) <= 0) ? stochvol::PriorSpec::Latent0() : stochvol::PriorSpec::Latent0(stochvol::PriorSpec::Constant(sv_priorh0(j))), // ? : conditional statement, similar to if else
      |                                                                                                ^~~~~~~~
bvar_cpp.cpp:349:27: error: 'stochvol' is not a class, namespace, or enumeration
  349 |                           stochvol::PriorSpec::Mu(stochvol::PriorSpec::Normal(sv_priormu[0], sv_priormu[1])),
      |                           ^~~~~~~~
bvar_cpp.cpp:349:51: error: 'stochvol' is not a class, namespace, or enumeration
  349 |                           stochvol::PriorSpec::Mu(stochvol::PriorSpec::Normal(sv_priormu[0], sv_priormu[1])),
      |                                                   ^~~~~~~~
bvar_cpp.cpp:350:27: error: 'stochvol' is not a class, namespace, or enumeration
  350 |                           stochvol::PriorSpec::Phi(stochvol::PriorSpec::Beta(sv_priorphi[0], sv_priorphi[1])),
      |                           ^~~~~~~~
bvar_cpp.cpp:350:52: error: 'stochvol' is not a class, namespace, or enumeration
  350 |                           stochvol::PriorSpec::Phi(stochvol::PriorSpec::Beta(sv_priorphi[0], sv_priorphi[1])),
      |                                                    ^~~~~~~~
bvar_cpp.cpp:351:27: error: 'stochvol' is not a class, namespace, or enumeration
  351 |                           stochvol::PriorSpec::Sigma2(stochvol::PriorSpec::Gamma(sv_priorsigma2(j,0), sv_priorsigma2(j,1)))//,
      |                           ^~~~~~~~
bvar_cpp.cpp:351:55: error: 'stochvol' is not a class, namespace, or enumeration
  351 |                           stochvol::PriorSpec::Sigma2(stochvol::PriorSpec::Gamma(sv_priorsigma2(j,0), sv_priorsigma2(j,1)))//,
      |                                                       ^~~~~~~~
bvar_cpp.cpp:361:20: error: invalid types 'int[int]' for array subscript
  361 |         prior_specs[j] = {
      |                    ^
bvar_cpp.cpp:362:34: error: 'stochvol' is not a class, namespace, or enumeration
  362 |           (sv_priorh0(j) <= 0) ? stochvol::PriorSpec::Latent0() : stochvol::PriorSpec::Latent0(stochvol::PriorSpec::Constant(sv_priorh0(j))),
      |                                  ^~~~~~~~
bvar_cpp.cpp:362:67: error: 'stochvol' is not a class, namespace, or enumeration
  362 |           (sv_priorh0(j) <= 0) ? stochvol::PriorSpec::Latent0() : stochvol::PriorSpec::Latent0(stochvol::PriorSpec::Constant(sv_priorh0(j))),
      |                                                                   ^~~~~~~~
bvar_cpp.cpp:362:96: error: 'stochvol' is not a class, namespace, or enumeration
  362 |           (sv_priorh0(j) <= 0) ? stochvol::PriorSpec::Latent0() : stochvol::PriorSpec::Latent0(stochvol::PriorSpec::Constant(sv_priorh0(j))),
      |                                                                                                ^~~~~~~~
bvar_cpp.cpp:363:27: error: 'stochvol' is not a class, namespace, or enumeration
  363 |                           stochvol::PriorSpec::Mu(stochvol::PriorSpec::Constant(0)),
      |                           ^~~~~~~~
bvar_cpp.cpp:363:51: error: 'stochvol' is not a class, namespace, or enumeration
  363 |                           stochvol::PriorSpec::Mu(stochvol::PriorSpec::Constant(0)),
      |                                                   ^~~~~~~~
bvar_cpp.cpp:364:27: error: 'stochvol' is not a class, namespace, or enumeration
  364 |                           stochvol::PriorSpec::Phi(stochvol::PriorSpec::Beta(sv_priorphi(2), sv_priorphi(3))),
      |                           ^~~~~~~~
bvar_cpp.cpp:364:52: error: 'stochvol' is not a class, namespace, or enumeration
  364 |                           stochvol::PriorSpec::Phi(stochvol::PriorSpec::Beta(sv_priorphi(2), sv_priorphi(3))),
      |                                                    ^~~~~~~~
bvar_cpp.cpp:365:27: error: 'stochvol' is not a class, namespace, or enumeration
  365 |                           stochvol::PriorSpec::Sigma2(stochvol::PriorSpec::Gamma(sv_priorsigma2(j,0), sv_priorsigma2(j,1)))
      |                           ^~~~~~~~
bvar_cpp.cpp:365:55: error: 'stochvol' is not a class, namespace, or enumeration
  365 |                           stochvol::PriorSpec::Sigma2(stochvol::PriorSpec::Gamma(sv_priorsigma2(j,0), sv_priorsigma2(j,1)))
      |                                                       ^~~~~~~~
bvar_cpp.cpp:377:9: error: 'stochvol' does not name a type
  377 |   const stochvol::ExpertSpec_FastSV expert_sv { // used for cholesky-sv and idiosyncratic variances of fsv
      |         ^~~~~~~~
bvar_cpp.cpp:388:9: error: 'stochvol' does not name a type
  388 |   const stochvol::ExpertSpec_FastSV expert_fac { // used for factor variances of fsv
      |         ^~~~~~~~
bvar_cpp.cpp:581:7: error: 'factorstochvol' has not been declared
  581 |       factorstochvol::update_fsv(armafacload,
      |       ^~~~~~~~~~~~~~
bvar_cpp.cpp:605:34: error: 'expert_sv' was not declared in this scope
  605 |                                  expert_sv, // aka expert_idi
      |                                  ^~~~~~~~~
bvar_cpp.cpp:606:34: error: 'expert_fac' was not declared in this scope
  606 |                                  expert_fac,
      |                                  ^~~~~~~~~~
bvar_cpp.cpp:695:11: error: 'stochvol' is not a class, namespace, or enumeration
  695 |           stochvol::update_fast_sv(resid_norm, mu, phi, sigma, h0_j, h_j, mixind_j, prior_specs[j], expert_sv); //resid_norm.col(j)
      |           ^~~~~~~~
bvar_cpp.cpp:695:96: error: invalid types 'int[int]' for array subscript
  695 |           stochvol::update_fast_sv(resid_norm, mu, phi, sigma, h0_j, h_j, mixind_j, prior_specs[j], expert_sv); //resid_norm.col(j)
      |                                                                                                ^
bvar_cpp.cpp:695:101: error: 'expert_sv' was not declared in this scope
  695 |           stochvol::update_fast_sv(resid_norm, mu, phi, sigma, h0_j, h_j, mixind_j, prior_specs[j], expert_sv); //resid_norm.col(j)
      |                                                                                                     ^~~~~~~~~
make: *** [bvar_cpp.o] Error 1
barracuda156 commented 8 months ago

Oh well, this is just wrong:

// <stochvol.h> is already included in <factorstochvol.h>

No, it is not included.

barracuda156 commented 8 months ago

Okay, I do not know how to make it work. Without stochvol.h it fails as described above, with stockvol.h added it still fails, but now with:

/opt/local/bin/g++-mp-13 -std=gnu++17 -I"/opt/local/Library/Frameworks/R.framework/Resources/include" -DNDEBUG  -I'/opt/local/Library/Frameworks/R.framework/Versions/4.3/Resources/library/factorstochvol/include' -I'/opt/local/Library/Frameworks/R.framework/Versions/4.3/Resources/library/Rcpp/include' -I'/opt/local/Library/Frameworks/R.framework/Versions/4.3/Resources/library/RcppArmadillo/include' -I'/opt/local/Library/Frameworks/R.framework/Versions/4.3/Resources/library/RcppProgress/include' -I'/opt/local/Library/Frameworks/R.framework/Versions/4.3/Resources/library/stochvol/include' -isystem/opt/local/include/LegacySupport -I/opt/local/include    -fPIC  -pipe -Os -arch ppc  -c RcppExports.cpp -o RcppExports.o
/opt/local/bin/g++-mp-13 -std=gnu++17 -I"/opt/local/Library/Frameworks/R.framework/Resources/include" -DNDEBUG  -I'/opt/local/Library/Frameworks/R.framework/Versions/4.3/Resources/library/factorstochvol/include' -I'/opt/local/Library/Frameworks/R.framework/Versions/4.3/Resources/library/Rcpp/include' -I'/opt/local/Library/Frameworks/R.framework/Versions/4.3/Resources/library/RcppArmadillo/include' -I'/opt/local/Library/Frameworks/R.framework/Versions/4.3/Resources/library/RcppProgress/include' -I'/opt/local/Library/Frameworks/R.framework/Versions/4.3/Resources/library/stochvol/include' -isystem/opt/local/include/LegacySupport -I/opt/local/include    -fPIC  -pipe -Os -arch ppc  -c bvar_cpp.cpp -o bvar_cpp.o
bvar_cpp.cpp: In function 'Rcpp::List bvar_cpp(const arma::mat&, const arma::mat&, const int&, const int&, const int&, const int&, const int&, const int&, const std::string&, const int&, arma::vec, arma::mat&, Rcpp::List, Rcpp::List, Rcpp::List, const arma::imat&, const arma::ivec&, const bool&, const double&, const double&, const bool&)':
bvar_cpp.cpp:581:7: error: 'factorstochvol' has not been declared
  581 |       factorstochvol::update_fsv(armafacload,
      |       ^~~~~~~~~~~~~~
luisgruber commented 8 months ago

Oh well, this is just wrong:

// <stochvol.h> is already included in <factorstochvol.h>

No, it is not included.

It is definitely included, see https://github.com/gregorkastner/factorstochvol/blob/b467797a43d871ff608fc8a728356d2aae57c016/inst/include/factorstochvol.h#L30

Did you try running devtools::install_github("luisgruber/bayesianVARs") as stated in the README?

barracuda156 commented 8 months ago

@luisgruber I am sorry, maybe I have an outdated version of factorstochvol.h then. Let me check.

UPD. Indeed, I have 1.0.6 on that machine, and Macports version is at 1.1.0. I should have noticed that before filing an issue.

However, git blame shows it was added in 1.1.0 in https://github.com/gregorkastner/factorstochvol/commit/689a517f8278dad13932da3945aa53e38fbd077f Perhaps, add a version check, so it fails with a clear message of factorstochvol being too old?

luisgruber commented 8 months ago

Good point, updated DESRIPTION, see https://github.com/luisgruber/bayesianVARs/blob/70790cb0bbd7a0df4773c2b1b1facf2d3d2cdb85/DESCRIPTION#L21

barracuda156 commented 8 months ago

Thank you! Sorry for a somewhat misleading initial report.

barracuda156 commented 8 months ago

Just to confirm, with factorstochvol updated to 1.1.0, it builds fine and tests pass:

--->  Testing R-bayesianVARs
* using log directory ‘/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_R_R-bayesianVARs/R-bayesianVARs/work/bayesianVARs/bayesianVARs.Rcheck’
* using R version 4.3.2 (2023-10-31)
* using platform: powerpc-apple-darwin10.0.0d2 (32-bit)
* R was compiled by
    gcc-mp-13 (MacPorts gcc13 13.2.0_4+stdlib_flag) 13.2.0
    GNU Fortran (MacPorts gcc12 12.3.0_3+stdlib_flag) 12.3.0
* running under: OS X Snow Leopard 10.6
* using session charset: UTF-8
* using option ‘--ignore-vignettes’
* checking for file ‘bayesianVARs/DESCRIPTION’ ... OK
* this is package ‘bayesianVARs’ version ‘0.1.1’
* package encoding: UTF-8
* checking package namespace information ... OK
* checking package dependencies ... OK
* checking if this is a source package ... OK
* checking if there is a namespace ... OK
* checking for executable files ... OK
* checking for hidden files and directories ... OK
* checking for portable file names ... OK
* checking for sufficient/correct file permissions ... OK
* checking whether package ‘bayesianVARs’ can be installed ... OK
* used C++ compiler: ‘g++-mp-13 (MacPorts gcc13 13.2.0_4+stdlib_flag) 13.2.0’
* used SDK: ‘NA’‘NA’‘NA’‘NA’‘NA’‘NA’
* checking installed package size ... OK
* checking package directory ... OK
* checking DESCRIPTION meta-information ... OK
* checking top-level files ... OK
* checking for left-over files ... OK
* checking index information ... OK
* checking package subdirectories ... OK
* checking R 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 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 ... OK
* checking Rd files ... OK
* checking Rd metadata ... OK
* checking Rd cross-references ... OK
* 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 line endings in C/C++/Fortran sources/headers ... OK
* checking line endings in Makefiles ... OK
* checking compilation flags in Makevars ... OK
* checking for GNU extensions in Makefiles ... OK
* checking for portable use of $(BLAS_LIBS) and $(LAPACK_LIBS) ... OK
* checking use of PKG_*FLAGS in Makefiles ... OK
* checking compiled code ... OK
* checking installed files from ‘inst/doc’ ... OK
* checking files in ‘vignettes’ ... SKIPPED
* checking examples ... OK
* checking for unstated dependencies in ‘tests’ ... OK
* checking tests ...
  Running ‘testthat.R’
 OK
* checking PDF version of manual ... OK
* DONE

Status: OK