Jeffreys Interval for One-Sample Proportion with SAS/STAT Software

Similar documents
An Introduction to Using WinBUGS for Cost-Effectiveness Analyses in Health Economics

Tutorial on Markov Chain Monte Carlo

More details on the inputs, functionality, and output can be found below.

Sensitivity Analysis in Multiple Imputation for Missing Data

Parallelization Strategies for Multicore Data Analysis

Imputing Missing Data using SAS

Using SAS PROC MCMC to Estimate and Evaluate Item Response Theory Models

Foundations of Statistics Frequentist and Bayesian

ESTIMATING COMPLETION RATES FROM SMALL SAMPLES USING BINOMIAL CONFIDENCE INTERVALS: COMPARISONS AND RECOMMENDATIONS

Service courses for graduate students in degree programs other than the MS or PhD programs in Biostatistics.

Reliability estimators for the components of series and parallel systems: The Weibull model

CHAPTER 3 EXAMPLES: REGRESSION AND PATH ANALYSIS

CHAPTER 2 Estimating Probabilities

Likelihood: Frequentist vs Bayesian Reasoning

Comparison of frequentist and Bayesian inference. Class 20, 18.05, Spring 2014 Jeremy Orloff and Jonathan Bloom

11. Time series and dynamic linear models

4. Continuous Random Variables, the Pareto and Normal Distributions

Analysis of Bayesian Dynamic Linear Models

Gaussian Processes to Speed up Hamiltonian Monte Carlo

Likelihood Approaches for Trial Designs in Early Phase Oncology

SENSITIVITY ANALYSIS AND INFERENCE. Lecture 12

Lecture 2 ESTIMATING THE SURVIVAL FUNCTION. One-sample nonparametric methods

Probabilistic Models for Big Data. Alex Davies and Roger Frigola University of Cambridge 13th February 2014

Confidence Intervals for One Standard Deviation Using Standard Deviation

Inference of Probability Distributions for Trust and Security applications

Confidence Intervals for Spearman s Rank Correlation

Two-Sample T-Tests Allowing Unequal Variance (Enter Difference)

The Variability of P-Values. Summary

Dongfeng Li. Autumn 2010

Basics of Statistical Machine Learning

Markov Chain Monte Carlo Simulation Made Simple

Statistics Graduate Courses

Monte Carlo and Empirical Methods for Stochastic Inference (MASM11/FMS091)

Bayesian Analysis for the Social Sciences

THE USE OF STATISTICAL DISTRIBUTIONS TO MODEL CLAIMS IN MOTOR INSURANCE

Bayesian Statistics in One Hour. Patrick Lam

Basic Bayesian Methods

Statistics I for QBIC. Contents and Objectives. Chapters 1 7. Revised: August 2013

Introduction to Bayesian Analysis Using SAS R Software

Confidence Intervals for the Difference Between Two Means

Two-Sample T-Tests Assuming Equal Variance (Enter Means)

Introduction to the Monte Carlo method

Inference on Phase-type Models via MCMC

Hypothesis Testing for Beginners

Parameter estimation for nonlinear models: Numerical approaches to solving the inverse problem. Lecture 12 04/08/2008. Sven Zenker

Tests for Two Proportions

Notes on the Negative Binomial Distribution

Package zic. September 4, 2015

Part 2: One-parameter models

Introduction to Monte Carlo. Astro 542 Princeton University Shirley Ho

MISSING DATA TECHNIQUES WITH SAS. IDRE Statistical Consulting Group

Big data challenges for physics in the next decades

Aachen Summer Simulation Seminar 2014

Getting Correct Results from PROC REG

Validation of Software for Bayesian Models using Posterior Quantiles. Samantha R. Cook Andrew Gelman Donald B. Rubin DRAFT

Applications of R Software in Bayesian Data Analysis

SAS Certificate Applied Statistics and SAS Programming

Lecture 9: Bayesian hypothesis testing

Handling attrition and non-response in longitudinal data

Fairfield Public Schools

Chapter 8 Hypothesis Testing Chapter 8 Hypothesis Testing 8-1 Overview 8-2 Basics of Hypothesis Testing

Standard Deviation Estimator

Dealing with Missing Data

HYPOTHESIS TESTING: CONFIDENCE INTERVALS, T-TESTS, ANOVAS, AND REGRESSION

SIMULATION STUDIES IN STATISTICS WHAT IS A SIMULATION STUDY, AND WHY DO ONE? What is a (Monte Carlo) simulation study, and why do one?

Similarity Search and Mining in Uncertain Spatial and Spatio Temporal Databases. Andreas Züfle

BASIC STATISTICAL METHODS FOR GENOMIC DATA ANALYSIS

" Y. Notation and Equations for Regression Lecture 11/4. Notation:

Multiple Imputation for Missing Data: A Cautionary Tale

Gamma Distribution Fitting

EMPIRICAL FREQUENCY DISTRIBUTION

Good luck! BUSINESS STATISTICS FINAL EXAM INSTRUCTIONS. Name:

People have thought about, and defined, probability in different ways. important to note the consequences of the definition:

Specification of the Bayesian CRM: Model and Sample Size. Ken Cheung Department of Biostatistics, Columbia University

Centre for Central Banking Studies

Model-based Synthesis. Tony O Hagan

CA200 Quantitative Analysis for Business Decisions. File name: CA200_Section_04A_StatisticsIntroduction

Week 4: Standard Error and Confidence Intervals

Problem of Missing Data

Overview of Violations of the Basic Assumptions in the Classical Normal Linear Regression Model

A Bayesian Model to Enhance Domestic Energy Consumption Forecast

Confidence Intervals for Cp

Auxiliary Variables in Mixture Modeling: 3-Step Approaches Using Mplus

Sampling via Moment Sharing: A New Framework for Distributed Bayesian Inference for Big Data

Tests for One Proportion

Model Calibration with Open Source Software: R and Friends. Dr. Heiko Frings Mathematical Risk Consulting

Data Mining: An Overview of Methods and Technologies for Increasing Profits in Direct Marketing. C. Olivia Rud, VP, Fleet Bank

SAS Software to Fit the Generalized Linear Model

Monte Carlo-based statistical methods (MASM11/FMS091)

Another Look at Sensitivity of Bayesian Networks to Imprecise Probabilities

Why Taking This Course? Course Introduction, Descriptive Statistics and Data Visualization. Learning Goals. GENOME 560, Spring 2012

MAS2317/3317. Introduction to Bayesian Statistics. More revision material

Bayesian Statistics: Indian Buffet Process

STATISTICA Formula Guide: Logistic Regression. Table of Contents

Simulation Models for Business Planning and Economic Forecasting. Donald Erdman, SAS Institute Inc., Cary, NC

A Coefficient of Variation for Skewed and Heavy-Tailed Insurance Losses. Michael R. Powers[ 1 ] Temple University and Tsinghua University

Confidence Intervals for Cpk

5.1 Identifying the Target Parameter

Confidence Interval Calculation for Binomial Proportions

Transcription:

Paper 3020-2015 Jeffreys Interval for One-Sample Proportion with SAS/STAT Software Wu Gong, The Children s Hospital of Philadelphia ABSTRACT This paper introduces Jeffreys interval for one-sample proportion using SAS software. It compares the credible interval from a Bayesian approach with the confidence interval from a frequentist approach. Different ways to calculate the Jeffreys interval are presented using PROC FREQ, the QUANTILE function, a SAS program of random walk Metropolis sampler, and PROC MCMC. INTRODUCTION Statisticians give estimates to decision makers. For example, given a fact that 81 events occurred after 263 trials (Newcombe, 1998), what is the probability of success? A simple answer is 30.8%. If given another fact that 8 events occurred after 26 trials, a simple point estimate would be almost same, 30.8%. Most people may agree intuitively that the first fact gives more accurate estimate than the second fact. Anyway, how to express the accuracy, the belief, the uncertainty, or the confidence of the estimate has been a big question for statisticians. Historically, there are two approaches to measure the estimate regarding its variation. One is called frequentist approach, the other is called Bayesian s approach. This paper serves an introduction to the Jeffreys interval for one-sample proportion using SAS/STAT software. It explains some basic concepts of Bayesian statistics, and how these concepts could be implemented in different SAS procedures. Related SAS codes and outputs are also presented. The section Interval Estimate compares two methods of Ward confidence interval and Jeffreys credible interval. The next section Jeffreys Interval explains how Jeffreys interval been derived and how to use QUANTILE function to get values of the interval. The following section Random Walk Metropolis Algorithm will explain the detailed steps of the algorithm and how to get posterior sample with SAS codes. Finally, the section PROC MCMC will show how to use PROC MCMC procedure to get numbers. INTERVAL ESTIMATE Interval estimate uses sample to calculate an interval of values for an unknown population parameter. Interval estimate and point estimate both are methods of statistical inference. They make prediction about the universe population by sample. While point estimate is a single value of the best guess, interval estimate deals with random component of the sampling, and tells audience how precise the estimate is. Two popular forms of interval estimation are confidence intervals from a frequentist approach, and credible intervals from Bayesian approach. A confidence interval is an interval bounded by an upper limit and a lower limit. Frequentists treat the unknown parameter as a fixed value. Assuming sampling repeatedly from the universe with the fixed parameter, each sampling will generate a different interval. The uncertainty of the estimate is expressed as a probability of how often the interval will contain the true population parameter (Lesaffre & Lawson, 2012). This probability is called nominal confidence level. Often a 95% level is used in practice. The confidence interval for a binomial proportion is derived through a normal approximation to the binomial distribution. It is also called Wald interval. p (1 p ) p (1 p ) Binomial Confidence Interval: p 1.96, p + 1.96 n n In Bayesian statistics, the estimated parameter is treated as a random variable. A credible interval or credible region covers the probability that the population parameter would fall in the interval. It expresses the degree of belief that the parameter falls in this interval. Two methods could be used for defining a credible interval. One is called equal-tailed interval where the probability of being below the interval is equal to the probability of being above. The other one is called highest probability density (HPD) interval 1

which is the narrowest interval that covers the nominal credible level. All values within the HPD interval are more probable than any other values outside of the HPD interval (Woodworth, 2004). SAS procedure PROC FREQ provides Wald confidence interval and Jeffreys equal-tailed credible interval for the binomial proportion with binomial-options. The SAS codes to calculate Wald and Jeffreys interval, brief explanation of the codes, and SAS output are followed. data d1; ❶ do i=1 to 263; if i <= 81 then x=1; else x=0; output; drop i; title "Table 1. Wald and Jeffreys Interval"; ods noproc ods select binomialcls; ❷ proc freq data=d1 order=data; tables x/binomial(wald Jeffreys); ❸ ❶ Create a table with 263 records, and 81 of them are successes. ❷ Select ODS output of Binomial Confidence Limits table. ❸ Binomial option for Wald confidence interval and Jeffereys credible interval. Table 1. Wald and Jeffreys Interval Binomial Proportion for x = 1 Type 95% Confidence Limits Wald 0.2522 0.3638 Jeffreys 0.2545 0.3656 JEFFREYS INTERVAL A Bayesian approach starts with a prior distribution of the parameter. The prior distribution represents estimator s belief about the parameter before any observation, and the posterior distribution is the updated belief about the parameter after observation. By multiplying the prior distribution with the likelihood of observed data, the Bayesian theorem gives you posterior distribution of the parameter. You use the posterior distribution to carry out all inference (SAS/STAT(R) 9.3 User's Guide, 2011) including Jeffreys credible interval. It is often required that a prior is objective and has minimal influence on the posterior. A flat prior is obviously a candidate. Anyway, a flat prior becomes non-flat after transformation. For example, a distribution of parameter becomes non-flat after a log transformation. It had been unacceptable that the conclusions of a Bayesian analysis depends on what scale the flat prior was taken on (Lesaffre & Lawson, 2012) until Harold Jeffreys proposed a rule to construct priors. The Jeffreys prior is a noninformative prior invariant under transformation or called re-parameterization. The Jeffreys prior for the binomial proportion is a Beta distribution with parameters (1/2, 1/2). After observing r successes in n trials, the posterior distribution could be derived and has a closed form formula of Beta distribution with parameters (r + 1/2, n r + 1/2) (Lee, 2012). 2

The Jeffreys interval is a Bayesian credible interval using the Jeffreys prior. Since the posterior distribution is known, the equal tailed 95% credible interval is simply an interval bounded by 2.5% percentile and 97.5% percentile. The SAS codes to calculate Jeffreys interval using QUANTILE function, brief explanation of codes, and SAS output are followed. title "Table 2. Jeffreys Interval by Calculating Quantiles of Beta Distribution"; data jeff; n=263; r=81; p=r/n; u=quantile('beta',0.975,r+1/2,n-r+1/2,); ❶ l=quantile('beta',0.025,r+1/2,n-r+1/2,); ❷ proc print data=jeff noobs; var n r p l u; format p l u 7.4; ❶ Upper limit equals quantile at.975 of distribution Beta(r + 1/2, n r + 1/2). ❷ Lower limit equals quantile at.025 of distribution Beta(r + 1/2, n r + 1/2). Table 2. Jeffreys Interval by Calculating Quantiles of Beta Distribution N R P L U 263 81.3080.2545.3656 RANDOM WALK METROPOLIS ALGORITHM The posterior distribution of a one-sample proportion has a closed form solution, Beta(r + 1/2, n r + 1/2). That means a mathematical formula for the probability density function of the distribution is derivable through a set of equations. This method is called an analytic solution. Sometimes, a closed form distribution doesn t exist or it might be difficult to be derived or calculated. Then comes numerical method. Numerical method solves equation by guessing or approximating. A numerical algorithm repeats guessing again and again, produces result closer and closer to the real answer. Although each run of approximating could produce a little different result than another, an appropriate degree of accuracy can be achieved after enough number of iterations. The Bayesian statistics became popular after a numerical method called Metropolis Algorithm was developed. The concept of the Metropolis Algorithm comes from Von Neumann. If you want to sample from some specific probability distribution, simply sample from any distribution you have on hand, but keep only the good samples (Beichl & Sullivan, 2000). The Metropolis Algorithm is a Markov chain Monte Carlo (MCMC) method for generating random samples for a probability distribution. The generated sample is called posterior sample and could be used for statistical inference. For example, the posterior sample could be used to derive upper and lower limits of credible interval. Markov train is a sequence of numbers, of which every successive number is generated only depending on its preceding number. Russian mathematician Andrei Andreyevich Markov introduced this concept (Gamerman & Lopes, 2006). In this one-sample proportion example, the statistic of interest is to estimate the population probability for a success event. The unknown parameter is modelled as a random variable with value from 0 to 1. To build a Markov train, the algorithm starts with an arbitrary value, for example 0.5. Then, it generates the next value through a stochastic process based on this current value. The stochastic process could be a random walk. It mimics a particle moves randomly from one position to left or right on the line. The distances the particle moves for each step could be a normal distribution with zero mean and a variance, for example, N(0, 0.08). So the next value on the sequence is 0.5 plus a 3

random distance. After multiple iterations, a sequence of numbers is generated to construct a Markov train. Random walk Markov train: θ n = θ n 1 + ω n, ω n N(0, δ) In Metropolis Algorithm, not all values on Markov train are accepted in the posterior sample in order to construct a specific distribution. Good samples are accepted and bad samples are rejected. The new generated candidate value is compared with the current value. If the observations (81 events over 263 trials) are more likely to happen under the candidate value, this candidate value is more likely to be accepted in the posterior sample. Then the ratio of likelihoods for observed data under the current and candidate sample population parameter is evaluated. The ratio is used to determine the probability whether the candidate is accepted or rejected. Steps of the Metropolis algorithm: 1, Set an arbitrary initial value of the sample, p 0 = 0.5, which is the population parameter. 2, Set a normal distribution as the proposal distribution to generate the next candidate sample, p 1 ~ N(p 0, δ). The variance δ defines how far the step is for a new generated sample value goes from the current value. 3, Generate p 1 based on p 0 (random walk from p 0 to p 1 ). 4, Calculate likelihood for observed sample by prior distribution and binomial likelihood. 1 D (p 0 ; 1 2, 1 2 ) = p 2 1 0 (1 p 0 ) 1 2 1 B ( 1 Density of the Prior Distribution: 2, 1 2 ) 1 D (p 1 ; 1 2, 1 2 ) = p 2 1 1 (1 p 1 ) 1 2 1 { B ( 1 2, 1 2 ) Binomial Likelihood: { L(X p 0) = p 0 r (1 p 0 ) n r L(X p 1 ) = p 1 r (1 p 1 ) n r 5, If the candidate value has higher likelihood than the current value, accept the candidate. 6, If the candidate value has lower likelihood, accept the candidate in a probability equals ratio. Ratio = L(X p 1) D (p 1 ; 1 2, 1 2 ) L(X p 0 ) D (p 0 ; 1 2, 1 2 ) 7, If accept, set p 0 = p 1. If reject, discard the candidate and keep the current value again in the posterior sample. 8, Go to step 3. The SAS DATA step could be considered as a process of numerical iteration. And it is very easy to implement a Random Walk Metropolis Algorithm through a do while loop. The RETAIN statement helps to generate values sequentially. Once the posterior sample is generated, empirical percentiles are calculated through PROC UNIVARIATE procedure to construct the equal tailed credible interval. The SAS codes for the Random Walk Metropolis Algorithm, brief explanation of codes, and SAS output are followed. 4

%let nmc=1010000; %let c=0.08; data PosteriorSample; call streaminit(123); n=263; r=81; p0=0.5; ❶ retain p0; do i = 1 to &nmc.; ❷ p1=p0+rand('normal',0,&c.); ❸ do while(p1 lt 0 or p1 gt 1); p1=p0+rand('normal',0,&c.); ❹ logratio=(1/2-1)*log(p1)+(1/2-1)*log(1-p1)+r*log(p1)+(n-r)*log(1-p1) - (1/2-1)*log(p0)-(1/2-1)*log(1-p0)-r*log(p0)-(n-r)*log(1-p0); ❺ if log(rand('uniform')) <= logratio then do; ❻ p0=p1; if i gt 10000 and floor(i/20)*20 eq i then do; ❼ output; keep i p0; title "Table 3. Jeffreys Interval by Random Walk Metropolis Algorithm"; proc univariate data=posteriorsample noprint; var p0; output out=pp pctlpts = 2.5 97.5 pctlpre = pct; proc print data=pp noobs; format pct2_5 pct97_5 6.4; ❶ Arbitrary initial value of the current candidate, p 0. ❷ Number of total iteration. It will control total number of records on posterior sample after consideration of burn-in and thinning. ❸ Set proposal distribution of random walk as normal distribution. Variance defines step size. ❹ Regenerate p 1 in case the probability less than zero or greater than 1. ❺ Calculate the log ratio of likelihood of the sample under two proposals. See step 6. ❻ Reject or accept the proposal. ❼ Drop the first 10000 records (burn-in) and keep one record every 20 records (thinning). Table 3. Jeffreys Interval by Random Walk Metropolis Algorithm pct2_5 pct97_5 0.2548 0.3657 5

PROC MCMC SAS procedure PROC MCMC uses a self-tuning random walk Metropolis algorithm to obtain posterior sample (Chen, 2009). The MCMC procedure produces Jeffreys equal-tailed interval and highest probability density interval. It also provides diagnostics for the convergence of the posterior sample. PROC MCMC has strong flexibility to perform a wide range of Bayesian statistical analysis. The SAS codes to calculate Jefreys interval using PROC MCMC procedure, brief explanation of the codes, and related SAS output are followed. title "Table 4. Jeffreys Credible Interval by PROC MCMC"; ods select PostIntervals; proc mcmc data=jeff seed=123 outpost=posteriorsample ❶ nbi=10000 ❷ nthin=20 ❸ nmc=1000000 ❹ statistics=(summary interval) diagnostics=none plots=none; parms prb 0.5; ❺ prior prb ~ beta(1/2,1/2); ❻ model r ~ binomial(n,prb); ❼ ❶ Output posterior sample into a dataset called PosteriorSample. There will be 1000000/20=50000 records in the posterior sample. ❷ Number of burn-in iterations that be discharged before saved into posterior sample. ❸ Number of thinning controls the thinning of the Markov chain and keep one of every 20 samples. ❹ Number of iteration. ❺ The parameter of posterior probability is named as prb with arbitrary initial value of 0.5. ❻ Prior distribution of beta(1/2,1/2). ❼ It specifies the likelihood function as binomial. There are r events occurred after n trials under binomial likelihood with probability prb. Table 4. Jeffreys Credible Interval by PROC MCMC Posterior Intervals Parameter Alpha Equal-Tail Interval HPD Interval PRB 0.050 0.2547 0.3660 0.2543 0.3652 CONCLUSION SAS provides various methods in Bayesian analysis and MCMC procedure is a great tool of them. In the scenario of one-sample proportion, the Jeffreys credible interval could be calculated using several different ways. Credible interval serves a summary of posterior information. It has more meaningful interpretation than the confidence interval. Also, once the posterior sample has been generated, it has advantages to derive all other statistics such as mean, median, variance and all quantiles. The Bayesian posterior could be used to answer decision makers questions more directly and intuitively. 6

REFERENCES Beichl, I., & Sullivan, F. (2000). The Metropolis Algorithm. Computing in Science and Engineering, 65-69. Chen, F. (2009). Bayesian Modeling Using the MCMC Procedure. SAS Global Forum 2009. SAS Institute Inc. Gamerman, D., & Lopes, H. F. (2006). Markov Chain Monte Carlo : Stochastic Simulation for Bayesian Inference. Chapman & Hall/CRC. Lee, P. M. (2012). Bayesian Statistics : An Introduction (4th Edition). John Wiley & Sons. Lesaffre, E., & Lawson, A. B. (2012). Bayesian Biostatistics. John Wiley & Sons, Ltd. Newcombe, R. G. (1998). Two-sided confidence intervals for the single proportion: comparison of seven methods. Statistics in Medicine. SAS/STAT(R) 9.3 User's Guide. (2011). SAS Institute Inc. Woodworth, G. G. (2004). Biostatistics: A Bayesian Introduction. John Wiley & Sons, Inc. CONTACT INFORMATION Your comments and questions are valued and encouraged. Contact the author at: Wu Gong Healthcare Analytic Unit/CPCE/PolicyLab, The Children s Hospital of Philadelphia 3535 Market Street, Philadelphia, PA 19104 Work Phone: (267) 426-9445 gongw1@email.chop.edu SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. indicates USA registration. Other brand and product names are trademarks of their respective companies. 7