Created
September 24, 2025 09:51
-
-
Save carlislerainey/12b3d0e97b918099573ae2c42cc312eb to your computer and use it in GitHub Desktop.
Illustrating IC with the turnout dataset
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # load packages | |
| library(tidyverse) | |
| library(tinytable) | |
| # data | |
| devtools::install_github("jrnold/ZeligData") | |
| turnout <- ZeligData::turnout | |
| # fit model | |
| f <- vote ~ age + educate + income + race | |
| fit <- glm(f, family = binomial, data = turnout) | |
| # fit model | |
| f <- vote ~ poly(age, 3) + educate + income + race | |
| fit3 <- glm(f, family = binomial, data = turnout) | |
| # create table | |
| BIC(fit, fit3) |> | |
| mutate(diff_min = BIC - min(BIC), | |
| post_prob = exp(-0.5*diff_min)/sum(exp(-0.5*diff_min))) |> | |
| tt(rownames = TRUE, digits = 3) | |
| # create table | |
| AIC(fit, fit3) |> | |
| mutate(diff_min = AIC - min(AIC), | |
| akaike_weights = exp(-0.5*diff_min)/sum(exp(-0.5*diff_min))) |> | |
| tt(rownames = TRUE, digits = 3) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment