2

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?

MichaelChirico
  • 33,841
  • 14
  • 113
  • 198
  • [here](http://docs.zeligproject.org/en/latest/installation_quickstart.html) are instructions for the development version and [here](https://github.com/IQSS/Zelig) is their github – MichaelChirico Jun 24 '15 at 03:34

1 Answers1

2

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)
jeremycg
  • 24,657
  • 5
  • 63
  • 74
  • how did you use `str`, exactly? – MichaelChirico Jun 24 '15 at 03:46
  • calling it on each object - `str(ztob)` gives us the structure of ztob, and then you can go down levels once you find what you think is going to have your data - `str(ztob[["sim.out"]])` etc etc. – jeremycg Jun 24 '15 at 03:55
  • I was trying `ztob$` and looking at the autocompletes suggested by Rstudio--is this basically the same thing? sorry not at computer now... – MichaelChirico Jun 24 '15 at 04:01
  • str gives you the type of data each one is, and a few representatives, it's a much more detailed way of doing it. – jeremycg Jun 24 '15 at 04:04