Skip to content

Commit

Permalink
include mcmc_accpetance_rate1 #6
Browse files Browse the repository at this point in the history
  • Loading branch information
donotdespair committed Jun 2, 2024
1 parent cb5cbce commit 89edcab
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 0 deletions.
4 changes: 4 additions & 0 deletions R/RcppExports.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ log_kernel_nu <- function(aux_nu, aux_Sigma_c_cpp, aux_Sigma_c_inv, aux_Sigma, p
.Call(`_bvarPANELs_log_kernel_nu`, aux_nu, aux_Sigma_c_cpp, aux_Sigma_c_inv, aux_Sigma, prior_lambda, C, N, K)
}

mcmc_accpetance_rate1 <- function(mcmc) {
.Call(`_bvarPANELs_mcmc_accpetance_rate1`, mcmc)
}

sample_nu <- function(aux_nu, aux_Sigma_c_cpp, aux_Sigma_c_inv, aux_Sigma, prior) {
.Call(`_bvarPANELs_sample_nu`, aux_nu, aux_Sigma_c_cpp, aux_Sigma_c_inv, aux_Sigma, prior)
}
Expand Down
12 changes: 12 additions & 0 deletions src/RcppExports.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,17 @@ BEGIN_RCPP
return rcpp_result_gen;
END_RCPP
}
// mcmc_accpetance_rate1
double mcmc_accpetance_rate1(arma::vec& mcmc);
RcppExport SEXP _bvarPANELs_mcmc_accpetance_rate1(SEXP mcmcSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< arma::vec& >::type mcmc(mcmcSEXP);
rcpp_result_gen = Rcpp::wrap(mcmc_accpetance_rate1(mcmc));
return rcpp_result_gen;
END_RCPP
}
// sample_nu
double sample_nu(const double& aux_nu, const arma::cube& aux_Sigma_c_cpp, const arma::cube& aux_Sigma_c_inv, const arma::mat& aux_Sigma, const Rcpp::List& prior);
RcppExport SEXP _bvarPANELs_sample_nu(SEXP aux_nuSEXP, SEXP aux_Sigma_c_cppSEXP, SEXP aux_Sigma_c_invSEXP, SEXP aux_SigmaSEXP, SEXP priorSEXP) {
Expand Down Expand Up @@ -228,6 +239,7 @@ static const R_CallMethodDef CallEntries[] = {
{"_bvarPANELs_sample_w", (DL_FUNC) &_bvarPANELs_sample_w, 2},
{"_bvarPANELs_sample_s", (DL_FUNC) &_bvarPANELs_sample_s, 5},
{"_bvarPANELs_log_kernel_nu", (DL_FUNC) &_bvarPANELs_log_kernel_nu, 8},
{"_bvarPANELs_mcmc_accpetance_rate1", (DL_FUNC) &_bvarPANELs_mcmc_accpetance_rate1, 1},
{"_bvarPANELs_sample_nu", (DL_FUNC) &_bvarPANELs_sample_nu, 5},
{"_bvarPANELs_sample_Sigma", (DL_FUNC) &_bvarPANELs_sample_Sigma, 4},
{"_bvarPANELs_sample_AV", (DL_FUNC) &_bvarPANELs_sample_AV, 6},
Expand Down
19 changes: 19 additions & 0 deletions src/sample_mniw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,25 @@ double log_kernel_nu (



// [[Rcpp:interface(cpp)]]
// [[Rcpp::export]]
double mcmc_accpetance_rate1 (
arma::vec& mcmc
) {
const int N = mcmc.n_elem;
double acc = 0;
for (int i=1; i<N; i++) {
if (mcmc(i) == mcmc(i-1)) {
acc++;
}
}
return 1 - (acc / (N - 1));
} // END mcmc_accpetance_rate1





// [[Rcpp:interface(cpp)]]
// [[Rcpp::export]]
double sample_nu (
Expand Down
5 changes: 5 additions & 0 deletions src/sample_mniw.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ double log_kernel_nu (
);


double mcmc_accpetance_rate1 (
arma::vec& mcmc
);


double sample_nu (
const double& aux_nu, // scalar
const arma::cube& aux_Sigma_c_cpp, // NxNxC
Expand Down

0 comments on commit 89edcab

Please sign in to comment.