Introduction

Numerious studies have found conomic and financial crises tend to result in the significant changes on international migration patterns (Kothari et al., 2013). While there are many researches that have examined the relationship between labor (aged from 16 to64) mobility and financial crisis, it seems there are not many studies which focus on the relationship between financial crisis and total population. Instead of exploring causality between financial crisis and population mobility, this project attempts to conduct a visualization. Specifically, this project aims to visualize the changing rate of population mobility of 5o states in the United States from 2008 to 2009 when the global financial severely hit U.S. This project attempts to examine population mobility based on the four different types of population mobility; moved population from same county, moved population from different counties within same state, moved population from different states, and moved population from abroad.

Materials and methods

Packages

Particulary, ‘Plotly’ R package is necessary for creating interactive map.

library(readr)
library(sp)
library(DT)
library(tigris)
library(ggplot2)
library(plotly)

Data

Population mobility data (only in-migration data) was downloaded from American Factfinder website.

moved population from same county moved population from different counties within same state moved population from different states moved population from abroad

All those four moved population data are aggregated at the state-level.

Methodology

Changing rate of moved population size = (moved population in 2009) - (moved population in 2008) / (moved population in 2008) * 100

Since U.S. census provides the ration of moved population to total population, it is necessary to calculate the value of moved population. The only variable which is provided in orignial value is total population. In addition, the ration values are not provided in numeric type, it is also necessary to change ration value from factor type into numeric type.

## change data type from factor to numeric (2008)
df08<-read.csv("https://raw.githubusercontent.com/jongseow/RDataScience_Project/master/data_project/ACS_08_1YR_S0701_with_ann.csv")
df08<-df08[-c(1,10),]
popValues08<-as.numeric(levels(df08$HC01_EST_VC01))[df08$HC01_EST_VC01]
incounty08<-as.numeric(levels(df08$HC02_EST_VC01))[df08$HC02_EST_VC01]*popValues08
instate08<-as.numeric(levels(df08$HC03_EST_VC01))[df08$HC03_EST_VC01]*popValues08
diffstate08<-as.numeric(levels(df08$HC04_EST_VC01))[df08$HC04_EST_VC01]*popValues08
abroad08<-as.numeric(levels(df08$HC05_EST_VC01))[df08$HC05_EST_VC01]*popValues08


## change data type from factor to numeric (2009)
df09<-read.csv("https://raw.githubusercontent.com/jongseow/RDataScience_Project/master/data_project/ACS_09_1YR_S0701_with_ann.csv")
df09<-df09[-c(1,10),]
popValues09<-as.numeric(levels(df09$HC01_EST_VC01))[df09$HC01_EST_VC01]
incounty09<-as.numeric(levels(df09$HC02_EST_VC01))[df09$HC02_EST_VC01]*popValues09
instate09<-as.numeric(levels(df09$HC03_EST_VC01))[df09$HC03_EST_VC01]*popValues09
diffstate09<-as.numeric(levels(df09$HC04_EST_VC01))[df09$HC04_EST_VC01]*popValues09
abroad09<-as.numeric(levels(df09$HC05_EST_VC01))[df09$HC05_EST_VC01]*popValues09

Results

All five interactive coropleth maps below demonstrate changing rate of total population, moved population from same county, moved population from different counties within same state, moved population from different states, and moved population from abroad from 2008 to 2009.

# creat a new dataframe for Choropleth map  (changing rate 08-09)
df<-data.frame(((popValues09- popValues08)/popValues08)*100, ((incounty09- incounty08)/incounty08)*100, 
               ((instate09- instate08)/instate08)*100, ((diffstate09- diffstate08)/diffstate08)*100, ((abroad09- abroad08)/abroad08)*100)

df.example<-read.csv("https://raw.githubusercontent.com/plotly/datasets/master/2011_us_ag_exports.csv")
df$state<-with(df.example, paste(state))
df$code<-with(df.example, paste(code))
colnames(df)<-c("pop", "incounty", "instate", "diffstate", "abroad", "state", "code")



# Map for populaltion changes in 2008-2009 
df$box <- with(df, paste(state))

g <- list(scope = 'usa',
          projection = list(type = 'albers usa'))

p <- plot_geo(df,locationmode = 'USA-states') %>%
  add_trace(
    z = ~pop,text = ~box, locations = ~code,
    color = ~pop, colors = 'Purples'
  ) %>%
  colorbar(title = "Population Change (percentage)") %>%
  layout(
    title = '2008-09 population changes by State',
    geo = g
  )
p
# Map for population mobility (different counties within same state) changes in 2008-2009
df$box <- with(df, paste(state))

g <- list(scope = 'usa',
          projection = list(type = 'albers usa'))

p <- plot_geo(df,locationmode = 'USA-states') %>%
  add_trace(
    z = ~incounty,text = ~box, locations = ~code,
    color = ~incounty, colors = 'Purples'
  ) %>%
  colorbar(title = "population changes (percentage)") %>%
  layout(
    title = '2008-09 US intra-county moved population changes',
    geo = g
  )
p
# Map for population mobility (from different states) changes in 2008-2009
df$box <- with(df, paste(state))

g <- list(scope = 'usa',
          projection = list(type = 'albers usa'))

p <- plot_geo(df,locationmode = 'USA-states') %>%
  add_trace(
    z = ~instate,text = ~box, locations = ~code,
    color = ~instate, colors = 'Purples'
  ) %>%
  colorbar(title = "population change (percentage)") %>%
  layout(
    title = '2008-09 moved population from different counties within same state',
    geo = g
  )
p
# Map for population mobility (different counties within same state) changes in 2008-2009
df$box <- with(df, paste(state))

g <- list(scope = 'usa',
          projection = list(type = 'albers usa'))

p <- plot_geo(df,locationmode = 'USA-states') %>%
  add_trace(
    z = ~diffstate,text = ~box, locations = ~code,
    color = ~diffstate, colors = 'Purples'
  ) %>%
  colorbar(title = "population changes (percentage)") %>%
  layout(
    title = '2008-09 US inter-state moved population changes',
    geo = g
  )
p
# Map for population mobility (from abroad) changes in 2008-2009 
df$box <- with(df, paste(state))

g <- list(scope = 'usa',
          projection = list(type = 'albers usa'))

p <- plot_geo(df,locationmode = 'USA-states') %>%
  add_trace(
    z = ~abroad,text = ~box, locations = ~code,
    color = ~abroad, colors = 'Purples'
  ) %>%
  colorbar(title = "Moved population size from abroad (percentage)") %>%
  layout(
    title = '2008-09 moved population from abroad',
    geo = g
  )
p

Conclusions

Those five interactive coropleth maps successfully visualize the changing rate of four different types of population mobility and total population from 2008 to 2009 when global financial crisis had a significant impact on the U.S. According to five interactive coropleth maps, it is hard to find any similar geographical patterns among them. This project is meaningful as the first stage of exploring the relationship between population mobility and financial crisis. Visualization of changing rate of four different population mobility types enables us to find out which states experienced dramatic increase or decrease in terms of population mobility during the recession. On the basis of this first step, it might be possible to investigate the causal relationship between population mobility and financial crisis.

References

Kothari, S., Saporta-Eksten, I., & Yu, E. (2013). The (un) importance of geographical mobility in the Great Recession. Review of Economic Dynamics, 16(3), 553-563.

Data source: The population mobility data set used in this project was downloaded from the US Census Bureau U.S. Census Bureau (2008-2009). Geographic Mobility by selected characerustucs in the United States, 2008 and 2009 American Community Survey 1-year estimates.