Download Remarks on Notation, Bayesian Basic - Computing in Statistics | 22S 166 and more Study notes Statistics in PDF only on Docsity!
22S:
Computing in Statistics
Review of Bayesian Concepts and Intro to MCMC
Lecture 14 October 15, 2006
Kate Cowles 374 SH, 335- [email protected]
Remarks on notation
- I will use f (·), p(·), and π(·) to refer to distributions that may be either continuous, discrete, or mixed.
- I will frequently use an integral. When the argument may be a discrete distribution, think summation.
- y will refer to observed, or potentially observable, quantities.
- θ will refer to unobservable quantities.
3
Bayesian Basics
- Unknown model parameters are random variables.
- Our knowledge / uncertainty about unknown model parameters is appropriately expressed through prob- ability distributions.
- Whenever we observe data, these probability distri- butions are updated.
4 Steps in Bayesian data analysis
- Specify a full probability model
- joint probability distribution for all observable and unobservable quantities in a problem.
- Calculate and interpret the posterior distribution
- the conditional probability distribution of the un- observed quantities of interest given the observed data
- Evaluate model
- fit to observed data
- consistency of posterior inference with substantive knowledge
- sensitivity to model specification
Components of a Bayesian model
- The first stage: the likelihood
- the probability distribution for the observed data y conditional on a vector of unknown param- eters f (y|θ)
- The second stage: the priors
- probability distribution(s) that express our knowl- edge or uncertainty about model parameters before the data are observed
π(θ|η)
where η is a vector of “hyperparameters”
Bayes theorem and the posterior distribution
- Bayes theorem is the recipe for using the data to up- date the prior and produce the posterior distribution p(θ|y):
p(θ|y, η) =
p(y, θ|η) p(y|η)
=
p(y, θ|η) ∫ p(y, θ∗|η)dθ∗
=
f (y|θ)π(θ|η) ∫ f (y|θ∗)π(θ∗|η)dθ∗
- Remarks:
- Dependence on η in posterior distributions if of- ten suppressed when values of hyperparameters are known constants.
- In principle, this computation can be done for any valid prior and any well-defined likelihood.
- The challenge is the integral in the denominator.
7
The marginal likelihood
- the marginal distribution of the data y given the com- plete model
m(y) =
∫ f (y|θ∗)π(θ∗|η)dθ∗
- also called
- prior predictive distribution
- normalizing constant
- Useful in model comparison employing Bayes factors
8 Classifications of priors
- informative and noninformative
- proper and improper
- In general, posterior inference is impossible if the posterior is improper (i.e. if unnormalized poste- rior does not have a finite integral). ∗ The use of proper priors guarantees a proper posterior. ∗ If improper priors are used, it is important to verify analytically that posterior is proper. ∗ If prior information is minimal and likelihood is complicated, vague but proper priors are advis- able.
- conjugate and nonconjugate
- a class of prior distributions is said to be conju- gate for a parameter in a likelihood if the resulting posterior distribution is in the same family as the prior
- make computation (analytic or by computer) eas- ier, but may not reflect actual prior information
- for many likelihood functions, there is no conjugate prior
Example of a simple Bayesian model
- Normal likelihood, mean and variance both unknown
- precision is inverse of variance
yi|μ, σ^2 ∼ N (μ, σ^2 ), i = 1,... , n
- Semi conjugate priors on μ and σ^2 μ ∼ N (μ 0 , σ^20 ) (1) τ 2 ∼ G(a, b) (2)
Hierarchical models
- arise if
- we don’t know values of hyperparameters in 2nd stage
- or we wish to express relationships among param- eters
- likelihood is the first “stage” of the model
- 2nd stage is priors on the parameters that appear in the likelihood
- subsequent stages are priors on hyperparameters from the previous stages
15
Example of hierarchical model
- A hierarchical model is fit to data on failure rates of the pump at each of 10 power plants. The number of failures for the i-th pump is assumed to follow a Poisson distribution:
xi ∼ P oisson(θiti), i = 1.... , 10
where θi is the failure rate for pump i and ti is the length of operation time of the pump (in 1000s of hours).
- A conjugate gamma prior distribution is adopted for the failure rates:
θi ∼ Gamma(α, β), i = 1.... , 10
- The following priors are specified for the hyperparam- eters α and β:
α ∼ Exponential(1.0) β ∼ Gamma(0. 10 , 1 .0)
16 Markov chain Monte Carlo: one method of Bayesian computation
- If we can’t analytically do the integration to get the needed joint and marginal posterior distributions, gen- erate random samples from the joint posterior
- MCMC: Do this by constructing a Markov chain with the joint posterior distribution as its stationary distri- bution - choose initial values for all parameters - run chain until it reaches its stationary distribution - outputs from subsequent iterations are (dependent) draws from the joint posterior - also, outputs from these iterations for any single parameter are draws from its posterior marginal - the Gibbs sampler: one method of constructing the transition kernel for such a Markov chain
Markov chains
- A Markov chain is a sequence of random variables X 0 , X 1 , X 2 ,...
- At each time t ≥ 0 the next state Xt+1 is sampled from a distribution
P (Xt+1|Xt) that depends only on the state at time t
- called “transition kernel”
- Under certain regularity conditions, the iterates from a Markov chain will gradually converge to draws from a unique stationary or invariant distribution
- i.e. chain will “forget’ its initial state
- as t increases, sampled points Xt will look increas- ingly like (correlated) samples from the stationary distribution
- Suppose:
- MC is run for N (large number) iterations
- we throw away output from first m iterations
- regularity conditions are met
- then by ergodic theorem
- we can use averages of remaining samples to esti- mate means
E[f (X)] ≃
N − m
N∑ t=m+
f (Xt)
19 Gibbs sampling: one way to construct the transition kernel
- seminal references
- Geman and Geman (IEEE Trans. Pattn. Anal. Mach. Intel., 1984)
- Gelfand and Smith (JASA, 1990)
- Hastings (Biometrika, 1970)
- Metropolis, Rosenbluth, et al. (J. Chem. Phys,
- subject to regularity conditions, joint distribution is uniquely determined by “full conditional distributions” - full conditional distribution for a model quantity is distribution of that quantity conditional on as- sumed known values of all the other quantities in the model
- break complicated, high-dimensional problem into a large number of simpler, low-dimensional problems
20 The Gibbs sampler
- breaks up the problem of generating from a complex, high-dimensional posterior into many easier problems of generating from univariate (or low- dimensional dis- tributions)
- algorithm for generating from p(θ 1 , θ 2 ,... , θp|y)
- Select initial values θ (0) 1 , θ
(0) 2 ,... , θ (0) p
- At each iteration k, generate new values for each parameter, one at a time, from their full condi- tional distributions, conditional on most recent values of each of the other parameters
p(θ( 1 k )|θ 2 (k −^1 ,... , θ p(k −1), y) p(θ (k) 2 |θ
(k) 1 , θ
(k− 1 2 ,... , θ
(k−1) p , y) ... p(θ( pk )|θ 1 (k ,... , θ p(k−) 1 , y)
Types of nodes in directed graphs
- constants
- fixed by design of study
- always are founder notes (i.e. do not have parents
- denoted as single- or sometimes double-edged rect- angles
- stochastic nodes
- variables that are given a distribution
- may be parents or children or both
- may be observed data or unobservable parameters
- generally denoted as circles ∗ athough data often denoted as single-edg e rect- angles
- deterministic nodes
- logical functions of other nodes
Types of directed links in a directed graph
- stochastic dependence
- logical function
- indicated by dashed or hollow arrow
27
Example: directed graph for Pumps problem
28 Example: An AR(1) time-series with additive normal measurement error
- Assume constant mean μ
- Specify likelihood so as to make observed data points y conditionally independent given parameters
f (yi|μ, δi, τ 2 ) = N (μ + δi,
τ 2
), i = 1,... , n
- Second stage: Prior on vector of δs
- There are several equivalent ways to do this.
- Third stage: Priors on μ, τ 2 , and τ (^) δ^2
The Metropolis and Metropolis-Hastings algo- rithms
- can be used to define a transition kernel for a Markov chain - may be multivariate and generate a vector of sam- ples from all unknown quantities at once - or may be used within Gibbs sampler to generate from full conditionals of single or blocked parame- ters
- idea:
- denote the joint unnormalized posterior distribu- tion as p(θ 1 , θ 2 ,... , θp|y) ∗ we are trying to construct a Markov chain with this as its stationary distribution ∗ we don’t know normalizing constant
- denote vector of values from kth iteration of Markov chain as θ 1 (k ), θ 2 (k ),... , θ( pk)
- at each iteration, “propose” a vector of values θnew 1 , θnew 2 ,... , from a “candidate-generating” density q(θnew 1 , θnew 2 ,... , θnewp |θ( 1 k −1), θ 2 (k −1),... , θ( pk−1)
- compute an “acceptance probability” α, and with probabilities
∗ α, set θ 1 (k +1), θ( 2 k +1),... , θ( pk +1)= θnew 1 , θnew 2 ,... , θnewp ∗ 1 −α, set θ( 1 k +1), θ( 2 k +1),... , θ p(k +1)= θ( 1 k ), θ 2 (k ),... , θ( pk)
31
- Metropolis
- candidate-generating density must by symmetric ∗ e.g. q(θ(new)|θ(k−1)) is normal with mean θ(k−1)
- acceptance probability is
min
1 , p(θ(new)|y) p(θ(k−1)|y)
- Metropolis-Hastings
- candidate generating density does not have to be symmetric
- acceptance probability is
min
1 , p(θ(new)|y)q(θ(k−^1 )|θ(new)) p(θ(k−1)|y)q(θ(new)|θ(k−^1 ))