MyNixOS website logo
Description

Bayesian Lasso Regression and Tools for the Lasso Distribution.

Implements Bayesian Lasso regression using efficient Gibbs sampling algorithms, including modified versions of the Hans and Park–Casella (PC) samplers. Includes functions for working with the Lasso distribution, such as its density, cumulative distribution, quantile, and random generation functions, along with moment calculations. Also includes a function to compute the Mills ratio. Designed for sparse linear models and suitable for high-dimensional regression problems.

BayesianLasso

BayesianLasso is an R package for efficient Bayesian inference in sparse linear regression models using the Bayesian Lasso. It includes optimized Gibbs sampling algorithms and utilities for working with the Lasso distribution.

Installation

You can install the development version of BayesianLasso from GitHub with:

# install.packages("pak")
pak::pak("garthtarr/BayesianLasso")

Features

  • Efficient Gibbs samplers for Bayesian Lasso (e.g., Modified_Hans_Gibbs, Modified_PC_Gibbs)

  • Support for drawing from the Lasso distribution

  • Utilities for computing moments and densities

Example Usage

These are basic examples which show you how to solve a common problem:

library(BayesianLasso)
## basic example code

# Simulated data
set.seed(123)
X <- matrix(rnorm(100), 20, 5)
y <- rnorm(20)
beta_init <- rep(1, 5)

# Run modified Hans Gibbs sampler
result <- Modified_Hans_Gibbs(
  X = X,
  y = y,
  a1 = 0.01,
  b1 = 0.01,
  u1 = 0.01,
  v1 = 0.01,
  nsamples = 100,
  beta_init = beta_init,
  lambda_init = 0.1,
  sigma2_init = 1,
  verbose = 0
)

str(result)
#> List of 6
#>  $ mBeta   : num [1:100, 1:5] 0.2441 0.2277 0.2478 -0.1356 -0.0692 ...
#>  $ vsigma2 : num [1:100, 1] 0.913 0.767 0.704 0.747 0.623 ...
#>  $ vlambda2: num [1:100, 1] 34.96 87.38 9.41 53.49 68.44 ...
#>  $ mA      : num [1:100, 1:5] 18.4 20.1 24 26.1 24.6 ...
#>  $ mB      : num [1:100, 1:5] 5.67 3.15 3 2.11 2.49 ...
#>  $ mC      : num [1:100, 1:5] 0.1 6.19 10.68 3.66 8.46 ...

The Modified_Hans_Gibbs() function returns a list with the following components:

  • mBeta: MCMC samples of the regression coefficients $\boldsymbol{\beta}$, stored as a matrix with nsamples rows and p columns.
  • vsigma2: MCMC samples of the error variance $\sigma^2$.
  • vlambda2: MCMC samples of the global shrinkage parameter $\lambda^2$.
  • mA, mB, mC: Matrices containing the MCMC samples of the Lasso distribution parameters $A_j$, $B_j$, and $C_j$ for each coefficient $\beta_j$, where each row corresponds to one MCMC iteration and each column to a regression coefficient.

Lasso Distribution Functions

The package provides functions for working with the Lasso distribution:

  • zlasso(): Normalizing constant

  • dlasso(): Density function

  • plasso(): CDF

  • qlasso(): Quantile function

  • rlasso(): Random generation

  • elasso(): Expected value

  • vlasso(): Variance

  • mlasso(): Mode

  • MillsRatio(): Mills ratio

Citation

If you use this package in your work, please cite it appropriately. Citation information can be found using:

citation("BayesianLasso")
#> To cite package 'BayesianLasso' in publications use:
#> 
#>   Ormerod J, Davoudabadi M, Tarr G, Mueller S, Tidswell J (2025).
#>   _Bayesian Lasso Regression and Tools for the Lasso Distribution_. R
#>   package version 0.3.0, <https://garthtarr.github.io/BayesianLasso/>.
#> 
#> A BibTeX entry for LaTeX users is
#> 
#>   @Manual{,
#>     title = {Bayesian Lasso Regression and Tools for the Lasso Distribution},
#>     author = {John Ormerod and Mohammad Javad Davoudabadi and Garth Tarr and Samuel Mueller and Jonathon Tidswell},
#>     year = {2025},
#>     note = {R package version 0.3.0},
#>     url = {https://garthtarr.github.io/BayesianLasso/},
#>   }
Metadata

Version

0.3.5

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-freebsd
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64-windows
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows