MyNixOS website logo
Description

Bayesian Variable Selection and Model Averaging using Bayesian Adaptive Sampling.

Package for Bayesian Variable Selection and Model Averaging in linear models and generalized linear models using stochastic or deterministic sampling without replacement from posterior distributions. Prior distributions on coefficients are from Zellner's g-prior or mixtures of g-priors corresponding to the Zellner-Siow Cauchy Priors or the mixture of g-priors from Liang et al (2008) <DOI:10.1198/016214507000001337> for linear models or mixtures of g-priors from Li and Clyde (2019) <DOI:10.1080/01621459.2018.1469992> in generalized linear models. Other model selection criteria include AIC, BIC and Empirical Bayes estimates of g. Sampling probabilities may be updated based on the sampled models using sampling w/out replacement or an efficient MCMC algorithm which samples models using a tree structure of the model space as an efficient hash table. See Clyde, Ghosh and Littman (2010) <DOI:10.1198/jcgs.2010.09049> for details on the sampling algorithms. Uniform priors over all models or beta-binomial prior distributions on model size are allowed, and for large p truncated priors on the model space may be used to enforce sampling models that are full rank. The user may force variables to always be included in addition to imposing constraints that higher order interactions are included only if their parents are included in the model. This material is based upon work supported by the National Science Foundation under Division of Mathematical Sciences grant 1106891. Any opinions, findings, and conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of the National Science Foundation.

BAS: Bayesian Variable Selection and Model Averaging using Bayesian Adaptive Sampling

CII BestPractices R-CMD-check CoverageStatus Rdoc DOI

The BASR package is designed to provide an easy to use package and fast code for implementing Bayesian Model Averaging and Model Selection in R using state of the art prior distributions for linear and generalized linear models. The prior distributions in BAS are based on Zellner’s g-prior or mixtures of g-priors for linear and generalized linear models. These have been shown to be consistent asymptotically for model selection and inference and have a number of computational advantages. BAS implements three main algorithms for sampling from the space of potential models: a deterministic algorithm for efficient enumeration, adaptive sampling without replacement algorithm for modest problems, and a MCMC algorithm that utilizes swapping to escape from local modes with standard Metropolis-Hastings proposals.

Installation

The stable version can be installed easily in the R console like any other package:

install.packages('BAS')

On the other hand, I welcome everyone to use the most recent version of the package with quick-fixes, new features and probably new bugs. It’s currently hosted on GitHub. To get the latest development version from GitHub, use the devtools package from CRAN and enter in R:

devtools::install_github('merliseclyde/BAS')

You can check out the current build status R-CMD-check before installing.

Installing the package from source does require compilation of C and FORTRAN code as the library makes use of BLAS and LAPACK for efficient model fitting. See CRAN manuals for installing packages from source under different operating systems.

Usage

To begin load the package:

library(BAS)

The two main function in BAS are bas.lm and bas.glm for implementing Bayesian Model Averaging and Variable Selection using Zellner’s g-prior and mixtures of g priors. Both functions have a syntax similar to the lm and glm functions respectively. We illustrate using BAS on a simple example with the famous Hald data set using the Zellner-Siow Cauchy prior via

data(Hald)
hald.ZS = bas.lm(Y ~ ., data=Hald, prior="ZS-null", modelprior=uniform(), method="BAS")

BAS has summary, plotcoef, predict and fitted functions like the lm/glm functions. Images of the model space highlighting which variable are important may be obtained via

image(hald.ZS)

Run demo("BAS.hald") or demo("BAS.USCrime") or see the package vignette for more examples and options such as using MCMC for model spaces that cannot be enumerated.

Generalized Linear Models

BAS now includes for support for binomial and binary regression, Poisson regression, and Gamma regression using Laplace approximations to obtain Bayes Factors used in calculating posterior probabilities of models or sampling of models. Here is an example using the Pima diabetes data set with the hyper-g/n prior:

library(MASS)
data(Pima.tr)
Pima.hgn = bas.glm(type ~ ., data=Pima.tr, method="BAS", family=binomial(),
                  betaprior=hyper.g.n(), modelprior=uniform())

Note, the syntax for specifying priors on the coefficients in bas.glm uses a function with arguments to specify the hyper-parameters, rather than a text string to specify the prior name and a separate argument for the hyper-parameters. bas.lm will be moving to this format sometime in the future.

Feature Requests and Issues

Feel free to report any issues or request features to be added via the github issues page.

For current documentation and vignettes see the BAS website

Support

This material is based upon work supported by the National Science Foundation under Grant DMS-1106891. Any opinions, findings, and conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of the National Science Foundation.

Metadata

Version

1.7.1

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • 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