90 likes | 218 Vues
This guide introduces Markov Chain Monte Carlo (MCMC) methods, specifically focusing on Bayesian inference using BUGS (Bayesian inference Using Gibbs Sampling). MCMC allows for the approximation of complex posterior distributions through simulation techniques, overcoming challenges of exact computation in high-dimensional parameter spaces. While MCMC is powerful for various models, understanding convergence and output analysis is essential. This document provides step-by-step instructions on using BUGS, integrating it with R, and automating routines for practical inference and visualization.
E N D
Computational problems • More parameters -> even more parameter combinations • Exact computation and grid approximation become infeasible • The posterior distribution can be approximated faster by simulation techniques • Simulation: drawing random numbers from a distribution
Markov chain Monte Carlo • Draw random numbers from the posterior distribution • Each number depends on the previous one • Start from arbitrary value • Simulation “finds” the posterior distribution and provides random numbers from it • Advantage: very complex models can be analysed • Disadvantage: length of the searching phase is difficult to identify
Remarks • MCMC is only one way to approximate the posterior distribution. It is not a modeling approach itself! • There are other methods as well: • Importance sampling • Sampling- Importance –Resampling • Sequential Monte Carlo (particle filter) • etc. • MCMC usually easier to set up
BUGS • Bayesian Inference Using Gibbs Sampling • Gibbs sampling is one form of MCMC • User specifies the model structure • User inputs the data • Software uses Bayes’ theorem and constructs an MCMC algorithm to sample from the posterior • User assesses the convergence of MCMC • Use software to calculate descriptive statistics and produce figures
Using BUGS • Lots of pointing and clicking • Some time is needed to learn the procedure • Also a scripting language is available • Routine points and clicks can be automated • Useful once you know how to point and click • R interface • BUGS can be used from R by the same scripting language • Results are exported to R for further analysis
How to point and click • Follow these steps to specify a simple model and simulate the posterior distribution • Start BUGS : winbugs.exe • Create new document: File ->New • Write a model specification to the blank document: model{ x~dnorm(10,0.25) }
Running the simulation: • Model ->Specification… • Specification Tool: check model • [Activate the document or area that contains data] • [Specification tool: load data] • Specification tool: compile • [Activate the document or area that contains the set of initial values] • [Specification tool: load inits] • Specification tool: gen inits • Inference -> Samples… • Sample monitor tool: node : “x” • Sample monitor tool: set • Model -> Update… • Update tool: refresh: “1” • Update tool: update • Sample monitor tool: node: “x” • Sample monitor tool: history • Sample monitor tool: stats • Sample monitor tool: density