[英]Extracting output from `zlogit$sim()` (Zelig)
I'm still trying to get used to the totally new syntax the developers of Zelig
are working towards (in Zelig5, instructions for installing the current development version here ).我仍在努力适应
Zelig
开发人员正在努力的全新语法(在 Zelig5 中,此处安装当前开发版本的说明)。 Feels very Pythonic, except, not...感觉非常 Pythonic,除了,不是...
Anyway, I just want to store the results of a sim
exercise, but can only figure out how to print the results to the console.无论如何,我只想存储一个
sim
练习的结果,但只能弄清楚如何将结果打印到控制台。
Let's use the example cited in the documentation (well, sort of--updated to reflect the Zelig5 syntax seen, eg, here ):让我们使用文档中引用的示例(好吧,有点--更新以反映所见的 Zelig5 语法,例如, here ):
set.seed(1234)
library(Zelig) #Zelig_5.0-5
ztob<-ztobit$new()
ztob$zelig(durable~age+quant,data=tobin)
ztob$setx(ztob)
ztob$sim()
summary(ztob)
sim x :
-----
ev
mean sd 50% 2.5% 97.5%
1 1.534273 0.6350075 1.451001 0.5103966 3.042459
pv
mean sd 50% 2.5% 97.5%
[1,] 3.002031 4.027547 1.310886 0 13.19713
I don't really know what pv
means (not really documented), but I'm pretty sure the expected value I want is 1.53 (under ev
, mean
).我真的不知道
pv
是什么意思(没有真正记录),但我很确定我想要的预期值是 1.53 (在ev
下, mean
)。
Can anyone figure out how to extract that value?谁能弄清楚如何提取该值? I can't find anything like
summary.Zelig
or summary.zelig
;我找不到像
summary.Zelig
或summary.zelig
类的东西; I've tried:我试过了:
summary(ztob)$ev
/ ztob$ev
summary(ztob)$ev
/ ztob$ev
print(summary(ztob))
summary(ztob)[1]
/ summary(ztob)[[1]]
summary(ztob)[1]
/ summary(ztob)[[1]]
Anything?任何事物?
In cases like this, str
is your friend.在这种情况下,
str
是您的朋友。
You can get all the values:您可以获得所有值:
x<-unlist(ztob[["sim.out"]][["x"]][["ev"]])
And the mean:和平均值:
mean(x)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.