install.packages(c(“openintro”, “tidyverse”, “broom”))
library(openintro) library(tidyverse) library(broom) data(resume)
names(resume) resume <- resume %>% rename(sex = gender)
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)) )
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))
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)) )