Created
October 25, 2016 11:27
-
-
Save kieranrcampbell/c016616b4641ea27476214f913109ac3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// [[Rcpp::export]] | |
NumericMatrix sample_tau_pg(NumericMatrix beta, | |
double a_beta, double b_beta) { | |
int P = beta.nrow(); | |
int G = beta.ncol(); | |
NumericMatrix tau_pg(P, G); | |
for(int p = 0; p < P; p++) { | |
for(int g = 0; g < G; g++) { | |
double beta_new = b_beta + beta(p,g) * beta(p,g) / 2; | |
tau_pg(p,g) = as<double>(rgamma(1, a_beta + 1, 1 / beta_new)); | |
} | |
} | |
return tau_pg; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment