texreg
uses a generic function called extract
to pull the relevant data from a model object and then processes the resulting texreg
object to create a regression table. In order to extend the range of models texreg
is applicable to, you can write your own methods for the extract
function.
Zelig-relogit
objects apparently store a glm
object with the relevant data somewhere inside the object and attach a different class name to it. So it should be relatively straightforward to create a copy of this sub-object, fix its class name, and apply the existing extract.glm
method to this object to extract the data. More specifically:
# extension for Zelig-relogit objects (Zelig package >= 5.0)
extract.Zeligrelogit <- function(model, include.aic = TRUE, include.bic = TRUE,
include.loglik = TRUE, include.deviance = TRUE, include.nobs = TRUE, ...) {
g <- model$zelig.out$z.out[[1]]
class(g) <- "glm"
e <- extract(g, include.aic = include.aic, include.bic = include.bic,
include.loglik = include.loglik, include.deviance = include.deviance,
include.nobs = include.nobs, ...)
return(e)
}
setMethod("extract", signature = className("Zelig-relogit", "Zelig"),
definition = extract.Zeligrelogit)
This code creates a Zelig-relogit
method for the extract
function. You can use it by typing something like screenreg(relogit)
, where relogit
is the name of your Zelig-relogit
object. The result should look like this:
==================================
Model 1
----------------------------------
(Intercept) -9446502571.59 ***
(62615.78)
x1 19409089045.70 ***
(141084.20)
x2 856836055.47 ***
(98175.65)
----------------------------------
AIC 6.00
BIC 4.83
Log Likelihood -0.00
Deviance 0.00
Num. obs. 5
==================================
*** p < 0.001, ** p < 0.01, * p < 0.05
More generally, if you want to make any Zelig
model work with texreg
, you should look at model$zelig.out$z.out[[1]]
to find the relevant information. I will include the Zelig-relogit
extract
method in the next texreg
release.