在R观星机中显示小于0.1的P值

时间:2018-08-08 10:51:37

标签: r stargazer

我的回归系数为p值0.06。观星者的输出表不显示点(。)表示p值小于0.1。如何让寻星者在输出表中发出低于0.1的p值信号?

*很难找到或创建p值大于0.05而小于0.1的可复制示例。如果需要,我会尝试找到一些东西。希望这是一个垒球问题,可以提供快速解决方案。

1 个答案:

答案 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创建。