1 making bugs open 2 adopt a module bugs is a long
play

1 Making BUGS Open 2 Adopt a module BUGS is a long running - PDF document

1 Making BUGS Open 2 Adopt a module BUGS is a long running software project aiming to make modern MCMC Unique once in a life time opertunity. You can choose which techniques based on graphical models available to applied OpenBUGS module you


  1. 1 Making BUGS Open 2 Adopt a module BUGS is a long running software project aiming to make modern MCMC Unique once in a life time opertunity. You can choose which techniques based on graphical models available to applied OpenBUGS module you would like to care for. Adopt a module and statisticians in an easy to use package. This talk will give an you can take a precious piece of software home with you to read overview of the structure of OpenBUGS the open source version of the and play with! Hundreds of modules to choose from but many BUGS software and the tools used in its creation and maintenance. thousands of BUGS users. Hurry while stocks last! Interfacing BUGS to R will also be discussed in particular the possibilities for closer coupling than currently available in the BRugs package. 3 Happy modules 4 Myth I BUGS is one big scary monster Would an OpenBUGS module be happy with you? Some questions to ask yourself: what is a module? what is a class? what is an object? Reality what is a factory object? what is an interface? what is the difference between client and extension interfaces? why are concrete classes BUGS is lots of friendly little bits hidden? what is metaprogramming? what do I do with blue diamonds? why are trap messages helpful? what is the Hollywood principle of programming? can I program in C?

  2. 5 Myth II 6 Myth III BUGS is writen in a strange BUGS uses strange developement complicated language tools Reality Reality Component Pascal is a very simple BlackBox tools are very simple to powerful language use (they are also free...) 7 Myth IV 8 Myth V Open source software must be Software technology has not developed in C/C++ using GNU changed in the past 20 years tools Reality Reality There is Microsoft, there is Linux, Open source software must be there is the Intel based PC developed in C/C++ using GNU (and the Mac...) tools

  3. 9 How BUGS works 10 The plan Create lots of objects, wire them together and then get the objects alpha.tau alpha.c alpha0 beta.c beta.tau to talk to each other. Need a plan of how to do this alpha[i] beta[i] tau.c mu[i, j] x[j] sigma Y[i, j] for(j IN 1 : T) for(i IN 1 : N) 11 Bayesian graphical models 12 Graphs as (formal) language model The type of plan BUGS { understands is called a bayesian for( i in 1 : N ) { graphical model. for( j in 1 : T ) { Y[i , j] ~ dnorm(mu[i , j],tau.c) mu[i , j] <- alpha[i] + beta[i] * (x[j] - xbar) Bayesian graphical models } describe conditional idependence alpha[i] ~ dnorm(alpha.c,alpha.tau) beta[i] ~ dnorm(beta.c,beta.tau) assumptions } tau.c ~ dgamma(0.001,0.001) Give factorization of joint sigma <- 1 / sqrt(tau.c) alpha.c ~ dnorm(0.0,1.0E-6) probability distribution alpha.tau ~ dgamma(0.001,0.001) beta.c ~ dnorm(0.0,1.0E-6)

  4. 13 Compilation 14 An analogy Turning description in one Science program writen in language into equivalent fortran description in another language Compiled to assembly language Can add extra information Assembly language - low level New description can be instruction that cause the CPU executable to do things 15 An analogy continued 16 Inference algorithms Statistical model writen as a graph Many possibilities Compiled into inference algorithm Want good natured algorithm not fussy about what it is asked Inference algorithm executed to do. MCMC simulation good choice

  5. 17 MCMC simulation 18 MCMC simulation continued Generate lots of random numbers 0.5 1.0 1.5 alpha.Base After a bit calculate averages of these random numbers -0.5 Also can calculate quartiles, 0 5000 10000 iteration kernel densities etc. 1.5 alpha.Base 1.0 0.5 0.0 1000 2500 5000 7500 10000 iteration mean sd MC_error val2.5pc median val97.5pc start sample alpha.Base 0.8934 0.1388 0.006738 0.6265 0.8891 1.173 1001 10000 19 The BUGS software 20 Tasks and subsystems BUGS has to do lots of tasks. Describing graphical models Doodle subsystem This does not make BUGS one big scary monster. Compiling graphical model Bugs subsystem BUGS contains subsystems to perform specific tasks Probability calculations Graph subsystem Each subsystem consists of a number of modules MCMC simulation Updater subsystem Each module is small and easy to understand Summary statistics Samples, Summary, Ranks, Deviance subsystems

  6. 21 Subsystems and modules I 22 Subsystems and modules contd Subsystems can consist of a small Graph subsystem is large number of modules or a large GraphRules GraphNodes GraphLogical GraphStochastic number GraphScalar GraphVector GraphUnivariate GraphMultivariate GraphConjugateMV GraphChain GraphConstant GraphCompile GraphStack GraphMixture Samples subsystem is small GraphFlat GraphGeneric GraphBlock GraphCloglog GraphCut GraphEigenvals GraphGammap GraphInprod GraphInverse GraphKepler GraphLog SamplesMonitors SamplesIndex SamplesInterface GraphLogdet GraphLogit GraphProbit GraphProduct SamplesFormatted SamplesEmbed SamplesViews GraphRanks GraphPValue GraphSumation GraphTable SamplesPlots SamplesCmds SamplesCorrelat GraphFunctional GraphODEmath GraphODElang SamplesDensity SamplesDiagnostics SamplesHistory GraphPredictive GraphBern GraphBinomial GraphCat SamplesQuantiles SamplesTrace GraphFounder GraphGeometric GraphGEV GraphHypergeometric GraphMendelian GraphNegbin GraphPoisson GraphRecessive GraphMultinom GraphBeta GraphChisqr GraphDbexp GraphExp GraphF GraphGamma GraphGengamma GraphLogistic GraphLognorm GraphNormal GraphPareto GraphPolygene GraphT GraphTrapezium GraphUniform GraphWeibull GraphWeibullShifted GraphDirichlet GraphMVNormal GraphMVT GraphRENormal GraphStochtrend GraphWishart 23 Subsystems and modules II 24 Styles of modules in BUGS BUGS consists of 15 subsystems Many different styles of module in BUGS both within and between 5 Windows only subsystems subsystems. BUGS consists of 263 modules Example the BugsNames modules contains 78 statements, the 63 windows only modules BugsInterpreter module contains 20 statements BUGS is a small system In general modules either implement algorithms or they establish concepts

  7. 25 What is a module (in CP) 26 Languages other than CP A module is a package of source Weird languages have weird code with a well defined interface ideas (they just happened) A module is a unit of compilation Header files A module is a unit of loading Include A module knows what services it Name spaces provides (syntaxticaly) Only classes A module can make "use" of other modules main{} Under the "use" relation modules Dynamic link libraries are arranged in a DAG 27 Software developement tools 28 Object orientated software I These tools are never free Objects are the easy bit These tools are often very complex Designing the classes is the hard bit These tools often do tasks that are not needed (or should not be (Code) Inheritance is evil needed) Methods should not be extended Best to use commonly used tools (it's nice to be in a crowd) Composition is good

  8. 29 Object orientated software II 30 IDL Interface Definition Language DEFINITION GraphNodes; Large class hierarchies can be a TYPE nightmare Factory = POINTER TO ABSTRACT RECORD (f: Factory) New (option: INTEGER): Node, NEW, ABSTRACT END; Multiple inheritance deepens that List = POINTER TO RECORD nightmare node-: Node; next-: List END; Need tools that control the Node = POINTER TO ABSTRACT RECORD props-: SET; complexity of the hierarchy (node: Node) AddParent (VAR list: List), NEW; (node: Node) Check (): SET, NEW, ABSTRACT; (node: Node) Init, NEW, ABSTRACT; Need IDL to describe software (node: Node) Parents (): List, NEW, ABSTRACT; (node: Node) Representative (): Node, NEW, ABSTRACT; (node: Node) Set (IN args: Args; OUT res: SET), NEW, ABSTRACT; (node: Node) SetProps (props: SET), NEW; (node: Node) Signature (OUT signature: ARRAY OF CHAR), NEW, ABSTRACT; (node: Node) Size (): INTEGER, NEW, ABSTRACT; (node: Node) Value (): REAL, NEW, ABSTRACT END; Vector = POINTER TO ARRAY OF Node; Args = ABSTRACT RECORD valid: BOOLEAN; (VAR args: Args) Init, NEW, ABSTRACT END; PROCEDURE SetFactory (f: Factory); END GraphNodes. 31 More IDL 32 Metaprogramming DEFINITION GraphLogical; Self awareness for software IMPORT GraphNodes; TYPE List = POINTER TO RECORD Software can ask itself questions node-: Node; next-: List END; Is there an item called FooBar? Node = POINTER TO ABSTRACT RECORD (GraphNodes.Node) level-: INTEGER; parents-: List; What sort of item is FooBar? (node: Node) AddToList (VAR list: List), NEW; (node: Node) CalculateLevel, NEW; (node: Node) ClassFunction (parent: GraphNodes.Node): INTEGER, NEW, ABSTRACT; Do this with item FooBar (node: Node) ClearLevel, NEW; (node: Node) HandleMsg (msg: INTEGER), NEW, EMPTY; (node: Node) Init; (node: Node) Optimize (parent: GraphNodes.Node), NEW, EMPTY; (node: Node) StoreParents, NEW END; Vector = POINTER TO ARRAY OF Node; Args = RECORD (GraphNodes.Args) numConsts, numOps, numScalars, numVectors: INTEGER; consts: ARRAY 50 OF REAL; scalars: ARRAY 50 OF GraphNodes.Node; ops: ARRAY 100 OF INTEGER; vectors: ARRAY 10 OF GraphNodes.SubVector; (VAR args: Args) Init END; PROCEDURE Ancestors (node: GraphNodes.Node): List; END GraphLogical.

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend