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

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

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

Doran, Harold
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]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

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

Giovanni Petris

You are not comparing estimates of the population proportion.

Giovanni

> Date: Tue, 05 Dec 2006 17:08:27 -0500
> From: "Doran, Harold" <[hidden email]>
> Sender: [hidden email]
> 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]]
>
> ______________________________________________
> [hidden email] 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  <[hidden email]>
Associate Professor
Department of Mathematical Sciences
University of Arkansas - Fayetteville, AR 72701
Ph: (479) 575-6324, 575-8630 (fax)
http://definetti.uark.edu/~gpetris/

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

[R] dynamic panel data estimation

pu chen
In reply to this post by Doran, Harold
Hello every one,

is there an R package that can handle dynamic panel data model aviablable ?

thank you for help

chen

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: [R] dynamic panel data estimation

mabonazel
yes, can you use the (plm) package for panel data estimation in general
but, i not know a package for dynamic panel data models
Reply | Threaded
Open this post in threaded view
|

Re: dynamic panel data estimation

Jose Iparraguirre
You can run dynamic panel data models with plm -see the package's vignette "Panel Data Econometrics in R: The plm Package" by Yves Croissant and Giovanni Millo (section 5.4)
Check Giovanni Petris, Sonia Petrone, Patrizia Campagnoli's monograph "Dynamic Linear Models with R" as well.
Hope this helps.

José


José Iparraguirre
Chief Economist
Age UK

T 020 303 31482
E [hidden email]
Twitter @jose.iparraguirre@ageuk


Tavis House, 1- 6 Tavistock Square
London, WC1H 9NB
www.ageuk.org.uk | ageukblog.org.uk | @ageukcampaigns


For a copy of our new Economic Monitor and the full Chief Economist's report, visit the Age UK Knowledge Hub http://www.ageuk.org.uk/professional-resources-home/knowledge-hub-evidence-statistics/


For evidence and statistics on the older population, visit the Age UK Knowledge Hub http://www.ageuk.org.uk/professional-resources-home/knowledge-hub-evidence-statistics/


-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of mabonazel
Sent: 21 October 2012 12:20
To: [hidden email]
Subject: Re: [R] dynamic panel data estimation

yes, can you use the (plm) package for panel data estimation in general
but, i not know a package for dynamic panel data models



--
View this message in context: http://r.789695.n4.nabble.com/R-Comparing-posterior-and-likelihood-estimates-for-proportions-off-topic-tp814022p4646910.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
[hidden email] 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.

Age UK and YouthNet are official charities for the Virgin London Marathon 2013

We need you to Run for it. Join the team and help raise vital funds to bring generations together to combat loneliness and isolation.

Go to http://www.runforit.org.uk for more information or contact Helen Parson at [hidden email] or on 020 303 31369.

Age UK and YouthNet. A lifeline, online.

www.runforit.org.uk



Age UK Improving later life

www.ageuk.org.uk



-------------------------------
Age UK is a registered charity and company limited by guarantee, (registered charity number 1128267, registered company number 6825798).
Registered office: Tavis House, 1-6 Tavistock Square, London WC1H 9NA.

For the purposes of promoting Age UK Insurance, Age UK is an Appointed Representative of Age UK Enterprises Limited, Age UK is an Introducer
Appointed Representative of JLT Benefit Solutions Limited and Simplyhealth Access for the purposes of introducing potential annuity and health
cash plans customers respectively.  Age UK Enterprises Limited, JLT Benefit Solutions Limited and Simplyhealth Access are all authorised and
regulated by the Financial Services Authority.
------------------------------

This email and any files transmitted with it are confide...{{dropped:28}}

______________________________________________
[hidden email] 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.