Statistics and Time Series.

Maryland Unemployment Rate by County, Estimates for July 2024


CountyUnemployment Rate
Worcester County3.4
Allegany County2.9
Baltimore city3
Cecil County2.3
Baltimore County2.3
Carroll County1.7
Calvert County1.9
Dorchester County2.4
Anne Arundel County1.9
Frederick County2
Prince George’s County2.3
Howard County1.8
Garrett County2.4
Montgomery County1.9
Queen Anne’s County1.8
Talbot County2.3
Wicomico County2.6
Somerset County3.2
Harford County2
St. Mary’s County2
Kent County2.4
Charles County2.2
Washington County2.4
Caroline County2.2

Unemployment Rate for Maryland is calculated as the four weeks rolling average of Unemployment Insurance Initial Claims reported by the Maryland Department of Labor, plus the number of Unemployed People, divided by the Estimated Labor Force from the Bureau of Labor Statistics. All data granularity is collected at the county level.

Below the code that creates the map:


#################################################
###
### Unemployment Insurance Claims Based County Unemployment Rate Calculation 
### Check estimation method here: https://www.bls.gov/opub/hom/lau/calculation.htm
### Maryland claims data: https://labor.maryland.gov/employment/uicounty.shtml
###
#################################################

library(RColorBrewer)
library(ggplot2)
library(ggspatial)
library(sf)
library(maps)
library(googleway)
library(ggmap)
library(tigris)

##
## Load Data
##

Labor_Force     <- openxlsx::read.xlsx("Labor_Force_laucnty23.xlsx")

Claims_1             <- read.csv("Maryland_June_Last_Week_2024.csv")
Claims_2             <- read.csv("Maryland_July_First_Week_2024.csv")
Claims_3             <- read.csv("Maryland_July_Second_Week_2024.csv")
Claims_4             <- read.csv("Maryland_July_Third_Week_2024.csv")
Claims_4$Regular.UI  <- rowMeans(cbind(Claims_1$Regular.UI, Claims_2$Regular.UI, Claims_3$Regular.UI, Claims_4$Regular.UI))
Tigris_Counties      <- tigris::counties(state = "MD")


##
## Select State Data and process special characters in county names
##


Labor_Force <- subset(Labor_Force, Labor_Force$State_Code=="24")
Flag        <- as.data.frame(stringr::str_locate(Labor_Force$`County.Name/State.Abbreviation`," "))

Labor_Force$County_Name <- substr(Labor_Force$`County.Name/State.Abbreviation`,0,Flag$start)

Labor_Force$County_Name[2]   <- c("Anne Arundel")
Labor_Force$County_Name[3]   <- c("Baltimore")
Labor_Force$County_Name[16]  <- c("Prince Georges")
Labor_Force$County_Name[17]  <- c("Queen Annes")
Labor_Force$County_Name[18]  <- c("ST MARYS")

Labor_Force$County_Name <- toupper(Labor_Force$County_Name)
Labor_Force$County_Name <- trimws(Labor_Force$County_Name)
Labor_Force$Match       <- match(Labor_Force$County_Name, Claims_4$Claim.Filed.By)

Labor_Force$Initial_Claims <- Claims_4[Labor_Force$Match,]$Regular.UI

##
## Calculate County Unemployment Rate as (Initial UI Claims + Unemployed) / Labor Force
##

Labor_Force$Unemployment_Rate_Calculated <- ((Labor_Force$Initial_Claims + Labor_Force$Unemployed)*100)/Labor_Force$Force

##
## process Data to Plot Map
##


Labor_Force$County_Name_2 <- substr(Labor_Force$`County.Name/State.Abbreviation`,0,nchar(Labor_Force$`County.Name/State.Abbreviation`)-4)

Tigris_Counties$Match             <- match(Tigris_Counties$NAMELSAD, Labor_Force$County_Name_2)
Tigris_Counties$Unemployment_Rate <- Labor_Force[Tigris_Counties$Match,]$Unemployment_Rate_Calculated
Tigris_Counties_Plot              <- Tigris_Counties[,c("Unemployment_Rate", "geometry")]
Tigris_Points                     <- Tigris_Counties[,c("NAMELSAD", "INTPTLAT", "INTPTLON")]

plot(Tigris_Counties_Plot, main= "Maryland Unemployment Rate by County July 2024",nbreaks = 9,pal = brewer.pal(9, "YlOrRd"))
text(x= Tigris_Points$INTPTLON, y= Tigris_Points$INTPTLAT, Tigris_Points$NAMELSAD,pos = 1, col = "blue")

class(Tigris_Counties)
plot(Tigris_Points$NAMELSAD)

Tigris_Points$lat   <- Tigris_Points$INTPTLAT
Tigris_Points$lng   <- Tigris_Points$INTPTLON



Raw_Data <- as.data.frame(matrix(ncol = 2, nrow = 24))

colnames(Raw_Data) <- c("County", "State")
Raw_Data$County    <- Tigris_Counties$NAMELSAD
Raw_Data$State     <- "Maryland"

Raw_Data$County_Name <- paste(Raw_Data$County, Raw_Data$State)

##
## Retrieve Lat Long Data for County Centroids 
##



for(i in 1:nrow(Raw_Data))
{
  result <- geocode(Raw_Data$County_Name[i], output = "latlona", source = "google")
  Raw_Data$lon[i]<- as.numeric(result[1])
  Raw_Data$lat[i]<- as.numeric(result[2])
}

Raw_Data$Match               <- match(Raw_Data$County, Tigris_Counties$NAMELSAD)
Raw_Data$Unemployment_Rate   <- Tigris_Counties[Raw_Data$Match,]$Unemployment_Rate
Raw_Data$geometry            <- Tigris_Counties[Raw_Data$Match,]$geometry
Raw_Data$Unemployment_Rate   <- round(Raw_Data$Unemployment_Rate,1)
Raw_Data$County_Unemployment <- paste0(Raw_Data$County,", ", Raw_Data$Unemployment_Rate," %")


##
## Plot Map
##

ggplot(data = Tigris_Counties) +
  geom_sf() +
  geom_sf(data = Tigris_Counties, aes(fill=Unemployment_Rate)) +
  #scale_fill_viridis_c(trans = "sqrt", alpha = .4) +
  geom_text(data = Raw_Data, aes(lon,lat, label=County_Unemployment), size=2, col="white") +
  geom_label(data = Raw_Data, aes(x = lat, y = lon, label = County)) +
  coord_sf(xlim = c(-80, -74.9), ylim = c(37.8, 40), expand = TRUE)+
  labs(title = "Maryland Unemployment Rate by County, July 2024")

mean(Raw_Data$Unemployment_Rate)


##
## Write out data
##



write.csv(Raw_Data[,c("County", "Unemployment_Rate")], "Maryland_Unemployment_Rate_July_2024.csv")

← Back

Thank you for your response. ✨

Leave a comment