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.2     ✔ tibble    3.3.0
## ✔ lubridate 1.9.4     ✔ tidyr     1.3.1
## ✔ purrr     1.1.0     
## ── 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(tidyverse)
library(lmtest)
## Loading required package: zoo
## 
## Attaching package: 'zoo'
## 
## The following objects are masked from 'package:base':
## 
##     as.Date, as.Date.numeric
library(MASS)
## 
## Attaching package: 'MASS'
## 
## The following object is masked from 'package:dplyr':
## 
##     select
library(readxl)
district<-read_excel("district.xls")
district_data <-district
district_data<-lm(DA0GR21N~DA0GR21N+DPSTURNR,data=district)
## Warning in model.matrix.default(mt, mf, contrasts): the response appeared on
## the right-hand side and was dropped
## Warning in model.matrix.default(mt, mf, contrasts): problem with term 1 in
## model.matrix: no columns are assigned
plot(district_data,which=1)
## Warning in model.matrix.default(object, data = structure(list(DA0GR21N = c(36,
## : the response appeared on the right-hand side and was dropped
## Warning in model.matrix.default(object, data = structure(list(DA0GR21N = c(36,
## : problem with term 1 in model.matrix: no columns are assigned

raintest(district_data)
## Warning in model.matrix.default(terms(formula), model.frame(formula)): the
## response appeared on the right-hand side and was dropped
## Warning in model.matrix.default(terms(formula), model.frame(formula)): problem
## with term 1 in model.matrix: no columns are assigned
## 
##  Rainbow test
## 
## data:  district_data
## Rain = 0.82271, df1 = 539, df2 = 537, p-value = 0.9881
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
durbinWatsonTest(district_data)
## Warning in model.matrix.default(model, data = structure(list(DA0GR21N = c(36, :
## the response appeared on the right-hand side and was dropped
## Warning in model.matrix.default(model, data = structure(list(DA0GR21N = c(36, :
## problem with term 1 in model.matrix: no columns are assigned
##  lag Autocorrelation D-W Statistic p-value
##    1       0.2519676      1.495862       0
##  Alternative hypothesis: rho != 0
plot(district_data,which=3)
## Warning in model.matrix.default(object, data = structure(list(DA0GR21N = c(36,
## : the response appeared on the right-hand side and was dropped
## Warning in model.matrix.default(object, data = structure(list(DA0GR21N = c(36,
## : problem with term 1 in model.matrix: no columns are assigned

bptest(district_data)
## Warning in model.matrix.default(terms(formula), model.frame(formula)): the
## response appeared on the right-hand side and was dropped
## Warning in model.matrix.default(terms(formula), model.frame(formula)): problem
## with term 1 in model.matrix: no columns are assigned
## 
##  studentized Breusch-Pagan test
## 
## data:  district_data
## BP = 4.1191, df = 1, p-value = 0.0424
plot(district_data,which=2)
## Warning in model.matrix.default(object, data = structure(list(DA0GR21N = c(36,
## : the response appeared on the right-hand side and was dropped
## Warning in model.matrix.default(object, data = structure(list(DA0GR21N = c(36,
## : problem with term 1 in model.matrix: no columns are assigned

plot(district_data,which=2)
## Warning in model.matrix.default(object, data = structure(list(DA0GR21N = c(36,
## : the response appeared on the right-hand side and was dropped
## Warning in model.matrix.default(object, data = structure(list(DA0GR21N = c(36,
## : problem with term 1 in model.matrix: no columns are assigned

shapiro.test(district_data$residuals)
## 
##  Shapiro-Wilk normality test
## 
## data:  district_data$residuals
## W = 0.43666, p-value < 2.2e-16
kitchen_sink<-lm(DA0GR21N~DPSTURNR+DPSTTOSA+DPSTTOFP+DA0CSA21R,data=district)
vif(kitchen_sink)
##  DPSTURNR  DPSTTOSA  DPSTTOFP DA0CSA21R 
##  1.090660  1.125615  1.043334  1.059666

the variables i have selected go against the multicollinearity rules adn are way below the “under 10” for Multicollinearity. it seems these variables have almost nocorrelation to each other. Perhaps I can use the log function and run the shaprio test/vif test again to see if the correlation would be affected?