I am using stargazer
to create my plm summary tables.
library(plm)
library(pglm)
data("Unions", package = "pglm")
anb1 <- plm(wage ~ union + exper + rural, Unions, model = "random", method = "bfgs")
stargazer(anb1)
Unfortunately stargazer does not support pglm models. I am looking for a solution on how to plot the results of a pglm model with binary dependent variable, as the following stargazer call does not work with pglm models.
anb2 <- pglm(union ~ wage + exper + rural, Unions, family = "binomial",
model = "random", method = "bfgs")
stargazer(anb2)
Any alternative to just extract each summary item and than format it respectively? The class of the outcome is:
[1] "maxLik" "maxim" "list"
Here's a simple extract function to make texreg work with pglm:
extract.pglm <- function (model, include.nobs = TRUE, include.loglik = TRUE, ...) {
s <- summary(model, ...)
coefficient.names <- rownames(s$estimate)
coefficients <- s$estimate[, 1]
standard.errors <- s$estimate[, 2]
significance <- s$estimate[, 4]
loglik.value <- s$loglik
n <- nrow(model$model)
gof <- numeric()
gof.names <- character()
gof.decimal <- logical()
if (include.loglik == TRUE) {
gof <- c(gof, loglik.value)
gof.names <- c(gof.names, "Log-Likelihood")
gof.decimal <- c(gof.decimal, TRUE)
}
if (include.nobs == TRUE) {
gof <- c(gof, n)
gof.names <- c(gof.names, "Num. obs.")
gof.decimal <- c(gof.decimal, FALSE)
}
tr <- createTexreg(coef.names = coefficient.names, coef = coefficients,
se = standard.errors, pvalues = significance, gof.names = gof.names,
gof = gof, gof.decimal = gof.decimal)
return(tr)
}
In order for this code to work, you should also register the function so that it handles the pglm maxLik
objects by default when extract
is called:
setMethod("extract", signature = className("maxLik", "maxLik"),
definition = extract.pglm)
After that, you can use texreg with pglm just like with plm or other models supported by texreg.