winbugs

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

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

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.

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

View Full Document
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
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”.

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 08/01/2008 for the course ST 790M taught by Professor Fuentes during the Fall '07 term at N.C. State.

Page1 / 10

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

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

View Full Document
Ask a homework question - tutors are online