2024-02-06

Dataset 1

North Dakota’s Estimated Percentage of Poverty Population in 2014

North Dakota’s Estimated Percentage of Poverty Population in 2015

Dataset 2

North Dakota’s Estimated Median Household Income in 2014

North Dakota’s Estimated Median Household Income in 2015

Ch-square test based on dataset 1 and 2

\[ 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

Product-moment correlation based on Dataset 1

\[ 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

Product-moment correlation based on Dataset 2

## 
##  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

Code Used for the ggplot

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)