简体   繁体   English

如何覆盖 p 值并删除 stargazer package 中的标准错误?

[英]How to override p-values and remove standard errors in stargazer package?

I am trying to override the p-values that are displayed by stargazer package and its significance levels.我试图覆盖 stargazer package 显示的 p 值及其显着性水平。

Using this simple model (taken from the "SjPlot" package, referenced below):使用这个简单的 model(取自“SjPlot”package,参考如下):

data(efc)
library(sjPlot)

# fit a model
fit1 <- lm(barthtot ~ c160age + c12hour + c161sex + c172code, data = efc)

# plot model
plot_models(fit1, std.est = "std", show.p  = TRUE, p.shape =TRUE, grid = TRUE)

This creates:这会创建:

在此处输入图像描述

Now I want to report the results associated with this plot in stargazer using a table.现在我想使用表格在 stargazer 中报告与此 plot 相关的结果。 To do this, I will obtain the standardized coefficients (using lm.beta referenced below):为此,我将获得标准化系数(使用下面引用的 lm.beta):

library(lm.beta)
fit1_std = lm.beta(fit1)

Now I am making the table, and I am specifying I want to use the standardized coefficients:现在我正在制作表格,并指定我想使用标准化系数:

stargazer(fit_1_std, 
          coef = list(fit_1_std$standardized.coefficients),
          type='text')

Which has the output:其中有 output:

===============================================
                        Dependent variable:    
                    ---------------------------
                             barthtot          
-----------------------------------------------
c160age                       -0.100           
                              (0.071)          
                                               
c12hour                      -0.477***         
                              (0.019)          
                                               
c161sex                       -0.004           
                              (2.086)          
                                               
c172code                      -0.016           
                              (1.420)          
                                               
Constant                       0.000           
                              (6.172)          
                                               
-----------------------------------------------
Observations                    821            
R2                             0.270           
Adjusted R2                    0.266           
Residual Std. Error      25.353 (df = 816)     
F Statistic           75.284*** (df = 4; 816)  
===============================================
Note:               *p<0.1; **p<0.05; ***p<0.01

Here, the coefficients look right.在这里,系数看起来是正确的。 They are the same standardized coefficients as in the plot. However, looking at the p-values: they are definitely different.它们与 plot 中的标准化系数相同。但是,查看 p 值:它们肯定不同。

Looking at "career's age", which was significant in the forest plot, it suddenly is not significant anymore in the table provided by the stargazer.查看“career's age”,在森林 plot 中是显着的,在观星者提供的表格中它突然不再显着了。 Further, the standard errors are the ones from the original model (not corresponding to the standardized coefficients anymore).此外,标准误差是原始 model 中的标准误差(不再对应于标准化系数)。

How could I remove the standard errors and use the correct p-values?我怎样才能删除标准错误并使用正确的 p 值? In other words, how can I make my stargazer table reflect exactly what is shown in the "plot_model" figure?换句话说,我怎样才能使我的观星表准确反映“plot_model”图中显示的内容?

I tried something like this, in which I would manually add the p-values and try to remove the standard errors:我试过这样的事情,我会手动添加 p 值并尝试删除标准错误:

stargazer(fit_1_std, 
          coef = list(fit_1_std$standardized.coefficients),
          p = list(c(0.0019),c(<2e-16),c(0.9002),c(0.5915)), se = FALSE, 
          type='text')

But it did not work.但它没有用。

Citation lm.beta: https://cran.r-project.org/web/packages/lm.beta/lm.beta.pdf Citation sjPlot: https://cran.r-project.org/web/packages/sjPlot/index.html引用 lm.beta: https://cran.r-project.org/web/packages/lm.beta/lm.beta.pdf引用 sjPlot: https://cran.r-project.org/web/packages/sjPlot /index.html

I think there is a misunderstanding of what stargazer show underneath estimates by default, ie the standard errors.我认为stargazer默认情况下在估计值下显示的内容存在误解,即标准误差。 You can turn them into p-values with the report option.您可以使用report选项将它们转换为 p 值。 No need to substitute something manual.无需替代手动的东西。

data(efc)
library(sjPlot)

# fit a model
fit1 <- lm(barthtot ~ c160age + c12hour + c161sex + c172code, data = efc)

summary(fit1)

stargazer(fit1, type="text", report = "vs*p")

===============================================
                        Dependent variable:    
                    ---------------------------
                             barthtot          
-----------------------------------------------
c160age                     (0.071)***         
                             p = 0.002         
                                               
c12hour                     (0.019)***         
                             p = 0.000         
                                               
c161sex                       (2.086)          
                             p = 0.901         
                                               
c172code                      (1.420)          
                             p = 0.592         
                                               
Constant                    (6.172)***         
                             p = 0.000         
                                               
-----------------------------------------------
Observations                    821            
R2                             0.270           
Adjusted R2                    0.266           
Residual Std. Error      25.353 (df = 816)     
F Statistic           75.284*** (df = 4; 816)  
===============================================
Note:               *p<0.1; **p<0.05; ***p<0.01

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM