《贝叶斯专业软件WinBUGS.ppt》由会员分享,可在线阅读,更多相关《贝叶斯专业软件WinBUGS.ppt(27页珍藏版)》请在三一办公上搜索。
1、“WinBUGS”by Haitao Chu,Presented as part of the Statistical Software Interest Groups seminar series.April 15,2003,Outline,What is BUGS/WinBUGS?Why do we want to use WinBUGS?Where do we get WinBUGS?How do we install WinBUGS?How do we use WinBUGS?Example What kind of output can WinBUGS give us?What ki
2、nd of sampling method does WinBUGS implement?Summary,What is BUGS?,What is BUGS?,Bayesian inference Using Gibbs Sampling is a piece of computer software for the Bayesian analysis of complex statistical models using Markov chain Monte Carlo(MCMC)methods.It grew from a statistical research project at
3、the MRC BIOSTATISTICAL UNIT in Cambridge,but now is developed jointly with the Imperial College School of Medicine at St Marys,London.,What is BUGS?,The Classic BUGS program uses text-based model description and a command-line interface,and versions are available for major computer platforms(Sparc,D
4、os).However,it is not being further developed.,What is WinBUGS?,WinBUGS,a windows program with an option of a graphical user interface,the standard point-and-click windows interface,and on-line monitoring and convergence diagnostics.It also supports Batch-mode running(version 1.4).GeoBUGS,an add-on
5、to WinBUGS that fits spatial models and produces a range of maps as output.PKBUGS,an efficient and user-friendly interface for specifying complex population pharmacokinetic and pharmacodynamic(PK/PD)models within WinBUGS software.,Why do we want to use WinBUGS?,Its ability to fit complex statistical
6、 models using MCMC methods.Its flexibility to program,two different ways to specify modelDoodleBUGS:Direct graphicsBUGS languageFree to downloadA lot of examples in WinBUGSA lot of online resourceshttp:/www.mrc-bsu.cam.ac.uk/bugs/weblinks/webresource.shtml,Where do we get WinBUGS,Free download http:
7、/www.mrc-bsu.cam.ac.uk/bugs.Package needs to be downloaded WinBUGS14.exePotential useful packages for convergence diagnosticsCODA(Convergence Diagnostic and Output Analysis)for S+or RBOA(Bayesian Output Analysis)for S+or R,How do we install WinBUGS?,Downloading the file WinBUGS14.exe(also available
8、in S:/Haitao Chu/WinBUGs)Exit all other programs currently running(particularly if using Windows XP)Go into Explore and double click on WinBUGS14.exe Follow the instructions in the dialog box You should have a new directory called WinBUGS14 within Program Files Inside the WinBUGS14 directory is a pr
9、ogram called WinBUGS14.exe Drag the pretty icon to your desktop to create a shortcut.Double click on WinBUGS14.exe to run WinBUGS14.,How do we install WinBUGS?,Obtaining the key for unrestricted use by registration athttp:/www.mrc-bsu.cam.ac.uk/bugs/winbugs/register.shtmlFollowing the instructions f
10、rom automatic response of your registration to remove the restrictions in WinBUGS 1.4 check that the date of Keys.ocf file in.WinBUGS14BugsCode has been updated.,How do we use WinBUGS?,Educational Example:Pumps:conjugate Gamma-Poisson hierarchical modelThe pumps dataGamma-Poisson hierarchical modelM
11、odel specification in WinBUGS DoodleBUGS,Direct graphicsBUGS languageFormat data and specify initial valuesTutorial,The pumps data,ti:the length of operation time of the pump(in 1000s of hours).xi:the number of failures,Gamma-Poisson hierarchical model,Model specification through DoodleBUGS,NodesCon
12、stants,denoted by rectanglesStochastic nodes,denoted by ellipsesDeterministic nodes,logical function of other nodesEdgesDirected linksSolid arrow:stochastic dependenceHollow arrow:logical functionUndirected links,dashed linerepresenting an upper or lower boundPlates,repeated parts of the graphRead t
13、he User Manual&Doodle help at the Help menu,Model specification through DoodleBUGS,Constant node,Stochastic node,Plate,Stochastic dependence,logical function,Deterministic node,Model specification through BUGS language,Format data and specify initial values,Data formatS-Plus formatlist(t=c(94.3,15.7
14、,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)Rectangular formatPlease see formatting of data at model specification at User ManualInitial valueslist(alpha=1,beta=1)list(alpha=10,beta=10),Tutorial:Interactive submission,Standard windows“point and click”methodExamplePumps c
15、onjugate Gamma-Poisson hierarchical model in Example Volume I at Help menuS:/Haitao Chu/WinBUGS/pumps/pumps.odc,Tutorial:Batch mode submission,Files required The script itself,S:/Haitao Chu/WinBUGS/pumps/pumpsbatch.odcModel file,S:/Haitao Chu/WinBUGS/pumps/pumpsmodel.txtData file,S:/Haitao Chu/WinBU
16、GS/pumps/pumpsdata.txtInitial values fileS:/Haitao Chu/WinBUGS/pumps/pumpsin1.txtS:/Haitao Chu/WinBUGS/pumps/pumpsin2.txtFormat of the files native WinBUGS format with.odc extensiontext format with.txt extension,Tutorial:running WinBUGS from R and other programs,From Rhttp:/www.stat.columbia.edu/gel
17、man/bugsRS:/Haitao Chu/WinBUGS/bugsRFrom other programshttp:/www.mrc-bsu.cam.ac.uk/bugs/winbugs/remote14.shtml,What kind of output can WinBUGS give us?,Samples at Inference Menutrace:plots the variable value against iteration number.history:plots out a complete trace for the variable.density:smoothe
18、d kernel density estimate for continuous variable or a histogram for discrete variable.auto cor:auto correlation,up to lag-50stats:Summary statistics,pooling over the chains selected.coda:output the monitored values to CODA or BOA,What kind of output can WinBUGS give us?,Samples at Inference Menuqua
19、ntiles:plots out the running mean with running 95%confidence intervals against iteration number.bgr diag:Brooks-Gelman-Rubin convergence statistic Brooks and Gelman(1998)Green:the width of the central 80%interval of the pooled runs Blue:the average width of the 80%intervals within the individual run
20、sRed:their ratio R(=pooled/within).Convergence:R to 1,and with convergence of both the pooled and within interval widths to stability.,What kind of output can WinBUGS give us?,Compare at Inference Menu,Box Plot,Caterpillar Plot,What kind of output can WinBUGS give us?,Rank at Inference Menustats:the
21、 distribution of the ranks of each component of the variable.histogram:the empirical distribution of the simulated rank for each componentDIC at Inference MenuDeviance Information Criterion,What kind of sampling method does WinBUGS implement?,Sampling methods are used in the following hierarchies Co
22、ntinuous target distributionConjugateDirect sampling using standard algorithmsLog-concaveDerivative-free adaptive rejection sampling Non-log-concave(restricted range)Slice samplingNon-log-concave(unrestricted range)MetropolisDiscrete target distribution(I have no experience)Finite upper boundInversi
23、onShifted PoissonDirect sampling using standard algorithm,Summary,What is BUGS/WinBUGS?Why do we want to use WinBUGS?Where do we get WinBUGS?How do we install WinBUGS?How do we use WinBUGS?What kind of output can WinBUGS give us?What kind of sampling method does WinBUGS implement?MCMC can be dangerous,Thank you very much for attending and participating in this Statistical Software Interest Group seminarMore volunteers!,The End,