Bayesian Methods LABORATORY. Lesson 1: Jan Software: R. Bayesian Methods p.1/20

Similar documents
Introduction to Bayesian Analysis 1

Practical Bayesian Design and Analysis for Drug and Device Clinical Trials

Bayesian performance

Coherence and calibration: comments on subjectivity and objectivity in Bayesian analysis (Comment on Articles by Berger and by Goldstein)

A Brief Introduction to Bayesian Statistics

A Case Study: Two-sample categorical data

Introduction. Patrick Breheny. January 10. The meaning of probability The Bayesian approach Preview of MCMC methods

Bayesian Statistics Estimation of a Single Mean and Variance MCMC Diagnostics and Missing Data

Att vara eller inte vara (en Bayesian)?... Sherlock-conundrum

Application of Multinomial-Dirichlet Conjugate in MCMC Estimation : A Breast Cancer Study

A Bayesian Nonparametric Model Fit statistic of Item Response Models

UNIT 4 ALGEBRA II TEMPLATE CREATED BY REGION 1 ESA UNIT 4

Bayesian Inference. Thomas Nichols. With thanks Lee Harrison

Bayesian Inference Bayes Laplace

An Introduction to Bayesian Statistics

ST440/550: Applied Bayesian Statistics. (10) Frequentist Properties of Bayesian Methods

Cognitive Modeling. Lecture 12: Bayesian Inference. Sharon Goldwater. School of Informatics University of Edinburgh

An Exercise in Bayesian Econometric Analysis Probit and Linear Probability Models

How few countries will do? Comparative survey analysis from a Bayesian perspective

Meta-analysis of few small studies in small populations and rare diseases

STATISTICAL INFERENCE 1 Richard A. Johnson Professor Emeritus Department of Statistics University of Wisconsin

Bayesian Bi-Cluster Change-Point Model for Exploring Functional Brain Dynamics

BayesOpt: Extensions and applications

Unit 1 Exploring and Understanding Data

Bayesian and Frequentist Approaches

A Nonlinear Hierarchical Model for Estimating Prevalence Rates with Small Samples

Bayesian Logistic Regression Modelling via Markov Chain Monte Carlo Algorithm

For general queries, contact

Empowered by Psychometrics The Fundamentals of Psychometrics. Jim Wollack University of Wisconsin Madison

A Bayesian Account of Reconstructive Memory

Meta-analysis of two studies in the presence of heterogeneity with applications in rare diseases

Bayesian Mediation Analysis

Probabilistic Projections of Populations With HIV: A Bayesian Melding Approach

Inference About Magnitudes of Effects

A Predictive Chronological Model of Multiple Clinical Observations T R A V I S G O O D W I N A N D S A N D A M. H A R A B A G I U

Bayesian meta-analysis of Papanicolaou smear accuracy

Dimensionality of the Force Concept Inventory: Comparing Bayesian Item Response Models. Xiaowen Liu Eric Loken University of Connecticut

Ordinal Data Modeling

Data Analysis Using Regression and Multilevel/Hierarchical Models

MS&E 226: Small Data

How to weigh the strength of prior information and clarify the expected level of evidence?

TRIPODS Workshop: Models & Machine Learning for Causal I. & Decision Making

Bayesian graphical models for combining multiple data sources, with applications in environmental epidemiology

2014 Modern Modeling Methods (M 3 ) Conference, UCONN

Advanced Bayesian Models for the Social Sciences

Missing data. Patrick Breheny. April 23. Introduction Missing response data Missing covariate data

Bayesian Model Averaging for Propensity Score Analysis

Georgetown University ECON-616, Fall Macroeconometrics. URL: Office Hours: by appointment

An application of a pattern-mixture model with multiple imputation for the analysis of longitudinal trials with protocol deviations

A Bayesian approach for constructing genetic maps when markers are miscoded

SWITCH Trial. A Sequential Multiple Adaptive Randomization Trial

An Empirical Assessment of Bivariate Methods for Meta-analysis of Test Accuracy

Fundamental Clinical Trial Design

Bayesian Dose Escalation Study Design with Consideration of Late Onset Toxicity. Li Liu, Glen Laird, Lei Gao Biostatistics Sanofi

BayesRandomForest: An R

PSYCH-GA.2211/NEURL-GA.2201 Fall 2016 Mathematical Tools for Cognitive and Neural Science. Homework 5

Regression Discontinuity Designs: An Approach to Causal Inference Using Observational Data

Equilibrium Selection In Coordination Games

Subgroup-specific dose finding in phase I clinical trials based on time to toxicity allowing adaptive subgroup combination

Bayesian Nonparametric Modeling of Individual Differences: A Case Study Using Decision-Making on Bandit Problems

Inference Methods for First Few Hundred Studies

Methods Research Report. An Empirical Assessment of Bivariate Methods for Meta-Analysis of Test Accuracy

Bayesian Confidence Intervals for Means and Variances of Lognormal and Bivariate Lognormal Distributions

A Diabetes minimal model for Oral Glucose Tolerance Tests

Applying the Minimax Principle to Sequential Mastery Testing

Statistics and Probability

Dynamic Causal Modeling

Stepwise Knowledge Acquisition in a Fuzzy Knowledge Representation Framework

WinBUGS : part 1. Bruno Boulanger Jonathan Jaeger Astrid Jullion Philippe Lambert. Gabriele, living with rheumatoid arthritis

V. Gathering and Exploring Data

Advanced Bayesian Models for the Social Sciences. TA: Elizabeth Menninga (University of North Carolina, Chapel Hill)

Using follow-up data to adjust for selective non-participation in cross-sectional setting

HIDDEN MARKOV MODELS FOR ALCOHOLISM TREATMENT TRIAL DATA

AB - Bayesian Analysis

Technical Specifications

CS 4365: Artificial Intelligence Recap. Vibhav Gogate

Joint Spatio-Temporal Modeling of Low Incidence Cancers Sharing Common Risk Factors

Hidden Markov Models for Alcoholism Treatment Trial Data

Inference with Difference-in-Differences Revisited

Bayesian Models for Combining Data Across Subjects and Studies in Predictive fmri Data Analysis

INTRODUCTION TO BAYESIAN REASONING

Catherine A. Welch 1*, Séverine Sabia 1,2, Eric Brunner 1, Mika Kivimäki 1 and Martin J. Shipley 1

Propensity scores: what, why and why not?

Exploring the Influence of Particle Filter Parameters on Order Effects in Causal Learning

SPRING GROVE AREA SCHOOL DISTRICT. Course Description. Instructional Strategies, Learning Practices, Activities, and Experiences.

Modelling heterogeneity variances in multiple treatment comparison meta-analysis Are informative priors the better solution?

Sample size and power calculations in Mendelian randomization with a single instrumental variable and a binary outcome

Aspects of Statistical Modelling & Data Analysis in Gene Expression Genomics. Mike West Duke University

1 Introduction. st0020. The Stata Journal (2002) 2, Number 3, pp

Xiaoyan(Iris) Lin. University of South Carolina Office: B LeConte College Fax: Columbia, SC, 29208

Chapter 11: Advanced Remedial Measures. Weighted Least Squares (WLS)

Quantifying and Mitigating the Effect of Preferential Sampling on Phylodynamic Inference

Statistical Methods Exam I Review

Bayesian Methods for Medical Test Accuracy. Broemeling & Associates Inc., 1023 Fox Ridge Road, Medical Lake, WA 99022, USA;

Causal Inference in Statistics A primer, J. Pearl, M Glymur and N. Jewell

2 Critical thinking guidelines

NANO: Network Access Neutrality Observatory

Chapter 6: Confidence Intervals

Transcription:

Bayesian Methods LABORATORY Lesson 1: Jan 24 2002 Software: R Bayesian Methods p.1/20

The R Project for Statistical Computing http://www.r-project.org/ R is a language and environment for statistical computing and graphics. Bayesian Methods p.2/20

The R Project for Statistical Computing http://www.r-project.org/ R is a language and environment for statistical computing and graphics. R, like S, is designed around a computer language, and it allows users to add additional functionality by defining new functions. Bayesian Methods p.2/20

The R Project for Statistical Computing http://www.r-project.org/ R is a language and environment for statistical computing and graphics. R, like S, is designed around a computer language, and it allows users to add additional functionality by defining new functions. The term "environment" is intended to characterize it as a fully planned and coherent system, rather than an incremental accretion of very specific and inflexible tools. Bayesian Methods p.2/20

It is a GNU project which is similar to the S language and environment. Bayesian Methods p.3/20

It is a GNU project which is similar to the S language and environment. The GNU Project was launched in 1984 to develop a complete Unix-like operating system which is free software. Bayesian Methods p.3/20

It is a GNU project which is similar to the S language and environment. The GNU Project was launched in 1984 to develop a complete Unix-like operating system which is free software. Free software is a matter of the users freedom to run, copy, distribute, study, change and improve the software. It is not a matter of price! Bayesian Methods p.3/20

It is a GNU project which is similar to the S language and environment. The GNU Project was launched in 1984 to develop a complete Unix-like operating system which is free software. Free software is a matter of the users freedom to run, copy, distribute, study, change and improve the software. It is not a matter of price! R can be considered as a different implementation of S. There are some important differences, but much code written for S runs unaltered under R. Bayesian Methods p.3/20

ONE-DIMENSIONAL parameter models 1. The Binomial model and its coniugate Beta prior in Bin(n, θ) there is a single parameter of interest (n is tipically assumed known), that is the probability θ of a certain outcome in each of the n trials considered. Bayesian Methods p.4/20

Bayesian estimation of a probability from BINOMIAL data Gelman book, pag. 39, sec. 2.5 R code placenta.r is in the Lab notes at the course web page Our interest focus on the proportion of female births in the so called maternal condition placenta previa Bayesian Methods p.5/20

Bayesian estimation of a probability from BINOMIAL data Gelman book, pag. 39, sec. 2.5 R code placenta.r is in the Lab notes at the course web page Our interest focus on the proportion of female births in the so called maternal condition placenta previa Our data consist in a early study in Germany: 437 females on 980 placenta previa births Bayesian Methods p.5/20

Bayesian estimation of a probability from BINOMIAL data Gelman book, pag. 39, sec. 2.5 R code placenta.r is in the Lab notes at the course web page Our interest focus on the proportion of female births in the so called maternal condition placenta previa Our data consist in a early study in Germany: 437 females on 980 placenta previa births How much evidence do they provide that the proportion of placenta previa female births is < 0.485, the proportion of the general population female births? Bayesian Methods p.5/20

Analysis using a UNIFORM PRIOR Let the 1-parameter θ denote the proportion of placenta previa female births Bayesian Methods p.6/20

Analysis using a UNIFORM PRIOR Let the 1-parameter θ denote the proportion of placenta previa female births We assume a Bin(θ, 980) θ 437 (1 θ) 980 437 to be the model generating the data Bayesian Methods p.6/20

Analysis using a UNIFORM PRIOR Let the 1-parameter θ denote the proportion of placenta previa female births We assume a Bin(θ, 980) θ 437 (1 θ) 980 437 to be the model generating the data We specify the prior for θ to be a U[0, 1] Bayesian Methods p.6/20

Analysis using a UNIFORM PRIOR Let the 1-parameter θ denote the proportion of placenta previa female births We assume a Bin(θ, 980) θ 437 (1 θ) 980 437 to be the model generating the data We specify the prior for θ to be a U[0, 1] The posterior for θ is, then, θ 437 (1 θ) 980 437, i.e., is a Beta(437 + 1, 980 437 + 1) Bayesian Methods p.6/20

(Beta-)Uniform Binomial 0 5 10 15 20 25 likelihood 0.35 0.40 0.45 0.50 0.55 Bayesian Methods p.7/20

(Beta-)Uniform Binomial 0 5 10 15 20 25 likelihood prior 0.35 0.40 0.45 0.50 0.55 Bayesian Methods p.7/20

(Beta-)Uniform Binomial 0 5 10 15 20 25 likelihood posterior prior 0.35 0.40 0.45 0.50 0.55 Bayesian Methods p.7/20

Analysis using different BETA PRIORS As the likelihood p(y θ) L(θ; y) is θ y (1 θ) n y if the prior is of the same form, e.g., p(θ) is θ α 1 (1 θ) β 1 then the posterior will also be of this form. In fact, p(θ y) is θ y+α 1 (1 θ) n y+β 1 = Beta(α + y, β + n y) -> the BETA prior distribution is a coniugate family for the BINOMIAL likelihood Bayesian Methods p.8/20

0 5 10 15 20 25 a+b 2= 0 0 5 10 15 20 25 a+b 2= 0 0.35 0.40 0.45 0.50 0.55 0.35 0.40 0.45 0.50 0.55 0 5 10 15 20 25 a+b 2= 10 0 5 10 15 20 25 a+b 2= 100 0.35 0.40 0.45 0.50 0.55 0.35 0.40 0.45 0.50 0.55 0 5 15 25 35 a+b 2= 1000 0 20 40 60 80 a+b 2= 10000 0.35 0.40 0.45 0.50 0.55 0.35 0.40 0.45 0.50 0.55 Bayesian Methods p.9/20

0 5 10 15 20 25 a+b 2= 0 0 5 10 15 20 25 a+b 2= 0 0.35 0.40 0.45 0.50 0.55 0.35 0.40 0.45 0.50 0.55 0 5 10 15 20 25 a+b 2= 10 0 5 10 15 20 25 a+b 2= 100 0.35 0.40 0.45 0.50 0.55 0.35 0.40 0.45 0.50 0.55 0 5 15 25 35 a+b 2= 1000 0 20 40 60 80 a+b 2= 10000 0.35 0.40 0.45 0.50 0.55 0.35 0.40 0.45 0.50 0.55 Bayesian Methods p.9/20

0 5 10 15 20 25 a+b 2= 0 0 5 10 15 20 25 a+b 2= 0 0.35 0.40 0.45 0.50 0.55 0.35 0.40 0.45 0.50 0.55 0 5 10 15 20 25 a+b 2= 10 0 5 10 15 20 25 a+b 2= 100 0.35 0.40 0.45 0.50 0.55 0.35 0.40 0.45 0.50 0.55 0 5 15 25 35 a+b 2= 1000 0 20 40 60 80 a+b 2= 10000 0.35 0.40 0.45 0.50 0.55 0.35 0.40 0.45 0.50 0.55 Bayesian Methods p.9/20

How does posterior COMPROMISE between prior and the data? The compromise depends on how much weight prior has (or how much informative it is) w.r.t. the data at hand Bayesian Methods p.10/20

How does posterior COMPROMISE between prior and the data? The compromise depends on how much weight prior has (or how much informative it is) w.r.t. the data at hand i.e., in the binomial case, depends on the relative weight of α + β 2 number of prior observations ( prior precision) Note: precision=1/variance, var= θ(1 θ) α+β+1 w.r.t. n, the sample size Bayesian Methods p.10/20

A first SENSITIVITY ANALYSIS concept of sensitivity: sensitivity or robustness of the inferences to the choice of the prior Prior information Posterior information α + β 2 mean mean 95% interval 0 0.500 0.446 [ 0.415, 0.477 ] 0 0.485 0.446 [ 0.415, 0.477 ] 10 0.485 0.446 [ 0.416, 0.477 ] 100 0.485 0.450 [ 0.420, 0.479 ] 1000 0.485 0.466 [ 0.444, 0.488 ] 10000 0.485 0.482 [ 0.472, 0.491 ] NOTE: in placenta previa example n 1000 and ȳ = 0.446 Bayesian Methods p.11/20

The SIMULATION-based estimation approach The modern approach to Bayesian estimation has become closely linked to simulation-based estimation methods. Bayesian Methods p.12/20

The SIMULATION-based estimation approach The modern approach to Bayesian estimation has become closely linked to simulation-based estimation methods. In fact, Bayesian estimation focuses on estimating the entire density of a parameter. Bayesian Methods p.12/20

The SIMULATION-based estimation approach The modern approach to Bayesian estimation has become closely linked to simulation-based estimation methods. In fact, Bayesian estimation focuses on estimating the entire density of a parameter. This density estimation is based on generating samples from the posterior density of the parameters themselves or of functions of parameters. Bayesian Methods p.12/20

In the BETA-BINOMIAL model, the coniugacy allows us knowing the posterior density in closed form. Bayesian Methods p.13/20

In the BETA-BINOMIAL model, the coniugacy allows us knowing the posterior density in closed form. Then, direct calculations are feasible or direct simulation from it can be performed. Bayesian Methods p.13/20

In the BETA-BINOMIAL model, the coniugacy allows us knowing the posterior density in closed form. Then, direct calculations are feasible or direct simulation from it can be performed. However, even if posterior density cannot be explicitly integrated, iterative simulation methods (or MCMC) are alternatively used. We will see them in future lab s. Bayesian Methods p.13/20

a first (direct) simulation Congdon book, pag. 31, sec. 2.11 Wilcox (1996) presents data from a 1991 gallup opinion poll about the morality of President Bush s not helping Iraqi rebel groups after the formal end of the gulf war. Of the 751 adults responding, 150 thought the president s actions were not moral. Bayesian Methods p.14/20

a first (direct) simulation Congdon book, pag. 31, sec. 2.11 Wilcox (1996) presents data from a 1991 gallup opinion poll about the morality of President Bush s not helping Iraqi rebel groups after the formal end of the gulf war. Of the 751 adults responding, 150 thought the president s actions were not moral. We are interested in assessing the probability that a randomly sampled adult would respond immoral. Bayesian Methods p.14/20

a first (direct) simulation Congdon book, pag. 31, sec. 2.11 Wilcox (1996) presents data from a 1991 gallup opinion poll about the morality of President Bush s not helping Iraqi rebel groups after the formal end of the gulf war. Of the 751 adults responding, 150 thought the president s actions were not moral. We are interested in assessing the probability that a randomly sampled adult would respond immoral. In the inference we might use evidence from previous polls on the proportion of the population generally likely to consider a President s actions immoral. Bayesian Methods p.14/20

a first (direct) simulation The R code is in betabin.r at the course web page We present Bayesian inference about the probability of an adult responding immoral assuming different Beta priors: 1. α = β = 1 prior information 0 E = 1/2 2. α = β = 0.001 prior information < 0 E = 1/2 3. α = 1 β = 0.11 prior information < 0 E = 0.9 4. α = 1.8 β = 0.2 prior information 0 E = 0.9 5. α = 4.5, 45 β = 0.5, 5 prior information 5,50 E = 0.9 Bayesian Methods p.15/20

1., 2. are both non informative, but 2. is a reasonable choice for one-off events (or for correlated data) 3., 4. may be assumed on the basis of previous polls. Although E=0.9 they still are diffuse. increasingly informative. density(x = rbeta(50000, 45, 5)) 5., 6 are Density 0 2 4 6 8 10 a=.001 b=.001 a=1 b=1 a=45 b=5 0.0 0.2 0.4 0.6 0.8 1.0 N = 50000 Bandwidth = 0.004278 Bayesian Methods p.16/20

Legend for the next figure > in each figure: curves: histogram of 10,000 draws from the posterior Beta(150+α,601+β); likelihood Bin(150,751). intervals: Unif-Bin 95% posterior interval; 95% (Beta(150+α,601+β)) posterior interval; Normal approximation of the 95% posterior interval; Inverted 95% posterior interval on the logit scale. Bayesian Methods p.17/20

Legend for the next figure > in each figure: curves: histogram of 10,000 draws from the posterior Beta(150+α,601+β); likelihood Bin(150,751). intervals: Unif-Bin 95% posterior interval; 95% (Beta(150+α,601+β)) posterior interval; Normal approximation of the 95% posterior interval; Inverted 95% posterior interval on the logit scale. Though θ is close to 0, because of the large sample size (751), the normal approximation is good as well as posterior inferences are insensitive to prior choice (even if discordant to data), at least for prior information 0. Bayesian Methods p.17/20

0 5 10 20 30 a+b 2= 0 a= 1 0.16 0.18 0.20 0.22 0.24 0.26 0 5 10 20 30 a+b 2= 1.998 a= 0.001 0.16 0.18 0.20 0.22 0.24 0.26 Histogram of post Histogram of post 0 5 10 20 30 a+b 2= 0.89 a= 1 0.16 0.18 0.20 0.22 0.24 0.26 0 5 10 20 30 a+b 2= 0 a= 1.8 0.16 0.18 0.20 0.22 0.24 0.26 0.28 Histogram of post Histogram of post 0 5 10 20 30 a+b 2= 3 a= 4.5 0.16 0.18 0.20 0.22 0.24 0.26 0 5 10 20 30 a+b 2= 48 a= 45 0.20 0.22 0.24 0.26 0.28 0.30 Bayesian Methods p.18/20

And what about if our sample size was only n = 5, with y = 1 adults considering immoral the President s actions? -> NOTE: the empirical mean still is y/n = 0.2 Bayesian Methods p.19/20

Histogram of post Histogram of post 0.0 1.0 2.0 a+b 2= 0 a= 1 0.0 0.2 0.4 0.6 0.8 Histogram of post 0 1 2 3 a+b 2= 1.998 a= 0.001 0.0 0.2 0.4 0.6 0.8 Histogram of post 0.0 1.0 2.0 a+b 2= 0.89 a= 1 0.0 0.2 0.4 0.6 0.8 Histogram of post 0.0 1.0 2.0 a+b 2= 0 a= 1.8 0.0 0.2 0.4 0.6 0.8 Histogram of post 0.0 1.0 2.0 a+b 2= 3 a= 4.5 0.2 0.4 0.6 0.8 0 2 4 6 8 a+b 2= 48 a= 45 0.65 0.70 0.75 0.80 0.85 0.90 0.95 Bayesian Methods p.20/20