观星表中的附属变量标签

时间:2014-02-27 00:19:58

标签: r stargazer

将字符向量传递给dep.var.labels参数到stargazer时,我希望因变量标签由此向量组成。但是,当模型属于不同类型时,这似乎才会发生。

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'))

即使模型属于同一类型,我怎样才能让观星者显示不同的因变量标签呢?

1 个答案:

答案 0 :(得分:3)

stargazer使用相同的因变量,因为您的因变量是相同的,而不是因为您使用相同类型的统计模型。您可能对使用column.labels参数感兴趣:

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")