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(readxl)

data<-read_excel("district.xls")

Linear Model

data_model<-lm(DPETPCIP~DA0AT21R,data=data)

Plot & Raintest

options(repos = c(CRAN = "https://cloud.r-project.org/"))
install.packages("lmtest")
## 
## The downloaded binary packages are in
##  /var/folders/7h/rg3ggrys2lj017504msn5gx00000gn/T//RtmpFd6iax/downloaded_packages
install.packages("car")
## 
## The downloaded binary packages are in
##  /var/folders/7h/rg3ggrys2lj017504msn5gx00000gn/T//RtmpFd6iax/downloaded_packages
install.packages("psych")
## 
## The downloaded binary packages are in
##  /var/folders/7h/rg3ggrys2lj017504msn5gx00000gn/T//RtmpFd6iax/downloaded_packages
install.packages("zoo")
## 
## The downloaded binary packages are in
##  /var/folders/7h/rg3ggrys2lj017504msn5gx00000gn/T//RtmpFd6iax/downloaded_packages
library(lmtest)
## Loading required package: zoo
## 
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
## 
##     as.Date, as.Date.numeric
install.packages("lmtest", repos = "https://cloud.r-project.org/")
## 
## The downloaded binary packages are in
##  /var/folders/7h/rg3ggrys2lj017504msn5gx00000gn/T//RtmpFd6iax/downloaded_packages
raintest(data_model)
## 
##  Rainbow test
## 
## data:  data_model
## Rain = 0.13841, df1 = 602, df2 = 599, p-value = 1
plot(data_model, which=1)

Independence of Errors

dwtest((data_model))
## 
##  Durbin-Watson test
## 
## data:  (data_model)
## DW = 1.9751, p-value = 0.3328
## alternative hypothesis: true autocorrelation is greater than 0

Homoscedasticity (Plot & BPtest)

plot(data_model,which=3)

bptest(data_model)
## 
##  studentized Breusch-Pagan test
## 
## data:  data_model
## BP = 0.049537, df = 1, p-value = 0.8239

Normality of Residuals

plot(data_model,which=2)

shapiro.test(residuals(data_model))
## 
##  Shapiro-Wilk normality test
## 
## data:  residuals(data_model)
## W = 0.14468, p-value < 2.2e-16

No Multicolinarity

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

4)From the looks of my normality of residuals … all residuals are normally distributed linearly. 5) Homoscedasticity was violated with my p-value being .8239 6)To mitigate this violation you could apply a log to the response varible.

R Markdown

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.

When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

summary(cars)
##      speed           dist       
##  Min.   : 4.0   Min.   :  2.00  
##  1st Qu.:12.0   1st Qu.: 26.00  
##  Median :15.0   Median : 36.00  
##  Mean   :15.4   Mean   : 42.98  
##  3rd Qu.:19.0   3rd Qu.: 56.00  
##  Max.   :25.0   Max.   :120.00

Including Plots

You can also embed plots, for example:

Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.