Introduction to WinBUGS Olivier Gimenez. A brief history  1989: project began with a Unix version called BUGS  1998: first Windows version, WinBUGS.

Slides:



Advertisements
Similar presentations
Model checking in mixture models via mixed predictive p-values Alex Lewin and Sylvia Richardson, Centre for Biostatistics, Imperial College, London Mixed.
Advertisements

Introduction to Monte Carlo Markov chain (MCMC) methods
Other MCMC features in MLwiN and the MLwiN->WinBUGS interface
NCeSS e-Stat quantitative node Prof. William Browne & Prof. Jon Rasbash University of Bristol.
Lecture #4: Bayesian analysis of mapped data Spatial statistics in practice Center for Tropical Ecology and Biodiversity, Tunghai University & Fushan Botanical.
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
Gibbs Sampling Qianji Zheng Oct. 5th, 2010.
2005 Hopkins Epi-Biostat Summer Institute1 Module 2: Bayesian Hierarchical Models Francesca Dominici Michael Griswold The Johns Hopkins University Bloomberg.
Bayesian statistics – MCMC techniques
Everything you ever wanted to know about BUGS, R2winBUGS, and Adaptive Rejection Sampling A Presentation by Keith Betts.
Department of Geography, Florida State University
Introduction to Bayesian Statistical Software: WinBUGS Beth Devine, PharmD, MBA, PhD Rafael Alfonso, MD, PhC Evidence Synthesis 9/22/2011 2:30 pm.
7. Bayesian phylogenetic analysis using MrBAYES UST Jeong Dageum Thomas Bayes( ) The Phylogenetic Handbook – Section III, Phylogenetic.
Modeling Menstrual Cycle Length in Pre- and Peri-Menopausal Women Michael Elliott Xiaobi Huang Sioban Harlow University of Michigan School of Public Health.
FW364 Ecological Problem Solving Lab 4: Blue Whale Population Variation [Ramas Lab]
2006 Hopkins Epi-Biostat Summer Institute1 Module 2: Bayesian Hierarchical Models Instructor: Elizabeth Johnson Course Developed: Francesca Dominici and.
Bayesian parameter estimation in cosmology with Population Monte Carlo By Darell Moodley (UKZN) Supervisor: Prof. K Moodley (UKZN) SKA Postgraduate conference,
Introduction to MCMC and BUGS. Computational problems More parameters -> even more parameter combinations Exact computation and grid approximation become.
Priors, Normal Models, Computing Posteriors
A Beginner’s Guide to Bayesian Modelling Peter England, PhD EMB GIRO 2002.
2 nd Order CFA Byrne Chapter 5. 2 nd Order Models The idea of a 2 nd order model (sometimes called a bi-factor model) is: – You have some latent variables.
WinBUGS Demo Saghir A. Bashir Amgen Ltd, Cambridge, U.K. 4 th January 2001.
1 Develop a Tool for Therapeutic Drug Monitoring in R Using OpenBUGS Speaker: Miao-ting Chen 1, M.S. Mentor: Yung-jin Lee 2 1 Department of Hospital Pharmacy,
R2WinBUGS: Using R for Bayesian Analysis Matthew Russell Rongxia Li 2 November Northeastern Mensurationists Meeting.
Department of SOCIAL MEDICINE Producing Small Area Estimates of the Need for Hip and Knee Replacement Surgery ANDY JUDGE Nicky Welton Mary Shaw Yoav Ben-Shlomo.
Active-HDL Interfaces Debugging C Code Course 10.
1 Gil McVean Tuesday 24 th February 2009 Markov Chain Monte Carlo.
Downloading and Installing Autodesk Revit 2016
Multilevel Modeling Software Wayne Osgood Crime, Law & Justice Program Department of Sociology.
An Application of Bayesian Analysis in Forecasting Insurance Loss Payments Yanwei (Wayne) Zhang CAS annual meeting 2010 Washington DC Nov 9th, 2010.
Stat 112: Notes 2 Today’s class: Section 3.3. –Full description of simple linear regression model. –Checking the assumptions of the simple linear regression.
Downloading and Installing Autodesk Inventor Professional 2015 This is a 4 step process 1.Register with the Autodesk Student Community 2.Downloading the.
“Users of scooters must transfer to a fixed seat” (Notice in Brisbane Taxi)
WFM 6311: Climate Risk Management © Dr. Akm Saiful Islam WFM 6311: Climate Change Risk Management Akm Saiful Islam Lecture-7:Extereme Climate Indicators.
1 Getting Started with C++. 2 Objective You will be able to create, compile, and run a very simple C++ program on Windows, using Visual Studio 2008.
1 / 61 Using the Customer Support Web Site © 2006, Universal Tax Systems, Inc. All Rights Reserved. Customer Support Site Objectives –In this chapter you.
Tool Install How to download & install Java 6 & Eclipse updated version based on Dr. G. L. Ray’s slides.
Latent Class Regression Model Graphical Diagnostics Using an MCMC Estimation Procedure Elizabeth S. Garrett Scott L. Zeger Johns Hopkins University
1 Econometrics (NA1031) Lecture 1 Introduction. 2 ”How much” type questions oBy how much a unit change in income affects consumption? oBy how much should.
Multi-level Models Summer Institute 2005 Francesca Dominici Michael Griswold The Johns Hopkins University Bloomberg School of Public Health.
1 Francisco José Vázquez Polo [ Miguel Ángel Negrín Hernández [ {fjvpolo or
The Diagnostic Pathfinder System Introduction Getting Started.
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.
Bayesian Travel Time Reliability
Item Parameter Estimation: Does WinBUGS Do Better Than BILOG-MG?
1 Chapter 8: Model Inference and Averaging Presented by Hui Fang.
The Unscented Particle Filter 2000/09/29 이 시은. Introduction Filtering –estimate the states(parameters or hidden variable) as a set of observations becomes.
Bayesian Modelling Harry R. Erwin, PhD School of Computing and Technology University of Sunderland.
1 Getting started with WinBUGS Mei LU Graduate Research Assistant Dept. of Epidemiology, MD Anderson Cancer Center Some material was taken from James and.
Anders Nielsen Technical University of Denmark, DTU-Aqua Mark Maunder Inter-American Tropical Tuna Commission An Introduction.
Active-HDL Server Farm Course 11. All materials updated on: September 30, 2004 Outline 1.Introduction 2.Advantages 3.Requirements 4.Installation 5.Architecture.
Bootstrapping James G. Anderson, Ph.D. Purdue University.
Density Estimation in R Ha Le and Nikolaos Sarafianos COSC 7362 – Advanced Machine Learning Professor: Dr. Christoph F. Eick 1.
Jump to first page Bayesian Approach FOR MIXED MODEL Bioep740 Final Paper Presentation By Qiang Ling.
How many iterations in the Gibbs sampler? Adrian E. Raftery and Steven Lewis (September, 1991) Duke University Machine Learning Group Presented by Iulian.
Bursts modelling Using WinBUGS Tim Watson May 2012 :diagnostics/ :transformation/ :investment planning/ :portfolio optimisation/ :investment economics/
Hierarchical Models. Conceptual: What are we talking about? – What makes a statistical model hierarchical? – How does that fit into population analysis?
Generalization Performance of Exchange Monte Carlo Method for Normal Mixture Models Kenji Nagata, Sumio Watanabe Tokyo Institute of Technology.
Markov Chain Monte Carlo in R
Chapter 13 Simple Linear Regression
Module 2: Bayesian Hierarchical Models
MCMC Stopping and Variance Estimation: Idea here is to first use multiple Chains from different initial conditions to determine a burn-in period so the.
IMa2(Isolation with Migration)
Introducing Bayesian Approaches to Twin Data Analysis
Introduction to the bayes Prefix in Stata 15
Markov Chain Monte Carlo
Course on Bayesian Methods in Environmental Valuation
Bayesian Networks in Educational Assessment
Presentation transcript:

Introduction to WinBUGS Olivier Gimenez

A brief history  1989: project began with a Unix version called BUGS  1998: first Windows version, WinBUGS was born  Initially developed by the MRC Biostatistics Unit in Cambridge and now joint work with Imperial College School of Medicine at St Mary's, London.  Windows Bayesian inference Using Gibbs Sampling  Software for the Bayesian analysis of complex statistical models using Markov chain Monte Carlo (MCMC) methods

Nicky Best Imperial College Faculty of Medicine, London (UK) Thomas Andrew University of Helsinki, Helsinki (Finland) David Spiegelhalter MRC Biostatistics Unit Institute of Public Health Cambridge (UK) Wally Gilks MRC Biostatistics Unit Institute of Public Health Cambridge (UK) Who?

How to obtain and install WinBUGS 1.downloadable from: (... see section Obtaining the File to download WinBUGS14.exe ) 2.to install WinBUGS: Exit all other programs currently running (particularly if using Windows XP); Copy WinBUGS14.exe to your computer; Double click on WinBUGS14.exe and follow the instructions in the dialog box; You should have a new directory called WinBUGS14 within Program Files; Inside the WinBUGS14 directory is a program called WinBUGS14.exe; Right-click on the pretty WinBUGS icon, select `create shortcut', then drag this shortcut to the desktop; Double click on WinBUGS14.exe to run WinBUGS14.

How to obtain and install WinBUGS  To obtain the key for unrestricted use: Fill in the registration form ~1h later, you will receive an from Bugs with subject WinBUGS registration - AUTOMATIC RESPONSE! Follow the instructions...  Congratulations, you're ready to use WinBUGS

Principle  You specify the prior and build up the likelihood  WinBUGS computes the posterior by running a Gibbs sampling algorithm, based on: (|D) / L(D|) ()  WinBUGS computes some convergence diagnostics that you have to check

Demographic components (fecundity, breeding success, survival, etc…) A biological example throughout White stork (Ciconia ciconia) in Alsace Climate (Temperature, rainfall, etc…)

WinBUGS & Linear Regression Y Number of chicks per pairs T Temp. May (°C) R Rainf. May (mm)

1. Do temperature and rainfall affect the number of chicks? Y i =  +  r R i +  t T i +  i, i=1,...,23  i i.i.d. ~ N(0, 2 ) 2. Regression model: 3. Estimation of parameters: ,  r,  t,  4. Frequentist inference uses t-tests Y i i.i.d. ~ N( i, 2 ), i=1,...,23  i =  +  r R i +  t T i WinBUGS & Linear Regression

Y Number of chicks per pairs T Temp. May (°C) R Rainf. May (mm) EstimateStd. Error t value Pr(>|t|) temperature rainfall * Linear Regression using Frequentist approach Y = T R

Y Number of chicks per pairs T Temp. May (°C) R Rainf. May (mm) Linear Regression using Frequentist approach  Influence of Rainfall only EstimateStd. Error t value Pr(>|t|) temperature rainfall * Y = T R

Running WinBUGS What do you need? 1 - a model giving the likelihood and the priors 2 - some data of course3 - initial values to start the MCMC algorithm

Running WinBUGS The model use the WinBUGS command 'model' don't forget to embrace the model with {...} Define the likelihood... Y i ~ N( +  r R i +  t T i, 2 ) Note:  2 = 1/ Specify the priors We use noninformative or vague or flat priors here Monitor any other parameter you'd like to... e.g.  2 = 1/

Running WinBUGS Data and initial values Use 'list' structures (R/Splus syntax)......and 'vector' structures (R/Splus syntax)

Running WinBUGS Overall 1 - a model giving the likelihood and the priors 2 - data3 - initial values

1- check model 2- load data 3- compile model 4- load initial values 5- generate burn-in values 6- parameters to be monitored 7- perform the sampling to generate posteriors 8- check convergence and display results Running WinBUGS At last!!

Running WinBUGS 1. Check model

Running WinBUGS 1. Check model: highlight 'model'

Running WinBUGS 1. Check model: open the Model Specification Tool

Running WinBUGS 1. Check model: Now click 'check model'

Running WinBUGS 1. Check model: Watch out for the confirmation at the foot of the screen

Running WinBUGS 2. Load data: Now highlight the 'list' in the data window

Running WinBUGS 2. Load data: then click 'load data'

Running WinBUGS 2. Load data: watch out for the confirmation at the foot of the screen

Running WinBUGS 3. Compile model: Next, click 'compile'

Running WinBUGS 3. Compile model: watch out for the confirmation at the foot of the screen

Running WinBUGS 4. Load initial values: highlight the 'list' in the data window

Running WinBUGS 4. Load initial values: click 'load inits'

Running WinBUGS 4. Load initial values: watch out for the confirmation at the foot of the screen

Running WinBUGS 5. Generate Burn-in values: Open the Model Update Tool

Running WinBUGS 5. Generate Burn-in values: Give the number of burn-in iterations (1000)

Running WinBUGS 5. Generate Burn-in values: click 'update' to do the sampling

Running WinBUGS 6. Monitor parameters: open the Inference Samples Tool

Running WinBUGS 6. Monitor parameters: Enter 'intercept' in the node box and click 'set'

Running WinBUGS 6. Monitor parameters: Enter 'slope_temperature' in the node box and click 'set'

Running WinBUGS 6. Monitor parameters: Enter 'slope_rainfall' in the node box and click 'set'

Running WinBUGS 7. Generate posterior values: enter the number of samples you want to take (10000)

Running WinBUGS 7. Generate posterior values: click 'update' to do the sampling

Running WinBUGS 8. Summarize posteriors: Enter '*' in the node box and click 'stats'

Running WinBUGS 8. Summarize posteriors: mean, median and credible intervals

Running WinBUGS 8. Summarize posteriors: 95% Credible intervals tell us the same story EstimateStd. Error t value Pr(>|t|) temperature rainfall *

Running WinBUGS 8. Summarize posteriors: 95% Credible intervals tell us the same story EstimateStd. Error t value Pr(>|t|) temperature rainfall *

Running WinBUGS 8. Summarize posteriors: click 'history'

Running WinBUGS 8. Summarize posteriors: click 'auto cor'  Problem of autocorrelation

Coping with autocorrelation use standardized covariates

Coping with autocorrelation use standardized covariates

Re-running WinBUGS 1,2,...7, and 8. Summarize posteriors: click 'auto cor'  autocorrelation OK

Re-running WinBUGS 1,2,...7, and 8. Summarize posteriors: click 'density'

Re-running WinBUGS 1,2,...7, and 8. Summarize posteriors: click 'quantiles'

Running WinBUGS 8. Checking for convergence using the Brooks-Gelman-Rubin criterion A way to identify non-convergence is to simulate multiple sequences for over-dispersed starting points Intuitively, the behaviour of all of the chains should be basically the same. In other words, the variance within the chains should be the same as the variance across the chains. In WinBUGS, stipulate the number of chains after 'load data' and before 'compile' (obviously, as many sets of initial values as chains have to be loaded, or generated)

Running WinBUGS 8. Checking for convergence using the Brooks-Gelman-Rubin criterion The normalized width of the central 80% interval of the pooled runs is green The normalized average width of the 80% intervals within the individual runs is blue

Re-running WinBUGS 1,2,...7, and 8. Summarize posteriors: others... Click 'coda' to produce lists of data suitable for external treatment via the Coda R package Click 'trace' to produce dynamic history changing in real time

/ / / / / / / / / / / / / / / / / / / / / / / 23 Another example: logistic regression Y Proportion of nests with success (>0 youngs) T Temp. May (°C) R Rainf. May (mm)

Performing a logistic regression with WinBUGS

model # succ. in year i ~ Bin(p i, total # couples in year i) where p i the probability of success in year i logit(p i )= +  r R i +  t T i, i=1,...,23 Performing a logistic regression with WinBUGS

noninformative priors Performing a logistic regression with WinBUGS

data & initial values Performing a logistic regression with WinBUGS

the results influence of rainfall, but not temperature (see credible intervals) lowerupper

additional parameters as a by-product of the MCMC samples: just add them in the model as parameters to be monitored - geometric mean: geom <- pow(prod(p[]),1/N) - odds-ratio: odds.rainfall <- exp(slope.rainfall) odds.temperature <- exp(slope.temperature) Performing a logistic regression with WinBUGS the results

additional parameters as a by-product of the MCMC samples - geom. mean probability of success around 82% [81%;84%] - odds-ratio: -16% for an increase of rainfall of 1 unit Performing a logistic regression with WinBUGS the results

Climatic conditions affect survival in the wild a) European dippers in Eastern France ( ) Practical session 1 Estimating survival using capture-recapture models CJS model: time-dependent survival and detection rates Case study a): A flood occured in the 1983 breeding season so that survival rates are expected to differ between flood ( f ) and non-flood ( n ) years  use constraints to estimate parameters  f and  n

Climatic conditions affect survival in the wild b) Lapwings in UK ( ) Practical session 2 Estimating survival using ring-recovery models Case study b): Number of days that the mean temperature is below freezing in central England (fdays) is expected to affect Lapwings survival  use fdays as a covariate Strong assumption: variation in survival is totally explained by the covariate alone  incorporate random effects