7.1 Data

# remotes::install_github("Paula-Moraga/SpatialEpiApp")
library(SpatialEpiApp)
namecsv <- "SpatialEpiApp/data/Ohio/dataohiocomplete.csv"
dohio <- read.csv(system.file(namecsv, package = "SpatialEpiApp"))
head(dohio)
##   county gender race year y     n  NAME
## 1      1      1    1 1968 6  8912 Adams
## 2      1      1    1 1969 5  9139 Adams
## 3      1      1    1 1970 8  9455 Adams
## 4      1      1    1 1971 5  9876 Adams
## 5      1      1    1 1972 8 10281 Adams
## 6      1      1    1 1973 5 10876 Adams

Map of Ohio

library(rgdal)
library(sf)

nameshp <- system.file(
"SpatialEpiApp/data/Ohio/fe_2007_39_county/fe_2007_39_county.shp",
package = "SpatialEpiApp")
map <- readOGR(nameshp, verbose = FALSE)

plot(map)

Calculate the observed and expected counts, and the SIRs for each county and year, and create a data frame.

library(tidyverse)
d <- dohio %>%
  group_by(county=NAME,year) %>%
  summarize(Y=sum(y))%>%
  ungroup()%>%
  arrange(year)
head(d)
## # A tibble: 6 × 3
##   county     year     Y
##   <chr>     <int> <int>
## 1 Adams      1968     6
## 2 Allen      1968    32
## 3 Ashland    1968    15
## 4 Ashtabula  1968    27
## 5 Athens     1968    12
## 6 Auglaize   1968     7