#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

Because the p-value is so low, the Moran’s I value is important and we can reject the

null hypothesis (H0 = no autocorrelation). Note: I learned how to interpret p-values in

this way MATH-448. A Moran’s I value of 0.2789 tells us that poverty, and unemployed

and num_crimes relate somewhat, but not strongly.

#Lagrange Test:

LM <- lm.RStests(lm1, chicago_list, test = “all”) LM

Results:

# adjRSerr = 6.0185, df = 1, p-value = 0.01416
# adjRSlag = 0.022755, df = 1, p-value = 0.8801

the adjusted R-squred value is way higher for the error model, so that is the model I

will use!

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.

Both variables, employed and num_crimes, relate to poverty to some extent, which can

be inferred both from this analysis, as well as intuitively.