简体   繁体   English

在观星者表中包括标准化系数

[英]Including standardized coefficients in a stargazer table

I have a series of linear models and I'd like to report the standardized coefficients for each.我有一系列线性模型,我想报告每个模型的标准化系数。 However, when I print the models in stargazer, it looks like stargazer automatically prints the significance stars for the standardized coefficients as if they were unstandardized coefficients.但是,当我在 stargazer 中打印模型时,看起来 stargazer 会自动打印标准化系数的重要性星,就好像它们是非标准化系数一样。 You can see how the differences emerge below.您可以在下面看到差异是如何出现的。

Is it statistically wrong to print the significance stars based on the unstandardized values?根据非标准化值打印重要性星在统计上是否错误? How is this done in stargazer?这是如何在观星者中完成的? Thanks!谢谢!

#load libraries
library(stargazer)
library(lm.beta)
#fake data
var1<-rnorm(100, mean=10, sd=5)
var2<-rnorm(100, mean=5, sd=2)
var3<-rnorm(100, mean=2, sd=3)
var4<-rnorm(100, mean=5, sd=1)
df<-data.frame(var1, var2, var3, var4)
#model with unstandardized betas
model1<-lm(var1~var2+var3+var4, data=df)
#Standardized betas
model1.beta<-lm.beta(model1)
#print
stargazer(model1, model1.beta, type='text')

Stargazer does not automatically know it should look for the standardized coefficients in the second model. Stargazer不会自动知道它应该在第二个模型中寻找标准化系数。 lm.beta just add standardzied coefficients to the lm.object . lm.beta只是将标准系数添加到lm.object So it is still an lm.object , so it extracts the coefficients as per usual (from model1.beta$coefficients . Use the coef = argument to specify the specific coefficients you want to use: coef = list(model1$coefficients, model1.beta$standardized.coefficients)所以它仍然是一个lm.object ,所以它像往常一样提取系数(来自model1.beta$coefficients 。使用coef =参数来指定你想要使用的特定系数: coef = list(model1$coefficients, model1.beta$standardized.coefficients)

> stargazer(model1, model1.beta, 
            coef = list(model1$coefficients, 
            model1.beta$standardized.coefficients),
            type='text')

==========================================================
                                  Dependent variable:     
                              ----------------------------
                                          var1            
                                   (1)            (2)     
----------------------------------------------------------
var2                              0.135          0.048    
                                 (0.296)        (0.296)   

var3                              -0.088        -0.044    
                                 (0.205)        (0.205)   

var4                              -0.190        -0.030    
                                 (0.667)        (0.667)   

Constant                         10.195**        0.000    
                                 (4.082)        (4.082)   

----------------------------------------------------------
Observations                       100            100     
R2                                0.006          0.006    
Adjusted R2                       -0.025        -0.025    
Residual Std. Error (df = 96)     5.748          5.748    
F Statistic (df = 3; 96)          0.205          0.205    
==========================================================
Note:                          *p<0.1; **p<0.05; ***p<0.01

A big thank you to paqmo for the answer.非常感谢paqmo的回答。 I would just add that to get the correct p-values for the standardized solution, you need to add another line detailing which p-values to use:我只想补充一点,以获得标准化解决方案的正确 p 值,您需要添加另一行详细说明要使用的 p 值:


    stargazer(model1, model1.beta, 
    coef = list(model1$coefficients, 
    model1.beta$standardized.coefficients),
    p = list (coef(summary(model1))[,4], coef(summary(model1.beta))[,5]),
    type='text')

Also, generally, Stargazer sometimes does not work with longer model names and gives the warning Error in if (is.na(s)) {: the condition has length > 1此外,一般情况下,Stargazer 有时不适用于较长的 model 名称,并Error in if (is.na(s)) {: the condition has length > 1

Thus, I would recommend to keep your models' names short (especially if you want Stargazer to display a few of them).因此,我建议保持模型名称简短(尤其是如果您希望 Stargazer 显示其中的一些)。

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

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