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()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(ggplot2)
library(readxl)
cities <- read_xlsx("City_data.xlsx")
ed_model <- lm(tax_income_indiv_city~education_city+public_welfare_city+public_safety_city+housing_commdevt_city, data=cities)
summary(ed_model)
## 
## Call:
## lm(formula = tax_income_indiv_city ~ education_city + public_welfare_city + 
##     public_safety_city + housing_commdevt_city, data = cities)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -1435.76  -114.05   -72.07    -5.45  1475.86 
## 
## Coefficients:
##                         Estimate Std. Error t value Pr(>|t|)    
## (Intercept)           -21.706351   6.245923  -3.475 0.000512 ***
## education_city         -0.044370   0.002736 -16.218  < 2e-16 ***
## public_welfare_city     0.473886   0.008443  56.131  < 2e-16 ***
## public_safety_city      0.206354   0.010434  19.777  < 2e-16 ***
## housing_commdevt_city   0.079101   0.017362   4.556 5.27e-06 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 251 on 10241 degrees of freedom
## Multiple R-squared:  0.3823, Adjusted R-squared:  0.382 
## F-statistic:  1584 on 4 and 10241 DF,  p-value: < 2.2e-16

All the variables that were chose appear to be extremely significant to individual income tax revenue. R^2 is 38.2%, meaning these variables explain 38.2% of the results from individual income tax revenues. Any increase in the different programs chosen seem to result in an increase in income tax revenue, with the largest increase being public welfare, which seems an increase in tax revenue of .47 for every unit increase. The exception is education, as a unit increase in education funding results in a .04 unit decrease in income tax revenue

plot(ed_model,which=1)

The results from the graph show the residuals vs fitted has a highly curved line, which suggests the assumption of linearity has been violated. As such, the validity of the R^2 values are thrown into question