簡體   English   中英

在Stargazer表中包含標准化系數

[英]Include standardized coefficients in a Stargazer table

原諒我,因為我是R的新手,如果這很傻/容易,但我一直在找了幾個小時,但無濟於事。 我有一系列的GLM模型,我想在Stargazer表中報告每個模型的標准化/重新參數化系數以及直接系數。 我創建了兩個單獨的模型,其中一個模型使用arm包具有標准化系數。

require(arm)
model1 <- glm(...)
model1.2 <- standardize(model1)

兩種模型都能正常工作,找到並提供所需的輸出,但是我似乎無法找出一種方法使Stargazer模仿這種結構/外觀: http : //citeseerx.ist.psu.edu/viewdoc/download?doi = 10.1.1.65.699&rep = rep1&type = pdf

這可以通過要求觀星者為兩個模型產生輸出,並確保模型中的系數具有相同的名稱來完成,以便觀星者知道標准化系數和非標准化系數應該在同一行上。

以下代碼將幫助您入門。

# generate fake data
x <- runif(100)
y <- rbinom(100, 1, x)

# fit the model
m1 <- glm(y~x, family = binomial())

# standardize it
m2 <- arm::standardize(m1)

# we make sure the coefficients have the same names in both models
names(m2$coefficients) <- names(m1$coefficients)

# we feed to stargazer
stargazer::stargazer(m1, m2, type = "text", 
                     column.labels = c("coef (s.e.)", "standarized coef (s.e.)"), 
                     single.row = TRUE)
#> 
#> ===========================================================
#>                              Dependent variable:           
#>                   -----------------------------------------
#>                                       y                    
#>                      coef (s.e.)    standarized coef (s.e.)
#>                          (1)                  (2)          
#> -----------------------------------------------------------
#> x                 4.916*** (0.987)     2.947*** (0.592)    
#> Constant          -2.123*** (0.506)      0.248 (0.247)     
#> -----------------------------------------------------------
#> Observations             100                  100          
#> Log Likelihood         -50.851              -50.851        
#> Akaike Inf. Crit.      105.703              105.703        
#> ===========================================================
#> Note:                           *p<0.1; **p<0.05; ***p<0.01

reprex軟件包 (v0.2.1)創建於2019-02-13

通常,您可以通過深入研究stargazer幫助文件並查看此有用的網頁https://www.jakeruss.com/cheatsheets/stargazer/來找出如何從輸出中實現所需的功能

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM