SAVE THE FOLLOWING MODEL IN FILE "MODELsessio5.bug" or "MODELsessio5.txt"
and place in c:\nieveblanca\MODELsessio5.bug
#-----------------------------
#-----------------------------
###in R Console
library(R2WinBUGS)
#Data:
x1 = c( 1.0, 1.5, 1.5, 1.5, 2.5, 4.0, 5.0, 5.0, 7.0, 8.0, 8.5, 9.0, 9.5, 9.5, 10.0, 12.0, 12.0, 13.0,
13.0, 14.5, 15.5, 15.5, 16.5, 17.0, 22.5, 29.0, 31.5)
y = c(1.80, 1.85, 1.87, 1.77, 2.02, 2.27, 2.15, 2.26, 2.47, 2.19, 2.26, 2.40, 2.39, 2.41, 2.50, 2.32, 2.32, 2.43,
2.47, 2.56, 2.65, 2.47, 2.64, 2.56, 2.70, 2.72, 2.57)
N=length(y)
#y <- c(9.6,7,5,8,8.4,6.4,6.1,9.1,8.8,5.7,8.9,6.1,6.5)
#x1 <-c(1,1,1,1,1,1,0,0,0,0,0,0,0)
#N<- length(y)
dades <- list("N", "y", "x1" )
inicials <- list(list(tau=1, b0=0, b1=1))
parametres <- c("b0", "b1", "sigma")
model<- bugs(dades, inicials, parameters.to.save=parametres,
model.file="MODELsessio5.bug",n.chains=1,n.thin=1,debug=TRUE,DIC=TRUE,
n.iter=2000,n.burnin=1000,working.directory = "c:/nieveblanca/",
bugs.directory="d:/WinBUGS14/")
print(model , digits=4)
Inference for Bugs model at "MODELsessio5.bug", fit using WinBUGS,
1 chains, each with 2000 iterations (first 1000 discarded)
n.sims = 1000 iterations saved
mean sd 2.5% 25% 50% 75% 97.5%
b0 1.7608 0.0470 1.6680 1.7317 1.7615 1.7900 1.8490
b1 0.2778 0.0201 0.2385 0.2655 0.2775 0.2903 0.3163
sigma 0.0970 0.0146 0.0729 0.0865 0.0954 0.1055 0.1280
deviance -52.0948 2.7305 -55.2100 -54.1700 -52.7500 -50.8850 -45.1283
DIC info (using the rule, pD = Dbar-Dhat)
pD = 3.1 and DIC = -49.0
DIC is an estimate of expected predictive error (lower deviance is better).