library(readxl)
district <- read_excel("district.xls")
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.3 ✔ 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(pastecs)
##
## Attaching package: 'pastecs'
## The following objects are masked from 'package:dplyr':
##
## first, last
## The following object is masked from 'package:tidyr':
##
## extract
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
data_multiple <- lm(DA0CT21R ~ DA0CSA21R + DPETECOP, data = district)
plot(data_multiple,which=1)
raintest(data_multiple)
##
## Rainbow test
##
## data: data_multiple
## Rain = 1.0444, df1 = 473, df2 = 469, p-value = 0.3189
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(data_multiple)
## lag Autocorrelation D-W Statistic p-value
## 1 0.04991637 1.897388 0.118
## Alternative hypothesis: rho != 0
plot(data_multiple,which=3)
bptest(data_multiple)
##
## studentized Breusch-Pagan test
##
## data: data_multiple
## BP = 76.387, df = 2, p-value < 2.2e-16
plot(data_multiple,which=2)
shapiro.test(data_multiple$residuals)
##
## Shapiro-Wilk normality test
##
## data: data_multiple$residuals
## W = 0.97447, p-value = 7.998e-12
vif(data_multiple)
## DA0CSA21R DPETECOP
## 1.042353 1.042353
```