Reputation: 8009
I want to format my stargazer table like what is below. This is my code
stargazer(reg_1a, reg_2a, reg_3a, reg_4a, reg_5a, reg_6a, type="text",
dep.var.labels = c("Ed76", "Ed76", "Wages", "Wages", "Wages", "Wages"),
model.names = FALSE,
title = "Table 3",
keep = c("nearc4", "ed76"),
omit.stat = c("rsq", "adj.rsq", "ser", "f"),
single.row = FALSE,
column.separate = c(1,1,1,1,1,1),
multicolumn = TRUE,
column.labels = c("OLS","OLS","OLS", "OLS", "iv", "iv"))
these are the results I am getting
Table 3
=================================================================
Dependent variable:
----------------------------------------------------
Educ Educ
OLS OLS OLS OLS iv iv
(1) (2) (3) (4) (5) (6)
-----------------------------------------------------------------
nearc4 0.290*** 0.273*** 0.043** 0.048***
(0.081) (0.077) (0.018) (0.018)
ed76 0.027*** 0.035***
(0.004) (0.004)
-----------------------------------------------------------------
Observations 3,613 3,613 3,010 3,010 3,010 3,010
=================================================================
Note: *p<0.1; **p<0.05; ***p<0.01
but this is what I want
Table 3
=================================================================
----------------------------------------------------
ed76 ed76 wages wages wages wages
OLS OLS OLS OLS iv iv
(1) (2) (3) (4) (5) (6)
-----------------------------------------------------------------
nearc4 0.290*** 0.273*** 0.043** 0.048***
(0.081) (0.077) (0.018) (0.018)
ed76 0.027*** 0.035***
(0.004) (0.004)
-----------------------------------------------------------------
Observations 3,613 3,613 3,010 3,010 3,010 3,010
=================================================================
Note: *p<0.1; **p<0.05; ***p<0.01
I'm not sure how to assign the dep. variable lines to each column.
Upvotes: 2
Views: 3268
Reputation: 287
The dep.var.labels
argument is only looking for two values, since you only have two different dependent variables. As an example, the following code uses the mtcars
dataset. This code doesn't work correctly:
library(stargazer)
data(mtcars)
lm1 <- lm(data=mtcars, mpg ~ cyl)
lm2 <- lm(data=mtcars, mpg ~ disp)
lm3 <- lm(data=mtcars, hp ~ cyl)
lm4 <- lm(data=mtcars, hp ~ disp)
stargazer(lm1, lm2, lm3, lm4,
type = "text",
dep.var.labels = c("mpg", "mpg", "hp", "hp"),
column.labels=c("1", "2", "3", "4"),
column.separate = c(1,1,1,1))
Whereas this code generates the correct labels:
stargazer(lm1, lm2, lm3, lm4,
type = "text",
dep.var.labels = c("mpg", "hp"),
column.labels=c("1", "2", "3", "4"),
column.separate = c(1,1,1,1))
Upvotes: 2