#What is the impact of unemployment on poverty?
library(sf)
library(dplyr)
library(spData) library(ggplot2) library(ggthemes) library(spdep)
library(spatialreg) library(GWmodel) library(tidyr)
setwd(“~/Desktop/DIDA 370/chicago_airbnb”) chicago_data <- st_read(“airbnb_Chicago 2015.shp”)
model <- chicago_data %>% select(c(poverty, unemployed, num_crimes)) %>% filter(!poverty %in% “NA”) %>% mutate(poverty = as.numeric(poverty))
summary(lm1 <- lm(poverty ~ unemployed + num_crimes, data = model))
chicago_list <- model %>% poly2nb(st_geometry(model)) %>% nb2listw(zero.policy = TRUE)
lm.morantest(lm1, chicago_list)
#The Moran’s I p-value = 7.287e-6 #Observed Moran’s I = 0.278915049
#Lagrange Test:
LM <- lm.RStests(lm1, chicago_list, test = “all”) LM
# adjRSerr = 6.0185, df = 1, p-value = 0.01416
# adjRSlag = 0.022755, df = 1, p-value = 0.8801
lm_error <- errorsarlm(poverty ~ unemployed + num_crimes, data = model, listw = chicago_list, zero.policy = TRUE, na.action = na.omit) summary(lm_error)
#Lambda = 0.49507 which is positive and relatively close to 0, further supporting the # idea that poverty, and employed and num_crimes are related to a certain degree.