Giter Club home page Giter Club logo

bas's Introduction

The BAS R 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. These have been shown to be consistent and have a number of computational advantages. BAS implements two main algorithms for sampling from the space of potential models: an adaptive sampling without replacement algorithm and a MCMC algorithm that utilizes swapping to escape from local modes.

Some CRAN statistics:

DOI version v1.4.2 DOI

Rdocumentation Rdoc

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 and test coverage status courtesy Travis CI: 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, plot coef, 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 and poisson 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 syntac for specifying priors on the coefficients in bas.glm uses a function with arguments to specify the hyperparameters, rather than a text string to specify the prior name and a separate argument for the hyperpameters. 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 page.

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.

bas's People

Contributors

merliseclyde avatar akashrajkn avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.