BwUniCluster2.0/Software/R/Glmnet: Difference between revisions
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
<span style="color:red"><b>Note that the instructions provided below refer to R 4. |
<span style="color:red"><b>Note that the instructions provided below refer to R 4.4.1 (but not R 4.2.1)!</b></span> |
||
= General information = |
= General information = |
||
<code>glmnet</code> is an <code>R</code> package that fits generalized linear and similar models via penalized maximum likelihood, particularly, lasso and elastic-net. |
|||
glmnet is a R library for lasso and elastic-net regularized generalized linear models |
|||
= Installation instructions = |
= Installation instructions = |
||
== Preparations == |
|||
Consider starting an interactive job for compiling. Copy and paste the following to your shell. |
|||
Installing <code>glmnet</code> involves compiling source code. Therefore, ensure that the following flags are set in <code>$HOME/.R/Makevars</code>: |
|||
<pre> |
<pre> |
||
cat ~/.R/Makevars |
|||
CXX14=g++ |
|||
CXX17=g++ |
|||
CXX14FLAGS += -std=c++14 |
|||
CXX17FLAGS += -std=c++17 |
|||
CXXFLAGS = -O3 -fPIC -march=cascadelake -ffp-contract=off -fno-fast-math -fno-signed-zeros -fopenmp -Wno-unknown-warning-option |
|||
</pre> |
|||
Since installing <code>glmnet</code> involves compiling, we start an <b>interactive session</b> on one of the compute nodes: |
|||
<pre> |
|||
salloc -n 1 -t 30 -p dev_single |
|||
</pre> |
|||
# Load the R software module, e.g. |
# Load the R software module, e.g. |
||
module load math/R/4.1.2 |
module load math/R/4.1.2 |
Revision as of 18:28, 28 October 2024
Note that the instructions provided below refer to R 4.4.1 (but not R 4.2.1)!
General information
glmnet
is an R
package that fits generalized linear and similar models via penalized maximum likelihood, particularly, lasso and elastic-net.
Installation instructions
Preparations
Installing glmnet
involves compiling source code. Therefore, ensure that the following flags are set in $HOME/.R/Makevars
:
cat ~/.R/Makevars CXX14=g++ CXX17=g++ CXX14FLAGS += -std=c++14 CXX17FLAGS += -std=c++17 CXXFLAGS = -O3 -fPIC -march=cascadelake -ffp-contract=off -fno-fast-math -fno-signed-zeros -fopenmp -Wno-unknown-warning-option
Since installing glmnet
involves compiling, we start an interactive session on one of the compute nodes:
salloc -n 1 -t 30 -p dev_single
- Load the R software module, e.g.
module load math/R/4.1.2
- Prepare .R directory (if it does not already exists)
mkdir -p ~/.R
- Write the following environment variables to Makevars
- Skip the 2nd and 3rd commands below if Makevars already consist these variables (1st command shows content of Makevars)
cat ~/.R/Makevars echo "CXX17=icpc" >> ~/.R/Makevars echo "CXX17FLAGS=-O3 -fPIC -std=c++17 -axCORE-AVX512,CORE-AVX2,AVX -xSSE4.2 -fp-model strict -qopenmp" >> ~/.R/Makevars
- Install the glmnet package from within R session
R -q > install.packages("glmnet", dependencies=TRUE)
- Run a quick test
> library(glmnet) > data(QuickStartExample) > x <- QuickStartExample$x > y <- QuickStartExample$y > fit <- glmnet(x, y) > print(fit)