Linux
Run these commands in the R session:
install.packages("devtools") # optional, in case you don't have it
require(devtools)
install_version("BayesLogit", version = "0.6") # the latest version on CRAN archive
macOS
Compiling BayesLogit from source requires GFortran, which requires XCode and command-line tools:
- install XCode from the App Store, or install only command-line tools only (e.g., from this thread)
- install
gfortran
, e.g. using an appropriate disk image
- run the same code as above inside R:
install.packages("devtools") # optional, in case you don't have it
require(devtools)
install_version("BayesLogit", version = "0.6") # the latest version on CRAN archive
Alternative package
The GitHub page of BayesLogit
was last updated 11 months ago, so I venture a guess that it will not be on CRAN. An alternative is this package, which implements the same Polya-Gamma scheme as BayesLogit
and has very similar syntax:
# BayesLogit
obj <- BayesLogit::logit(y=y, X=X, P0=diag(rep(precision, ncol(X)), samp=n_samples, burn=burn)
# PolyaGamma
obj <- PolyaGamma::gibbs_sampler(y=y, X=X, lambda=precision, n_iter_total=burn + n_samples, burn_in=burn)
To install the PolyaGamma
package, run these commands in your R session:
install.packages("devtools") # optional, in case you don't have it
require(devtools)
devtools::install_github("kasparmartens/PolyaGamma")
library(PolyaGamma)