[R] Comparing posterior and likelihood estimates for proportions (off topic)

Giovanni Petris GPetris at uark.edu
Wed Dec 6 17:50:48 CET 2006


You are not comparing estimates of the population proportion. 

Giovanni

> Date: Tue, 05 Dec 2006 17:08:27 -0500
> From: "Doran, Harold" <HDoran at air.org>
> Sender: r-help-bounces at stat.math.ethz.ch
> Precedence: list
> Thread-topic: Comparing posterior and likelihood estimates for proportions	(off
>  topic)
> Thread-index: AccYuQPSLwIrLya5T4ivem8lVU99aQ==
> 
> This question is slightly off topic, but I'll use R to try and make it
> as relevant as possible. I'm working on a problem where I want to
> compare estimates from a posterior distribution with a uniform prior
> with those obtained from a frequentist approach. Under these conditions
> the estimates should agree.
> 
> Specifically, I am asking the question, "What is the probability that
> the true proportion of students passing a test is 50% when the observed
> proportion for that school is only 38%?"
> 
> For my example, there are 100 students in the school and 38 of them
> passed an exam. For conjugacy, if we choose a beta prior, then posterior
> in this case is also a beta distribution. Now, I believe the a and b
> parameters for a beta with a uniform prior is a=1 and b=1, or 1/(1+1)
> 
> Here is my R code for the posterior with a flat prior
> 
> n <- 100 # Total number of individuals
> y <- 38  # Number of successes
> a <- 1   # Parameter 1 for Beta prior
> b <- 1   # Parameter 2 for Beta prior
> theta <- .38 # Proportion passing
> 
> pbeta(.50, a + y, b+n-y, lower.tail=FALSE)
> [1] 0.008253
> 
> Now, the binomial distribution gives
> 
> > dbinom(50, 100, .38)
> [1] 0.0040984
> 
> Obviously, the results don't agree. So, I'm wondering if I have 
> 
> A) made a computational error
> B) have an error in my assumption that the results should agree in this
> case
> 
> Thanks for any reactions
> Harold
> 
> Windows XP
> > version
>                _                           
> platform       i386-pc-mingw32             
> arch           i386                        
> os             mingw32                     
> system         i386, mingw32               
> status                                     
> major          2                           
> minor          4.0                         
> year           2006                        
> month          10                          
> day            03                          
> svn rev        39566                       
> language       R                           
> version.string R version 2.4.0 (2006-10-03)
> 
>  
> 
> 
> 
> 
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
> 

-- 

Giovanni Petris  <GPetris at uark.edu>
Associate Professor
Department of Mathematical Sciences
University of Arkansas - Fayetteville, AR 72701
Ph: (479) 575-6324, 575-8630 (fax)
http://definetti.uark.edu/~gpetris/




More information about the R-help mailing list