d_vars <- district[, c("DAGC4X21R", "DPFVTOTK", "DPETECOP", "DPSTTOSA")]
# graduation rate, property wealth, % economically disadvantaged, and average teacher salary.
colnames(d_vars) <- c("Grad Rate", "Property Wealth", "% Low Income", "Teacher Salary")
cor(d_vars, use = "complete.obs")
## Grad Rate Property Wealth % Low Income Teacher Salary
## Grad Rate 1.00000000 0.04509333 -0.23574039 -0.01784474
## Property Wealth 0.04509333 1.00000000 -0.15595775 0.09702166
## % Low Income -0.23574039 -0.15595775 1.00000000 -0.07348822
## Teacher Salary -0.01784474 0.09702166 -0.07348822 1.00000000
pairs(d_vars)

cor.test(district$DPETECOP, district$DAGC4X21R, method = "pearson")
##
## Pearson's product-moment correlation
##
## data: district$DPETECOP and district$DAGC4X21R
## t = -7.968, df = 1072, p-value = 4.098e-15
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## -0.2921474 -0.1791774
## sample estimates:
## cor
## -0.2364613
cor.test(district$DPETECOP, district$DAGC4X21R, method = "spearman")
## Warning in cor.test.default(district$DPETECOP, district$DAGC4X21R, method =
## "spearman"): cannot compute exact p-value with ties
##
## Spearman's rank correlation rho
##
## data: district$DPETECOP and district$DAGC4X21R
## S = 271146333, p-value < 2.2e-16
## alternative hypothesis: true rho is not equal to 0
## sample estimates:
## rho
## -0.3132352
cor.test(district$DPETECOP, district$DAGC4X21R, method = "kendall")
##
## Kendall's rank correlation tau
##
## data: district$DPETECOP and district$DAGC4X21R
## z = -10.367, p-value < 2.2e-16
## alternative hypothesis: true tau is not equal to 0
## sample estimates:
## tau
## -0.2183232
# Most districts had graduation rates close to 100%, and many had exactly the same rate or tied rates, so I used Kendall’s tau. I found a statistically significant negative relationship between the share of low-income students and the four-year graduation rate (τ = -0.21, p < 0.001). Meaning districts with a higher share of low-income students tended to have lower graduation rates.