I am running a series of regressions on subgroups (all combinations of year and group) using this fantastic method I found here.
year <- rep(2014:2015, length.out = 10000)
group <- sample(c(0,1,2,3,4,5,6), replace=TRUE, size=10000)
value <- sample(10000, replace = T)
female <- sample(c(0,1), replace=TRUE, size=10000)
smoker <- sample(c(0,1), replace=TRUE, size=10000)
dta <- data.frame(year = year, group = group, value = value, female=female, smoker = smoker)
library(dplyr)
library(broom)
library(stargazer)
table <- dta %>%
group_by(year, group) %>%
do(tidy(lm(smoker ~ female, data = .))) %>%
ungroup()
This gives me a table of all possible combinations of year and group as separate model estimates. My problem is that I would like to present these regression output as separate models using stargazer. But stargazer doesn't recognize them as regression output.
stargazer(table, type = "text")
Instead of the usual regression output I get this:
==================================================
Statistic N Mean St. Dev. Min Pctl(25) Pctl(75) Max
===================================================
Is there a nifty way to feed Stargazer all the regression output in a way that it would recognize it?