install.packages(c(“openintro”, “tidyverse”, “broom”))

library(openintro) library(tidyverse) library(broom) data(resume)

Step 2: Prepare the Data —–

names(resume) resume <- resume %>% rename(sex = gender)

Step 3: Full Logistic Regression Model —–

full_model <- glm(received_callback ~ job_city + college_degree + years_experience + honors + military + has_email_address + race + sex, data = resume, family = “binomial”) full_model %>% tidy() %>% select(term, estimate, std.error, statistic, p.value) %>% mutate( across(c(estimate, std.error, statistic), ~ sprintf(“%.2f”, .x)), p.value = ifelse(p.value < 0.0001, “<0.0001”, sprintf(“%.4f”, p.value)) )

Step 4: Evaluate Model Strength (AIC) —–

data.frame(AIC = round(AIC(full_model), 0), n_obs = nobs(full_model)) reduced_model <- glm(received_callback ~ job_city + years_experience + honors + military + has_email_address + race + sex, data = resume, family = “binomial”)

data.frame(AIC = round(AIC(reduced_model), 0), n_obs = nobs(reduced_model))

Step 5: Final Reduced Model —–

reduced_model %>% tidy() %>% select(term, estimate, std.error, statistic, p.value) %>% mutate( across(c(estimate, std.error, statistic), ~ sprintf(“%.2f”, .x)), p.value = ifelse(p.value < 0.0001, “<0.0001”, sprintf(“%.4f”, p.value)) )