# NOT RUN {
data("rongelapUTM")
if(require("sp", quietly=TRUE)){
plot(rongelapUTM)
}
# }
# NOT RUN {
rongelapBorderLL = raster::getData("GADM",
country="MHL",level=0)
library("rgdal")
rongelapBorderUTM = spTransform(rongelapBorderLL,
CRS(proj4string(rongelapUTM)))
plot(rongelapBorderUTM, add=TRUE)
# }
# NOT RUN {
rongelapUTM$logOffset = log(rongelapUTM$time)
rongelapUTM$site = seq(1, length(rongelapUTM$time))
forBugs = glmmBUGS(
formula=count + logOffset ~ 1, family="poisson",
data=rongelapUTM@data, effects="site",
spatial=rongelapUTM,
priors=list(phisite="dgamma(100,1)")
)
startingValues = forBugs$startingValues
startingValues$phi=list(site = 100)
source("getInits.R")
# }
# NOT RUN {
rongelapResult = bugs(forBugs$ragged, getInits,
parameters.to.save = names(getInits()),
model.file="model.bug", n.chain=2, n.iter=20, n.burnin=4, n.thin=2,
program="winbugs", debug=TRUE,
working.directory=getwd())
rongelapParams = restoreParams(rongelapResult, forBugs$ragged)
# }
# NOT RUN {
data("rongelapResult")
rongelapParams = restoreParams(rongelapResult)
checkChain(rongelapParams)
rongelapSummary=summaryChain(rongelapParams)
# }
Run the code above in your browser using DataLab