Description Usage Format Examples
Shape file of the state of Rio de Janeiro
1 |
A shape file with 92 observations on the following 9 variables.
Rio de Janeiro counties numeric codes
Rio de Janeiro counties names
Rio de Janeiro counties latitude
Rio de Janeiro counties longitude
Rio de Janeiro counties population
Rio de Janeiro counties percentage of homes living with less than one minimun salary
Rio de Janeiro counties percentage of urban area
Counts of dengue fever cases by county in the state of Rio de Janeiro
Expected counts of dengue fever cases by county in the state of Rio de Janeiro, conditioned on the total number of cases the stratified by population rate
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | data(rio)
## Not run:
library(spdep)
rio.bug <- system.file("bugs/model/dengue.bug", package="rbugs")
## Get the neighbor structure for Rio
rj.nb=poly2nb(rio)
## Number of cases by county
Y = rio@data$Dengue
## Get covariates
X <- as.matrix(rio@data[,c("Urban","Income")])
## Get expected values
E <- rio@data$E
## Number of covariates
P <- ncol(X)
## Total counties
N <- length(rj.nb)
## Number of neighbors of each county
num <- sapply(rj.nb, length)
## Adjacency neighbor list of each county
adj <- unlist(rj.nb)
## Total sum of the number of neighbors in the map
sumNumNeigh <- length(adj)
## Set data file
data.rio <- list (N=N, P=P, Y=Y, adj=adj, X=X, E=E, num=num, sumNumNeigh=sumNumNeigh)
## Generate the intial values for spatial vector (u), random noise (v) and covariates effects (beta)
u.aux <- rep(0,N)
v.aux <- rep(0,N)
beta.aux <- rep(0,P)
## Generate the list with the nescessary information in the init file
inits <- list( list(beta = beta.aux, tau.u = 1, tau.v = 1, u=u.aux, v=v.aux, Int=0.0))
## Set the parameters that will be saved and returned by BUGS
parameters <- c("beta", "tau.u", "tau.v", "RR", "Int")
## no tested examples for mac-os.
rio.sim <- rbugs(data.rio, inits, parameters,
rio.bug, n.chains=2, n.iter=60000,
n.burnin = 10000, n.thin = 10,
bugs="/usr/bin/OpenBUGS",
bugsWorkingDir="/home/marcos/tmp")
## MCMC analysis
library("coda")
rio.mcmc <- rbugs2coda(rio.sim)
summary(rio.mcmc)
effectiveSize(rio.mcmc)
gelman.diag(rio.mcmc)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.