Project 2: Student Academic Performance and Family Income
Author
Nathan Pak
Source: The New York Times
Introduction
Throughout the United States, there are different amounts of education funding, educational program availability, and different family income, which can greatly impact a child’s learning and performance. Student’s GPA and SAT scores are consistently used nationwide for admissions to college and universities, although such circumstances mentioned earlier can show a correlation between these factors and results. As a student myself, I have noticed significant differences in student backgrounds severely steering the course of their academic life, especially involving socioeconomic factors. And thus, this presentation will review over how socioeconomic backgrounds over the past 2 decades correlate to student’s academic success via GPA and SAT scores.
The dataset that will be used in this project is data from National Center for Education Statistics organized by the CORGIS Dataset Project. This dataset has over 500 rows of entries of academic data averaged per state per year starting from 2005, with almost 100 columns of variables. For this project, the variables used from this dataset will be 2 categorical and 4 quantitative, the categorical being the family income range (“<$20k”, “$20-40k”, etc) and category of year (2 groups of years: “2005-2009” and “2010-2015”), while the quantitative will be the average GPA, the average SAT math score, the average math SAT score of a specific family income group, and the average number of years a test taker has studied math.
Load Libraries and Dataset
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(GGally)library(highcharter)
Registered S3 method overwritten by 'quantmod':
method from
as.zoo.data.frame zoo
Highcharts (www.highcharts.com) is a Highsoft software product which is
not free for commercial and Governmental use
Rows: 577 Columns: 99
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (2): State.Code, State.Name
dbl (97): Year, Total.Math, Total.Test-takers, Total.Verbal, Academic Subjec...
ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Tidyverse is used for plotting and functions, GGally for the ggpairs plot for correlational analysis, highcharter for an interactable plot, and ggfortify for linear regression diagnostics.
In order to implement the variables in, I added a column that will instead use year as a categorical variable within the respective ranges for comparison of the data over time. Then select and rename all the necessary columns in order to be more convenient and organized to use in creating the visualizations. And finally, filtering out any possible 0 or NA values due to not enough samples included under some columns.
In order to make a boxplot based on income group, the data needs to be reshaped using pivot_longer()
hc_box_data <-data_to_boxplot(data = school_scores_long,variable = math_score,group_var = income_group,group_var2 = year_group,add_outliers =TRUE)highchart() |>hc_xAxis(type ="category",title =list(text ="Annual Family Income") ) |>hc_yAxis(title =list(text ="SAT Math Score"),min =200,max =800 ) |>hc_add_series_list(hc_box_data) |>hc_colors(c("#0080FE", "#238b45")) |>hc_title(text ="Distribution of SAT Math Scores by Income Bracket") |>hc_caption(text ="Source: National Center for Education Statistics" ) |>hc_plotOptions(boxplot =list(fillColor ="#F0F0E0",lineWidth =2 ) )
This boxplot gives general context of how family income is correlating with SAT Math score, with a positive relationship trend suggesting that family income has a positive relationship with academic performance.
Visualization 2
ggplot(school_scores_clean, aes(x = avg_gpa, y = avg_sat_math)) +geom_point(aes(color = avg_experience), alpha =0.7, size =3) +geom_smooth(method ="lm", color ="#08519c", se =TRUE) +scale_color_viridis_c(option ="plasma", name ="Avg Years of\nStudy") +labs(title ="GPA vs. SAT Math Score\n(Colored by Academic Experience)",x ="Average Math GPA",y ="Average SAT Math Score",caption ="Source: National Center for Education Statistics" ) +theme_minimal(base_size =13)
`geom_smooth()` using formula = 'y ~ x'
This scatter plot now addresses the other variables of GPA and academic experience, showing a visually clear positive trend between SAT and GPA, as well as a positive trend of those two variables and academic experience. And thus can be traced back to the previous income group boxplot to suggest correlations for the GPA and academic experience variables along the income groups
This multiple linear regression model represents the correlation between the SAT math scores with the other quantitative variables for GPA, experience, and income group. This yields the following coefficients into the linear equation:
SAT math score = 40.077 + 135.374 (avg GPA) - 4.678 (years studied) + 31.554 ($20-40k income group) + 52.954 ($40-60k income group) + 64.071 ($60-80k income group) + 77.233 ($80-100k income group) + 97.510 ($100k+ income group)
With GPA being limited below 5.0, its clear to see why the coefficient for that variable is so high, as it shows the amount of SAT math points gained for every 1.0 increase in GPA. As for the income groups, the coefficients clearly have a positive relationship with higher income, showing how much each group increases over the <$20k income group which aligns with the first boxplot.
As seen with the coefficient p-values, all of them are very close to 0 except for the years studied variable, which is possibly due to outliers as seen in the colored scatter plot. Thus, every other variable has a statistically significant effect on SAT math scores. The R-squared value is 0.6344, which is fairly high as it means that around 63% of the SAT math score variation is explained by this model.
autoplot(sat_model)
Warning: `fortify(<lm>)` was deprecated in ggplot2 4.0.0.
ℹ Please use `broom::augment(<lm>)` instead.
ℹ The deprecated feature was likely used in the ggfortify package.
Please report the issue at <https://github.com/sinhrks/ggfortify/issues>.
Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
ℹ Please use `linewidth` instead.
ℹ The deprecated feature was likely used in the ggfortify package.
Please report the issue at <https://github.com/sinhrks/ggfortify/issues>.
To double check the validity of the multiple linear regression model, we have diagnostic plots to outline how much outliers affect the residuals. Overall, the massive amount of data points do generally follow the requirements, as the residuals vs fitted plot has a horizontal trendline at 0, the normal Q-Q plot is generally linear minus the low quantile tail, the scale location trendline is generally horizontal, and the residuals vs leverage plot trendline being somewhat horizontal with some outliers on the high end making the trendline curve down slightly.
school_scores_long |>select(math_score, avg_gpa, avg_experience, income_group) |>ggpairs(columns =1:3, # Plots math_score, avg_gpa, and avg_experiencemapping =aes(color = income_group, alpha =0.5),columnLabels =c("SAT Math", "Avg GPA", "Experience (Yrs)"),upper =list(continuous =wrap("cor", size =2.8)),lower =list(continuous =wrap("points", alpha =0.2, size =0.8)) ) +theme_minimal(base_size =11) +labs(title ="Relationships Between SAT Math, GPA & Experience by Income Group")
Here I implemented a ggpairs plot for SAT math scores, GPA, and study experience. I also implemented income group through color gradient, allowing more insight with that variable as well. The SAT math plot shows how right skewed the data becomes with higher income, and thus supports the earlier statements about how higher income correlates with higher SAT scores. The scatter plots on the bottom left and the correlation values on the upper right both also support this statement, also confirming these relationships are statistically significant.
Conclusion
With all the analysis data, there is statistically significant evidence to suggest how family income correlates with academic performance via GPA and SAT math scores. With this, further research can be made as to how further increase in equity educational programs or funding can increase average student performance for the lower income groups, and how it can allow students with lower socioeconomic background to catch up with the rest of the income groups.