Reputation: 34703
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). Feels very Pythonic, except, not...
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.
Let's use the example cited in the documentation (well, sort of--updated to reflect the Zelig5 syntax seen, e.g., 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
).
Can anyone figure out how to extract that value? I can't find anything like summary.Zelig
or summary.zelig
; I've tried:
summary(ztob)$ev
/ ztob$ev
print(summary(ztob))
summary(ztob)[1]
/ summary(ztob)[[1]]
Anything?
Upvotes: 2
Views: 772
Reputation: 24945
In cases like this, str
is your friend.
You can get all the values:
x<-unlist(ztob[["sim.out"]][["x"]][["ev"]])
And the mean:
mean(x)
Upvotes: 2