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: anRfunctionBayes_LM.RCheck_Valid_Input.R
-
bayes_lm_arma: aC++-only implementation using theArmadillolibrary (an executable)Bayes_LM_Arma.cppParse_Args.cppStats_Fcns_Arma.cpp
-
bayes_lm_eigen: aC++-only implementation using theEigenlibrary (an executable)Bayes_LM_Eigen.RParse_Args.cppStats_Fcns_Eigen.cpp
-
bayes_lm_rcpp_arma: anRfunction internally calling a workhorseC++function constructed using theArmadillolibraryBayes_LM_Rcpp_Arma.RCheck_Valid_Input.RStats_Fcns_Arma.cpp
-
bayes_lm_rcpp_eigen: an R function internally calling a workhorseC++function constructed using theEigenlibraryBayes_LM_Rcpp_Eigen.RCheck_Valid_Input.RStats_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