Skip to content

Instantly share code, notes, and snippets.

@MilesMcBain
Last active February 21, 2017 02:54
Show Gist options
  • Save MilesMcBain/8265daa9f05ca6470cd88a09f74e3cb5 to your computer and use it in GitHub Desktop.
Save MilesMcBain/8265daa9f05ca6470cd88a09f74e3cb5 to your computer and use it in GitHub Desktop.
library(alr3)
library(purrr)
library(dplyr)
library(broom)
library(modelr)
challenger_data <- challeng
link <- c("logit", "probit", "cloglog")
formulas <- formulas(.response = ~ cbind(Fail, n-Fail),
~ Temp,
~ Temp + Pres)
model_grid <- as_data_frame(expand.grid(formulas, link, stringsAsFactors = FALSE))
names(model_grid) <- c("formula","link")
model_grid <-
model_grid %>%
mutate(family = map(link, binomial),
model = paste0(formula),
fit = pmap(.l = list( formula = formula, family = family),
.f = glm,
data = challenger_data),
results = map(fit, glance)) %>%
unnest(results)
View(model_grid)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment