winbugs - Areal analysis in WinBUGS Installing WinBUGS 1)...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
Areal analysis in WinBUGS Installing WinBUGS 1) Go to the website http://www.mrc-bsu.cam.ac.uk/bugs/winbugs/contents.shtml . 2) Save and run the file WinBUGS14.exe . 3) With this “educational” version you can analyze small data sets. However, to analysis large spatial datasets you need to register (for free) and obtain the key to unlock the full version. Register at the website http://www.mrc-bsu.cam.ac.uk/bugs/winbugs/register.shtml . BUGS will email you the key. 4) Along with the key, you’ll receive these instructions for using the key. To install the key for WinBUGS 1.4 please follow these instructions: 1. Start your copy of WinBUGS14. 2. Either a) open this file (menu File option Open) as a .txt file or b) open a new empty window (menu File option New), and cut and copy this email message into the window (WinBUGS will ignore all this preceding text). 3. From the Tools menu pick the Decode option. A dialog box will appear. Click on the "Decode All" button to install the key. 4. Check the date of the file c:\Program Files\WinBUGS14\Bugs\Code\Keys.ocf (or wherever you have installed WinBUGS 1.4). If it shows the current date and time then the upgrade has been successfully installed. Quit and restart WinBUGS to start using the full version.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Simple linear regression in WinBUGS We observed the data: X 1 2 3 4 5 6 7 8 9 10 Y 6 7 8 4 9 11 12 14 15 19 First let’s do regression in R: summary(lm(y~x)) Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 2.8667 1.3574 2.112 0.067681 . x 1.3879 0.2188 6.344 0.000222 *** Here is WinBUGS code to perform simple linear regression #The model: model{ for(i in 1:n){ y[i]~dnorm(mu[i],taue) #taue is a precision, not a variance! mu[i] <- alpha + beta*x[i] } taue~dgamma(0.01,0.01) alpha~dnorm(0,0.01) beta~dnorm(0,0.01) } #The data list(n=10,x=c(1,2,3,4,5,6,7,8,9,10),y=c(6,7,8,4,9,11,12,14,15,19)) #The initial values list(taue=1,alpha=0,beta=1) The steps for running this code are on the next page. The WinBUGS output is very similar to the R output node mean sd MC error 2.5% median 97.5% alpha 2.8 1.531 0.004971 -0.2888 2.813 5.831 beta 1.397 0.248 8.212E-4 0.9059 1.396 1.896
Background image of page 2
Running WinBUGS 1) Highlight the word “model” in the first line of the model code. 2) Go to “model/specification” and click “check model”. “model is syntactically correct” should pop up on the bottom of the WinBUGS window. 3) Highlight “list” in the data list and click “load data”. “data loaded” should pop up on the bottom of the WinBUGS window. 4) Highlight “list” in the initial values list and click “load inits”. Click “gen inits” to have BUGS randomly generate initial values. 5) For each variable you’d like to analyze, go to “inference/sample”, enter the name of the variable in the “nodes” box, and click “set”. Samples of variables you don’t request to record are automatically discarded. 6) To begin sampling, go to model/update and click “update”.
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 10

winbugs - Areal analysis in WinBUGS Installing WinBUGS 1)...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online