WinBUGS Demo Saghir A. Bashir Amgen Ltd, Cambridge, U.K. 4 th January 2001.

Slides:



Advertisements
Similar presentations
Introduction to Monte Carlo Markov chain (MCMC) methods
Advertisements

Other MCMC features in MLwiN and the MLwiN->WinBUGS interface
Microsoft Word for the Mac Tricia Sharkey & Nick Kozin C.A.S.E. Assistive Technology.
Basics of Biostatistics for Health Research Session 2 – February 14 th, 2013 Dr. Scott Patten, Professor of Epidemiology Department of Community Health.
Probabilistic models Jouni Tuomisto THL. Outline Deterministic models with probabilistic parameters Hierarchical Bayesian models Bayesian belief nets.
Welcome to Amsterdam!. Bayesian Modeling for Cognitive Science: A WinBUGS Workshop.
Loading Excel Double click the Excel icon on the desktop (if you have this) OR Click on Start All Programs Microsoft Office Microsoft Office Excel 2003.
Windows XP Basics OVERVIEW Next.
Gibbs Sampling Qianji Zheng Oct. 5th, 2010.
GRAPHICAL DESCRIPTIVE STATISTICS FOR QUANTITATIVE DATA.
Drinks Bottle Using CREO DEVELOPMENT
Computer Basics. Using a computer The purpose of this class is to get comfortable with: Using Windows.
1 An Introduction to IBM SPSS PSY450 Experimental Psychology Dr. Dwight Hennessy.
T T Population Sampling Distribution Purpose Allows the analyst to determine the mean and standard deviation of a sampling distribution.
A Simple Guide to Using SPSS© for Windows
Introduction to Spreadsheets Presented by Frank H. Osborne, Ph. D. © 2005 Bio 2900 Computer Applications in Biology.
Computer vision: models, learning and inference Chapter 10 Graphical Models.
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.
EViews. Agenda Introduction EViews files and data Examining the data Estimating equations.
Department of Geography, Florida State University
What is so good about Archie and RevMan 5
InDesign CS3 Lessons 1 and 2. Work Area When First Opened.
Overview G. Jogesh Babu. Probability theory Probability is all about flip of a coin Conditional probability & Bayes theorem (Bayesian analysis) Expectation,
Frequency Distributions, Histograms, and Related Topics.
Introduction to Excel, Word and Powerpoint Developing Valuable Technology Skills! Shawn Koppenhoefer Training in Research in Reproductive Health/Sexual.
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.
Objectives Understand what MATLAB is and why it is widely used in engineering and science Start the MATLAB program and solve simple problems in the command.
 Starting Excel 2003  Using Help  Workbook Management  Cursor Management  Manipulating Data  Using Formulae and Functions  Formatting Spreadsheet.
Chapter Three The UNIX Editors. 2 Lesson A The vi Editor.
Setting Up an on-line Store Tutorial Using SmartStore.biz This Tutorial assumes you have downloaded the software from This Tutorial.
CPG 4331 Class Agenda Word  Getting Started  Editing Documents  Changing Views in Documents  Format Text / Format Documents  Work With Tables  Work.
Introduction to Computers and Windows. Overview  What is a computer?  What is an operating system?  Starting and Shutting Down a computer  The mouse.
2 Syntax of Bayesian networks Semantics of Bayesian networks Efficient representation of conditional distributions Exact inference by enumeration Exact.
1 SMU EMIS 7364 NTU TO-570-N Inferences About Process Quality Updated: 2/3/04 Statistical Quality Control Dr. Jerrell T. Stracener, SAE Fellow.
Multilevel Modeling Software Wayne Osgood Crime, Law & Justice Program Department of Sociology.
PowerPoint Basics Tutorial 4: Interactivity & Media PowerPoint can communicate with the outside world by linking to different applications, managing different.
Chapter 4 Working with Frames. Align and distribute objects on a page Stack and layer objects Work with graphics frames Work with text frames Chapter.
Chapter Three The UNIX Editors.
1 Francisco José Vázquez Polo [ Miguel Ángel Negrín Hernández [ {fjvpolo or
1.Introduction to SPSS By: MHM. Nafas At HARDY ATI For HNDT Agriculture.
© 2011 Delmar, Cengage Learning Chapter 4 Working with Frames.
Probabilistic models Jouni Tuomisto THL. Outline Deterministic models with probabilistic parameters Hierarchical Bayesian models Bayesian belief nets.
ESD.70J Engineering Economy Module - Session 21 ESD.70J Engineering Economy Fall 2010 Session Two Xin Zhang – Prof. Richard de Neufville.
2D Design – A Guide! SECTION 1.
1 Chapter 8: Model Inference and Averaging Presented by Hui Fang.
Chapter 3 Graphs and Charts. Agenda Chart Object linking and embedding.
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.
LET’S PLAY JEOPARDY!! How to Measuring Final JeopardyJeopardy.
Please open JCreator and follow these steps: 1)Configure  Options 2)JDK Tools 3)Choose Run Applet from drop-down 4)Click Default, then Edit 5)Click the.
1 Sobah Abbas Petersen Adjunct Associate Professor TDT4252 Modelling of Information Systems Advanced Course Lecture 4: Introduction to.
>>0 >>1 >> 2 >> 3 >> 4 >>
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?
Fundamentals of Windows Mouse n 4 Basic Operations: –Pointing –Clicking –Double Clicking –Dragging.
Probability and Statistics
MCMC Output & Metropolis-Hastings Algorithm Part I
Release Numbers MATLAB is updated regularly
Introducing Bayesian Approaches to Twin Data Analysis
Guide To UNIX Using Linux Third Edition
European Computer Driving Licence
Markov Networks.
Course on Bayesian Methods in Environmental Valuation
1. Open Visual Studio 2008.
Ch13 Empirical Methods.
Otasuke GP-EX! Chapter 2 Run State Screen.
Presentation transcript:

WinBUGS Demo Saghir A. Bashir Amgen Ltd, Cambridge, U.K. 4 th January 2001

Outline  Introduction  BUGS and WinBUGS  Graphical Models  DoodleBUGS  Example - Simulation  Power calculation  Summary

Introduction  Bayesian Inference Using Gibbs Sampling BUGSBUGS  Analysis of Complex Models  Bayesian Methods  Markov Chain Monte Carlo Integration Useful when no closed form existsUseful when no closed form exists

Classic BUGS  Declarative Language Similar to SplusSimilar to Splus  Complex Statistical Models Missing dataMissing data Measurement ErrorMeasurement Error No closed form for LikelihoodNo closed form for Likelihood  Graphical Modelling  Flexible compared to approximations

WinBUGS  Similar to Classic BUGS Plus new methodological developmentsPlus new methodological developments  Graphical representation of model DoodleBUGSDoodleBUGS  Menu Control of session  Cut and paste to other packages

BUGS and WinBUGS  No data management facility Why reinvent the wheel?Why reinvent the wheel?  “Easy” interface with other packages R and SplusR and Splus Stata (S. Bashir)Stata (S. Bashir)  Simple analysis of output

Working with BUGS Output Analysis Output Analysis R/Splus STATA Prepare Data Prepare Data Editor Stats package Spread sheet BUGS Analysis BUGS Analysis WinBUGS BUGS

Graphical Models  Complex multivariate probability models RepresentationRepresentation VisualisationVisualisation  Graphs... simplify complex modelssimplify complex models communicate structure of the problemcommunicate structure of the problem provide basis for computationprovide basis for computation

WinBUGS  BUGS language  DoodleBUGS Used for the purposed of this Demo.Used for the purposed of this Demo.  WinBUGS is currently free from: Register to get full version accessRegister to get full version access

DoodleBUGS  Start WinBUGS  Select “Doodle” from menu bar

DoodleBUGS - Basics  Select “New…”  Press “ok”  You have a window to “Doodle” in.

Nodes  Creating a node Mouse click in Doodle WindowMouse click in Doodle Window  Deleting a node: CTRL + Del

 Nodes can be StochasticStochastic LogicalLogical Constant (rectangle)Constant (rectangle) Node Types

Example - Simulation  Let r1 ~ Bin (0.25, 250)r1 ~ Bin (0.25, 250) r2 ~ Bin (0.35, 150)r2 ~ Bin (0.35, 150)  Calculate p: common proportion for r1 & r2  p = (r1+r2)/400  Classical p =

DoodleBUGS  Start with r1 ~ Bin(0.25, 250) (stochastic node)

DoodleBUGS  Add r2 ~ Bin(0.35, 150) (stochastic node)

Logical Nodes  Add p as a logical node To define a logical node click on “type” for choices.To define a logical node click on “type” for choices.

Logical Functions  Add “edges” for the logical relationship Whilst node p is highlighted, CTRL + click in “parent nodes” r1 and r2 (hollow arrows  logical function)Whilst node p is highlighted, CTRL + click in “parent nodes” r1 and r2 (hollow arrows  logical function)

Stochastic Nodes  Stochastic dependence p1 ~ N(0.25, )(i.e., p1 ~ [0.24, 0.26])p1 ~ N(0.25, )(i.e., p1 ~ [0.24, 0.26]) size1 = 250 (constant)size1 = 250 (constant) Single arrows for stochastic dependenciesSingle arrows for stochastic dependencies

Normal Distribution  Note the Normal distribution in BUGS is defined as N (mean, precision) where precision = 1/variance Note that we can define upper and lower bounds so that the proportion is between 0 and 1.Note that we can define upper and lower bounds so that the proportion is between 0 and 1.

DoodleBUGS Model  Let us add these stochastic dependencies to our “logical” model

DoodleBUGS Model  What is our model? r1 ~ Bin (p1, size1)r1 ~ Bin (p1, size1) p1 ~ N (0.25, )p1 ~ N (0.25, ) size1 = 250size1 = 250 r2 ~ Bin (p2, size2)r2 ~ Bin (p2, size2) p2 ~ N (0.35, )p2 ~ N (0.35, ) size2 = 150size2 = 150

WinBUGS Modelling  Running our model in WinBUGS Create a New documentCreate a New document Menu bar - File - NewMenu bar - File - New  A New document window will appear

WinBUGS Document  Select your Doodle from your Doodle Window Menu bar - Edit - Select DocumentMenu bar - Edit - Select Document  Copy your Doodle Menu bar - Edit - CopyMenu bar - Edit - Copy  Paste it into your New Document Menu bar - Edit - PasteMenu bar - Edit - Paste

Model Data  Before running we need to give BUGS some data Type list(size1=250, size2=150) at the top (or the bottom) of your new document.Type list(size1=250, size2=150) at the top (or the bottom) of your new document.

Running BUGS  Use “Specification...” from the “Model” option on Menu Bar to run BUGS

Running BUGS Checks Syntax Checks Syntax Start Sampler Start Sampler Check Model Check Model Load Data Load Data Compile Model Compile Model Initial Values Initial Values Update Sampler Update Sampler

Check Model  Select the Doodle (note the hairy boarder)  Menu bar - Model - Check model  Note the message in bottom left hand corner

Load Data  Highlight the word “list”  Menu bar - Model - Data  Bottom left hand corner

Compiling the Model  Menu bar - Model - Compile  Bottom left hand corner

Load Initial Values  Menu bar - Model - Gen inits  Bottom left hand side

Update the Model Update the Model  Menu bar - Model - Update  1000 MCMC updates to be carried out.

Burn In  Model has been updated  MCMC run did not store any data. Used for the “burn in”Used for the “burn in”  Store values by “monitoring” them to Draw inferencesDraw inferences Monitor MCMC runMonitor MCMC run

Monitoring Nodes  Monitoring p our parameter of interest  Menu bar - Inference - Samples...  Sample Monitor Tool

Monitoring Nodes  Type name of node “p” to monitor  Press “set”

Update & Monitor  Update model again  1000 values “monitored” of the MCMC run for p

Summary Statistics  Summary statistics  Select “p” from the Sample Monitor Tool  Press “stats” (Sample Monitor Tool)  Node statistics window

Summary Statistics  Mean =  Median = (usually more stable)  95% credible interval (0.245, 0.335)  MCMC run size 1000

MCMC Time Series  Press “History” in Sample Monitor Tool

Kernel Density  Press “Density” in the Sample Monitor Tool

Kernel Density  Increase monitored values to 25,000

Plates  Creating a plate CTRL + mouse click in Doodle WindowCTRL + mouse click in Doodle Window Deleting a plate: CTRL + DelDeleting a plate: CTRL + Del

 Allow more complex structure, e.g., Repeated measuresRepeated measures Hierarchical modelsHierarchical models  Extend our example to calculate power r1 and r2 from Binomial distributionr1 and r2 from Binomial distribution Simulte r1 and r2 100 times per “update”Simulte r1 and r2 100 times per “update” Calculate test statisticCalculate test statistic Count number of times it falls in critical regionCount number of times it falls in critical region Plates

 H 0 : p1 = p2 = p vs H 1 : p1 < p2 p1 = r1/size1&p2 = r2/size2p1 = r1/size1&p2 = r2/size2  Test statistic Test Statistic (p2 - p1) s.d.(p) s.d.(p) =  (p(1-p)(1/size1 + 1/size2))

Power  Data list(prop1=.25, prop2=.35, size1=250,size2=150, N=100, alpha.val=1.96)list(prop1=.25, prop2=.35, size1=250,size2=150, N=100, alpha.val=1.96)  Results  Power = 57% (47%, 67%)

Power - History

Power - Density

Updates  Updating - Bottom left hand corner  After updates finish

Summary  BUGS is a power tool Bayesian AnalysisBayesian Analysis Simulation ToolSimulation Tool  Graphical Models Doodle BUGSDoodle BUGS Simple representation of modelSimple representation of model  Easy to use!