[英]Access z-value and other statistics in output of Zelig relogit
I want to compute a logit regression for rare events.我想计算罕见事件的 logit 回归。 I decided to use the Zelig
package ( relogit
function) to do so.我决定使用Zelig
包( relogit
函数)来做到这一点。
Usually, I use stargazer
to extract and save regression results.通常,我使用stargazer
来提取和保存回归结果。 However, there seem to be compatibility issues with these two packages ( Using stargazer with Zelig ).但是,这两个软件包似乎存在兼容性问题( Using stargazer with Zelig )。
I now want to extract the following information from the Zelig
relogit
output:我现在想从Zelig
relogit
输出中提取以下信息:
Coefficients, z values, p values, number of observations, log likelihood, AIC系数、z 值、p 值、观察次数、对数似然、AIC
I have managed to extract the p-values and coefficients.我设法提取了 p 值和系数。 However, I failed at the rest.但是,其余的我都失败了。 But I am sure these values must be accessible somehow, because they are reported in the summary()
output (however, I did not manage to store the summary
output as an R
object).但我确信这些值必须以某种方式访问,因为它们在summary()
输出中报告(但是,我没有设法将summary
输出存储为R
对象)。 The summary cannot be processed in the same way as a regular glm
summary ( https://stats.stackexchange.com/questions/176821/relogit-model-from-zelig-package-in-r-how-to-get-the-estimated-coefficients )无法以与常规glm
摘要相同的方式处理摘要( https://stats.stackexchange.com/questions/176821/relogit-model-from-zelig-package-in-r-how-to-get-the -估计系数)
A reproducible example:一个可重现的例子:
##Initiate package, model and data
require(Zelig)
data(mid)
z.out1 <- zelig(conflict ~ major + contig + power + maxdem + mindem + years,
data = mid, model = "relogit")
##Call summary on output (reports in console most of the needed information)
summary(z.out1)
##Storing the summary fails and only produces a useless object
summary(z.out1) -> z.out1.sum
##Some of the output I can access as follows
z.out1$get_coef() -> z.out1.coeff
z.out1$get_pvalue() -> z.out1.p
z.out1$get_se() -> z.out1.se
However, I did not find similar commands for other elements, such as z values
, AIC
etc. However, as they are shown in the summary()
call, they should be accessible somehow.但是,我没有找到其他元素的类似命令,例如z values
、 AIC
等。但是,正如它们在summary()
调用中所示,它们应该可以以某种方式访问。
The summary
call result: summary
调用结果:
Model:
Call:
z5$zelig(formula = conflict ~ major + contig + power + maxdem +
mindem + years, data = mid)
Deviance Residuals:
Min 1Q Median 3Q Max
-3.0742 -0.4444 -0.2772 0.3295 3.1556
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -2.535496 0.179685 -14.111 < 2e-16
major 2.432525 0.157561 15.439 < 2e-16
contig 4.121869 0.157650 26.146 < 2e-16
power 1.053351 0.217243 4.849 1.24e-06
maxdem 0.048164 0.010065 4.785 1.71e-06
mindem -0.064825 0.012802 -5.064 4.11e-07
years -0.063197 0.005705 -11.078 < 2e-16
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 3979.5 on 3125 degrees of freedom
Residual deviance: 1868.5 on 3119 degrees of freedom
AIC: 1882.5
Number of Fisher Scoring iterations: 6
Next step: Use 'setx' method
Use from_zelig_model
for deviance, AIC.使用from_zelig_model
进行偏差,AIC。
m <- from_zelig_model(z.out1)
m$aic
...
Z-values are coefficient / sd. Z 值是系数 / sd。
z.out1$get_coef()[[1]]/z.out1$get_se()[[1]]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.