I am trying to extract the mean value of the first differences from an ordered probit model I ran with Zelig. If I just call the name of the object created by the sim() function, I get a print-out of the mean values for each value the DV takes. I'm trying to reference these values in Rmarkdown, so I'd like to call them programatically rather than just copy from the printout.
So in the example below, I'd like to be able to call the mean values for "fd" for each value 1:4.
Thanks for any help you might have!
EDIT: Adding reproducible example.
library(zeligverse)
library(dplyr)
data(sanction)
simulation_out <- zelig(factor(cost) ~ mil+coop, model="oprobit",data=sanction) %>% setx(z.out, coop = 1) %>% setx1(z.out, coop = 4) %>% sim()
summary(simulation_out)
OK. It looks like you can extract that information with
I found that by tracking down what
sumamry()
does. I ranto see we have an S4 object and then tried to find the specific function for the generic method with
which shows it calls
$summzarize
on itself. And looking at that functionwe see that it calls a
show()
function from it's environment. We can get that function withThe
fd
information seems to come from the linepstat(.self$sim.out$x1, "sim x1")
which runsprint(stat(.self$sim.out$x1$fd, .self$num))
. Thisstat()
function calls astatmat()
function which calculates the mean and quantiles. here we just usecolMean
to do the work for us.