library(readxl)
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.4
## ── 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
district<-read_excel("district.xls")
biligual<-district%>%select(DPETBILP,DPSTBIFP,DPSTTOSA,DPETHISP)
biligual_clean<-biligual%>%na.omit(.)
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
biligual_clean_model<-lm(DPETBILP~DPSTBIFP+DPSTTOSA+DPETHISP,data = biligual_clean)
plot(biligual_clean_model,which = 1)

raintest(biligual_clean_model)
##
## Rainbow test
##
## data: biligual_clean_model
## Rain = 0.7052, df1 = 602, df2 = 597, p-value = 1
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(biligual_clean_model)
## lag Autocorrelation D-W Statistic p-value
## 1 0.2465686 1.504285 0
## Alternative hypothesis: rho != 0
plot(biligual_clean_model,which = 3)

bptest(biligual_clean_model)
##
## studentized Breusch-Pagan test
##
## data: biligual_clean_model
## BP = 152.19, df = 3, p-value < 2.2e-16
plot(biligual_clean_model,which = 2)

shapiro.test(biligual_clean_model$residuals)
##
## Shapiro-Wilk normality test
##
## data: biligual_clean_model$residuals
## W = 0.85181, p-value < 2.2e-16
vif(biligual_clean_model)
## DPSTBIFP DPSTTOSA DPETHISP
## 1.183359 1.062115 1.137910
biligual_clean_model<-district%>%dplyr::select(DPSTBIFP,DPSTTOSA,DPETHISP)
cor(biligual_clean_model)
## DPSTBIFP DPSTTOSA DPETHISP
## DPSTBIFP 1 NA NA
## DPSTTOSA NA 1 NA
## DPETHISP NA NA 1