% % WinBUGS 1.4 CODE FOR "DIRECT" METHOD, EXPONENTIAL KRIGING MODEL: % % SB NOTE RE USE OF "USELESS": % we need the % useless[i] <- x[i] + y[i] % since the data includes the x and y coordinate vectors % (WHICH ARE ONLY NEEDED FOR THE NONSPAIAL (IID) MODEL) % % These vectors are actually not needed in the code, which uses the % inter-site distance matrix directly (also being fed in the data as matrix % d). Basically, it is easier (and faster) to compute the inter-site % distance matrix in R and then feed it directly to BUGS (as an object), % rather than having BUGS compute it. %%%%%%%%%%%%%% model { for (i in 1:N) { Y[i] ~ dnorm(mu[i], error.prec) mu[i] <- inprod(X[i,],beta[]) + W[i] muW[i] <- 0.0 useless[i] <- x[i]+y[i] } error.prec ~ dgamma(0.1,0.1) tausq <- 1/error.prec for (i in 1:p) {beta[i] ~ dnorm(0.0, 0.001)} W[1:N] ~ dmnorm(muW[], Omega[,]) spat.prec ~ dgamma(0.1,0.1) sigmasq <- 1/spat.prec phi ~ dunif(0,10) for (i in 1:N) { for (j in 1:N) { H[i,j] <- sigmasq*exp(-phi*d[i,j]) } } Omega[1:N,1:N] <- inverse(H[,]) } #Initial Values list(beta=c(0),phi=5.0,error.prec=1.0,spat.prec=1.0,W=c(0,0,0,0,0,0,0,0,0,0)) #Data: list(N=10, p=1,X = structure(.Data=c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1), .Dim = c(10, 1)), x=c(0.056,6.257,1.204,4.346,4.902,9.800,7.624,4.258,2.835,5.497),y=c(6.682,3.859,6.327,0.546,6.787,9.167,2.265,7.670,5.431,0.363), Y=c(5.972,3.391,4.891,5.352,4.423,3.057,4.553,4.365,7.374,6.554), d = structure(.Data=c(0.0, 6.81334939658902, 1.20163596817006, 7.48696173357391, 4.84713740263261, 10.0558819106034, 8.76267727352776, 4.31658985774651, 3.04759610184814, 8.33871944605405, 6.81334939658902, 0.0, 5.62350717968778, 3.82464246695034, 3.2263305782266, 6.38182677608849, 2.09988690171638, 4.30345465875963, 3.76580243772825, 3.57765509796571, 1.20163596817006, 5.62350717968778, 0.0, 6.57967514395658, 3.72650023480477, 9.05300038661216, 7.59712077039716, 3.33625014050206, 1.86090757427659, 7.34841105273787, 7.48696173357391, 3.82464246695034, 6.57967514395658, 0.0, 6.26571759657264, 10.2013605465154, 3.70138420053904, 7.12454349414754, 5.11334978267671, 1.16545699191347, 4.84713740263261, 3.2263305782266, 3.72650023480477, 6.26571759657264, 0.0, 5.44562246212497, 5.27804585050187, 1.09289752493086, 2.47208919741987, 6.45149602805427, 10.0558819106034, 6.38182677608849, 9.05300038661216, 10.2013605465154, 5.44562246212497, 0.0, 7.23689021610802, 5.74062479178007, 7.90372829745558, 9.7992971686749, 8.76267727352776, 2.09988690171638, 7.59712077039716, 3.70138420053904, 5.27804585050187, 7.23689021610802, 0.0, 6.36741556677432, 5.74091255812175, 2.85337221546717, 4.31658985774651, 4.30345465875963, 3.33625014050206, 7.12454349414754, 1.09289752493086, 5.74062479178007, 6.36741556677432, 0.0, 2.65293233988355, 7.4113001558431, 3.04759610184814, 3.76580243772825, 1.86090757427659, 5.11334978267671, 2.47208919741987, 7.90372829745558, 5.74091255812175, 2.65293233988355, 0.0, 5.72458452640888, 8.33871944605405, 3.57765509796571, 7.34841105273787, 1.16545699191347, 6.45149602805427, 9.7992971686749, 2.85337221546717, 7.4113001558431, 5.72458452640888, 0.0), .Dim = c(10, 10)))