As an exercise I decided to implement a Bayesian linear model using the C++
libraries Armadillo
and Eigen
, and then to interface the C++
code from R
via Rcpp
. The main purpose of this exercise was to obtain some familiarity
with these libraries and packages. Additionally I am also interested in
comparing the speeds of the implementations for this problem and practicing
profiling techniques on the software.
A more detailed explanation of the functions / programs found in this repository
can be found at Writeup/Bayes_LM_Writeup.pdf
. The file also displays my
findings and experiences in terms of speed comparisons and program profiling.
The root directory contains the following files:
-
bayes_lm_r
: anR
functionBayes_LM.R
Check_Valid_Input.R
-
bayes_lm_arma
: aC++
-only implementation using theArmadillo
library (an executable)Bayes_LM_Arma.cpp
Parse_Args.cpp
Stats_Fcns_Arma.cpp
-
bayes_lm_eigen
: aC++
-only implementation using theEigen
library (an executable)Bayes_LM_Eigen.R
Parse_Args.cpp
Stats_Fcns_Eigen.cpp
-
bayes_lm_rcpp_arma
: anR
function internally calling a workhorseC++
function constructed using theArmadillo
libraryBayes_LM_Rcpp_Arma.R
Check_Valid_Input.R
Stats_Fcns_Arma.cpp
-
bayes_lm_rcpp_eigen
: an R function internally calling a workhorseC++
function constructed using theEigen
libraryBayes_LM_Rcpp_Eigen.R
Check_Valid_Input.R
Stats_Fcns_Eigen.cpp
Compare the speeds of the programs as the number of observations (i.e. as n) increases
Compare the speeds of the programs as the number of variables (i.e. as p) increases