```

Appendix A: R Code for Statistical Analysis # Author: Pamela Williamson-Wyllie # Course: MPA Capstone Project # University of Texas at San Antonio # Date: [Insert Date] # Description: Regression models examining teacher experience, # SPED %, and district funding as predictors of STAAR and SAT outcomes and teacher certification # ———————————————————-

install.packages(c(“tidyverse”, “pastecs”, “psych”, “broom”, “stargazer”))
library(tidyverse) library(pastecs) library(psych) library(broom) library(stargazer) -

These libraries support data wrangling, stats, and output tables

setwd(“~/Desktop”)

df <- read.csv(“district.csv”) # Load TEA district dataset (district.csv

head(df)
names(df)
summary(df)

setwd(“~/Desktop”)

head(df)
names(df)
summary(df)
df <- read.csv(“district.csv”) head(df) names(df) grep(“ST”, names(df), value = TRUE) df %>% select(DPSATOFC, DPSATOSA) %>% head() library(tidyverse) df %>% select(DPSATOFC, DPSATOSA) %>% head()

df_small <- df %>% select(DPSTTOFP, DPSATOFC, DPSTEXPA, DPETSPEP, DPFUNAB1T)

head(df_small)

dim(df_small)

summary(df_small) stat.desc(df_small)

library(pastecs) stat.desc(df_small)

package ‘pastecs’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in C:_packages > > stat.desc(df_small) Error in stat.desc(df_small) : could not find function cor_matrix <- corr.test(df_small, use = “pairwise.complete.obs”, method = “pearson”) cor_matrix\(r cor_matrix\)p # ———————————————————- # Regression Models (Tables 5 and 6) # ———————————————————- # These models test how teacher experience, SPED enrollment, # and funding predict STAAR and SAT performance.

Model 1: Predicting STAAR performance (DPSTTOFP)

model_STAAR <- lm(DPSTTOFP ~ DPSTEXPA + DPETSPEP + DPFUNAB1T, data = df_small) summary(model_STAAR)

Notes:

- Coefficients show how much STAAR performance changes with each unit increase in the predictor.

- Look for the “Estimate” column to see the direction (+/-) and “Pr(>|t|)” for significance.

- Significant p-values (< 0.05) indicate meaningful predictors.

Model 2: Predicting SAT performance (DPSATOFC)

model_SAT <- lm(DPSATOFC ~ DPSTEXPA + DPETSPEP + DPFUNAB1T, data = df_small) summary(model_SAT)

Notes:

- Compare which predictors are significant in both models.

- Teacher experience may show a negative relationship.

- Funding is often positive and significant.

- SPED % may not be significant (depends on data variation).

library(stargazer) stargazer(model_STAAR, model_SAT, type = “text”, title = “Regression Results for STAAR and SAT Performance”, dep.var.labels = c(“STAAR Performance”, “SAT Performance”), covariate.labels = c(“Teacher Experience (Years)”, “SPED Enrollment (%)”, “District Funding ($)”), digits = 4, omit.stat = c(“f”, “ser”))

———————————————————-

Pretty things for my powerpoint presentation

———————————————————-

library(ggplot2)

1️⃣ Histogram: STAAR Performance

ggplot(df_small, aes(x = DPSTTOFP)) + geom_histogram(bins = 30, fill = “steelblue”, color = “white”) + labs(title = “Distribution of STAAR Performance Across Districts”, x = “STAAR Performance (DPSTTOFP)”, y = “Number of Districts”) + theme_minimal()

2️⃣ Histogram: SAT Performance

ggplot(df_small, aes(x = DPSATOFC)) + geom_histogram(bins = 30, fill = “darkorange”, color = “white”) + labs(title = “Distribution of SAT Performance Across Districts”, x = “SAT Performance (DPSATOFC)”, y = “Number of Districts”) + theme_minimal()

3️⃣ Histogram: Teacher Experience

ggplot(df_small, aes(x = DPSTEXPA)) + geom_histogram(bins = 20, fill = “seagreen”, color = “white”) + labs(title = “Distribution of Average Teacher Experience”, x = “Average Years of Experience (DPSTEXPA)”, y = “Number of Districts”) + theme_minimal()

4️⃣ Scatterplot: Funding vs. STAAR

ggplot(df_small, aes(x = DPFUNAB1T, y = DPSTTOFP)) + geom_point(alpha = 0.6, color = “steelblue”) + geom_smooth(method = “lm”, color = “red”, se = FALSE) + labs(title = “Relationship Between District Funding and STAAR Performance”, x = “Total District Funding ($)”, y = “STAAR Performance”) + theme_minimal()

5️⃣ Scatterplot: Funding vs. SAT

ggplot(df_small, aes(x = DPFUNAB1T, y = DPSATOFC)) + geom_point(alpha = 0.6, color = “darkorange”) + geom_smooth(method = “lm”, color = “red”, se = FALSE) + labs(title = “Relationship Between District Funding and SAT Performance”, x = “Total District Funding ($)”, y = “SAT Performance”) + theme_minimal()

6️⃣ Regression Coefficient Plot (optional, for advanced slides)

library(broom) library(dplyr)

Combine coefficients from both models

coef_data <- bind_rows( tidy(model_STAAR) %>% mutate(Model = “STAAR”), tidy(model_SAT) %>% mutate(Model = “SAT”) )

Remove intercepts

coef_data <- coef_data %>% filter(term != “(Intercept)”)

ggplot(coef_data, aes(x = term, y = estimate, fill = Model)) + geom_col(position = “dodge”) + labs(title = “Regression Coefficients for STAAR and SAT Models”, x = “Predictor Variable”, y = “Coefficient Estimate”) + theme_minimal()

grep(“CERT|COFP|PASPEP|REFP|BIFP”, names(df), value = TRUE)

df_cert <- df %>% select(DPSTTOFP, DPSATOFC, DPSTEXPA, DPETSPEP, DPFUNAB1T, DPFPASPEP) summary(df_cert)

library(pastecs) stat.desc(df_cert$DPFPASPEP)

library(ggplot2) ggplot(df_cert, aes(x = DPFPASPEP)) + geom_histogram(bins = 20, fill = “steelblue”, color = “white”) + labs(title = “Distribution of SPED/Dual Certification Rates”, x = “% of SPED/Dual-Certified Teachers”, y = “Number of Districts”) + theme_minimal()

library(psych) cor_matrix_cert <- corr.test(df_cert, use = “pairwise.complete.obs”, method = “pearson”) cor_matrix_cert\(r cor_matrix_cert\)p model_STAAR_cert <- lm(DPSTTOFP ~ DPSTEXPA + DPETSPEP + DPFUNAB1T + DPFPASPEP, data = df_cert) summary(model_STAAR_cert)

library(stargazer) stargazer(model_STAAR_cert, model_SAT_cert, type = “text”, title = “Regression Results Including Teacher Preparation and Certification”, dep.var.labels = c(“STAAR Performance”, “SAT Performance”), covariate.labels = c(“Teacher Experience (Years)”, “SPED Enrollment (%)”, “District Funding ($)”, “SPED/Dual Certification (%)”), digits = 4, omit.stat = c(“f”, “ser”))

Model 1: STAAR Performance

model_STAAR_cert <- lm(DPSTTOFP ~ DPSTEXPA + DPETSPEP + DPFUNAB1T + DPFPASPEP, data = df_cert)

Model 2: SAT Performance

model_SAT_cert <- lm(DPSATOFC ~ DPSTEXPA + DPETSPEP + DPFUNAB1T + DPFPASPEP, data = df_cert)

Model 1: STAAR Performance

model_STAAR_cert <- lm(DPSTTOFP ~ DPSTEXPA + DPETSPEP + DPFUNAB1T + DPFPASPEP, data = df_cert)

Model 2: SAT Performance

model_SAT_cert <- lm(DPSATOFC ~ DPSTEXPA + DPETSPEP + DPFUNAB1T + DPFPASPEP, data = df_cert) library(stargazer)

stargazer(model_STAAR_cert, model_SAT_cert, type = “text”, title = “Regression Results Including Teacher Preparation and Certification”, dep.var.labels = c(“STAAR Performance”, “SAT Performance”), covariate.labels = c(“Teacher Experience (Years)”, “SPED Enrollment (%)”, “District Funding ($)”, “SPED/Dual Certification (%)”), digits = 4, omit.stat = c(“f”, “ser”)) library(ggplot2) library(broom) library(dplyr)

Combine model outputs

coef_data <- bind_rows( tidy(model_STAAR_cert) %>% mutate(Model = “STAAR”), tidy(model_SAT_cert) %>% mutate(Model = “SAT”) )

Remove intercept

coef_data <- coef_data %>% filter(term != “(Intercept)”)

Plot

ggplot(coef_data, aes(x = term, y = estimate, fill = Model)) + geom_col(position = “dodge”) + geom_hline(yintercept = 0, linetype = “dashed”) + labs(title = “Regression Coefficients for STAAR and SAT Models (Including Teacher Certification)”, x = “Predictor Variable”, y = “Coefficient Estimate”) + theme_minimal() + coord_flip() # “This chart shows how each variable affects STAAR and SAT performance once we account for teacher certification. We can see that certification has a negative effect on STAAR but a positive and highly significant effect on SAT performance, while district funding remains the strongest overall predictor of SAT success.”