Problem installing BRMS package on Linux server

Hi, I am trying to install brms package on my Linux R server. Below is the specification of my platform:

platform       x86_64-pc-linux-gnu         
arch           x86_64                      
os             linux-gnu                   
system         x86_64, linux-gnu           
status                                     
major          3                           
minor          6.3                         
year           2020                        
month          02                          
day            29                          
svn rev        77875                       
language       R                           
version.string R version 3.6.3 (2020-02-29)
nickname       Holding the Windsock 

In order to install the brms package I am using below installation command:

install.packages("brms", repos = "https://cran.rstudio.com")

But I am getting below error:

I also tried installing rstan but it is failing as well:

install.packages("rstan", repos = "https://cran.rstudio.com")

But I am facing below error:

Error in .shlib_internal(args) : 
  C++14 standard requested but CXX14 is not defined
* removing ‘/opt/R/3.6.3/rstan’
Warning in install.packages :
  installation of package ‘rstan’ had non-zero exit status

It would be very helpful if someone could support me. My objective is to use “brm” function.

Thanks in advance,
Shubham

I think you will need to specify g++ or clang. See here for details

Thanks for the suggestion. This unfortunately didnt help. Is it possible to use brm function through cmdstanr package?

Yes you can just specify backend="cmdstanr" in the brm call.

As for the RStan call not working, what do you get from: readLines("~/.R/Makevars")?

Thanks for the response John. Below is the output from readLines("~/.R/Makevars")
image

Furthermore, while installing rstan package, I am facing below error:

Can you post more of the error message? It doesn’t show which part failed

Also, can you try changing CXX14 to:

CXX14 = g++ -std=c++1y

Thanks for the prompt response John. I have made the changes to CXX14 as asked. Attached is a slightly detailed error log. I copied few lines from the console and pasted in notepad so that it is easily readable.Please start reading from the end.
Error Log.txt (39.4 KB)
Thank you once again for your support :)

Hmm, I think your compiler might be out-of-date for Stan. What do you get from:

system("g++ --version")

This is the result from system(“g++ --version”) :

Ah yeah that’s the issue, Stan needs g++ 4.9.3 or higher. You’ll need to ask your server admin if they can upgrade the compiler for you

Ohh if that is the case platform update could take time. However, meanwhile can I use cmdstanr to use brm function? I used your suggestion you mention earier about incorporating backend=“cmdstanr”. Below is how my brm block looks:

library(cmdstanr)
bmod1 <-   brm(COS_NRX_PSO ~ 
                 lag.1.COMPNRX+adstock_samples_5_50_NT + 
                adstock_samples_5_50_ST + adstock_samples_5_50_T1+ 
                adstock_samples_5_50_T2, data = rawdb1, 
                family = gaussian("log"),
                warmup = 100, iter = 1000, chains = 4,prior= prior2,
                control = list(adapt_delta = 0.95), seed=150,
                cores = parallel::detectCores(),backend="cmdstanr")

But I am getting below error:

Is there anything I am missing?

You still need to do

library(brms)

You’ll have the same issue with cmdstanr, since that also needs g++ 4.9.3 or higher

3 Likes

Just a guess, but wouldn’t some older versions of rstan work with g++ 4.8.5? (one would then probably also need an older version of brms). If @Sham414 doesn’t need anything fancy, this could as well not be a big issue…

2 Likes

Hi @martinmodrak, thank you so much for the suggestion. How can I find an older version of rstan and brms which would work with my existing g++ 4.8.5? I only need to use brm function. My objective is to run bayesian regression model with priors.

It looks like the c++14 requirement was introduced in 2.17, so you would need to need install the Rstan and StanHeaders packages from those times (around four years old now!).

To install these versions, use:

devtools::install_version("StanHeaders",version="2.16.0-1")
devtools::install_version("rstan",version="2.16.2")

And it looks like the brms version from this time was 1.8.0, install via:

devtools::install_version("brms",version="1.8.0")

Note that these are quite outdated, so your models will likely be slower. And there may be aspects of your syntax that weren’t supported at this time, so you may not be able to run the model that you want.

4 Likes

Thank you so much, but I requested the server admin to update the compiler and install brms. The brms installation is successfull but when I am runnning the brm function I am facing errors.

Below are my codes:

library(brms)
bmod1 <-   brm(COS_NRX_PSO ~ 
                 lag.1.COMPNRX+adstock_samples_5_50_NT + 
                adstock_samples_5_50_ST + adstock_samples_5_50_T1+ 
                adstock_samples_5_50_T2, data = rawdb1, 
                family = gaussian("log"),
                warmup = 100, iter = 1000, chains = 4,prior= prior2,
                control = list(adapt_delta = 0.95), seed=150,
                cores = parallel::detectCores())

Below are the errors I am seeing:

I am totally confused why I am facing this error when the brms installation is completed successfully. Please help.

Thanks

Can you double-check that it’s detecting the new compiler by running:

system("g++ --version")

I just checked but it is still showing 4.8.5:

However, the server admin is telling he has updated the compiler from terminal:

image

what could be the problem?