Home > Software design >  How to show t stat and p value with coefficient with stargazer
How to show t stat and p value with coefficient with stargazer

Time:11-13

I would like to display the t value and p value from my regression output using the stargazer package. So far, I've found ways to show one or the other. I did find table output

shows beta coefficient names, but no pvalues. I would like to keep all three: coefficient names, t stat, and p-value

output not including p-value

edit

removed a function used on the website that I did not use

CodePudding user response:

You could mention it by using t in the report argument:

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. If one of the aforementioned letters is followed by an asterisk (""), significance stars will be reported next to the corresponding statistic.

Here is a reproducible example:

library(stargazer)
data("cars")
model <- lm(hp ~ wt, mtcars)
stargazer(model, type='text', report = "vcstp")
#> 
#> ===============================================
#>                         Dependent variable:    
#>                     ---------------------------
#>                                 hp             
#> -----------------------------------------------
#> wt                            46.160           
#>                               (9.625)          
#>                              t = 4.796         
#>                             p = 0.00005        
#>                                                
#> Constant                      -1.821           
#>                              (32.325)          
#>                             t = -0.056         
#>                              p = 0.956         
#>                                                
#> -----------------------------------------------
#> Observations                    32             
#> R2                             0.434           
#> Adjusted R2                    0.415           
#> Residual Std. Error      52.437 (df = 30)      
#> F Statistic           22.999*** (df = 1; 30)   
#> ===============================================
#> Note:               *p<0.1; **p<0.05; ***p<0.01

Created on 2022-11-12 with reprex v2.0.2

  • Related