R Markdown

library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.4     ✔ readr     2.1.5
## ✔ forcats   1.0.0     ✔ stringr   1.5.1
## ✔ ggplot2   3.5.1     ✔ tibble    3.2.1
## ✔ lubridate 1.9.4     ✔ tidyr     1.3.1
## ✔ purrr     1.0.2     
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(readxl)
library(MASS)
## 
## Attaching package: 'MASS'
## 
## The following object is masked from 'package:dplyr':
## 
##     select
library(lmtest)
## Loading required package: zoo
## 
## Attaching package: 'zoo'
## 
## The following objects are masked from 'package:base':
## 
##     as.Date, as.Date.numeric
library(car)
## Loading required package: carData
## 
## Attaching package: 'car'
## 
## The following object is masked from 'package:dplyr':
## 
##     recode
## 
## The following object is masked from 'package:purrr':
## 
##     some
EAVS<-read_xlsx("2022_EAVS_for_Public_Release_V1.1.xlsx")
EAVS1<-EAVS%>%filter(State_Full=="TEXAS")
EAVS1%>%
dplyr::select(Jurisdiction_Name,A1a,A1b,A1c,A4a,A4b,C9a,C9b,C9c)
## # A tibble: 254 × 9
##    Jurisdiction_Name A1a   A1b   A1c   A4a   A4b   C9a   C9b   C9c  
##    <chr>             <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr>
##  1 ANDERSON COUNTY   29494 26888 2606  1718  427   8     3     3    
##  2 ANDREWS COUNTY    10369 8907  1462  563   6     0     0     0    
##  3 ANGELINA COUNTY   54088 49311 4777  3197  465   36    16    1    
##  4 ARANSAS COUNTY    18821 16249 2572  1053  469   11    2     0    
##  5 ARCHER COUNTY     6557  6206  351   384   69    0     0     0    
##  6 ARMSTRONG COUNTY  1445  1325  120   126   25    0     0     0    
##  7 ATASCOSA COUNTY   29927 26716 3211  2277  284   3     0     0    
##  8 AUSTIN COUNTY     20848 18983 1865  1041  260   4     4     0    
##  9 BAILEY COUNTY     3501  3067  434   167   36    0     0     0    
## 10 BANDERA COUNTY    17963 17037 926   1043  312   0     0     0    
## # ℹ 244 more rows
EAVS2<-EAVS1
EAVS2$A1a<-as.numeric(EAVS2$A1a)
EAVS2$A1b<-as.numeric(EAVS2$A1b)
EAVS2$A1c<-as.numeric(EAVS2$A1c)
EAVS2$A4a<-as.numeric(EAVS2$A4a)
EAVS2$A4b<-as.numeric(EAVS2$A4b)
EAVS2$C9a<-as.numeric(EAVS2$C9a)
EAVS2$C9b<-as.numeric(EAVS2$C9b)
## Warning: NAs introduced by coercion
EAVS2$C9c<-as.numeric(EAVS2$C9c)
## Warning: NAs introduced by coercion
EAVS2<-EAVS1%>%dplyr::select(A1a,A1b,A1c,A4a,A4b,C9a,C9b,C9c)%>%na.omit(.)
EAVS3<-lm(A1a~A4a-C9a,data = EAVS2)
plot(EAVS3)
## Warning: not plotting observations with leverage one:
##   2, 3, 4, 7, 8, 12, 14, 15, 16, 17, 18, 19, 20, 21, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 37, 41, 42, 43, 44, 45, 46, 49, 52, 53, 54, 57, 58, 62, 64, 65, 67, 68, 70, 71, 73, 75, 76, 78, 79, 80, 83, 84, 85, 87, 88, 90, 93, 94, 95, 96, 97, 98, 100, 101, 102, 106, 109, 110, 111, 112, 113, 114, 116, 117, 120, 122, 123, 125, 127, 128, 129, 130, 131, 132, 136, 137, 139, 140, 142, 143, 144, 145, 146, 147, 149, 150, 151, 152, 153, 154, 155, 157, 158, 160, 161, 162, 163, 165, 167, 168, 171, 172, 173, 174, 175, 176, 177, 178, 180, 181, 182, 183, 184, 185, 186, 187, 189, 190, 191, 192, 194, 195, 196, 198, 199, 200, 201, 202, 203, 204, 205, 206, 208, 209, 210, 212, 213, 214, 215, 216, 217, 218, 220, 221, 222, 223, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254

## Warning in sqrt(crit * p * (1 - hh)/hh): NaNs produced
## Warning in sqrt(crit * p * (1 - hh)/hh): NaNs produced

EAVS4<-lm(A1a~A4a,data=EAVS2)
plot(EAVS4,which=3)
## Warning: not plotting observations with leverage one:
##   2, 3, 4, 7, 8, 12, 14, 15, 16, 17, 18, 19, 20, 21, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 37, 41, 42, 43, 44, 45, 46, 49, 52, 53, 54, 57, 58, 62, 64, 65, 67, 68, 70, 71, 73, 75, 76, 78, 79, 80, 83, 84, 85, 87, 88, 90, 93, 94, 95, 96, 97, 98, 100, 101, 102, 106, 109, 110, 111, 112, 113, 114, 116, 117, 120, 122, 123, 125, 127, 128, 129, 130, 131, 132, 136, 137, 139, 140, 142, 143, 144, 145, 146, 147, 149, 150, 151, 152, 153, 154, 155, 157, 158, 160, 161, 162, 163, 165, 167, 168, 171, 172, 173, 174, 175, 176, 177, 178, 180, 181, 182, 183, 184, 185, 186, 187, 189, 190, 191, 192, 194, 195, 196, 198, 199, 200, 201, 202, 203, 204, 205, 206, 208, 209, 210, 212, 213, 214, 215, 216, 217, 218, 220, 221, 222, 223, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254

durbinWatsonTest(EAVS4)
##  lag Autocorrelation D-W Statistic p-value
##    1     -0.00187601      2.003752   0.114
##  Alternative hypothesis: rho != 0
EAVS5<-lm(A1a~A4a,data=EAVS2)
plot(EAVS5,which=3)
## Warning: not plotting observations with leverage one:
##   2, 3, 4, 7, 8, 12, 14, 15, 16, 17, 18, 19, 20, 21, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 37, 41, 42, 43, 44, 45, 46, 49, 52, 53, 54, 57, 58, 62, 64, 65, 67, 68, 70, 71, 73, 75, 76, 78, 79, 80, 83, 84, 85, 87, 88, 90, 93, 94, 95, 96, 97, 98, 100, 101, 102, 106, 109, 110, 111, 112, 113, 114, 116, 117, 120, 122, 123, 125, 127, 128, 129, 130, 131, 132, 136, 137, 139, 140, 142, 143, 144, 145, 146, 147, 149, 150, 151, 152, 153, 154, 155, 157, 158, 160, 161, 162, 163, 165, 167, 168, 171, 172, 173, 174, 175, 176, 177, 178, 180, 181, 182, 183, 184, 185, 186, 187, 189, 190, 191, 192, 194, 195, 196, 198, 199, 200, 201, 202, 203, 204, 205, 206, 208, 209, 210, 212, 213, 214, 215, 216, 217, 218, 220, 221, 222, 223, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254