为了再现,我对虹膜数据做了一些处理:
data(iris)
View(iris)
library("dplyr")
library("magrittr")
library("tidyverse")
iris <- filter(iris, Petal.Width<1)
iris <- mutate(iris,
Species2 = case_when(
Petal.Width == 0.1 ~ "setosa",
Petal.Width != 0.1 ~ "versicolor"))
我能够为lm()
做这样的事情:
iris %>% group_by(Species2) %>%
do(tidy(lm(Petal.Width ~ Sepal.Width*Sepal.Length, data = .)))
fit1 <- nlme::lmList((Petal.Width) ~ Sepal.Width*Sepal.Length
| Species2, data = iris)
do.call(stargazer, c(fit1, type = "text"))
我希望能够对glm()执行相同的操作:
iris %>% group_by(Species2) %>%
do(tidy(glm(Petal.Width ~ Sepal.Width*Sepal.Length, data = .,
family=quasibinomial)))
fit1 <- nlme::lmList((Petal.Width) ~ Sepal.Width*Sepal.Length |
Species2, data = iris)
# this needs to be a lmList for glm and glmlist() does not seem to work
do.call(stargazer, c(fit1, type = "text"))
当前,当我使用nlme :: lmList时,会显示lm结果。我希望glm结果在表中。
model = glm(Petal.Width ~ Sepal.Width*Sepal.Length, data = iris, family=quasibinomial,
subset = type == "setosa")
model1 = glm(Petal.Width ~ Sepal.Width*Sepal.Length, data = iris, family=quasibinomial,
subset = type == "veriscolor")
stargazer(model, model1)