Areal analysis in WinBUGS Installing WinBUGS
1) Go to the website http://www.mrc-bsu.cam.ac.uk/bus/winbus/contents.shtml http://www.mrc-bsu.cam.ac.uk/bus/winbus/contents.shtml.. !) Sa"e an# run the $ile WinBUGS1%.e&e WinBUGS1%.e&e.. ') With With this (e#ucational "ersion you can analy*e small #ata sets. +owe"er, to analysis analysis lare spatial #atasets you nee# to reister $or $ree) an# obtain the key to unlock the $ull "ersion. eister at the website http://www http://www.mrc-bsu.cam.ac.uk/bus/winbus/reist .mrc-bsu.cam.ac.uk/bus/winbus/reister. er.shtml shtml.. BUGS will email you the key. %) Alon with the key, youll recei"e these instructions $or usin 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 !enu "ile option #pen) as a .t$t file or %) open a new e!pty win&ow !enu "ile option 'ew)( an& cut an& copy this e!ail !essae into the win&ow WinBUGS will inore all this prece&in te$t). *. "ro! the Tools !enu pick the +eco&e option. option. , &ialo %o$ will appear. -lick on the +eco&e ,ll %utton to install the key. 4.
-heck the &ate of the file
c:/0rora! "iles/WinBUGS14/B "iles/WinBUGS14/Bus/-o&e/eys.oc us/-o&e/eys.ocf f or whereer you hae installe& WinBUGS 1.4). 3f it shows the current &ate an& ti!e then the upra&e has %een successfully installe&. uit an& restart WinBUGS to start usin the full ersion.
Simple linear regression in WinBUGS We obser"e# the #ata: 0 7
1 2
! 3
' 4
% %
5
2 11
3 1!
4 1%
5 1
16 15
8irst lets #o reression in : su!!aryl!y5$)) -oefficients: Esti!ate St&. Error t alue 0r67t7) 3ntercept) 2.899 1.*;4 2.112 <.<9981 . $ 1.*8= <.2188 9.*44 <.<<<222 >>>
+ere is WinBUGS co#e to per$orm simple linear reression ?The !o&el: !o&el@ fori in 1:n)@ yAi5&nor!!uAi(taue) ?taue is a precision( not a arianceC !uAi D alpha F %eta>$Ai taue5&a!!a<.<1(<.<1) alpha5&nor!<(<.<1) %eta5&nor!<(<.<1) ?The &ata listnH1<($Hc1(2(*(4(;(9((8(=(1<)(yHc9((8(4(=(11(12(14(1;(1=)) ?The initial alues listtaueH1(alphaH<(%etaH1)
The steps for runnin this co&e are on the ne$t pae.
The WinBUGS output is ery si!ilar to the I output node
alpha %eta
mean
sd
MC error
2.8 1.;*1 <.<<4=1 1.*= <.248 8.212E4
2.5%
median
97.5%
<.2888 <.=<;=
2.81* 1.*=9
;.8*1 1.8=9
unnin WinBUGS 1) +ihliht the wor# (mo#el in the $irst line o$ the mo#el co#e. !) Go to (mo#el/speci$ication an# click (check mo#el. (mo#el is syntactically correct shoul# pop up on the bottom o$ the WinBUGS win#ow. ') +ihliht (list in the #ata list an# click (loa# #ata. (#ata loa#e# shoul# pop up on the bottom o$ the WinBUGS win#ow. %) +ihliht (list in the initial "alues list an# click (loa# inits. 9lick (en inits to ha"e BUGS ran#omly enerate initial "alues. ) 8or each "ariable you# like to analy*e, o to (in$erence/sample, enter the name o$ the "ariable in the (no#es bo&, an# click (set. Samples o$ "ariables you #ont reuest to recor# are automatically #iscar#e#. 2) ;o bein samplin, o to mo#el/up#ate an# click (up#ate. 3) When the <9<9 samplin is complete#, o back to (in$erence/sample to "iew summaries o$ the posterior.
Bayesian kriging in WinBUGS
The Surface elevation data can be found in the BUGS spatial manual, click on maps/manual/examples. N is the number of observed locations, (x,! are the N observation locations, hei"ht (surface elevation! is the outcome, and (xpred, pred! are # locations $here $e%ll make predictions of hei"ht. &e%d like to fit the model hei"ht ' N(beta 1,Si"ma!, $here the beta is the mean of each observation, 1 Nx) vector of ones, Si"ma is the NxN covariance matrix $ith i* element e+ual to si"maexp(-phih!, and h is the distance bet$een locations i and *. The hperpriors are beta ' Norm(,.)! normal $ith mean , precision .) si"ma ' 0nvGamma(.),,)! phi ' Unif(.),.1!.
The &inBUGS code for this model is2 !o&el@ heihtA1:' 5 spatial.e$p!uA( $A( yA( tau( phi( 1) fori in 1:') @!uAi D %eta %eta 5 &nor!<(<.<<1) tau 5 &a!!a<.<<1( <.<<1) phi 5 &unif<.<<1( <.8)
? "lat prior for the intercept ? -onJuate inerse a!!a on the precision ? Unifor! prior on phi
forJ in 1:K) @ ? Kake pre&ictions at uno%sere& locations heiht.pre&AJ 5 spatial.unipre&%eta( $.pre&AJ( y.pre&AJ( heihtA)
= ;here are two way to #o pre#iction in BUGS, spatial.pre# an# spatial.unipre# BUGS manual sas 3Spatial interpolation or prediction at arbitrar locations can be carried out usin" the spatial.pred or spatial.unipred functions, in con*unction $ith fittin" the spatial.exp model to a set of observed data. spatial.pred carries out *oint or simultaneous prediction at a set of tar"et locations, $hereas spatial.unipred carries out sin"le site prediction. The difference is that the sin"le site prediction ields mar"inal prediction intervals (i.e. i"norin" correlation bet$een prediction locations! $hereas *oint prediction ields simultaneous prediction intervals for the set of tar"et locations ($hich $ill tend to be narro$er than the mar"inal prediction intervals!. The predicted means should be the same under *oint or sin"le site prediction. The disadvanta"e of *oint prediction is that it is ver slo$ (the computational time is of order 45, $here 4 is the number of prediction sites!. 3
+ere are the initial "alues: listtauH<.<<1( phiH<.4( %etaH82<)
;he #ata well be usin is list'H;2( KH 22;( $ H c<.*( 1.4( 2.4( *.9( ;.( 1.9( 2.=( *.4( *.4( 4.8( ;.*( 9.2( <.2( <.=( 2.*( 2.;( *( *.;( 4.1( 4.=( 9.*( <.=( 1.( 2.4( *.( 4.;( ;.2( 9.*( <.*( 2( *.8( 9.*( <.9( 1.;( 2.1( 2.1( *.1( 4.;( ;.;( ;.( 9.2( <.4( 1.4( 1.4( 2.1( 2.*( *.1( 4.1( ;.4( 9( ;.( *.9)( y H c9.1( 9.2( 9.1( 9.2( 9.2( ;.2( ;.1( ;.*( ;.( ;.9( ;( ;.2( 4.*( 4.2( 4.8( 4.;( 4.;( 4.;( 4.9( 4.2( 4.*( *.2( *.8( *.8( *.;( *.2( *.2( *.4( 2.4( 2.( 2.*( 2.2( 1.( 1.8( 1.8( 1.1( 1.1( 1.8( 1.( 1( 1( <.;( <.9( <.1( <.( <.*( <( <.8( <.4( <.1( *( 9)( heiht H c8<( =*( ;;( 9=<( 8<<( 8<<( *<( 28(1<( 8<( 8<4( 8;;( 8*<( 81*( 92( 9;( 4<( 9;( 9<( =<( 82<( 8;;( 812( *( 812( 82( 8<;( 84<( 8=<( 82<( 8*( 8;( 8*( 89;( 841( 892( =<8( 8;;( 8;<( 882( =1<( =4<( =1;( 8=<( 88<( 8<( 88<( =9<( 8=<( 89<( 8*<( <;)( $.pre&Hc<.21( <.21( <.21( <.21( <.21( <.21( <.21( <.21( <.21( <.21( <.21( <.21( <.21( <.21( <.21( <.9*( <.9*( <.9*( <.9*( <.9*( <.9*( <.9*( <.9*( <.9*( <.9*( <.9*( <.9*( <.9*( <.9*( <.9*( 1.<;( 1.<;( 1.<;( 1.<;( 1.<;( 1.<;( 1.<;( 1.<;( 1.<;( 1.<;( 1.<;( 1.<;( 1.<;( 1.<;( 1.<;( 1.4( 1.4( 1.4( 1.4( 1.4( 1.4( 1.4( 1.4( 1.4( 1.4( 1.4( 1.4( 1.4( 1.4( 1.4( 1.8=( 1.8=( 1.8=( 1.8=( 1.8=( 1.8=( 1.8=( 1.8=( 1.8=( 1.8=( 1.8=( 1.8=( 1.8=( 1.8=( 1.8=( 2.*1( 2.*1( 2.*1( 2.*1( 2.*1( 2.*1( 2.*1( 2.*1( 2.*1( 2.*1( 2.*1( 2.*1( 2.*1( 2.*1( 2.*1( 2.*( 2.*( 2.*( 2.*( 2.*( 2.*( 2.*( 2.*( 2.*( 2.*( 2.*( 2.*( 2.*( 2.*( 2.*( *.1;( *.1;( *.1;( *.1;( *.1;( *.1;( *.1;( *.1;( *.1;( *.1;( *.1;( *.1;( *.1;( *.1;( *.1;( *.;( *.;( *.;( *.;( *.;( *.;( *.;( *.;( *.;( *.;( *.;( *.;( *.;( *.;( *.;( *.==( *.==( *.==( *.==( *.==( *.==( *.==( *.==( *.==( *.==( *.==( *.==( *.==( *.==( *.==( 4.41( 4.41( 4.41( 4.41( 4.41( 4.41( 4.41( 4.41( 4.41( 4.41( 4.41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41( *.==( *.;( *.1;( 2.*( 2.*1( 1.8=( 1.4( 1.<;( <.9*( <.21( 9.<=( ;.9( ;.2;( 4.8*( 4.41( *.==( *.;( *.1;( 2.*( 2.*1( 1.8=( 1.4( 1.<;( <.9*( <.21( 9.<=( ;.9( ;.2;( 4.8*( 4.41( *.==( *.;( *.1;( 2.*( 2.*1( 1.8=( 1.4( 1.<;( <.9*( <.21( 9.<=( ;.9( ;.2;( 4.8*( 4.41( *.==( *.;( *.1;( 2.*( 2.*1( 1.8=( 1.4( 1.<;( <.9*( <.21( 9.<=( ;.9( ;.2;( 4.8*( 4.41( *.==( *.;( *.1;( 2.*( 2.*1( 1.8=( 1.4( 1.<;( <.9*( <.21( 9.<=( ;.9( ;.2;( 4.8*( 4.41( *.==( *.;( *.1;( 2.*( 2.*1( 1.8=( 1.4( 1.<;( <.9*( <.21( 9.<=( ;.9( ;.2;( 4.8*( 4.41( *.==( *.;( *.1;( 2.*( 2.*1( 1.8=( 1.4( 1.<;( <.9*( <.21))
Map the predicted values at unobserved locations 1) Set a monitor on the "ariable heiht.pre# an# enerate some <9<9 samples. !) >pen the mappin tool, (map/mappin tool. ') Select map: ?le"ation. @n eneral, the ri# $or the #ata youre workin will not be pre#loa#e# in WinBUGS. @n this case, you can either loa# the ri# or e&port your results to or ArcG@S to make plots. %) Select "ariable: heiht.pre#. ) Select uantitymeansample). 2) Select (plot .
Calling WinBUGS from R library(!WinBUGS) Cownloa# this packae $rom 9AD. Step 1) 9reate a $ile with the WinBUGS comman#s to speci$y the mo#el. 8or e&le, create the $ile (9:/Cocuments an# Settins/$uentes/Cesktop/bus.t&t with the $ollowin lines: !o&el@ heihtA1:' 5 spatial.e$p!uA( $A( yA( tau( phi( 1) fori in 1:') @!uAi D %eta %eta 5 &flat) tau 5 &a!!a<.<<1( <.<<1) phi 5 &unif<.<<1( <.8)
? "lat prior for the intercept ? -onJuate inerse a!!a on the precision ? Unifor! prior on phi
forJ in 1:K) @ ? Kake pre&ictions at uno%sere& locations heiht.pre&AJ 5 spatial.unipre&%eta( $.pre&AJ( y.pre&AJ( heihtA)
= Step !) Eoa# the #ata in +ere is co#e to loa# the sur$ace ele"ation #ata. N6-7 #6-7 x6-c(.5, ).8, .8, 5.9, 7.:, ).9, .;, 5.8, 5.8, 8.1, 7.5, 9., ., .;, .5, .7, 5, 5.7, 8.), 8.;, 9.5, .;, ).:, .8, 5.:, 8.7, 7., 9.5, .5, , 5.1, 9.5, .9, ).7, .), .), 5.), 8.7, 7.7, 7.:, 9., .8, ) .8, ).8, .), .5, 5.), 8.), 7.8, 9, 7.:, 5.9! 6- c(9.), 9., 9.), 9., 9., 7., 7.), 7.5, 7.:, 7.9, 7, 7., 8.5, 8., 8.1, 8.7, 8.7, 8.7, 8.9, 8., 8.5, 5., 5.1, 5.1, 5.7, 5., 5., 5.8, .8, .:, .5, ., ).:, ).1, ).1, ).), ).), ).1, ).:, ), ), .7, .9, .), .:, .5, , .1, .8, .), 5, 9! hei"ht 6- c(1:, :;5, :77, 9;, 1, 1, :5, :1, :), :1, 18, 177, 15, 1)5, :9, :97, :8, :97, :9, :;, 1, 177, 1), ::5, 1), 1:, 17, 18, 1;, 1, 1:5, 1:7, 1:5, 197, 18), 19, ;1, 177, 17, 11, ;), ;8, ;)7, 1;, 11, 1:, 11, ;9, 1;, 19, 15, :7! x.pred6-c(.), .), .), .), .), .), .), .), .), .), .), .), .), .), .), .95, .95, .95, .95, .95, .95, .95, .95, .95, .95, .95, .95, .95, .95, .95, ).7, ).7, ).7, ).7, ).7, ).7, ).7, ).7, ).7, ).7, ).7, ).7, ).7, ).7, ).7, ).8:, ).8:, ).8:, ).8:, ).8:, ).8:, ).8:, ).8:, ).8:, ).8:, ).8:, ).8:, ).8:, ).8:, ).8:, ).1;, ).1;, ).1;, ).1;, ).1;, ).1;, ).1;, ).1;, ).1;, ).1;, ).1;, ).1;, ).1;, ) .1;, ).1;, .5), .5), .5), .5), .5), .5), .5), .5), .5), .5), .5), .5), .5), .5), .5), .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).8:, ).7, .95, .), 9.;, 7.9:, 7.7, 8.15, 8.8), 5.;;, 5.7:, 5.)7, .:5, .5), ).1;, ).8:, ).7, .95, .), 9.;, 7.9:, 7.7, 8.15, 8.8), 5.;;, 5.7:, 5.)7, .:5, .5), ).1;, ).8:, ).7, .95, .), 9.;, 7 .9:, 7.7, 8.15, 8.8), 5.;;, 5.7:, 5.)7, .:5, .5), ).1;, ).8:, ).7, .95, .), 9.;, 7.9:, 7.7, 8.15, 8.8), 5.;;, 5.7:, 5.)7, .:5, .5), ).1;, ).8:, ).7, .95, .), 9.;, 7.9:, 7.7, 8.15, 8.8), 5.;;, 5.7:, 5.)7, .:5, .5), ).1;, ).8:, ).7, .95, .), 9 .;, 7.9:, 7.7, 8.15, 8.8), 5.;;, 5.7:, 5.)7, .:5, .5), ).1;, ).8:, ).7, .95, .), 9.;, 7.9:, 7.7, 8.15, 8.8), 5.;;, 5.7:, 5 .)7, .:5, .5), ).1;, ).8:, ).7, .95, .), 9.;, 7.9:, 7.7, 8.15, 8.8), 5.;;, 5.7:, 5.)7, .:5, .5), ).1;, ).8:, ).7, .95, .), 9.;, 7.9:, 7.7, 8.15, 8.8), 5.;;, 5.7:, 5.)7, .:5,
.5), ).1;, ).8:, ).7, .95, .), 9.;, 7.9:, 7.7, 8.15, 8.8), 5.;;, 5 .7:, 5.)7, .:5, .5), ).1;, ).8:, ).7, .95, .), 9.;, 7.9:, 7.7, 8.15, 8.8), 5.;;, 5.7:, 5.)7, .:5, .5), ).1;, ).8:, ).7, .95, .), 9.;, 7.9:, 7.7, 8.15, 8.8), 5.;;, 5.7:, 5.)7, .:5, .5), ).1;, ).8:, ).7, .95, .)!
Step ') 9all WinBUGS $rom 8irst, loa# the packae (!WinBUGS $rom 9AD. ;hen submit the $ollowin co#e in . !o&elfileDI%us.t$tL &ataDlistM'L(LKL(L$L(LyL(LheihtL(L$.pre&L(Ly.pre&L) ars2keepDlistphiL(Lheiht.pre&L) initsDfunction)@listtauH<.<<1( phiH<.4( %etaH82<) outputD%us !o&el.fileHfile.path!o&elfile)( &ataH&ata( inits H inits( para!eters.to.sae H ars2keep( n.chainsH2( n.iterH1<<<( n.%urninH;<<( n.thinH1<( &e%uHTIUE( +3-HTIUE )
Step %) Analy*e the <9<9 output ? -heck conerence plotoutput) ? 0lot the posterior of phi sa!plesDoutputNsi!s.!atri$ ?sa!ples is a !atri$ with all the K-K- sa!ples. ?each aria%le is a colu!n histsa!plesA(1(!ainHL0osterior of phiL) ?the first colu!n is phi ?0lot the pre&icte& alues at the uno%sere& locations pre&alsDoutputN!eanNheiht.pre& ?pre&als is a ector with the post ?pre& !eans at the uno%sere& sites ? Oets use fille&.contour to plot the pre&icte& surface on the 1;$1; ri&. This ? "unction nee&s a 1;$1 ector of $ an& y coor&inates an& a 1;$1; !atri$ of ? pre&icte& alues. lonDsortuniPue$.pre&)) latDsortuniPuey.pre&)) QD!atri$<(1;(1;) fori in 1:1;)@ forJ in 1:1;)@ QAi(JDpre&alsA$.pre&HHlonAi R y.pre&HHlatAJ fille&.contourlon(lat(Q($la%HL$L(yla%HLyL(!ainHL0re&icte& eihtL)
Analy*in areal #ata in WinBUGS A mo#el $or spatial count #ata is: >Fi H Ioisson?FiJe&pthetaFi) Where >Fi is the obser"e# count in reion @, ?Fi is the known o$$set term usually population si*e) an# thetaFi is the spatial ran#om e$$ect that controls whether the rate is abo"e or below a"erae $or reion i. ;he thetaFi are spatially smoothe# with a con#itionally autoreressi"e prior 9A). Un#er the 9A prior, thetaFi con#itional on all theta at all sites other than site i is normal with mean eual to the a"erae o$ the neihborin thetaFK an# "ariance eual to simaL!/ mFi, where mFi is the number o$ neihbors an# simaL! is an unknown "ariance parameters. +ere is the 9A mo#el in WinBUGS $or the lip cancer #ata in the BUGS map manual. model< for (i in ) 2 N! < =>i? ' dpois(mu>i?! lo"(mu>i?! 6- lo"(@>i?! A theta>i? theta>i? 6- aAb>i? BUGS automaticall centers the CDE random effect to have mean Fero, so ou have to add an intercept (a! to allo$ the avera"e of theta to be nonFero. CDE prior distribution for random effects, the sum of b is al$as Fero b>)2N? ' car.normal(ad*>?, $ei"hts>?, m>?, tau! for(k in )2sumNumNei"h! <$ei"hts>k? 6- ) $ei"ht each nei"hbor the same in the conditional prior mean of theta>i? =ther priors2 a ' dflat(! tau ' d"amma(.7, .7!
prior on precision
The initial alues are list(tau ), a, bc(,,,,,ND,,ND,,, ND,,,,,,,,,, ,,,,,,,,,, ,,,,,,,,,, ,,,,,,,,,, ,,,,,!!
sites $ith no nei"hbors have bND
The &ata are: list(N 79, = c( ;, 5;, )), ;, )7, 1, 9, :, 9, , )5, 7, 5, 1, ):, ;, , :, ;, :, )9, 5), )), :, );, )7, :, ), )9, )), 7, 5, :, 1, )), ;, )), 1, 9, 8, ), 1, , 9, );, 5, , 5, 1, 9, ), ), ), ), , !, @ c( ).8, 1.:, 5., .7, 8.5, .8, 1.), .5, ., 9.9, 8.8, ).1, ).), 5.5, :.1, 8.9, ).), 8., 7.7, 8.8, ).7,.:, 1.1, 7.9,)7.7,).7, 9., ;.,)8.8,)., 8.1, .;, :., 1.7,).5,).),).:, ;.8, :., 7.5, )1.1,)7.1, 8.5,)8.9,7.:, 1., 7.9, ;.5,11.:,);.9,5.8, 5.9, 7.:, :., 8., ).1!, m c(5, , ), 5, 5, , 7, , 7, 8, , , 5, 5, , 9, 9, 9, 7, 5, 5, , 8, 1, 5, 5, 8, 8, )), 9, :, 5, 8, ;, 8, , 8, 9, 5, 8, 7, 7, 8, 7, 8, 9, 9, 8, ;, , 8, 8, 8, 7, 9, 7!, sumNumNei"h 58,
Here is $here $e tell BUGS ho$ to set up the ad*acenc structure. Ior example, site ) nei"hbors sites );,;, and 7. ad* c( );, ;, 7, ), :, ), 1, , )1, );, ), ), Site 9 has no nei"hbors ):, )9, )5, ), , ;, 5, );, ):, ), , )9, :, , 7, 5, );, ):, :, 57, 5, 5), ;, 7, ;, , ), ):, ), :, ;, );, )9, )5, ;, :, 79, 77, 55, 1, , 8, ):, )5, ;, 7, ), 79, )1, 8, 7, ;, )9, )9, ), 5;, 58, ;, ;, 79, 77, 81, 8:, 88, 5), 5, :, ;, 9, )7, 85, ;, 7, 79, 5, 5), 8, 87, 55, )1, 8, 7, 85, 58, 9, 7, 5, ), ):, )9, )7, ;, 77, 87, 88, 8, 51, 8, 8:, 89, 57, 5, :, 8, )8, 5), :, )8, 77, 87, 1, )1, 78, 7, 7), 85, 8, 8, 5;, ;, 5, 89, 5:, 5), )8, 8), 5:, 89, 8), 59, 57, 78, 7), 8;, 88, 8, 5, 8, 58, 5, 7, 8;, 5;, 58, 75, 8;, 89, 5:, 59, 7), 85, 51, 58, 5, 8, 58, ;, 9, 8;, 81, 51, 5, 8, 77, 55, 5, 1, 75, 8:, 8), 5:, 57, 5), 75, 8;, 81, 89, 5), 8, 8;, 8:, 88, 8, 78, 75, 7, 81, 8:, 88, 8), 8, 51, ;, ), 78, 8, 51, 58, 78, 8;, 8, 58, 8;, 8:, 89, 8), 7, 7), 8;, 51, 58, 79, 87, 55, 5, 8, )1, 77, :, 8, , )1 !!