I'm running into a problem with purrr::map and broom::tidy when running loglinear GLMs in R. For some reason, model p-values do not print when running many models but do print with a single model. In the end, I'd like the multiple models to print p values for each model as it does in the single model case. The provided example uses the built in "Titanic" data set (see William King's website).
data(Titanic)
#convert to data frame
T.df <- as.data.frame(Titanic)
head(T.df)
#run glm as loglinear model
model1 <- glm(Freq ~ Sex * Survived, family = poisson, data = T.df)
#print model with tidy--p-values print here
broom::tidy(anova(model1, test = "Chisq"))
#Now run multiple models by class
#Note the models print just fine but without p values
T.df %>%
tidyr::nest(-Class) %>%
dplyr::mutate(
fit = purrr::map(data, ~ anova(glm(Freq ~ Sex * Survived, family = poisson, data = .x)), test="Chisq"),
tidied = purrr::map(fit, broom::tidy)
) %>%
tidyr::unnest(tidied)
While I'm thinking about it, how does one stop broom::tidy from printing the warning messages about unrecognized columns?
Thanks in advance.