1

I am trying to install the BayesLogit package in R. The package was removed from the CRAN website, but I have the source files BayesLogit_0.6.tar.gz. I try running

install.packages("BayesLogit_0.6.tar.gz", type = "source", repos = NULL)

but get the following error: installation of package ‘BayesLogit_0.6.tar.gz’ had non-zero exit status.

Can anyone help, or can you no longer install this package? I have the package installed on another machine, which I installed it back when it was on the CRAN website.

norm850
  • 21
  • 4

2 Answers2

0

I was able to install the package on my Ubuntu machine with devtools::install_version("BayesLogit", "0.6")

Because the package has C++ source files, you well need compilation tools. If you use Windows, that means you will need to install RTools. On Mac, you will need the Xcode command line tools. See also How do I install a package that has been archived from CRAN? and https://cran.r-project.org/bin/windows/Rtools/

bojan
  • 363
  • 3
  • 5
  • I am trying to install on a mac. Running your command above gives the error: installation of package ‘/var/folders/0m/wz75_3gs17z6pd48q6v4g41w0000gn/T//Rtmp0VfIu3/remotes3843f86f7ef/BayesLogit’ had non-zero exit status. – norm850 Nov 20 '18 at 16:50
  • Perhaps I need to install Xcode... I will give that a try. – norm850 Nov 20 '18 at 16:55
  • Yes, you do need to install Xcode. I will update the answer. – bojan Nov 20 '18 at 17:00
  • Okay I have installed xcode, and when trying to rerun your command, I get ERROR: compilation failed for package ‘BayesLogit’. Is there something I need to do within xcode after installing it, or is it sufficient to install xcode and run your command within R? – norm850 Nov 20 '18 at 17:42
  • @norm850 do you have `gfortran` installed? If not, see my answer. – miguelmorin Feb 12 '19 at 16:19
0

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)
miguelmorin
  • 5,025
  • 4
  • 29
  • 64