Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "R2WinBUGS: Using R for Bayesian Analysis Matthew Russell Rongxia Li 2 November 2010 2010 Northeastern Mensurationists Meeting."— Presentation transcript:

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

2 Bayesian ideologies 8 (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 www.openbugs.info

6

7 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

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

9 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

10 .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

11

12 samplesHistory (‘*’)

13 samplesDensity(‘*’)

14 samplesStats (‘*’)

15 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

16 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

17 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.

18 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


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

Similar presentations


Ads by Google