Используя ваши данные:
d <- readr::read_rds( "database_match_results_1920.rds")
d <-
bind_rows(
tibble(
goals = database_mr$goals_team_home,
team = database_mr$club_name_home,
opponent=database_mr$club_name_away,
home=1),
tibble(
goals=database_mr$goals_team_away,
team=database_mr$club_name_away,
opponent=database_mr$club_name_home,
home=0))
# create a fake model
# note that team needs to include all of your factors
fake <- lm(goals ~ home + team , d)
# rename the coefficients
names(fake$coefficients) <- gsub("team","",names(fake$coefficients))
#
m <- glm(goals ~ home + team +opponent, family=poisson(link=log),data=d)
m.s <- summary(m)
## write a function that fixes the names in the glm output
f <- function(x){
names(x) <- gsub("team|opponent","", names(x))
return(x)
}
stargazer(fake,fake,
# coefficients
coef = list(
f( m.s$coefficients[grepl("Intercept|home|team", rownames(m.s$coefficients)), 1]),
f( m.s$coefficients[grepl("opponent", rownames(m.s$coefficients)), 1])
),
# standard errors
se = list(
f( m.s$coefficients[grepl("Intercept|home|team", rownames(m.s$coefficients)), 2]),
f( m.s$coefficients[grepl("opponent", rownames(m.s$coefficients)), 2])
),
column.labels = c("team", "opponent"),
# calculate pvalue using supplied coeff and se
t.auto = T,
out = "stargazer_data.html",
omit.stat=c("all"),
type = "html")
С 3 столбцами:
stargazer(fake,fake,fake,
# coefficients
coef = list(
f( m.s$coefficients[grepl("Intercept|home", rownames(m.s$coefficients)), 1]),
f( m.s$coefficients[grepl("team", rownames(m.s$coefficients)), 1]),
f( m.s$coefficients[grepl("opponent", rownames(m.s$coefficients)), 1])
),
# standard errors
se = list(
f( m.s$coefficients[grepl("Intercept|home", rownames(m.s$coefficients)), 2]),
f( m.s$coefficients[grepl("team", rownames(m.s$coefficients)), 2]),
f( m.s$coefficients[grepl("opponent", rownames(m.s$coefficients)), 2])
),
column.labels = c("control","team", "opponent"),
# calculate pvalue using supplied coeff and se
t.auto = T,
out = "stargazer_data.html",
omit.stat=c("all"),
type = "html")