1 / 18

R2WinBUGS: Using R for Bayesian Analysis

R2WinBUGS: Using R for Bayesian Analysis. Matthew Russell Rongxia Li 2 November 2010 2010 Northeastern Mensurationists Meeting. Bayesian ideologies 8 (aka what UMaine students needed to learn to pass Bill Halteman’s MAT500 course) . P( H| Y ), not P( Y |H )

krysta
Télécharger la présentation

R2WinBUGS: Using R for Bayesian Analysis

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. R2WinBUGS: Using R for Bayesian Analysis Matthew Russell Rongxia Li 2 November 2010 2010 Northeastern Mensurationists Meeting

  2. Bayesian ideologies8(aka what UMaine students needed to learn to pass Bill Halteman’s MAT500 course) • P(H|Y), not P(Y|H) • Probability is the likelihood of an event occurring • Prior knowledge can be incorporated • Model parameters are random variables

  3. Benefits • Posterior distributions generated for model parameters • Statistics can be computed (e.g. mean, median, mode) • A formal distribution does not need to be assumed • Uncertainty of model parameters can be directly assessed • Models easily updated with new data • Consider old model as a prior

  4. bayes* AND [forestry OR silvic*] Web of Science results:

  5. WinBUGS • Software for Bayesian analysis using Markov chain Monte Carlo methods • Standard GUI • http://www.mrc-bsu.cam.ac.uk/bugs/ • OpenBUGS • Open source version of BUGS • Future development will be with OpenBUGS • www.openbugs.info

  6. R packages • R2WinBUGS • Writes data and scripts in R and calls WinBUGS • Useful for: • running multiple datasets • changing model specifications • Results can be provided in R • BRugs • Collection of functions that allow graphical analysis

  7. Example: Penobscot Experimental Forest snag data n=1,009

  8. Snag survival • Probability of snag survival a function of time since tree death (Garber et al. 2005) • Seven species examined • BF, RS, EH, WS, WC, PB, RM

  9. .bug file model{ for(i in 1:3) {b[i]~dnorm(0,1.0E-6)} prec~dgamma(0.001,0.001) for(i in 1:numTrees) { preds[i]<-1/(b[1]+b[2]*pow((t[i]),b[3])) Psurv[i]~dnorm(preds[i],prec) } } Specify priors Loop through trees

  10. samplesHistory (‘*’)

  11. samplesDensity(‘*’)

  12. samplesStats (‘*’)

  13. Assessing results from BUGS (from McCarthy 2007) • samplesHistory • If it is not white noise, it might be autocorrelation • Are samplesDensity truncated? • Priors might be inadequate • Bumpy samplesDensity? • Consider more samples • Specify different initial values… do you get the same results? • Consider Gelman-Rubin statistic • Measures the influence of specifying initial values

  14. Other OS and other programs • WinBUGS can be run on Linux/Unix/Mac through Wine • But JAGS (Just Another Gibbs Sampler) might work better for Linux users • http://www-fis.airc.fr/~martyn/software/jags/ • Macros available for SAS/Excel • Matlab-WinBUGS GUI available

  15. Sources http://www.mrc-bsu.cam.ac.uk/bugs/ WinBUGS R2WinBUGS OpenBUGS BRugs JAGS McCarthy, M.A. 2007. Bayesian methods for ecology. Cambridge Univ. Press. 296 pp. Gelman et al. 2004. Bayesian data analysis. Chapman Hall/CRC. 696 pp. Albert, J. 2009. Bayesian computation with R. Springer. 300 pp.

  16. Summary • Plenty of tools available for Bayesian analysis with R • All are open source • Coding is not terribly complex • Lots of measures for assessing results • Graphical • Empirical • R2WinBUGS as a learning tool for Bayesian methods

More Related