Git Product home page Git Product logo

bang's Introduction

bang

AppVeyor Build Status R-CMD-check Coverage Status CRAN_Status_Badge Downloads (monthly) Downloads (total)

Bayesian Analysis, No Gibbs

What does bang do?

Provides functions for the Bayesian analysis of some simple commonly-used models, without using Markov Chain Monte Carlo (MCMC) methods such as Gibbs sampling. The β€˜rust’ package https://cran.r-project.org/package=rust is used to simulate a random sample from the required posterior distribution, using the ratio-of-uniforms method. Currently three conjugate hierarchical models are available: beta-binomial, gamma-Poisson and a 1-way Analysis of Variance (ANOVA). Advantages of the ratio-of-uniforms method over MCMC in this context are that the user is not required to set tuning parameters nor to monitor convergence and a random posterior sample is produced.

A simple example

The hef function samples from the posterior distribution of the parameters of certain hierarchical exponential family models. The following code performs essentially the same analysis of the rat tumor data using a beta-binomial hierarchical model that appears in Section 5.3 of Gelman, A., Carlin, J. B., Stern, H. S. Dunson, D. B., Vehtari, A. and Rubin, D. B. (2014) Bayesian Data Analysis. Chapman & Hall / CRC. http://www.stat.columbia.edu/~gelman/book/.

library(bang)
rat_res <- hef(model = "beta_binom", data = rat)
plot(rat_res)

Installation

To get the current released version from CRAN:

install.packages("bang")

bang's People

Contributors

paulnorthrop avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Forkers

aymanaamin

bang's Issues

Question on the posterior likelihood for (alpha,beta |y )

The posterior of alpha, beta i can derive to match the equation listed here (https://cran.r-project.org/web/packages/bang/vignettes/bang-b-hef-vignette.html)

the equation pi(a,b) i don't think corresponds to this equation described in the function 'gamma_pois_marginal_loglik '

could you clarify which likelihood is the gamma_pois_marginal_loglik' corresponding to ? (p(a,b | y) ?

if i derive the hyperparameter posterior on my end, the log like is in this form, which i'm not sure which likelihood is in this function
thanks for clarifying

 LP<-0
  for(i in 1:length(y)){
  LP <-LP+lgamma(a+y[i])+a*log(b) -lgamma(a)-(a+y[i])*log(b+x[i])
  }

question on the jacobian for log(a/b), log(b)

for p(u,v) = p(h1(u,v), h2(u,v)) |J( d(a,b)/du,v)|

where u = log(a/b), v= log(b) we would need to find the inverse functions of log(a,b) denoted here as h1(u,v), and h2(u,v) and then for the jacobian we need the partials of h1(u,v)/d(u,v) and similar for h2.

however because the derivatives of log(a/b) and log(b) are easier with respect to a,b as opposed to inverses, the jacobian d(u,v)/d(a,b) is 1/ab.

but we need to take the inverse of the jacobian = (ab)

which is what they did in the Gelman book equation 5.10 so the log of jacobian is log(a)+lob(b) but in yoru functions the jacobian is negative? why?

thank you!!!

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.