Learn R Programming

rbugs (version 0.5-9.1)

rio: Dengue Fever in the State of Rio de Janeiro

Description

Shape file of the state of Rio de Janeiro

Usage

data(rio)

Arguments

Format

A shape file with 92 observations on the following 9 variables.

GeoCode

Rio de Janeiro counties numeric codes

Name

Rio de Janeiro counties names

Lat

Rio de Janeiro counties latitude

Long

Rio de Janeiro counties longitude

Pop

Rio de Janeiro counties population

Income

Rio de Janeiro counties percentage of homes living with less than one minimun salary

Urban

Rio de Janeiro counties percentage of urban area

Dengue

Counts of dengue fever cases by county in the state of Rio de Janeiro

E

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

Examples

Run this code
# NOT RUN {
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)

## Windows using WinBugs
rio.sim <- rbugs(data.rio, inits, parameters,
                 rio.bug, n.chains=2, n.iter=60000, 
                 n.burnin = 10000, n.thin = 10, 
                 bugs="C:/Program Files/WinBUGS14/WinBUGS14.exe",
                 bugsWorkingDir="C:/temp/", 
                 OpenBugs = FALSE)
                   
## Windows using OpenBUGS
rio.sim <- rbugs(data.rio, inits, parameters,
                 rio.bug, n.chains=2, n.iter=60000, 
                 n.burnin = 10000, n.thin = 10, 
                 bugs="C:/Program Files/OpenBugs321/OpenBugs.exe",
                 bugsWorkingDir="C:/temp/",
                 OpenBugs=TRUE)

##MCMC analysis
library("coda")
rio.mcmc <- rbugs2coda(rio.sim)
summary(rio.mcmc)
effectiveSize(rio.mcmc)
gelman.diag(rio.mcmc)
              

# }

Run the code above in your browser using DataLab