2024-02-06
\[ x^2=\sum\frac{(O_i-E_i)^2}{E_i} \]
## ## Pearson's Chi-squared test ## ## data: xtabs(~factor(ND2014) + factor(Income14), data = ND) ## X-squared = 2067, df = 2028, p-value = 0.268
## ## Pearson's Chi-squared test ## ## data: xtabs(~factor(ND2015) + factor(Income15), data = ND) ## X-squared = 2014, df = 1976, p-value = 0.2705
\[ r=\frac{\sum(x_i-\overline{x})}{\sqrt{\sum(x_i-\overline{x})^2\sum(y_i-\overline{y})^2}}. \]
## ## Pearson's product-moment correlation ## ## data: ND2014 and Income14 ## t = -6.0506, df = 51, p-value = 1.709e-07 ## alternative hypothesis: true correlation is not equal to 0 ## 95 percent confidence interval: ## -0.7803729 -0.4557723 ## sample estimates: ## cor ## -0.6464307
## ## Pearson's product-moment correlation ## ## data: ND2015 and Income15 ## t = -5.8765, df = 51, p-value = 3.2e-07 ## alternative hypothesis: true correlation is not equal to 0 ## 95 percent confidence interval: ## -0.7729493 -0.4408228 ## sample estimates: ## cor ## -0.6354068
S<-usmap::plot_usmap(regions="counties",include = "ND",
color ="white",
data= ND, values ="ND2015",labels=TRUE) +
scale_fill_gradientn(name= "Poverty",
colors= rev(rainbow(7)),
label=scales::comma)+
labs(title = "North Dakota",
subtitle = "Poverty Population in North Dakota Counties in 2014") +
theme(legend.position = "right")
S$layers[[2]]$aes_params$size <- 2.5
print(S)