data1<-(X2020Election[-1,])
Elections <- read_xlsx("Quantitative Methods/2024Elections.xlsx")
## New names:
## • `` -> `...4`
Elections2024<- (Elections[-1,])
#removes United States total row
Elections2024$INELIGIBLE_FELONS_TOTAL<- parse_number(Elections2024$INELIGIBLE_FELONS_TOTAL)
Elections2024$TOTAL_BALLOTS_COUNTED<- parse_number(Elections2024$TOTAL_BALLOTS_COUNTED)
Elections2024$VEP<- parse_number(Elections2024$VEP)
#Elections2024$INELIGIBLE_FELONS_TOTAL <- as.numeric(Elections2024$INELIGIBLE_FELONS_TOTAL)
#MutantElections2024<- Elections2024 %>% mutate(INELIGIBLE_FELONS_TOTAL) = as.numeric(INELIGIBLE_FELONS_TOTAL)
Election_model<-lm(TOTAL_BALLOTS_COUNTED~VEP + INELIGIBLE_FELONS_TOTAL, data=(Elections2024))
#Election_model<-lm(TOTAL_BALLOTS_COUNTED~VEP, data=(Elections2024))
#Election_model<-lm(TOTAL_BALLOTS_COUNTED~ INELIGIBLE_FELONS_TOTAL, data=(Elections2024))
summary(Election_model)
##
## Call:
## lm(formula = TOTAL_BALLOTS_COUNTED ~ VEP + INELIGIBLE_FELONS_TOTAL,
## data = (Elections2024))
##
## Residuals:
## Min 1Q Median 3Q Max
## -637060 -134507 -77761 84991 793619
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.225e+05 6.184e+04 1.981 0.05336 .
## VEP 6.467e-01 1.156e-02 55.963 < 2e-16 ***
## INELIGIBLE_FELONS_TOTAL -2.176e+00 7.393e-01 -2.943 0.00499 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 321800 on 48 degrees of freedom
## Multiple R-squared: 0.9902, Adjusted R-squared: 0.9898
## F-statistic: 2433 on 2 and 48 DF, p-value: < 2.2e-16
First, the above information shows that there is a significant R-squared value which means the dependent variable is explained confidently by the independent variables used in the model. At 98.98% the model accounts for the variance in Total Ballots Counted. The P-Value’s being near zero means that there is a strong evidence that the predictors used are statistically significant. Both variables are significant, but VEP (Voter eligible population) has a more defined linear relationship with the dependent variable, and understandably so. As VEP falls, so do the number of ballots counted. I wouldn’t call ineligible voters insignificant, but compared to the VEP variable, it is significantly less reliable.
In VEP, for every one individual that is eligible to vote, we can estimate that Total Ballots Counted will increase by 6.467e-01 or .6467. For Ineligible Felon Total, the estimate has a negative relationship with Total Ballots Counted with an estimate of -2.176e+00 or -2.176 to Total Ballots Counted for every one Ineligible Felon Total.
plot(Election_model,which=1)
This model violates the assumption of linearity as the red line shifts
significantly midway through.