我想计算罕见事件的logit回归。我决定使用Zelig
包(relogit
函数)来执行此操作。
通常,我使用stargazer
来提取和保存回归结果。但是,这两个软件包似乎存在兼容性问题(Using stargazer with Zelig)。
我现在想从Zelig
relogit
输出中提取以下信息:
系数,z值,p值,观测数,对数似然,AIC
我设法提取了p值和系数。但是,我在其他方面都失败了。但我确信这些值必须以某种方式可访问,因为它们在summary()
输出中报告(但是,我没有设法将summary
输出存储为R
对象)。摘要的处理方式与常规glm
摘要(https://stats.stackexchange.com/questions/176821/relogit-model-from-zelig-package-in-r-how-to-get-the-estimated-coefficients)
可重复的示例:
##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
但是,我没有找到其他元素的类似命令,例如z values
,AIC
等。但是,正如summary()
调用中显示的那样,它们应该以某种方式访问
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
答案 0 :(得分:1)
使用from_zelig_model
表示偏离,AIC。
m <- from_zelig_model(z.out1)
m$aic
...
Z值是系数/ sd。
z.out1$get_coef()[[1]]/z.out1$get_se()[[1]]