From 9a5b64ca79a86998fccd006ec85c83a1bd95e190 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Wo=C5=BAniak?= Date: Thu, 6 Oct 2022 10:28:32 +1100 Subject: [PATCH] cpp functions done! #15 need to be checked --- src/forecast.cpp | 154 +++++++++++++++++++++++++++++++++++++++++++++++ src/forecast.h | 37 ++++++++++++ 2 files changed, 191 insertions(+) create mode 100644 src/forecast.cpp create mode 100644 src/forecast.h diff --git a/src/forecast.cpp b/src/forecast.cpp new file mode 100644 index 0000000..aa22333 --- /dev/null +++ b/src/forecast.cpp @@ -0,0 +1,154 @@ + +#include +#include "sample.h" + +using namespace Rcpp; +using namespace arma; + + +// [[Rcpp::interfaces(cpp)]] +// [[Rcpp::export]] +Rcpp::List forecast_bsvar ( + arma::cube& posterior_B, // (N, N, S) + arma::cube& posterior_A, // (N, K, S) + arma::vec& X_T, // (K) + const int horizon +) { + + const int N = posterior_B.n_rows; + const int S = posterior_B.n_slices; + const int K = posterior_A.n_cols; + const int p = (K - 1) / N; + + cube forecasts(N, horizon, S); + vec one(1, fill::value(1)); + + for (int s=0; s + +Rcpp::List forecast_bsvar ( + arma::cube& posterior_B, // (N, N, S) + arma::cube& posterior_A, // (N, K, S) + arma::vec& X_T, // (K) + const int horizon +); + + +Rcpp::List forecast_bsvar_msh ( + arma::cube& posterior_B, // (N, N, S) + arma::cube& posterior_A, // (N, K, S) + arma::cube& posterior_sigma2, // (N, M, S) + arma::cube& posterior_PR_TR, // (M, M, S) + arma::vec& X_T, // (K) + arma::vec& S_T, // (M) + const int horizon +); + + +Rcpp::List forecast_bsvar_sv ( + arma::cube& posterior_B, // (N, N, S) + arma::cube& posterior_A, // (N, K, S) + arma::cube& posterior_h_T, // NxS + arma::mat& posterior_rho, // NxS + arma::mat& posterior_omega, // NxS + arma::vec& X_T, // (K) + const int horizon +); + + +#endif // _BSVARTOOLS_H_ \ No newline at end of file