在 r stargazer 中显示低于 0.1 的 p 值

Display p-values under 0.1 in r stargazer

我的回归系数为 p 值 0.06。 stargazer 的输出 table 不显示低于 0.1 的点 (.) 信号 p 值。如何让 stargazer 在输出 table?

中发出低于 0.1 的 p 值信号

*很难找到或创建 p 值高于 0.05 且低于 0.1 的可重现示例。如果需要,我会尝试找到一些东西。但希望这是一个快速解决的垒球问题。

您可以使用 star.cutoffsstar.char 参数来做到这一点。下面的一些假数据来证明:

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

reprex package (v0.2.0) 创建于 2018-08-08。