R package for balance regression using the Supervised Log Ratio method


slr is an R package for selection of balances in compositional data analysis. It implements a supervised log ratio method for the identification of two groups of variables whose log ratio is associated with a continuous or binary response variable.

Getting Started

How to install

devtools::install_github(repo = "drjingma/slr",build_vignettes=T)

How to use

Once installed, you can call the library and check out the help functions



You can read the associated vignette in R directly if build_vignettes=T:


You can also find the vignette here. In this vignette, you will see that slr compares favorably to selbal on an HIV data set.


  • In the cv.slr function, if plot=TRUE, the function will display a plot of the cross-validation deviance measure as a function of the tuning parameter. The error bars of the CV deviance are also displayed. However, at the boundary of tuning parameters, the length of the error bar could be zero, which means that the standard error of the CV deviance across folds is 0. This may render the warning message:

      1: In doTryCatch(return(expr), name, parentenv, handler) :
        zero-length arrow is of indeterminate angle and so skipped
  • Currently, slr works only for continuous or binary response variables. We plan to allow survival response in the near future.