I would like to include the dependent variable labels in stargazer with multiple models. This is straightforward when the DVs are different for each model, but I have the same. Yet, I would like to manually indicate the DV label as there are differences in the models and I can indicate this by making use of the dep.var.labels
. I use also the column.labels
after that, so it cannot substitute the role of the DV labels. I combine the columns 2 by 2 with column.separate = c(2, 2)
.
How can I include in this case both the labels of the DVs and the labels of the columns?
There is a question from quite some time ago that I think touched upon this issue: Dependent variable labels in stargazer tables
and also another going in the same direction but with different DVs: How to make a dependent variable label for each column Stargazer
Here is my test code:
library(stargazer)
# example models
model1 <- lm(mpg ~ cyl + hp, data = mtcars)
model2 <- lm(mpg ~ cyl + hp + hp^2, data = mtcars)
model3 <- lm(mpg ~ cyl + wt, data = mtcars)
model4 <- lm(mpg ~ cyl + wt + wt^2, data = mtcars)
# use stargazer to indicate dep.var. labels + col.names
stargazer(list(model1, model2,model3, model4),
type="latex",
title = "Test on dep.var. labels",dep.var.labels.include = T,
column.labels = c("no sq.", "sq"),
column.separate = c(2, 2),
dep.var.labels = c("hp", "wt"),
column.sep.width = "0.25pt", table.layout = "=d-c-#-t-sa=n",
add.lines = list(c("Additional stats to be reported", NA, NA, NA, NA)))
# I also included multicolumn = T but it gives me the same output.
2