AnnaSonder
AnnaSonder

Reputation: 31

R Stargazer report coefficients, confidence intervals and exact p-values

I am running a Country Fixed Effects model further including a dummy variable. I am using the Stargazer package, but can not seem to figure out how to report both the confidence intervals and the exact p-values. If I run my model:

stargazer(dummy_CPP, title = "xx",align = TRUE, 
          no.space = TRUE, ci = TRUE, 
          report = ('vc*p'), single.row = TRUE)

Only the p-values are in my output. Furthermore, as I have 30+ variables, the whole table can not fit into 1 page, as the p-values are reported underneath the coefficients, even though I use single.row = TRUE.

Upvotes: 3

Views: 4403

Answers (2)

JWilliman
JWilliman

Reputation: 3883

From the stargazer documentation;

report = a character string containing only elements of "v", "c", "s","t", "p", "*" that determines whether, and in which order, variable names ("v"), coefficients ("c"), standard errors/confidence intervals ("s"), test statistics ("t") and p-values ("p") should be reported in regression tables.

So to report CI and p values include both the letters "s" and "p". I don't know how to get it all on one line though (the command single.row only applies to standard errors/CI but not p values I think).

stargazer(dummy_CPP, title = "xx",align = TRUE, 
          no.space = TRUE, ci = TRUE, 
          report = ('vcsp'), single.row = TRUE)

Upvotes: 4

user3603486
user3603486

Reputation:

Not using stargazer but my huxtable package:

library(plm)
library(dplyr)
library(huxtable)
dfr <- tibble( id = rep(1:10, 10), x = rnorm(100), y = x + id/10 + rnorm(100), time = rep(1:10, each = 10))

dummy_CPP <- plm(y ~ x, dfr, index = c("id", "time"), effect = "twoways")

huxreg(dummy_CPP, error_pos = 'right', error_format = "({std.error}) [{conf.low} - {conf.high}]", ci_level = 0.95, statistics = "nobs")
──────────────────────────────────────────────────
                          (1)                     
         ─────────────────────────────────────────
  x          1.100 ***   (0.093) [0.917 - 1.282]  
         ─────────────────────────────────────────
  nobs     100                                    
──────────────────────────────────────────────────
  *** p < 0.001; ** p < 0.01; * p < 0.05.         

You can include p values with {p.value} inside the error_format string, and you can manipulate the table with standard R subsetting, or by changing the font_size, to make it fit on the page or split over multiple pages.

Upvotes: 1

Related Questions