Lecture #4: Lecture #4: Bayesian analysis Bayesian analysis of mapped data of mapped data Spatial statistics in practice Spatial statistics in practice Center for Tropical Ecology and Biodiversity, Center for Tropical Ecology and Biodiversity, Tunghai University & Fushan Botanical Garden Tunghai University & Fushan Botanical Garden
54
Embed
Lecture #4: Bayesian analysis of mapped data Spatial statistics in practice Center for Tropical Ecology and Biodiversity, Tunghai University & Fushan Botanical.
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Lecture #4:Lecture #4: Bayesian Bayesian analysis of analysis of
mapped datamapped data
Spatial statistics in Spatial statistics in practicepractice
Center for Tropical Ecology and Center for Tropical Ecology and Biodiversity, Tunghai University & Fushan Biodiversity, Tunghai University & Fushan
Botanical GardenBotanical Garden
Topics for today’s lecture
• Frequentist versus Bayesian perspectives.
• Implementing random effects models in GeoBUGS.
• Spatially structured and unstructured random effects: the CAR, the ICAR, and the spatial filter specifications
LMM & GLMM move in the direction of Bayesian modeling
• Fixed effects are in keeping with a frequentist viewpoint―individual unknown parameters
• Random effects are distributions of parameters, and are in keeping with a Bayesian viewpoint
• The model specifications tend to be the same, with estimation methods tending to differ
Sampling distribution-based inference: the reported p values
• Frequentism: assigns probabilities to random events only according to their relative frequencies of occurrence, rejecting degree-of-belief interpretations of mathematical probability theory.
• The frequentist approach considers to be an unknown constant. Allowing for the possibility that can take on a range of values, frequentist inference is based on a hypothetical repeated sampling principle that obtains desirable and (often) physically interpretable properties (e.g., CIs).
• Frequentist statistics typically is limited to posing questions in terms of a null hypothesis (i.e., H0) that a parameter takes on a single value.
What is Bayesian analysis?
• Bayesianism: contends that mathematical probability theory pertains to degree of plausibility/belief; when used with Bayes theorem (which casts analysis in conditional terms), it becomes Bayesian inference.
• The Bayesian approach considers as the realized value of a random variable Θ with a probability density (mass) function called the prior distribution (a marginal probability distribution that is interpreted as a description of what is known about a variable in the absence of empirical/theoretical evidence).
• Bayesian statistics furnishes a generic tool for inferring model parameter probability distribution functions from data: a parameter has a distribution, not a single value.
• The Bayesian interpretation of probability allows (proper prior) probabilities to be assigned subjectively to random events, in accordance with a researcher’s beliefs.
• Proper prior: a probability distribution that is normalized to one, and asymptotically dominated by the likelihood function
– improper prior: a handy analytic form (such as a constant or logarithmic distribution) that, when integrated over a parameter space, tends to 1 and so is not normalizable.
• Noninformative prior: because no prior information is available, the selected prior contains vague/general information about a parameter, having minimal influence on inferences.
• conjugate prior: a prior probability distribution naturally connected with the likelihood function that, when combined with the likelihood and normalized, produces a posterior probability distribution that is of the same type as the prior, making the analytical mathematics of integration easy. (NOTE: MCMC techniques relaxes the need for this type of specification)
• The hierarchical Bayes model is called “hierarchical” because it has two levels. At the higher level, hyper-parameter distributions are described by multivariate priors. Such distributions are characterized by vectors of means and covariance matrices; spatial autocorrelation is captured here. At the lower level, individuals’ behavior is described by probabilities of achieving some outcome that are governed by a particular model specification.
• posterior distribution: a conditional probability distribution for a parameter taking empirical evidence into account computed with Bayes’ theorem as a normalized product of the likelihood function and the prior distributions that supports Bayesian inference about the parameter
• Bayesian statistics assumes that the probability distribution in question is known, and hence involves integration to get the normalizing constant. This integration might be tricky, and in many cases there is no analytical solution. With the advent of computers and various integration techniques, this problem can partially be overcome. In many Bayesian statistics applications a prior is tabulated and then sophisticated numerical integration techniques (e.g., MCMC) are used to derive posterior distributions.
The controversy
• A frequentist generally has no objection to the use of the Bayes formula, but when prior probabilities are lacking s/he deplores the Bayesians’ tendency to make them up out of thin air.
• Does a parameter have one or many values?
• For many (but not all) of the simpler problems where frequentist methodology seems to give satisfying answers, the Bayesian approach yields basically the same answers, provided noninformative proper priors are used.
Frequentist Bayesian
Definition of probability
Long-run expected frequency in repeated (actual or hypothetical) experiments (Law of LN)
Relative degree of belief in the state of the world
Point estimate
Maximum likelihood estimate
Mean, mode or median of the posterior probability distribution
Confidence intervals for parameters
Based on the Likelihood Ratio Test (LRT) i.e., the expected probability distribution of the maximum likelihood estimate over many experiments
“credible intervals” based on the posterior probability distribution
Confidence intervals of non-parameters
Based on likelihood profile/LRT, or by resampling from the sampling distribution of the parameter
Calculated directly from the distribution of parameters
Model selection
Discard terms that are not significantly different from a nested (null) model at a previously set confidence level
Retain terms in models, on the argument that processes are not absent simply because they are not statistically significant
Difficulties Confidence intervals are confusing (range that will contain the true value in a proportion α of repeated experiments); rejection of model terms for “non-significance”
Subjectivity; need to specify priors
Impact of sample size
priordistribution likelihood
distribution
As the sample size increases, a prior distri-bution has less and less impact on results; BUT
effectivesample sizefor spatially
autocorrelateddata
What is BUGS?
Bayesian inference Using Gibbs Sampling
• is a piece of computer software for the Bayesian analysis of complex statistical models using Markov chain Monte Carlo (MCMC) methods.
• It grew from a statistical research project at the MRC BIOSTATISTICAL UNIT in Cambridge, but now is developed jointly with the Imperial College School of Medicine at St Mary’s, London.
• The Classic BUGS program uses text-based model description and a command-line interface, and versions are available for major computer platforms (e.g., Sparc, Dos). However, it is not being further developed.
BUGS
Classic BUGS
WinBUGS (Windows Version)
GeoBUGS (spatial models)
PKBUGS (pharmokinetic modelling)
What is WinBUGS?
• WinBUGS, a windows program with an option of a graphical user interface, the standard ‘point-and-click’ windows interface, and on-line monitoring and convergence diagnostics. It also supports Batch-mode running (version 1.4).
• GeoBUGS, an add-on to WinBUGS that fits spatial models and produces a range of maps as output.
• PKBUGS, an efficient and user-friendly interface for specifying complex population pharmacokinetic and pharmacodynamic (PK/PD) models within the WinBUGS software.
• Bayesian inference is used to spatially smooth the standardized incidence ratios using Markov chain Monte Carlo (MCMC) methods. GeoBUGS implements models for data that are collected within discrete regions (not at the individual level), and smoothing is done based on Markov random field models for the neighborhood structure of the regions relative to each other.
Choice of Priors
• Can effect – model convergence – execution speed– computational overflow errors
• Consider– Conjugate prior– Sensible prior for the range of a parameter
• e.g. Poisson mean must be positive; hence, a normal distribution is not a good prior.
– Truncated Prior• useful if it is known that sensible or useful parameter
values are within a particular range
Parameter Initialization
• Initialize important parameters.– Parameters distributed according to a non-
informative prior must be initialized (otherwise an overflow error is very likely).
• Regions are numbered sequentially from 1 to n
• Each region is defined as a polygon in a map file
• Each region is associated with a unique index
• BUGs can import map files from Arcinfo, Epimap, SPLUS.
GeoBUGs
Review: What is MCMCMCMC?
MCMC is used to simulate from some distribution p known only up to a constant
factor, C:
pi = Cqi
where qi is known but C is unknown and too horrible to calculate.
MCMC begins with conditional (marginal) distributions, and MCMC sampling outputs a sample of parameters drawn from their joint
(posterior) distribution.
GeoBugs: spatial Poisson with a map
model;{for (i in 1:M){ for (j in 1:N){
#Poisson with a constant but unknown mean
y[i,j] ~ dpois(l)
#GeoBUGS numbers regions in a sequence#This statement turns a 2-D array into a 1-D array for GeoBUGS
mapy[j + (i-1)N] <- y[I,j]}
}
#priors#Noninformative conjugate priors for Poisson mean.
Step 1: open a new window in WinBUGS (this will be referred to as the user window)
Step 2: enter the model syntax, data, and initial values, using the WinBUGS format, in the user window
Step 3: select “Specification” in the “Model” pull down window
Step 4: highlight “model” in the user window, appearing at the beginning of the model syntax, and click once on the “check model” button in the “Specification Tool” window
NOTE: feedback from the program appears in the lower left-hand corner of the WinBUGS program window,
and should be monitored
Step 5: highlight “list” in the user window, appearing at the beginning of the data, and click once on the “load data” button in the “Specification Tool” window
Step 6: insert the number of chains to be run (the default number is 1) in the “Specification Tool” window
Step 7: click once on the “compile” button in the “Specification Tool” window
Step 8: highlight “list” in the user window, appearing at the beginning of the initial values, and click once on the “load inits” button in the “Specification Tool” window (one set is needed for each chain to be run; clicking the “gen inits” button can be dangerous for sound analysis)
Step 9: close the “Specification Tool” windowStep 10: select “Samples” in the “Inference” pull
down menuStep 11: in the “Sample Monitor Tool” window:
type in the name (as it appears in the model syntax) of the 1st parameter to be monitored, and click once on the “set” button; type in the name of the 2nd parameter to be monitored, and click once on the “set” button; …; type in the name of the pth parameter to be monitored, and click once on the “set” button
Step 12: close the “Sample Monitor Tool” window
Step 13: select “Update” in the “Model” pull down menu
Step 14: the default value in the “updates” box is 1000this value most likely needs to be substantially increased (say, to 50,000; once any desired changes are made, click once on the “updates” button
Step 15: once the number appearing in the “iteration” box equals the number in the “updates” box, close the “Update Tool” window
Step 16: select “Samples” in the “Inference” pull down menu
Step 17: click on the down arrow to the right of the “node” box, and select the parameter to be monitored
Step 18: click once of the “history” button to view the time-series plot for all iterations; click once on the “trace” plot to view the time-series plot for the last iterations; click once on the “auto cor” button to view the time-series correlogram (you may wish to enlarge the graphic in this window); click once on the “stats” button to view a parameter estimate’s statistics
Step 19: close the “Sample Monitor Tool” windowStep 20: select “Mapping Tool” from the “Map” pull down
menuStep 21: select the appropriate map from the list appearing
for the “Map” box when the down arrow to its right is clicked once (hint: your map that you imported from an Arc shapefile should appear here)
Step 22: type the name of the variable (exactly as it appears in the model syntax) to be mapped in the “variable” box, and click once on the “plot” box
Puerto Rico Binomial with Spatial Autocorrelation Example
#MODEL
model{for (i in 1 : N) { U[i] ~ dbin(p[i], T[i]) p[i] <- exp(alpha0 + b[i])/(1+exp(alpha0 + b[i]))}# CAR prior distribution for random effects: b[1:N] ~ car.normal(adj[], weights[], num[], tau)for(k in 1:sumNumNeigh) { weights[k] <- 1}# Other priors:alpha0 ~ dflat() tau ~ dgamma(0.5, 0.0005) # prior on precisionsigma <- sqrt(1 / tau) # standard deviation}
Convergence has not been achieved (10,000 burn in; + 25,000/100)
Random effects: spatially structured and unstructured
SA:2.67/(30.39+2.67)= 0.08(8% of variance)
Variance diagnostics
bugs.R: functions for running WinBUGS from R
The bugs() function takes data and starting values as input, calls a Bugs model, summarizes inferences and convergence in a table and graph, and saves the simulations in arrays for easy access in R.
1st: Download WinBugs1.4 2nd: Download OpenBUGS and extract
the zip file into "c:/Program Files/“3rd: Go into R and type