[[Category:Software]]
[https://www.r-inla.org/ R-INLA] is a package in [[R]] that do approximate Bayesian inference for Latent Gaussian Models.
== Installation ==
The installation of the R-INLA package is a bit more complicated than most [[R]]-packages, as it downloads
other pre-compiled executables that need to be made compatible with our [[Standard software environments|Standard software environment]].
The following installation script has been tested in Summer of 2022 with R 4.2.1 and R-INLA.
Because R will always install the latest versions of packages, the versions of the modules will likely have to be adjusted in the future.
{{File
|name=install_INLA.sh
|lang="bash"
|contents=
#!/bin/bash
# (1)
module load gcc/9.3.0 r/4.2.1 geos/3.9.1 gdal/3.2.3 udunits/2.2.26 gsl/2.6
LOGFILE=r_INLA_install_${EBVERSIONR}_${CC_CLUSTER}_$(date --iso=sec).log
# (2)
export R_LIBS="$HOME/R/x86_64-pc-linux-gnu-library/${EBVERSIONR:0:3}"
echo "R_LIBS is $R_LIBS"
mkdir -p $R_LIBS
R -e 'install.packages("INLA", repos=c("https://cran.utstat.utoronto.ca/", INLA="https://inla.r-inla-download.org/R/stable"), dep=TRUE, Ncpus=2)' \
{{!}}& tee $LOGFILE
# (3)
R -e 'library(INLA); inla.binary.install(os="CentOS Linux-7")' {{!}}& tee -a $LOGFILE
# (4)
chmod u+x $R_LIBS/INLA/bin/linux/64bit/{*.so.*,*.so,first/*.so}
sed -i 's/\(^.*export LD_LIBRARY_PATH\)/echo "Skipping LD_LIBRARY_PATH." #\1/g' $R_LIBS/INLA/bin/linux/64bit/*.run
setrpaths.sh --path $R_LIBS/INLA/bin/linux --add_path '$ORIGIN/first:$ORIGIN'
}}
Comments in the script:
* (1) Load required modules. The same modules have to be loaded in the job script as well.
* (2) Install the R-INLA package and its dependencies
* (3) Install the pre-compiled executables that R-INLA needs
* (4) Patch the pre-compiled executables so that they are compatible with our [[Standard software environments|Standard software environment]]