Everything you ever wanted to know about BUGS, R2winBUGS, and Adaptive Rejection Sampling A Presentation by Keith Betts.

Slides:



Advertisements
Similar presentations
Generalised linear mixed models in WinBUGS
Advertisements

Introduction to Monte Carlo Markov chain (MCMC) methods
Other MCMC features in MLwiN and the MLwiN->WinBUGS interface
Probabilistic models Jouni Tuomisto THL. Outline Deterministic models with probabilistic parameters Hierarchical Bayesian models Bayesian belief nets.
Slice Sampling Radford M. Neal The Annals of Statistics (Vol. 31, No. 3, 2003)
Markov Chain Monte Carlo Convergence Diagnostics: A Comparative Review By Mary Kathryn Cowles and Bradley P. Carlin Presented by Yuting Qi 12/01/2006.
Bayesian Estimation in MARK
By Addison Euhus, Guidance by Edward Phillips An Introduction To Uncertainty Quantification.
An Introduction to LDA Tools Kuan-Yu Chen Institute of Information Science, Academia Sinica.
Markov-Chain Monte Carlo
1 Graphical Diagnostic Tools for Evaluating Latent Class Models: An Application to Depression in the ECA Study Elizabeth S. Garrett Department of Biostatistics.
CHAPTER 16 MARKOV CHAIN MONTE CARLO
Bayesian statistics – MCMC techniques
Stochastic approximate inference Kay H. Brodersen Computational Neuroeconomics Group Department of Economics University of Zurich Machine Learning and.
BAYESIAN INFERENCE Sampling techniques
Industrial Engineering College of Engineering Bayesian Kernel Methods for Binary Classification and Online Learning Problems Theodore Trafalis Workshop.
1 Vertically Integrated Seismic Analysis Stuart Russell Computer Science Division, UC Berkeley Nimar Arora, Erik Sudderth, Nick Hay.
Computing the Posterior Probability The posterior probability distribution contains the complete information concerning the parameters, but need often.
. PGM: Tirgul 8 Markov Chains. Stochastic Sampling  In previous class, we examined methods that use independent samples to estimate P(X = x |e ) Problem:
Using ranking and DCE data to value health states on the QALY scale using conventional and Bayesian methods Theresa Cain.
Applied Bayesian Analysis for the Social Sciences Philip Pendergast Computing and Research Services Department of Sociology
Computer vision: models, learning and inference Chapter 10 Graphical Models.
Computer vision: models, learning and inference
Bayesian Analysis for Extreme Events Pao-Shin Chu and Xin Zhao Department of Meteorology School of Ocean & Earth Science & Technology University of Hawaii-
1 More BUGS James B. Elsner Department of Geography, Florida State University “You can, for example, never foretell what any one man will do, but you can.
Department of Geography, Florida State University
Binary Variables (1) Coin flipping: heads=1, tails=0 Bernoulli Distribution.
Bayes Factor Based on Han and Carlin (2001, JASA).
Introduction to WinBUGS Olivier Gimenez. A brief history  1989: project began with a Unix version called BUGS  1998: first Windows version, WinBUGS.
Introduction to MCMC and BUGS. Computational problems More parameters -> even more parameter combinations Exact computation and grid approximation become.
WinBUGS Demo Saghir A. Bashir Amgen Ltd, Cambridge, U.K. 4 th January 2001.
R2WinBUGS: Using R for Bayesian Analysis Matthew Russell Rongxia Li 2 November Northeastern Mensurationists Meeting.
Finding Scientific topics August , Topic Modeling 1.A document as a probabilistic mixture of topics. 2.A topic as a probability distribution.
1 Gil McVean Tuesday 24 th February 2009 Markov Chain Monte Carlo.
Mixture Models, Monte Carlo, Bayesian Updating and Dynamic Models Mike West Computing Science and Statistics, Vol. 24, pp , 1993.
Fast Simulators for Assessment and Propagation of Model Uncertainty* Jim Berger, M.J. Bayarri, German Molina June 20, 2001 SAMO 2001, Madrid *Project of.
Integrating Topics and Syntax -Thomas L
Suppressing Random Walks in Markov Chain Monte Carlo Using Ordered Overrelaxation Radford M. Neal 발표자 : 장 정 호.
1 Francisco José Vázquez Polo [ Miguel Ángel Negrín Hernández [ {fjvpolo or
Latent Class Regression Model Graphical Diagnostics Using an MCMC Estimation Procedure Elizabeth S. Garrett Scott L. Zeger Johns Hopkins University
Bayesian Hierarchical Modeling for Longitudinal Frequency Data Joseph Jordan Advisor: John C. Kern II Department of Mathematics and Computer Science Duquesne.
MCMC in practice Start collecting samples after the Markov chain has “mixed”. How do you know if a chain has mixed or not? In general, you can never “proof”
Bayesian Prior and Posterior Study Guide for ES205 Yu-Chi Ho Jonathan T. Lee Nov. 24, 2000.
1 Francisco José Vázquez Polo [ Miguel Ángel Negrín Hernández [ {fjvpolo or
An Introduction to Markov Chain Monte Carlo Teg Grenager July 1, 2004.
Probabilistic models Jouni Tuomisto THL. Outline Deterministic models with probabilistic parameters Hierarchical Bayesian models Bayesian belief nets.
Markov Chain Monte Carlo for LDA C. Andrieu, N. D. Freitas, and A. Doucet, An Introduction to MCMC for Machine Learning, R. M. Neal, Probabilistic.
Lecture #9: Introduction to Markov Chain Monte Carlo, part 3
Reducing MCMC Computational Cost With a Two Layered Bayesian Approach
1 Chapter 8: Model Inference and Averaging Presented by Hui Fang.
CS Statistical Machine learning Lecture 25 Yuan (Alan) Qi Purdue CS Nov
An Iterative Monte Carlo Method for Nonconjugate Bayesian Analysis B. P. Carlin and A. E. Gelfand Statistics and Computing 1991 A Generic Approach to Posterior.
1 Getting started with WinBUGS Mei LU Graduate Research Assistant Dept. of Epidemiology, MD Anderson Cancer Center Some material was taken from James and.
CSC321: Introduction to Neural Networks and Machine Learning Lecture 17: Boltzmann Machines as Probabilistic Models Geoffrey Hinton.
Kevin Stevenson AST 4762/5765. What is MCMC?  Random sampling algorithm  Estimates model parameters and their uncertainty  Only samples regions of.
Density Estimation in R Ha Le and Nikolaos Sarafianos COSC 7362 – Advanced Machine Learning Professor: Dr. Christoph F. Eick 1.
JAGS. Learning Objectives Be able to represent ecological systems as a network of known and unknowns linked by deterministic and stochastic relationships.
Hierarchical models. Hierarchical with respect to Response being modeled – Outliers – Zeros Parameters in the model – Trends (Us) – Interactions (Bs)
Bursts modelling Using WinBUGS Tim Watson May 2012 :diagnostics/ :transformation/ :investment planning/ :portfolio optimisation/ :investment economics/
Generalization Performance of Exchange Monte Carlo Method for Normal Mixture Models Kenji Nagata, Sumio Watanabe Tokyo Institute of Technology.
Introduction to Sampling based inference and MCMC
MCMC Output & Metropolis-Hastings Algorithm Part I
Advanced Statistical Computing Fall 2016
Intelligent Systems (AI-2) Computer Science cpsc422, Lecture 12
Introduction to the bayes Prefix in Stata 15
Predictive distributions
Course on Bayesian Methods in Environmental Valuation
Intelligent Systems (AI-2) Computer Science cpsc422, Lecture 12
Instructors: Fei Fang (This Lecture) and Dave Touretzky
Markov Networks.
Presentation transcript:

Everything you ever wanted to know about BUGS, R2winBUGS, and Adaptive Rejection Sampling A Presentation by Keith Betts

About BUGS Bayesian analysis Using Gibbs Sampling Developed by UK Medical Research Council and the Imperial College of Science, Technology and Medicine, London.

Why Use BUGS Sophisticated implementation of Markov Chain Monte Carlo for any given model No derivation required Useful for double-checking hand coded results Great for problems with no exact analytic solution

What does every BUGS file need? Model  Specify the Likelihood and Prior distributions Data  External data in either rectangular array or as R data type Initial Values  Starting values for MCMC parameters

Model a syntactical representation of the model, in which the distributional form of the data and parameters are specified. ~ assigns distributions <- assigns relations for loops to assign i.i.d. data.

Distributions Syntax can be found in User Manual, under Distributions Parameterization may be different than in R  dnorm(μ,τ), τ is the precision (not the standard deviation).

Data Place Data and Global variables in one list file Vectors represented just as in R, c(.,.) Matrices require structure command

Initial Values User requested initial values can be supplied for multiple chains Put starting values for all variables in one list statement BUGS can generate its own starting values

How to run Place your Model, Data, and Initial Values in one file. Open “Specification” from the model menu  Highlight “model” statement  Click “Check Model”  Highlight “list” in Data section  Click “Load Data”

How to run continued Still in Model Specification  Click Compile  Choose how many chains to run  Highlight “list” in initial values section  Click “load inits”  Alternatively click “gen inits”

How to run (Part 3) Open “Samples” from “Inference” menu  Enter all variables of interest (one at a time) into node box, and click “set Open “Update” from “Model” menu  Enter how many iterations wanted

Inference Open “Samples” from “Inference” Menu  Enter * in node box  Click “History” to view Trace plots  Click “Density” for density plots  Click “Stats” for summary statistics  Change value of “beg” for burnout

Example 1 Poisson-Gamma Model  Data: # of Failures in power plant pumps  Model # of Failures follows Poisson(θ i t i ) θ i failure rate follows Gamma(α, β) Prior for α is Exp(1) Prior for β is Gamma(.1, 1)

Example 1 Continued: Computational Issues  Gamma is natural conjugate for Poisson distribution  Posterior for β follows Gamma  Non-standard Posterior for α

Model Step model { for (i in 1 : N) { theta[i] ~ dgamma(alpha, beta) lambda[i] <- theta[i] * t[i] x[i] ~ dpois(lambda[i]) } alpha ~ dexp(1) beta ~ dgamma(0.1, 1.0) }

Data Step and Initial Values Data:  list(t = c(94.3, 15.7, 62.9, 126, 5.24, 31.4, 1.05, 1.05, 2.1, 10.5), x = c(5, 1, 5,14, 3, 19, 1, 1, 4, 22), N = 10) Initial Values:  list(alpha = 1, beta = 1)

Example 2 Data: 30 young rats whose weights were measured weekly for five weeks. Yij is the weight of the ith rat measured at age xj. Assume a random effects linear growth curve model

Example 2: Model model { for( i in 1 : N ) { for( j in 1 : J ) { mu[i, j] <- alpha[i] + beta[i] * (t[j] - tbar) Y[i, j] ~ dnorm(mu[i, j], sigma.y) } alpha[i] ~ dnorm(mu.alpha, sigma.alpha) beta[i] ~ dnorm(mu.beta, sigma.beta) } sigma.y ~ dgamma(0.001,0.001) mu.alpha ~ dunif( -1.0E9,1.0E9) sigma.alpha ~ dgamma(0.001,0.001) mu.beta ~ dunif(-1.0E9,1.0E9) sigma.beta ~ dgamma(0.001,0.001) }

R2winBUGS R package Runs BUGS through R Same computational advantages of BUGS with statistical and graphical capacities of R.

Make Model file Model file required  Must contain BUGS syntax  Can either be written in advance or by R itself through the write.model() function

Initialize Both data and Initial values stored as lists Create param vector with names of parameters to be tracked

Run bugs(datafile, initial.vals, parameters, modelfile, n.chains=1, n.iter=5000, n.burnin=2000, n.thin=1, bugs.directory="c:/Program Files/WinBUGS14/", working.directory=NULL) Extract results from $sims.matrix

How BUGS works BUGS determines the complete conditionals if possible by:  Closed form distributions  Adaptive-Rejection Sampling  Slice-Sampling  Metropolis Algorithm

Recall Rejection Sampling

Adaptive Rejection Sampling(ARS) ARS is a method for efficiently sampling from any univariate probability density function which is log-concave. Useful in applications of Gibbs sampling, where full-conditional distributions are algebraically messy yet often log-concave

Idea ARS works by constructing an envelope function of the log of the target density  Envelope used for rejection sampling Whenever a point is rejected by ARS, the envelope is updated to correspond more closely to the true log density.  reduces the chance of rejecting subsequent points

Results As the envelope function adapts to the shape of the target density, sampling becomes progressively more efficient as more points are sampled from the target density. The sampled points will be independent from the exact target density.

References W. R. Gilks, P. Wild (1992), "Adaptive Rejection Sampling for Gibbs Sampling," Applied Statistics, Vol. 41, Issue 2,