简体   繁体   English

使用Zelig的观星者

[英]Using stargazer with Zelig

I am trying to use stargazer (Version 5.2) to output the standard summary() results of a regression estimated with Zelig (Version 5.0.13). 我正在尝试使用stargazer(版本5.2)来输出使用Zelig(版本5.0.13)估计的回归的标准摘要()结果。 However, I obtain the error 但是,我得到了错误

Error in envRefInferField(x, what, getClass(class(x)), selfEnv) : 
‘result’ is not a valid field or method name for reference class “Zelig-ls”

when trying to feed the estimated model into stargazer. 当试图将估计的模型送入观星者时。

A minimal working example reproducing the error would be 再现错误的最小工作示例将是

library(Zelig)
library(stargazer)
data("swiss")
z <- zls$new()
z$zelig(Fertility~Education, data=swiss)
stargazer(z)

I assume I need to somehow access the place where the estimated model is stored in the zelig object, but I am having trouble finding it. 我假设我需要以某种方式访问​​估计模型存储在zelig对象中的位置,但我找不到它。

As of Zelig 5.0-13 and stargazer 5.2, stargazer doesn't seem to be able to handle Zelig's internal model. 从Zelig 5.0-13和stargazer 5.2开始,stargazer似乎无法处理Zelig的内部模型。 As a workaround, you can simply cast it to a "normal" lm to make it work: 作为一种解决方法,您可以简单地将其转换为“正常”lm以使其工作:

stargazer(lm(z$zelig.out$z.out[[1]]), type='text')

Result: 结果:

===============================================
                        Dependent variable:    
                    ---------------------------
                             Fertility         
-----------------------------------------------
Education                    -0.862***         
                              (0.145)          

Constant                     79.610***         
                              (2.104)          

-----------------------------------------------
Observations                    47             
R2                             0.441           
Adjusted R2                    0.428           
Residual Std. Error       9.446 (df = 45)      
F Statistic           35.446*** (df = 1; 45)   
===============================================
Note:               *p<0.1; **p<0.05; ***p<0.01 

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

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