SlideShare a Scribd company logo
Bayesian Statistics using R
An Introduction
J. Guzmán
30 March 2010
JGuzmanPhD@Gmail.Com
Bayesian: one who asks you
what you think before a study
in order to tell you what you think
afterwards
Adapted from:
S Senn, 1997. Statistical Issues
in Drug Development. Wiley
Content
•  Some Historical Remarks
•  Bayesian Inference:
– Binomial data
– Poisson data
– Normal data
•  Implementation using R program
•  Hierarchical Bayes Introduction
•  Useful References & Web Sites
We Assume
•  Student knows Basic Probability Rules
•  Including Conditional Probability
P(A | B) = P(A & B) / P(B)
•  And Bayes’ Theorem:
P( A | B ) = P( A ) × P( B | A ) ÷ P( B )
where
P( B ) = P( A )×P( B | A ) + P( AC )×P( B | AC )
We Assume
•  Student knows Basic Probability Models
•  Including Binomial, Poisson, Uniform,
Exponential & Normal
•  Could be familiar with t, Chi2 & F
•  Preferably, but not necessarily, familiar
with Beta & Gamma Distributions
•  Preferably, but not necessarily, knows
Basic Calculus
Bayesian [Laplacean] Methods
•  1763 – Bayes’ article on inverse probability
•  Laplace extended Bayesian ideas in different
scientific areas in Théorie Analytique des
Probabilités [1812]
•  Laplace & Gauss used the inverse method
•  1st three quarters of 20th Century dominated by
frequentist methods [Fisher, Neyman, et al.]
•  Last quarter of 20th Century – resurgence of
Bayesian methods [computational advances]
•  21st Century – Bayesian Century [Lindley]
Rev. Thomas Bayes
English Theologian and
Mathematician
c. 1700 – 1761
Pierre-Simon Laplace
French Mathematician
1749 – 1827
Karl Friedrich Gauss
“Prince of
Mathematics”
1777 – 1855
Bayes’ Theorem
•  Basic tool of Bayesian Analysis
•  Provides the means by which we learn
from data
•  Given prior state of knowledge, it tells
how to update belief based upon
observations:
P(H | Data) = P(H) · P(Data | H) / P(Data)
Bayes’ Theorem
•  Can also consider posterior probability of
any measure θ:
P(θ) x P( data | θ) → P(θ | data)
•  Bayes’ theorem states that the posterior
probability of any measure θ, is
proportional to the information on θ
external to the experiment times the
likelihood function evaluated at θ:
Prior · Likelihood → Posterior
Prior
•  Prior information about θ assessed as a
probability distribution on θ
•  Distribution on θ depends on the assessor: it
is subjective
•  A subjective probability can be calculated
any time a person has an opinion
•  Diffuse (Vague) prior - when a person’ s
opinion on θ includes a broad range of
possibilities & all values are thought to be
roughly equally probable
Prior
•  Conjugate prior – if the posterior distribution
has same shape as the prior distribution,
regardless of the observed sample values
•  Examples:
1.  Beta Prior x Binomial Likelihood →
Beta Posterior
2.  Normal Prior x Normal Likelihood →
Normal Posterior
3.  Gamma Prior x Poisson Likelihood →
Gamma Posterior
Community of Priors
•  Expressing a range of reasonable opinions
•  Reference – represents minimal prior
information [JM Bernardo, U of V]
•  Expertise – formalizes opinion of
well-informed experts
•  Skeptical – downgrades superiority of
new treatment
•  Enthusiastic – counterbalance of skeptical
Likelihood Function
P(data | θ)
•  Represents the weight of evidence from the
experiment about θ
•  It states what the experiment says about the
measure of interest [ LJ Savage, 1962 ]
•  It is the probability of getting certain result,
conditioning on the model
•  Prior is dominated by the likelihood as the
amount of data increases:
–  Two investigators with different prior opinions
could reach a consensus after the results of an
experiment
Likelihood Principle
•  States that the likelihood function contains
all relevant information from the data
•  Two samples have equivalent information if
their likelihoods are proportional
•  Adherence to the Likelihood Principle means
that inference are conditional on the
observed data
•  Bayesian analysts base all inferences about θ
solely on its posterior distribution
•  Data only affect the posterior through the
likelihood P(data | θ)
Likelihood Principle
•  Two experiments: one yields data y1
and the other yields data y2
•  If P(y1 | θ) & P(y2 | θ) are identical up to
multiplication by arbitrary functions of
y1 & y2 then they contain identical
information about θ and lead to
identical posterior distributions
•  Therefore, to equivalent inferences
Example
•  EXP 1: In a study of a
fixed sample of 20
students, 12 of them
respond positively to
the method [Binomial
distribution]
•  Likelihood is
proportional to
θ12 (1 – θ)8
•  EXP 2: Students are
entered into a study
until 12 of them
respond positively to
the method [Negative-
Binomial distribution]
•  Likelihood at n = 20 is
proportional to
θ12 (1 – θ)8
Exchangeability
•  Key idea in Statistical Inference in general
•  Two observations are exchangeable if they
provide equivalent statistical information
•  Two students randomly selected from a particular
population of students can be considered
exchangeable
•  If the students in a study are exchangeable with
the students in the population for which the
method is intended, then the study can be used to
make inferences about the entire population
•  Exchangeability in terms of experiments: Two
studies are exchangeable if they provide
equivalent statistical information about some
super-population of experiments
Bayesian Statistics (BS)
•  BS or inverse probability – method of
Statistical Inference until 1910s
•  No much progress of BS up to 1980s
•  Metropolis, Rosenbluth2, Teller2, 1953: MC
•  Hastings, 1970: Metropolis-Hastings
•  Geman2, 1984: Image analysis w. Gibbs
•  MRC – BU, 1989: BUGS
•  Gelfand and Smith,1990: McMC & Gibbs
Algorithms. JASA
Bayesian Estimation of θ
•  X successes & Y failures, N independent
trials
•  Prior Beta(a, b) Binomial likelihood →
Posterior Beta(a + x, b + y)
•  Example in:
Suárez, Pérez & Guzmán, 2000.
“Métodos Alternos de Análisis Estadístico en
Epidemiología”. PR HSJr. V.19: 153-156
Bayesian Estimation of θ
a = 1; b = 1
prob.p = seq(0, 1, .1)
prior.d = dbeta(prob.p, a, b)
Prior Density Plot
plot(prob.p, prior.d,
type = "l",
main="Prior Density for P",
xlab="Proportion",
ylab="Prior Density")
•  Observed 8 successes & 12 failures
x = 8; y = 12; n = x + y
Likelihood & Posterior
like = prob.p^x * (1-prob.p)^y
post.d0 = prior.d * like
post.d = dbeta(prob.p, a + x ,
b + y) # Beta Posterior
Posterior Distribution
plot(prob.p, post.d, type="l",
main = "Posterior Density for
θ", xlab = "Proportion",
ylab = "Posterior Density")
•  Get better plots using
library(Bolstad)
•  Install library(Bolstad) from CRAN
# 8 successes observed in 20 trials with a Beta(1, 1) prior
library(Bolstad)
results = binobp(8, 20, 1, 1, ret = TRUE)
par(mfrow = c(3, 1))
y.lims=c(0, 1.1*max(results$posterior, results$prior))
plot(results$theta, results$prior, ylim=y.lims, type="l",
xlab=expression(theta), ylab="Density", main="Prior")
polygon(results$theta, results$prior, col="red")
plot(results$theta, results$likelihood, ylim=c(0,0.25), type="l",
xlab=expression(theta), ylab="Density", main="Likelihood")
polygon(results$theta, results$likelihood, col="green")
plot(results$theta, results$posterior, ylim=y.lims, type="l",
xlab=expression(theta), ylab="Density", main="Posterior")
polygon(results$theta, results$posterior, col="blue")
par(mfrow = c(1, 1))
Posterior Inference
Results :
Posterior Mean : 0.4090909
Posterior Variance : 0.0105102
Posterior Std. Deviation : 0.1025195
Prob. Quantile
------ ---------
0.005 0.1706707
0.01 0.1891227
0.025 0.2181969
0.05 0.2449944
0.5 0.4062879
0.95 0.5828013
0.975 0.6156456
0.99 0.65276
0.995 0.6772251
0.0 0.2 0.4 0.6 0.8 1.0
01234
Prior
θ
Density
0.0 0.2 0.4 0.6 0.8 1.0
0.000.100.20
Likelihood
θ
Density
0.0 0.2 0.4 0.6 0.8 1.0
01234
Posterior
θ
Density
Credible Interval
•  Generate 1000 random observations
from beta(a + x , b + y)
set.seed(12345)
x.obs = rbeta(1000, a+x, b+y)
Mean & 90% Posterior Limits for P
•  Obtain a 90% credible limits:
q.obs.low = quantile(x.obs,
p = 0.05) # 5th percentile
q.obs.hgh = quantile(x.obs,
p = 0.95) # 95th percentile
print(c(q.obs.low, mean(x.obs),
q.obs.hgh))
Bayesian Inference: Normal Mean
•  Bayesian Inference on a Normal mean with a
Normal prior
•  Bayes’ Theorem:
Prior x Likelihood → Posterior
•  Assume σ is known:
If y ~ N(µ, σ); µ ~ N(µ0, σ0 )
→ µ | y ~ N(µ1, σ1)
•  Data: y = { y1, y2, …, yn }
Posterior Mean & SD
2 2
0
1 2 2
0
2 2 2
1 0
/ /
/ 1/
1/ / 1/
ny
n
n
σ µ σ
µ
σ σ
σ σ σ
+
=
+
= +
Shoe Wear Example
•  Ref. Box, Hunter & Hunter, 2005; p. 81 ff
library(BHH2)
attach(shoes.data)
shoes.data
D = matA – matB
shapiro.test(D)
normnp(D, 5) # Normal(0,SD = 5)
Prior
Shoe Wear Example
Posterior mean : -0.1171429
Posterior std. deviation : 0.8451543
Prob. Quantile
------ ---------
0.005 -2.294116
0.01 -2.0832657
0.025 -1.7736148
0.05 -1.5072979
0.5 -0.1171429
0.95 1.2730122
0.975 1.539329
0.99 1.8489799
0.995 2.0598302
-3 -2 -1 0 1 2 3
0.00.10.20.30.40.5
µ
Probabilty(µ)
Posterior
Prior
Poisson-Gamma
•  Y ~ Poisson(µ); Y = 0, 1, 2, …
•  Gamma Prior x Poisson Likelihood
→ Gamma Posterior
•  µ ~ Gamma(a, b); µ > 0, a>0, b>0
•  Mean(µ) = a/b
•  Var(µ) = a/b2
•  RE: Exponential & Chi2 are special
cases of Gamma Family
Poisson-Gamma Example
•  Y = Autos per family in a city
•  {Y1 , … ,Yn | µ} ~ Poisson(µ)
•  Prior: µ ~ Gamma(a0, b0)
•  Posterior: µ | data ~ Gamma(a1, b1)
•  Where a1 = a0 + Sum(Yi ) and
b1 = b0 + n
•  Data: n = 45, Sum(Yi ) = 121
Poisson-Gamma Example
•  Assume µ ~ Gamma(a0 = 2, b0 = 1)
a = 2; b = 1
n = 45; s.y = 121
•  95% Posterior Limits for µ:
qgamma( c(.025, .975),
a + s.y, b + n)
Hierarchical Models
•  Data from several subpopulations or groups
•  Instead of performing separate analyses for
each group, it may make good sense to
assume that there is some relationship
between the parameters of different groups
•  Assume exchangeability between groups &
introduce a higher level of randomness on
the parameters
•  Meta-Analysis approach – particularly
effective when the information from each
sub–population is limited
Hierarchical Models
•  Hierachical modeling also includes:
•  Mixed-effects models
•  Variance component models
•  Continuous mixture models
Hierarchical Models
•  Hierarchy:
– Prior distribution has parameters (a, b)
– Prior parameters (a, b) have hyper–prior
distributions
– Data likelihood, conditionally independent
of hyper-priors
•  Hyper–priors → Prior → Likelihood
→ Posterior Distribution
Hierarchical Modeling
•  Eight Schools Example
•  ETS Study – analyzes effects of
coaching program on test scores
•  Randomized experiments to estimate
effect of coaching for SAT-V in high
schools
•  Details – Gelman et al., B D A
Eight Schools Example
Sch A B C D E F G H
TrEf
yj 28 8 -3 7 -1 1 18 12
StdEr
sj 15 10 16 11 9 11 10 18
Hierarchical Modeling
•  θj ~ Normal(µ, σ) [Effect in School j]
•  Uniform hyper–prior for µ, given σ; and
diffuse prior for σ:
Pr(µ, σ) = Pr(µ | σ) x Pr(σ) α 1
•  Pr(µ, σ, θj | y ) = Pr(µ | σ) x p(σ) x
Π1:J [ θj | µ, σ] x Pr(y)
2
2
1
1
Assume parameters are conditionally independent
given ( , ): ~ ( , ). Therefore,
( ,..., | , ) ( | , ).
Assign non-informative uniform hyperprior to ,
given . And a diffuse non-informativ
j
J
jJ
j
N
p N
µ τ θ µ τ
θ θ µ τ θ µ τ
µ
τ
=
= Π
e prior for :
( , ) ( | ) ( ) 1p p p
τ
µ τ µ τ τ= ∝ ∝
2 2
.
j
2
Joint Posterior Distribution
( , , | ) ( , ) ( | , ) ( | )
( , ) ( | , ) ( | , )
Conditional Posterior of Normal Means:
ˆ| , , ~ ( , )
where
ˆ
j j j j
jj
j j
j
p y p p p y
p N N y
y N V
y
θ µ τ µ τ θ µ τ θ
µ τ θ µ τ θ σ
θ µ τ θ
σ τ
θ
−
∝
∝ Π Π
⋅ +
=
2
2 2 1
2 2
and ( )j j
j
V
µ
σ τ
σ τ
−
− − −
− −
⋅
= +
+
2 2 1
.1
2 2 1
1
-1 2 2 1
1
2 2
.1
Posterior for given :
ˆ| , ~ ( , )
where
( )
ˆ , and
( )
V ( ) .
Posterior for :
( , | )
( | )
( | , )
( | , )
ˆ( | , )
J
j jj
J
jj
J
jj
J
j jj
y N V
y
p y
p y
p y
N y
N V
µ
µ
µ
µ τ
µ τ µ
σ τ
µ
σ τ
σ τ
τ
µ τ
τ
µ τ
µ σ τ
µ µ
−
=
−
=
−
=
=
+ ⋅
=
+
= +
=
+
∝
∑
∑
∑
∏
2
..5 2 2 .5
2 2
ˆ( )
( ) exp
2( )
j
j
j
y
Vµ
µ
σ τ
σ τ
−
⎛ ⎞
⎜ ⎟
⎜ ⎟
⎝ ⎠
−
∝ +
+∏
BUGS + R = BRugs
Use File > Change dir ... to find required folder
# school.wd="C:/Documents and Settings/Josue Guzman/My Documents/R Project/My Projects/Bayesian/W_BUGS/Schools"
library(BRugs) # Load BRugs Package for MCMC Simulation
modelCheck("SchoolsBugs.txt") # HB Model
modelData("SchoolsData.txt") # Data
nChains=1
modelCompile(numChains=nChains)
modelInits(rep("SchoolsInits.txt",nChains))
modelUpdate(1000) # Burn in
samplesSet(c("theta","mu.theta","sigma.theta"))
dicSet()
modelUpdate(10000,thin=10)
samplesStats("*")
dicStats()
plotDensity("mu.theta",las=1)
Schools’ Model
model {
for (j in 1:J)
{
y[j] ~ dnorm (theta[j], tau.y[j])
theta[j] ~ dnorm (mu.theta, tau.theta)
tau.y[j] <- pow(sigma.y[j], -2)
}
mu.theta ~ dnorm (0.0, 1.0E-6)
tau.theta <- pow(sigma.theta, -2)
sigma.theta ~ dunif (0, 1000)
}
Schools’ Data
list(J=8, y = c(28.39, 7.94, -2.75, 6.82,
-0.64, 0.63, 18.01, 12.16),
sigma.y = c(14.9, 10.2, 16.3, 11.0, 9.4,
11.4, 10.4, 17.6))
Schools’ Initial Values
list(theta = c(0, 0, 0, 0, 0, 0, 0, 0),
mu.theta = 0,
sigma.theta = 50) )
BRugs Schools’ Results
samplesStats("*")
mean sd MCerror 2.5pc median 97.5pc start sample
mu.theta 8.147 5.28 0.081 -2.20 8.145 18.75 1001 10000
sigma.theta 6.502 5.79 0.100 0.20 5.107 21.23 1001 10000
theta[1] 11.490 8.28 0.098 -2.34 10.470 31.23 1001 10000
theta[2] 8.043 6.41 0.091 -4.86 8.064 21.05 1001 10000
theta[3] 6.472 7.82 0.103 -10.76 6.891 21.01 1001 10000
theta[4] 7.822 6.68 0.079 -5.84 7.778 21.18 1001 10000
theta[5] 5.638 6.45 0.091 -8.51 6.029 17.15 1001 10000
theta[6] 6.290 6.87 0.087 -8.89 6.660 18.89 1001 10000
theta[7] 10.730 6.79 0.088 -1.35 10.210 25.77 1001 10000
theta[8] 8.565 7.87 0.102 -7.17 8.373 25.32 1001 10000
Graphical Display
Ø plotDensity("mu.theta",las=1,
main = "Treatment Effect")
Ø plotDensity("sigma.theta",las=1,
main = "Standard Error")
Ø plotDensity("theta[1]",las=1,
main = "School A")
Ø plotDensity("theta[3]",las=1,
main = "School C")
Ø plotDensity("theta[8]",las=1,
main = "School H")
Graphical Display
-20 0 20 40
0.00
0.02
0.04
0.06
0.08
Treatment Effect
Graphical Display
0 10 20 30 40 50 60
0.00
0.02
0.04
0.06
0.08
0.10
Standard Error
Graphical Display
Graphical Display
-40 -20 0 20 40
0.00
0.01
0.02
0.03
0.04
0.05
0.06
School C
Graphical Display
-40 -20 0 20 40 60
0.00
0.01
0.02
0.03
0.04
0.05
0.06
School H
Laplace on Probability
It is remarkable that a science, which
commenced with the consideration of
games of chance, should be elevated to
the rank of the most important subjects
of human knowledge.
A Philosophical Essay on Probabilities,
1902. John Wiley & Sons. Page 195.
Original French Edition 1814.
Future Talk
•  Non-Conjugate Inference
•  McMC simulation:
– Gibbs
– Metropolis–Hastings
•  Bayesian Regression
– Normal Model
– Logistic Regression
– Poisson Regression
– Survival Analysis
Some Useful References
•  Bernardo JM & AFM Smith, 1994. Bayesian Theory.
Wiley.
•  Bolstad WM, 2004. Introduction to Bayesian
Statistics. Wiley.
•  Gelman A, GO Carlin, HS Stern & DB Rubin, 2004.
Bayesian Data Analysis, 2nd Edition. Chapman-Hall.
•  Gill J, 2008. Bayesian Methods 2nd Edition.
Chapman-Hall.
•  Lee P, 2004. Bayesian Statistics: An Introduction,
•  3rd Edition. Arnold.
•  O'Hagan A & Forster JJ, 2004. Bayesian Inference,
2nd Edition. Vol. 2B of "Kendall's Advanced Theory
of Statistics". Arnold.
•  Rossi PE, GM Allenby & R McCulloch, 2005.
Bayesian Statistics and Marketing. Wiley.
Some Useful References
•  Chib S & Greenberg E, 1995. Understanding
the Metropolis–Hastings algorithm.
TAS: V. 49: 327 - 335
•  Gelfand AE and Smith AFM, 1990. Sampling
based approaches to calculating marginal
densities JASA: V. 85: 398 - 409
•  Smith AFM & Gelfand AE, 1992. Bayesian
statistics without tears. TAS: V. 46: 84 - 88
Some Useful Web Sites
Bernardo JM: http://www.uv.es/~bernardo
CRAN: http://cran.r–project.org
Gelman A: http://www.stat.columbia.edu/
~gelman
Jefferys: http://bayesrules.net
OpenBUGS: http://mathstat.helsinki.fi/
openbugs
Joseph: http://www.medicine.mcgill.ca/
epidemiology/Joseph/index.html
BRugs click Manuals in OpenBUGS

More Related Content

What's hot

Tutorial on testing at O'Bayes 2015, Valencià, June 1, 2015
Tutorial on testing at O'Bayes 2015, Valencià, June 1, 2015Tutorial on testing at O'Bayes 2015, Valencià, June 1, 2015
Tutorial on testing at O'Bayes 2015, Valencià, June 1, 2015
Christian Robert
 
On the vexing dilemma of hypothesis testing and the predicted demise of the B...
On the vexing dilemma of hypothesis testing and the predicted demise of the B...On the vexing dilemma of hypothesis testing and the predicted demise of the B...
On the vexing dilemma of hypothesis testing and the predicted demise of the B...
Christian Robert
 
"reflections on the probability space induced by moment conditions with impli...
"reflections on the probability space induced by moment conditions with impli..."reflections on the probability space induced by moment conditions with impli...
"reflections on the probability space induced by moment conditions with impli...
Christian Robert
 
original
originaloriginal
original
butest
 
An overview of Bayesian testing
An overview of Bayesian testingAn overview of Bayesian testing
An overview of Bayesian testing
Christian Robert
 
Approximate Bayesian model choice via random forests
Approximate Bayesian model choice via random forestsApproximate Bayesian model choice via random forests
Approximate Bayesian model choice via random forests
Christian Robert
 
Can we estimate a constant?
Can we estimate a constant?Can we estimate a constant?
Can we estimate a constant?
Christian Robert
 
ABC workshop: 17w5025
ABC workshop: 17w5025ABC workshop: 17w5025
ABC workshop: 17w5025
Christian Robert
 
Designing Test Collections for Comparing Many Systems
Designing Test Collections for Comparing Many SystemsDesigning Test Collections for Comparing Many Systems
Designing Test Collections for Comparing Many Systems
Tetsuya Sakai
 
Statistics (1): estimation, Chapter 2: Empirical distribution and bootstrap
Statistics (1): estimation, Chapter 2: Empirical distribution and bootstrapStatistics (1): estimation, Chapter 2: Empirical distribution and bootstrap
Statistics (1): estimation, Chapter 2: Empirical distribution and bootstrap
Christian Robert
 
Big model, big data
Big model, big dataBig model, big data
Big model, big data
Christian Robert
 
Module 4 part_1
Module 4 part_1Module 4 part_1
Module 4 part_1
ShashankN22
 
Convergence of ABC methods
Convergence of ABC methodsConvergence of ABC methods
Convergence of ABC methods
Christian Robert
 
Statistics (1): estimation, Chapter 1: Models
Statistics (1): estimation, Chapter 1: ModelsStatistics (1): estimation, Chapter 1: Models
Statistics (1): estimation, Chapter 1: Models
Christian Robert
 
ABC short course: introduction chapters
ABC short course: introduction chaptersABC short course: introduction chapters
ABC short course: introduction chapters
Christian Robert
 
Statistics (1): estimation Chapter 3: likelihood function and likelihood esti...
Statistics (1): estimation Chapter 3: likelihood function and likelihood esti...Statistics (1): estimation Chapter 3: likelihood function and likelihood esti...
Statistics (1): estimation Chapter 3: likelihood function and likelihood esti...
Christian Robert
 
random forests for ABC model choice and parameter estimation
random forests for ABC model choice and parameter estimationrandom forests for ABC model choice and parameter estimation
random forests for ABC model choice and parameter estimation
Christian Robert
 
Pattern recognition binoy 05-naive bayes classifier
Pattern recognition binoy 05-naive bayes classifierPattern recognition binoy 05-naive bayes classifier
Pattern recognition binoy 05-naive bayes classifier
108kaushik
 
Statistics-2 : Elements of Inference
Statistics-2 : Elements of InferenceStatistics-2 : Elements of Inference
Statistics-2 : Elements of Inference
Giridhar Chandrasekaran
 
Considerate Approaches to ABC Model Selection
Considerate Approaches to ABC Model SelectionConsiderate Approaches to ABC Model Selection
Considerate Approaches to ABC Model Selection
Michael Stumpf
 

What's hot (20)

Tutorial on testing at O'Bayes 2015, Valencià, June 1, 2015
Tutorial on testing at O'Bayes 2015, Valencià, June 1, 2015Tutorial on testing at O'Bayes 2015, Valencià, June 1, 2015
Tutorial on testing at O'Bayes 2015, Valencià, June 1, 2015
 
On the vexing dilemma of hypothesis testing and the predicted demise of the B...
On the vexing dilemma of hypothesis testing and the predicted demise of the B...On the vexing dilemma of hypothesis testing and the predicted demise of the B...
On the vexing dilemma of hypothesis testing and the predicted demise of the B...
 
"reflections on the probability space induced by moment conditions with impli...
"reflections on the probability space induced by moment conditions with impli..."reflections on the probability space induced by moment conditions with impli...
"reflections on the probability space induced by moment conditions with impli...
 
original
originaloriginal
original
 
An overview of Bayesian testing
An overview of Bayesian testingAn overview of Bayesian testing
An overview of Bayesian testing
 
Approximate Bayesian model choice via random forests
Approximate Bayesian model choice via random forestsApproximate Bayesian model choice via random forests
Approximate Bayesian model choice via random forests
 
Can we estimate a constant?
Can we estimate a constant?Can we estimate a constant?
Can we estimate a constant?
 
ABC workshop: 17w5025
ABC workshop: 17w5025ABC workshop: 17w5025
ABC workshop: 17w5025
 
Designing Test Collections for Comparing Many Systems
Designing Test Collections for Comparing Many SystemsDesigning Test Collections for Comparing Many Systems
Designing Test Collections for Comparing Many Systems
 
Statistics (1): estimation, Chapter 2: Empirical distribution and bootstrap
Statistics (1): estimation, Chapter 2: Empirical distribution and bootstrapStatistics (1): estimation, Chapter 2: Empirical distribution and bootstrap
Statistics (1): estimation, Chapter 2: Empirical distribution and bootstrap
 
Big model, big data
Big model, big dataBig model, big data
Big model, big data
 
Module 4 part_1
Module 4 part_1Module 4 part_1
Module 4 part_1
 
Convergence of ABC methods
Convergence of ABC methodsConvergence of ABC methods
Convergence of ABC methods
 
Statistics (1): estimation, Chapter 1: Models
Statistics (1): estimation, Chapter 1: ModelsStatistics (1): estimation, Chapter 1: Models
Statistics (1): estimation, Chapter 1: Models
 
ABC short course: introduction chapters
ABC short course: introduction chaptersABC short course: introduction chapters
ABC short course: introduction chapters
 
Statistics (1): estimation Chapter 3: likelihood function and likelihood esti...
Statistics (1): estimation Chapter 3: likelihood function and likelihood esti...Statistics (1): estimation Chapter 3: likelihood function and likelihood esti...
Statistics (1): estimation Chapter 3: likelihood function and likelihood esti...
 
random forests for ABC model choice and parameter estimation
random forests for ABC model choice and parameter estimationrandom forests for ABC model choice and parameter estimation
random forests for ABC model choice and parameter estimation
 
Pattern recognition binoy 05-naive bayes classifier
Pattern recognition binoy 05-naive bayes classifierPattern recognition binoy 05-naive bayes classifier
Pattern recognition binoy 05-naive bayes classifier
 
Statistics-2 : Elements of Inference
Statistics-2 : Elements of InferenceStatistics-2 : Elements of Inference
Statistics-2 : Elements of Inference
 
Considerate Approaches to ABC Model Selection
Considerate Approaches to ABC Model SelectionConsiderate Approaches to ABC Model Selection
Considerate Approaches to ABC Model Selection
 

Viewers also liked

An introduction to bayesian statistics
An introduction to bayesian statisticsAn introduction to bayesian statistics
An introduction to bayesian statistics
John Tyndall
 
The Curious Case of the Inexpert Witness
The Curious Case of the Inexpert WitnessThe Curious Case of the Inexpert Witness
The Curious Case of the Inexpert Witness
Peter Coles
 
Introduction to Maximum Likelihood Estimator
Introduction to Maximum Likelihood EstimatorIntroduction to Maximum Likelihood Estimator
Introduction to Maximum Likelihood Estimator
Amir Al-Ansary
 
Chapter 3 maximum likelihood and bayesian estimation-fix
Chapter 3   maximum likelihood and bayesian estimation-fixChapter 3   maximum likelihood and bayesian estimation-fix
Chapter 3 maximum likelihood and bayesian estimation-fix
jelli123
 
Theory of estimation
Theory of estimationTheory of estimation
Theory of estimation
Tech_MX
 
The Method Of Maximum Likelihood
The Method Of Maximum LikelihoodThe Method Of Maximum Likelihood
The Method Of Maximum Likelihood
Max Chipulu
 
Internet of Things
Internet of ThingsInternet of Things
Internet of Things
Vala Afshar
 

Viewers also liked (7)

An introduction to bayesian statistics
An introduction to bayesian statisticsAn introduction to bayesian statistics
An introduction to bayesian statistics
 
The Curious Case of the Inexpert Witness
The Curious Case of the Inexpert WitnessThe Curious Case of the Inexpert Witness
The Curious Case of the Inexpert Witness
 
Introduction to Maximum Likelihood Estimator
Introduction to Maximum Likelihood EstimatorIntroduction to Maximum Likelihood Estimator
Introduction to Maximum Likelihood Estimator
 
Chapter 3 maximum likelihood and bayesian estimation-fix
Chapter 3   maximum likelihood and bayesian estimation-fixChapter 3   maximum likelihood and bayesian estimation-fix
Chapter 3 maximum likelihood and bayesian estimation-fix
 
Theory of estimation
Theory of estimationTheory of estimation
Theory of estimation
 
The Method Of Maximum Likelihood
The Method Of Maximum LikelihoodThe Method Of Maximum Likelihood
The Method Of Maximum Likelihood
 
Internet of Things
Internet of ThingsInternet of Things
Internet of Things
 

Similar to Bayesian statistics intro using r

2018 MUMS Fall Course - Introduction to statistical and mathematical model un...
2018 MUMS Fall Course - Introduction to statistical and mathematical model un...2018 MUMS Fall Course - Introduction to statistical and mathematical model un...
2018 MUMS Fall Course - Introduction to statistical and mathematical model un...
The Statistical and Applied Mathematical Sciences Institute
 
Warmup_New.pdf
Warmup_New.pdfWarmup_New.pdf
Warmup_New.pdf
HongAnhNguyn285885
 
from model uncertainty to ABC
from model uncertainty to ABCfrom model uncertainty to ABC
from model uncertainty to ABC
Christian Robert
 
Uncertainty
UncertaintyUncertainty
Uncertainty
Digvijay Singh
 
sigir2017bayesian
sigir2017bayesiansigir2017bayesian
sigir2017bayesian
Tetsuya Sakai
 
Bayesian data analysis1
Bayesian data analysis1Bayesian data analysis1
Bayesian data analysis1
SaritaTripathy3
 
Spsshelp 100608163328-phpapp01
Spsshelp 100608163328-phpapp01Spsshelp 100608163328-phpapp01
Spsshelp 100608163328-phpapp01
Henock Beyene
 
Data mining knowledge representation Notes
Data mining knowledge representation NotesData mining knowledge representation Notes
Data mining knowledge representation Notes
RevathiSundar4
 
Basic of Hypothesis Testing TEKU QM
Basic of Hypothesis Testing TEKU QMBasic of Hypothesis Testing TEKU QM
Basic of Hypothesis Testing TEKU QM
Prof Handley Mpoki Mafwenga
 
Non-parametric.pptx qualitative and quantity data
Non-parametric.pptx  qualitative  and quantity  dataNon-parametric.pptx  qualitative  and quantity  data
Non-parametric.pptx qualitative and quantity data
NuhaminTesfaye
 
Business research methods 2
Business research methods 2Business research methods 2
Business research methods 2
Free Talk 2 Other
 
Dive into the Data
Dive into the DataDive into the Data
Dive into the Data
dr_jp_ebejer
 
JHU Job Talk
JHU Job TalkJHU Job Talk
JHU Job Talk
jtleek
 
unit 3 -ML.pptx
unit 3 -ML.pptxunit 3 -ML.pptx
unit 3 -ML.pptx
Chitrachitrap
 
Bayesian decision making in clinical research
Bayesian decision making in clinical researchBayesian decision making in clinical research
Bayesian decision making in clinical research
Bhaswat Chakraborty
 
CSC446: Pattern Recognition (LN3)
CSC446: Pattern Recognition (LN3)CSC446: Pattern Recognition (LN3)
CSC446: Pattern Recognition (LN3)
Mostafa G. M. Mostafa
 
hypotesting lecturenotes by Amity university
hypotesting lecturenotes by Amity universityhypotesting lecturenotes by Amity university
hypotesting lecturenotes by Amity university
deepti .
 
Ppt1
Ppt1Ppt1
Ppt1
kalai75
 
Lec12-Probability (1).ppt
Lec12-Probability (1).pptLec12-Probability (1).ppt
Lec12-Probability (1).ppt
ShubhamChauhan562815
 
Lec12-Probability.ppt
Lec12-Probability.pptLec12-Probability.ppt
Lec12-Probability.ppt
ssuserc7c104
 

Similar to Bayesian statistics intro using r (20)

2018 MUMS Fall Course - Introduction to statistical and mathematical model un...
2018 MUMS Fall Course - Introduction to statistical and mathematical model un...2018 MUMS Fall Course - Introduction to statistical and mathematical model un...
2018 MUMS Fall Course - Introduction to statistical and mathematical model un...
 
Warmup_New.pdf
Warmup_New.pdfWarmup_New.pdf
Warmup_New.pdf
 
from model uncertainty to ABC
from model uncertainty to ABCfrom model uncertainty to ABC
from model uncertainty to ABC
 
Uncertainty
UncertaintyUncertainty
Uncertainty
 
sigir2017bayesian
sigir2017bayesiansigir2017bayesian
sigir2017bayesian
 
Bayesian data analysis1
Bayesian data analysis1Bayesian data analysis1
Bayesian data analysis1
 
Spsshelp 100608163328-phpapp01
Spsshelp 100608163328-phpapp01Spsshelp 100608163328-phpapp01
Spsshelp 100608163328-phpapp01
 
Data mining knowledge representation Notes
Data mining knowledge representation NotesData mining knowledge representation Notes
Data mining knowledge representation Notes
 
Basic of Hypothesis Testing TEKU QM
Basic of Hypothesis Testing TEKU QMBasic of Hypothesis Testing TEKU QM
Basic of Hypothesis Testing TEKU QM
 
Non-parametric.pptx qualitative and quantity data
Non-parametric.pptx  qualitative  and quantity  dataNon-parametric.pptx  qualitative  and quantity  data
Non-parametric.pptx qualitative and quantity data
 
Business research methods 2
Business research methods 2Business research methods 2
Business research methods 2
 
Dive into the Data
Dive into the DataDive into the Data
Dive into the Data
 
JHU Job Talk
JHU Job TalkJHU Job Talk
JHU Job Talk
 
unit 3 -ML.pptx
unit 3 -ML.pptxunit 3 -ML.pptx
unit 3 -ML.pptx
 
Bayesian decision making in clinical research
Bayesian decision making in clinical researchBayesian decision making in clinical research
Bayesian decision making in clinical research
 
CSC446: Pattern Recognition (LN3)
CSC446: Pattern Recognition (LN3)CSC446: Pattern Recognition (LN3)
CSC446: Pattern Recognition (LN3)
 
hypotesting lecturenotes by Amity university
hypotesting lecturenotes by Amity universityhypotesting lecturenotes by Amity university
hypotesting lecturenotes by Amity university
 
Ppt1
Ppt1Ppt1
Ppt1
 
Lec12-Probability (1).ppt
Lec12-Probability (1).pptLec12-Probability (1).ppt
Lec12-Probability (1).ppt
 
Lec12-Probability.ppt
Lec12-Probability.pptLec12-Probability.ppt
Lec12-Probability.ppt
 

Recently uploaded

PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
Dr. Shivangi Singh Parihar
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
David Douglas School District
 
How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17
Celine George
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
TechSoup
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
tarandeep35
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
eBook.com.bd (প্রয়োজনীয় বাংলা বই)
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
Celine George
 
Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5
sayalidalavi006
 
DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide shareDRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share
taiba qazi
 
How to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 InventoryHow to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 Inventory
Celine George
 
Hindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdfHindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdf
Dr. Mulla Adam Ali
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
Academy of Science of South Africa
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
adhitya5119
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
chanes7
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
Nicholas Montgomery
 
Smart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICTSmart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICT
simonomuemu
 
How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
Celine George
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Excellence Foundation for South Sudan
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
Nguyen Thanh Tu Collection
 

Recently uploaded (20)

PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
 
How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
 
Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5
 
DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide shareDRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share
 
How to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 InventoryHow to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 Inventory
 
Hindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdfHindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdf
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
 
Smart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICTSmart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICT
 
How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
 

Bayesian statistics intro using r

  • 1. Bayesian Statistics using R An Introduction J. Guzmán 30 March 2010 JGuzmanPhD@Gmail.Com
  • 2. Bayesian: one who asks you what you think before a study in order to tell you what you think afterwards Adapted from: S Senn, 1997. Statistical Issues in Drug Development. Wiley
  • 3. Content •  Some Historical Remarks •  Bayesian Inference: – Binomial data – Poisson data – Normal data •  Implementation using R program •  Hierarchical Bayes Introduction •  Useful References & Web Sites
  • 4. We Assume •  Student knows Basic Probability Rules •  Including Conditional Probability P(A | B) = P(A & B) / P(B) •  And Bayes’ Theorem: P( A | B ) = P( A ) × P( B | A ) ÷ P( B ) where P( B ) = P( A )×P( B | A ) + P( AC )×P( B | AC )
  • 5. We Assume •  Student knows Basic Probability Models •  Including Binomial, Poisson, Uniform, Exponential & Normal •  Could be familiar with t, Chi2 & F •  Preferably, but not necessarily, familiar with Beta & Gamma Distributions •  Preferably, but not necessarily, knows Basic Calculus
  • 6. Bayesian [Laplacean] Methods •  1763 – Bayes’ article on inverse probability •  Laplace extended Bayesian ideas in different scientific areas in Théorie Analytique des Probabilités [1812] •  Laplace & Gauss used the inverse method •  1st three quarters of 20th Century dominated by frequentist methods [Fisher, Neyman, et al.] •  Last quarter of 20th Century – resurgence of Bayesian methods [computational advances] •  21st Century – Bayesian Century [Lindley]
  • 7. Rev. Thomas Bayes English Theologian and Mathematician c. 1700 – 1761
  • 9. Karl Friedrich Gauss “Prince of Mathematics” 1777 – 1855
  • 10. Bayes’ Theorem •  Basic tool of Bayesian Analysis •  Provides the means by which we learn from data •  Given prior state of knowledge, it tells how to update belief based upon observations: P(H | Data) = P(H) · P(Data | H) / P(Data)
  • 11. Bayes’ Theorem •  Can also consider posterior probability of any measure θ: P(θ) x P( data | θ) → P(θ | data) •  Bayes’ theorem states that the posterior probability of any measure θ, is proportional to the information on θ external to the experiment times the likelihood function evaluated at θ: Prior · Likelihood → Posterior
  • 12. Prior •  Prior information about θ assessed as a probability distribution on θ •  Distribution on θ depends on the assessor: it is subjective •  A subjective probability can be calculated any time a person has an opinion •  Diffuse (Vague) prior - when a person’ s opinion on θ includes a broad range of possibilities & all values are thought to be roughly equally probable
  • 13. Prior •  Conjugate prior – if the posterior distribution has same shape as the prior distribution, regardless of the observed sample values •  Examples: 1.  Beta Prior x Binomial Likelihood → Beta Posterior 2.  Normal Prior x Normal Likelihood → Normal Posterior 3.  Gamma Prior x Poisson Likelihood → Gamma Posterior
  • 14. Community of Priors •  Expressing a range of reasonable opinions •  Reference – represents minimal prior information [JM Bernardo, U of V] •  Expertise – formalizes opinion of well-informed experts •  Skeptical – downgrades superiority of new treatment •  Enthusiastic – counterbalance of skeptical
  • 15. Likelihood Function P(data | θ) •  Represents the weight of evidence from the experiment about θ •  It states what the experiment says about the measure of interest [ LJ Savage, 1962 ] •  It is the probability of getting certain result, conditioning on the model •  Prior is dominated by the likelihood as the amount of data increases: –  Two investigators with different prior opinions could reach a consensus after the results of an experiment
  • 16. Likelihood Principle •  States that the likelihood function contains all relevant information from the data •  Two samples have equivalent information if their likelihoods are proportional •  Adherence to the Likelihood Principle means that inference are conditional on the observed data •  Bayesian analysts base all inferences about θ solely on its posterior distribution •  Data only affect the posterior through the likelihood P(data | θ)
  • 17. Likelihood Principle •  Two experiments: one yields data y1 and the other yields data y2 •  If P(y1 | θ) & P(y2 | θ) are identical up to multiplication by arbitrary functions of y1 & y2 then they contain identical information about θ and lead to identical posterior distributions •  Therefore, to equivalent inferences
  • 18. Example •  EXP 1: In a study of a fixed sample of 20 students, 12 of them respond positively to the method [Binomial distribution] •  Likelihood is proportional to θ12 (1 – θ)8 •  EXP 2: Students are entered into a study until 12 of them respond positively to the method [Negative- Binomial distribution] •  Likelihood at n = 20 is proportional to θ12 (1 – θ)8
  • 19. Exchangeability •  Key idea in Statistical Inference in general •  Two observations are exchangeable if they provide equivalent statistical information •  Two students randomly selected from a particular population of students can be considered exchangeable •  If the students in a study are exchangeable with the students in the population for which the method is intended, then the study can be used to make inferences about the entire population •  Exchangeability in terms of experiments: Two studies are exchangeable if they provide equivalent statistical information about some super-population of experiments
  • 20. Bayesian Statistics (BS) •  BS or inverse probability – method of Statistical Inference until 1910s •  No much progress of BS up to 1980s •  Metropolis, Rosenbluth2, Teller2, 1953: MC •  Hastings, 1970: Metropolis-Hastings •  Geman2, 1984: Image analysis w. Gibbs •  MRC – BU, 1989: BUGS •  Gelfand and Smith,1990: McMC & Gibbs Algorithms. JASA
  • 21. Bayesian Estimation of θ •  X successes & Y failures, N independent trials •  Prior Beta(a, b) Binomial likelihood → Posterior Beta(a + x, b + y) •  Example in: Suárez, Pérez & Guzmán, 2000. “Métodos Alternos de Análisis Estadístico en Epidemiología”. PR HSJr. V.19: 153-156
  • 22.
  • 23. Bayesian Estimation of θ a = 1; b = 1 prob.p = seq(0, 1, .1) prior.d = dbeta(prob.p, a, b)
  • 24. Prior Density Plot plot(prob.p, prior.d, type = "l", main="Prior Density for P", xlab="Proportion", ylab="Prior Density") •  Observed 8 successes & 12 failures x = 8; y = 12; n = x + y
  • 25. Likelihood & Posterior like = prob.p^x * (1-prob.p)^y post.d0 = prior.d * like post.d = dbeta(prob.p, a + x , b + y) # Beta Posterior
  • 26. Posterior Distribution plot(prob.p, post.d, type="l", main = "Posterior Density for θ", xlab = "Proportion", ylab = "Posterior Density") •  Get better plots using library(Bolstad) •  Install library(Bolstad) from CRAN
  • 27. # 8 successes observed in 20 trials with a Beta(1, 1) prior library(Bolstad) results = binobp(8, 20, 1, 1, ret = TRUE) par(mfrow = c(3, 1)) y.lims=c(0, 1.1*max(results$posterior, results$prior)) plot(results$theta, results$prior, ylim=y.lims, type="l", xlab=expression(theta), ylab="Density", main="Prior") polygon(results$theta, results$prior, col="red") plot(results$theta, results$likelihood, ylim=c(0,0.25), type="l", xlab=expression(theta), ylab="Density", main="Likelihood") polygon(results$theta, results$likelihood, col="green") plot(results$theta, results$posterior, ylim=y.lims, type="l", xlab=expression(theta), ylab="Density", main="Posterior") polygon(results$theta, results$posterior, col="blue") par(mfrow = c(1, 1))
  • 28. Posterior Inference Results : Posterior Mean : 0.4090909 Posterior Variance : 0.0105102 Posterior Std. Deviation : 0.1025195 Prob. Quantile ------ --------- 0.005 0.1706707 0.01 0.1891227 0.025 0.2181969 0.05 0.2449944 0.5 0.4062879 0.95 0.5828013 0.975 0.6156456 0.99 0.65276 0.995 0.6772251
  • 29. 0.0 0.2 0.4 0.6 0.8 1.0 01234 Prior θ Density 0.0 0.2 0.4 0.6 0.8 1.0 0.000.100.20 Likelihood θ Density 0.0 0.2 0.4 0.6 0.8 1.0 01234 Posterior θ Density
  • 30. Credible Interval •  Generate 1000 random observations from beta(a + x , b + y) set.seed(12345) x.obs = rbeta(1000, a+x, b+y)
  • 31. Mean & 90% Posterior Limits for P •  Obtain a 90% credible limits: q.obs.low = quantile(x.obs, p = 0.05) # 5th percentile q.obs.hgh = quantile(x.obs, p = 0.95) # 95th percentile print(c(q.obs.low, mean(x.obs), q.obs.hgh))
  • 32. Bayesian Inference: Normal Mean •  Bayesian Inference on a Normal mean with a Normal prior •  Bayes’ Theorem: Prior x Likelihood → Posterior •  Assume σ is known: If y ~ N(µ, σ); µ ~ N(µ0, σ0 ) → µ | y ~ N(µ1, σ1) •  Data: y = { y1, y2, …, yn }
  • 33. Posterior Mean & SD 2 2 0 1 2 2 0 2 2 2 1 0 / / / 1/ 1/ / 1/ ny n n σ µ σ µ σ σ σ σ σ + = + = +
  • 34. Shoe Wear Example •  Ref. Box, Hunter & Hunter, 2005; p. 81 ff library(BHH2) attach(shoes.data) shoes.data D = matA – matB shapiro.test(D) normnp(D, 5) # Normal(0,SD = 5) Prior
  • 35. Shoe Wear Example Posterior mean : -0.1171429 Posterior std. deviation : 0.8451543 Prob. Quantile ------ --------- 0.005 -2.294116 0.01 -2.0832657 0.025 -1.7736148 0.05 -1.5072979 0.5 -0.1171429 0.95 1.2730122 0.975 1.539329 0.99 1.8489799 0.995 2.0598302
  • 36. -3 -2 -1 0 1 2 3 0.00.10.20.30.40.5 µ Probabilty(µ) Posterior Prior
  • 37. Poisson-Gamma •  Y ~ Poisson(µ); Y = 0, 1, 2, … •  Gamma Prior x Poisson Likelihood → Gamma Posterior •  µ ~ Gamma(a, b); µ > 0, a>0, b>0 •  Mean(µ) = a/b •  Var(µ) = a/b2 •  RE: Exponential & Chi2 are special cases of Gamma Family
  • 38. Poisson-Gamma Example •  Y = Autos per family in a city •  {Y1 , … ,Yn | µ} ~ Poisson(µ) •  Prior: µ ~ Gamma(a0, b0) •  Posterior: µ | data ~ Gamma(a1, b1) •  Where a1 = a0 + Sum(Yi ) and b1 = b0 + n •  Data: n = 45, Sum(Yi ) = 121
  • 39. Poisson-Gamma Example •  Assume µ ~ Gamma(a0 = 2, b0 = 1) a = 2; b = 1 n = 45; s.y = 121 •  95% Posterior Limits for µ: qgamma( c(.025, .975), a + s.y, b + n)
  • 40. Hierarchical Models •  Data from several subpopulations or groups •  Instead of performing separate analyses for each group, it may make good sense to assume that there is some relationship between the parameters of different groups •  Assume exchangeability between groups & introduce a higher level of randomness on the parameters •  Meta-Analysis approach – particularly effective when the information from each sub–population is limited
  • 41. Hierarchical Models •  Hierachical modeling also includes: •  Mixed-effects models •  Variance component models •  Continuous mixture models
  • 42. Hierarchical Models •  Hierarchy: – Prior distribution has parameters (a, b) – Prior parameters (a, b) have hyper–prior distributions – Data likelihood, conditionally independent of hyper-priors •  Hyper–priors → Prior → Likelihood → Posterior Distribution
  • 43. Hierarchical Modeling •  Eight Schools Example •  ETS Study – analyzes effects of coaching program on test scores •  Randomized experiments to estimate effect of coaching for SAT-V in high schools •  Details – Gelman et al., B D A
  • 44. Eight Schools Example Sch A B C D E F G H TrEf yj 28 8 -3 7 -1 1 18 12 StdEr sj 15 10 16 11 9 11 10 18
  • 45. Hierarchical Modeling •  θj ~ Normal(µ, σ) [Effect in School j] •  Uniform hyper–prior for µ, given σ; and diffuse prior for σ: Pr(µ, σ) = Pr(µ | σ) x Pr(σ) α 1 •  Pr(µ, σ, θj | y ) = Pr(µ | σ) x p(σ) x Π1:J [ θj | µ, σ] x Pr(y)
  • 46. 2 2 1 1 Assume parameters are conditionally independent given ( , ): ~ ( , ). Therefore, ( ,..., | , ) ( | , ). Assign non-informative uniform hyperprior to , given . And a diffuse non-informativ j J jJ j N p N µ τ θ µ τ θ θ µ τ θ µ τ µ τ = = Π e prior for : ( , ) ( | ) ( ) 1p p p τ µ τ µ τ τ= ∝ ∝
  • 47. 2 2 . j 2 Joint Posterior Distribution ( , , | ) ( , ) ( | , ) ( | ) ( , ) ( | , ) ( | , ) Conditional Posterior of Normal Means: ˆ| , , ~ ( , ) where ˆ j j j j jj j j j p y p p p y p N N y y N V y θ µ τ µ τ θ µ τ θ µ τ θ µ τ θ σ θ µ τ θ σ τ θ − ∝ ∝ Π Π ⋅ + = 2 2 2 1 2 2 and ( )j j j V µ σ τ σ τ − − − − − − ⋅ = + +
  • 48. 2 2 1 .1 2 2 1 1 -1 2 2 1 1 2 2 .1 Posterior for given : ˆ| , ~ ( , ) where ( ) ˆ , and ( ) V ( ) . Posterior for : ( , | ) ( | ) ( | , ) ( | , ) ˆ( | , ) J j jj J jj J jj J j jj y N V y p y p y p y N y N V µ µ µ µ τ µ τ µ σ τ µ σ τ σ τ τ µ τ τ µ τ µ σ τ µ µ − = − = − = = + ⋅ = + = + = + ∝ ∑ ∑ ∑ ∏ 2 ..5 2 2 .5 2 2 ˆ( ) ( ) exp 2( ) j j j y Vµ µ σ τ σ τ − ⎛ ⎞ ⎜ ⎟ ⎜ ⎟ ⎝ ⎠ − ∝ + +∏
  • 49. BUGS + R = BRugs Use File > Change dir ... to find required folder # school.wd="C:/Documents and Settings/Josue Guzman/My Documents/R Project/My Projects/Bayesian/W_BUGS/Schools" library(BRugs) # Load BRugs Package for MCMC Simulation modelCheck("SchoolsBugs.txt") # HB Model modelData("SchoolsData.txt") # Data nChains=1 modelCompile(numChains=nChains) modelInits(rep("SchoolsInits.txt",nChains)) modelUpdate(1000) # Burn in samplesSet(c("theta","mu.theta","sigma.theta")) dicSet() modelUpdate(10000,thin=10) samplesStats("*") dicStats() plotDensity("mu.theta",las=1)
  • 50. Schools’ Model model { for (j in 1:J) { y[j] ~ dnorm (theta[j], tau.y[j]) theta[j] ~ dnorm (mu.theta, tau.theta) tau.y[j] <- pow(sigma.y[j], -2) } mu.theta ~ dnorm (0.0, 1.0E-6) tau.theta <- pow(sigma.theta, -2) sigma.theta ~ dunif (0, 1000) }
  • 51. Schools’ Data list(J=8, y = c(28.39, 7.94, -2.75, 6.82, -0.64, 0.63, 18.01, 12.16), sigma.y = c(14.9, 10.2, 16.3, 11.0, 9.4, 11.4, 10.4, 17.6))
  • 52. Schools’ Initial Values list(theta = c(0, 0, 0, 0, 0, 0, 0, 0), mu.theta = 0, sigma.theta = 50) )
  • 53. BRugs Schools’ Results samplesStats("*") mean sd MCerror 2.5pc median 97.5pc start sample mu.theta 8.147 5.28 0.081 -2.20 8.145 18.75 1001 10000 sigma.theta 6.502 5.79 0.100 0.20 5.107 21.23 1001 10000 theta[1] 11.490 8.28 0.098 -2.34 10.470 31.23 1001 10000 theta[2] 8.043 6.41 0.091 -4.86 8.064 21.05 1001 10000 theta[3] 6.472 7.82 0.103 -10.76 6.891 21.01 1001 10000 theta[4] 7.822 6.68 0.079 -5.84 7.778 21.18 1001 10000 theta[5] 5.638 6.45 0.091 -8.51 6.029 17.15 1001 10000 theta[6] 6.290 6.87 0.087 -8.89 6.660 18.89 1001 10000 theta[7] 10.730 6.79 0.088 -1.35 10.210 25.77 1001 10000 theta[8] 8.565 7.87 0.102 -7.17 8.373 25.32 1001 10000
  • 54. Graphical Display Ø plotDensity("mu.theta",las=1, main = "Treatment Effect") Ø plotDensity("sigma.theta",las=1, main = "Standard Error") Ø plotDensity("theta[1]",las=1, main = "School A") Ø plotDensity("theta[3]",las=1, main = "School C") Ø plotDensity("theta[8]",las=1, main = "School H")
  • 55. Graphical Display -20 0 20 40 0.00 0.02 0.04 0.06 0.08 Treatment Effect
  • 56. Graphical Display 0 10 20 30 40 50 60 0.00 0.02 0.04 0.06 0.08 0.10 Standard Error
  • 58. Graphical Display -40 -20 0 20 40 0.00 0.01 0.02 0.03 0.04 0.05 0.06 School C
  • 59. Graphical Display -40 -20 0 20 40 60 0.00 0.01 0.02 0.03 0.04 0.05 0.06 School H
  • 60. Laplace on Probability It is remarkable that a science, which commenced with the consideration of games of chance, should be elevated to the rank of the most important subjects of human knowledge. A Philosophical Essay on Probabilities, 1902. John Wiley & Sons. Page 195. Original French Edition 1814.
  • 61. Future Talk •  Non-Conjugate Inference •  McMC simulation: – Gibbs – Metropolis–Hastings •  Bayesian Regression – Normal Model – Logistic Regression – Poisson Regression – Survival Analysis
  • 62. Some Useful References •  Bernardo JM & AFM Smith, 1994. Bayesian Theory. Wiley. •  Bolstad WM, 2004. Introduction to Bayesian Statistics. Wiley. •  Gelman A, GO Carlin, HS Stern & DB Rubin, 2004. Bayesian Data Analysis, 2nd Edition. Chapman-Hall. •  Gill J, 2008. Bayesian Methods 2nd Edition. Chapman-Hall. •  Lee P, 2004. Bayesian Statistics: An Introduction, •  3rd Edition. Arnold. •  O'Hagan A & Forster JJ, 2004. Bayesian Inference, 2nd Edition. Vol. 2B of "Kendall's Advanced Theory of Statistics". Arnold. •  Rossi PE, GM Allenby & R McCulloch, 2005. Bayesian Statistics and Marketing. Wiley.
  • 63. Some Useful References •  Chib S & Greenberg E, 1995. Understanding the Metropolis–Hastings algorithm. TAS: V. 49: 327 - 335 •  Gelfand AE and Smith AFM, 1990. Sampling based approaches to calculating marginal densities JASA: V. 85: 398 - 409 •  Smith AFM & Gelfand AE, 1992. Bayesian statistics without tears. TAS: V. 46: 84 - 88
  • 64. Some Useful Web Sites Bernardo JM: http://www.uv.es/~bernardo CRAN: http://cran.r–project.org Gelman A: http://www.stat.columbia.edu/ ~gelman Jefferys: http://bayesrules.net OpenBUGS: http://mathstat.helsinki.fi/ openbugs Joseph: http://www.medicine.mcgill.ca/ epidemiology/Joseph/index.html BRugs click Manuals in OpenBUGS