library(car)
## Loading required package: carData
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.2.1     ✔ readr     2.2.0
## ✔ forcats   1.0.1     ✔ stringr   1.6.0
## ✔ ggplot2   4.0.3     ✔ tibble    3.3.1
## ✔ lubridate 1.9.5     ✔ tidyr     1.3.2
## ✔ purrr     1.2.2
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ✖ dplyr::recode() masks car::recode()
## ✖ purrr::some()   masks car::some()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(readxl)
library(ggplot2)
library(lmtest)
## Loading required package: zoo
## 
## Attaching package: 'zoo'
## 
## The following objects are masked from 'package:base':
## 
##     as.Date, as.Date.numeric
district<-read_excel("district.xls")

District is the full data set I used for this study.

district_report<-district|>select(DDA00A001222R,DPSTKIDR,DPETECOP)

District_report represents the clean dataset that focuses on my 3 variables used in my paper.

summary(district_report)
##  DDA00A001222R      DPSTKIDR        DPETECOP     
##  Min.   : 0.00   Min.   :-2.00   Min.   :  0.00  
##  1st Qu.:37.00   1st Qu.:10.80   1st Qu.: 47.95  
##  Median :46.00   Median :12.70   Median : 61.90  
##  Mean   :46.48   Mean   :12.56   Mean   : 60.75  
##  3rd Qu.:55.00   3rd Qu.:14.40   3rd Qu.: 77.15  
##  Max.   :88.00   Max.   :37.30   Max.   :100.00  
##  NAs    :5       NAs    :3

Based on the summary data, I will now clean my data of NAs.

district_report_clean<-district_report|>drop_na(DDA00A001222R, DPSTKIDR,DPETECOP)
hist(district_report_clean$DDA00A001222R)

district_report_variables<-lm(DDA00A001222R~DPSTKIDR+DPETECOP,data = district_report_clean)
summary(district_report_variables)
## 
## Call:
## lm(formula = DDA00A001222R ~ DPSTKIDR + DPETECOP, data = district_report_clean)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -64.006  -5.958   0.038   5.832  43.978 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 74.86627    1.42128  52.675   <2e-16 ***
## DPSTKIDR    -0.16791    0.09267  -1.812   0.0702 .  
## DPETECOP    -0.43374    0.01287 -33.695   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 9.595 on 1196 degrees of freedom
## Multiple R-squared:  0.4881, Adjusted R-squared:  0.4872 
## F-statistic: 570.2 on 2 and 1196 DF,  p-value: < 2.2e-16

Adjusted R-squared is .4872 which means the model accounts for 48% of the variance in student achievement.

plot(district_report_variables,which=1)

Visual review shows that this data is linear.

durbinWatsonTest(district_report_variables)
##  lag Autocorrelation D-W Statistic p-value
##    1      0.08268059      1.834169   0.008
##  Alternative hypothesis: rho != 0

The model likely contains some correlation of residuals. One can assume that errors are normally distrbuted, homoscedastic, no autocorrelation among errors.

plot(district_report_variables,which=3)

The model is fairly homoscedastic.

shapiro.test(district_report_variables$residuals)
## 
##  Shapiro-Wilk normality test
## 
## data:  district_report_variables$residuals
## W = 0.98405, p-value = 3.402e-10
plot(district_report_variables,which=2)