Question

When passing a character vector to the dep.var.labels argument to stargazer, I expected the dependent variable labels to consist of this vector. But this only seems to happen when the models are of different types.

data(mtcars)
m0 <- lm(mpg ~ hp, data=mtcars)
m1 <- lm(mpg ~ wt, data=mtcars)
m2 <- glm(cyl ~ disp, data=mtcars)

## Only shows the label 'foo' for both models.
stargazer(m0, m1, dep.var.labels=c('foo','bar'))

## shows 'foo' and 'bar' as labels.
stargazer(m0, m2, dep.var.labels=c('foo','bar'))

How can I get stargazer to show different dependent variable labels even when the models are of the same type?

Was it helpful?

Solution

stargazer uses the same dependent variable because your dependent variables are the same, not because you are using the same kind of statistical model. You may be interested in using the column.labels argument:

data(mtcars)
m0 <- lm(mpg ~ hp, data=mtcars)
m1 <- lm(mpg ~ wt, data=mtcars)
m2 <- glm(cyl ~ disp, data=mtcars)

## Only shows the label 'foo' for both models.
stargazer(m0, m1, column.labels=c('foo','bar'), type="text")

## shows 'foo' and 'bar' as labels.
stargazer(m0, m2, column.labels=c('foo','bar'), type="text")
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top