Search code examples
rstargazer

Display p-values under 0.1 in r stargazer


I have regression coefficients at p-value 0.06. The output table of stargazer does not display the dot (.) signalling p-values under 0.1. How do I make stargazer to signal p-values below 0.1 in the output table?

*It would be hard to find or create a reproducible example with p-values above 0.05 and below 0.1. If needed, I'll try and find something. But hopefully this is a softball question with a quick solution.


Solution

  • You can do this with the star.cutoffs and star.char arguments. Some fake data below to demonstrate:

    library(stargazer)
    
    # Generate some fake data
    set.seed(10)
    x <- rnorm(10)
    x1 <- rnorm(10)
    e <- rnorm(10)
    y <- 10 + x + 2*x1 + e
    
    # Estimate a model
    m1 <- lm(y~x + x1)
    
    # We can see that we have three different levels of sig at typical cutoffs
    summary(m1)
    #> 
    #> Call:
    #> lm(formula = y ~ x + x1)
    #> 
    #> Residuals:
    #>      Min       1Q   Median       3Q      Max 
    #> -1.12552 -0.20126 -0.06919  0.60370  0.76845 
    #> 
    #> Coefficients:
    #>             Estimate Std. Error t value Pr(>|t|)    
    #> (Intercept)   9.1012     0.3731  24.394 4.95e-08 ***
    #> x             0.8389     0.3923   2.138   0.0698 .  
    #> x1            1.7477     0.4094   4.269   0.0037 ** 
    #> ---
    #> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
    #> 
    #> Residual standard error: 0.7851 on 7 degrees of freedom
    #> Multiple R-squared:  0.8167, Adjusted R-squared:  0.7643 
    #> F-statistic: 15.59 on 2 and 7 DF,  p-value: 0.002639
    
    # We will make the 10% level a plus sign, and stars for .05, .01 and .001
    stargazer(m1, type = "text",
              star.char = c("+", "*", "**", "***"),
              star.cutoffs = c(.1, .05, .01, .001))
    #> 
    #> ===============================================
    #>                         Dependent variable:    
    #>                     ---------------------------
    #>                                  y             
    #> -----------------------------------------------
    #> x                             0.839+           
    #>                               (0.392)          
    #>                                                
    #> x1                            1.748**          
    #>                               (0.409)          
    #>                                                
    #> Constant                     9.101***          
    #>                               (0.373)          
    #>                                                
    #> -----------------------------------------------
    #> Observations                    10             
    #> R2                             0.817           
    #> Adjusted R2                    0.764           
    #> Residual Std. Error       0.785 (df = 7)       
    #> F Statistic            15.589** (df = 2; 7)    
    #> ===============================================
    #> Note:               *p<0.1; **p<0.05; ***p<0.01
    

    Created on 2018-08-08 by the reprex package (v0.2.0).