在 Stargazer 中包含标准化系数 table
Include standardized coefficients in a Stargazer table
请原谅我,因为我是 R 的新手,如果这是 silly/easy,但我一直在寻找数小时但无济于事。
我有一系列 GLM 模型,我想报告每个模型的 standardized/reparametrized 系数以及 Stargazer table 中的直接系数。我创建了两个单独的模型,一个使用 arm 包具有标准化系数。
require(arm)
model1 <- glm(...)
model1.2 <- standardize(model1)
两种模型都能工作,找到并给出我想要的输出,但是
我似乎无法找到一种方法让 Stargazer 模仿这个 structure/look:
http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.65.699&rep=rep1&type=pdf
这可以通过要求 stargazer 为两个模型生成输出并确保模型中的系数具有相同的名称以便 stargazer 知道标准化系数和非标准化系数应该相同来完成行。
下面的代码应该可以帮助您入门。
# 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 package (v0.2.1)
创建于 2019-02-13
您通常可以通过深入研究 stargazer 帮助文件并查看这个有用的网页来弄清楚如何从输出中获得您想要的结果 https://www.jakeruss.com/cheatsheets/stargazer/
请原谅我,因为我是 R 的新手,如果这是 silly/easy,但我一直在寻找数小时但无济于事。 我有一系列 GLM 模型,我想报告每个模型的 standardized/reparametrized 系数以及 Stargazer table 中的直接系数。我创建了两个单独的模型,一个使用 arm 包具有标准化系数。
require(arm)
model1 <- glm(...)
model1.2 <- standardize(model1)
两种模型都能工作,找到并给出我想要的输出,但是 我似乎无法找到一种方法让 Stargazer 模仿这个 structure/look: http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.65.699&rep=rep1&type=pdf
这可以通过要求 stargazer 为两个模型生成输出并确保模型中的系数具有相同的名称以便 stargazer 知道标准化系数和非标准化系数应该相同来完成行。
下面的代码应该可以帮助您入门。
# 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 package (v0.2.1)
创建于 2019-02-13您通常可以通过深入研究 stargazer 帮助文件并查看这个有用的网页来弄清楚如何从输出中获得您想要的结果 https://www.jakeruss.com/cheatsheets/stargazer/