Difference between revisions of "BwUniCluster2.0/Software/R/Rjags"

From bwHPC Wiki
Jump to: navigation, search
(Created page with "= Installation instructions = Consider starting an interactive job for compiling. Just copy paste this to your shell (please only copy line by line so you see errors fast). ...")
 
m (M Janczyk moved page Rjags to BwUniCluster2.0/Software/R/Rjags)
 
(6 intermediate revisions by 3 users not shown)
Line 1: Line 1:
= Installation instructions =
 
   
  +
= General information =
Consider starting an interactive job for compiling. Just copy paste this to your shell (please only copy line by line so you see errors fast).
 
  +
  +
rjags is a R interface to use JAGS, [https://mcmc-jags.sourceforge.io/ Just another Gibbs Sampler]. JAGS is a program for analysis of Bayesian hierarchical models using Markov Chain Monte Carlo (MCMC) simulation
  +
  +
rjags needs a JAGS installation on the side. We recommend to compile via Intel compiler and with the Intel MKL library (Intel Math Kernel Library), which allows JAGS to use various efficient implementations of mathematical computations. These are, as of now, loaded alongside with the module R 4.1.2.
  +
  +
  +
= Installation =
  +
  +
Please enter the following code, presented in the boxes below, directly into your shell/command line on bwUniCluster
   
 
<pre>
 
<pre>
  +
#Load R module
module load math/R
 
  +
module load math/R/4.1.2
  +
  +
  +
# Set up JAGS installation directory
  +
export JAGS_HOME=$HOME/sw/jags
  +
  +
  +
# Prepare JAGS source directory (if not yet existing)
 
mkdir -p ~/src
 
mkdir -p ~/src
 
cd ~/src
 
cd ~/src
# copy the JAGS-4.3.0.tar.gz here
 
   
  +
# Build JAGS
 
tar xf JAGS-4.3.0.tar.gz
+
# Get JAGS source
  +
wget https://sourceforge.net/projects/mcmc-jags/files/JAGS/4.x/Source/JAGS-4.3.1.tar.gz
cd JAGS-4.3.0
 
  +
tar xf JAGS-4.3.1.tar.gz
./configure --prefix=$HOME/sw
 
  +
cd JAGS-4.3.1
make -j4
 
  +
rm JAGS-4.3.1.tar.gz
  +
  +
  +
# Install JAGS
  +
export CFLAGS="-O3 -axCORE-AVX512,CORE-AVX2,AVX -xSSE4.2 -fp-model strict -qopenmp"
  +
export CXXFLAGS="-O3 -std=c++14 -axCORE-AVX512,CORE-AVX2,AVX -xSSE4.2 -fp-model strict -qopenmp"
  +
./configure --prefix=$JAGS_HOME --with-blas="-lmkl_rt -lpthread -lm"
  +
make
 
make install
 
make install
cd ..
+
cd
  +
  +
  +
# Set up environment
  +
export PKG_CONFIG_PATH=$JAGS_HOME/lib/pkgconfig
  +
export LD_RUN_PATH=$JAGS_HOME/lib
   
# Set up environment (you may want to put these lines in your ~/.bashrc as well)
 
export PATH=$PATH:$HOME/sw/bin
 
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$HOME/sw/lib
 
export MANPATH=$MANPATH:$HOME/sw/man
 
export CFLAGS=-I$HOME/sw/include
 
export JAGS_LIBDIR=~/sw/lib
 
   
 
# Install rjags package from within R session
 
# Install rjags package from within R session
 
R -q
 
R -q
install.packages("rjags")
+
> install.packages("rjags", configure.args="--enable-rpath")
library("rjags")
+
> library(rjags)
  +
</pre>
 
  +
----
  +
[[Category:BwUniCluster]]
  +
[[Category:BwUniCluster_2.0]]

Latest revision as of 11:53, 14 March 2023

1 General information

rjags is a R interface to use JAGS, Just another Gibbs Sampler. JAGS is a program for analysis of Bayesian hierarchical models using Markov Chain Monte Carlo (MCMC) simulation

rjags needs a JAGS installation on the side. We recommend to compile via Intel compiler and with the Intel MKL library (Intel Math Kernel Library), which allows JAGS to use various efficient implementations of mathematical computations. These are, as of now, loaded alongside with the module R 4.1.2.


2 Installation

Please enter the following code, presented in the boxes below, directly into your shell/command line on bwUniCluster

#Load R module
module load math/R/4.1.2


# Set up JAGS installation directory 
export JAGS_HOME=$HOME/sw/jags


# Prepare JAGS source directory (if not yet existing) 
mkdir -p ~/src
cd ~/src


# Get JAGS source
wget https://sourceforge.net/projects/mcmc-jags/files/JAGS/4.x/Source/JAGS-4.3.1.tar.gz
tar xf JAGS-4.3.1.tar.gz
cd JAGS-4.3.1
rm JAGS-4.3.1.tar.gz


# Install JAGS 
export CFLAGS="-O3 -axCORE-AVX512,CORE-AVX2,AVX -xSSE4.2 -fp-model strict -qopenmp"
export CXXFLAGS="-O3  -std=c++14 -axCORE-AVX512,CORE-AVX2,AVX -xSSE4.2 -fp-model strict -qopenmp"
./configure  --prefix=$JAGS_HOME --with-blas="-lmkl_rt -lpthread -lm"
make
make install
cd


# Set up environment
export PKG_CONFIG_PATH=$JAGS_HOME/lib/pkgconfig
export LD_RUN_PATH=$JAGS_HOME/lib


# Install rjags package from within R session
R -q
> install.packages("rjags", configure.args="--enable-rpath")
> library(rjags)