1

This is a strange question, but here goes:

I am trying to output my model results into a TeX table with texreg.

reg <- zelig(Y ~ X, model = "tobit", below = 0, above = Inf)

However, I'm getting an error from texreg:

texreg(reg)

Error in .local(model, ...) : Only the following Zelig models are currently supported: logit, ls, mlogit, ologit, probit, relogit.

My question is basically: is this an error from Zelig or from texreg?

MichaelChirico
  • 33,841
  • 14
  • 113
  • 198
  • its an error in that it look as if `texreg` does not support the `tobit` model. If you only want the coefficients you can try `xtable::xtable(summary(reg)$table)` – user20650 Apr 02 '15 at 01:15
  • How can you tell this isn't an error generated within `Zelig`? – MichaelChirico Apr 02 '15 at 01:16
  • because you get the error after running the command `texreg`. The `zelig` function executes, no? The `texreg` looks as if it just converts the model output to latex - but does not support all models – user20650 Apr 02 '15 at 01:19
  • right--but for example if `texreg` tries to run `residuals(reg)` and this is not a supported method for `zelig` objects, the fault would be on `Zelig`, no? Is that not possible? – MichaelChirico Apr 02 '15 at 01:21
  • Sorry, i dont quite understand this *texreg tries to run residuals(reg)*. But the `texreg` function (which i was not familiar with before this) appears to just extract certain model outputs and prepare then for latex. I dont know if it can be said to be a functions (zelig) *fault* if another function (texreg) does not execute due to a method not being defined. – user20650 Apr 02 '15 at 01:38
  • 1
    Have a look at the end of the function `extract.zelig`, which is called by `texreg:::get.data` in `texreg`. – user20650 Apr 02 '15 at 02:06
  • 1
    thanks! for the record, I've updated the `extract.zelig` function of `texreg` and the maintainer of `texreg` (Philip Leifield) has incorporated it into the latest update. – MichaelChirico Apr 07 '15 at 21:42
  • Great stuff...well done and thanks for following up. You should add this as an answer. – user20650 Apr 07 '15 at 22:48

1 Answers1

3

UPDATE 2015-07-20:

extract.zelig now has a tobit method (Zelig_4.2-1)

So texreg(reg) now works as expected. I'll leave the below for posterity anyway.


Having identified the source of the issue, I updated the extract.zelig method and passed this along to the package creator/maintainer Philip Leifield, who incorporated into the latest R-Forge version (available via install.packages("texreg", repos="http://R-Forge.R-project.org")). I'm not sure it's in the current CRAN release (2015-04-07)...

Here's what we needed to add:

else if ("tobit" %in% class(model)) {
        coefficient.names <- rownames(s$table)
        coefficients <- s$table[, 1]
        standard.errors <- s$table[, 2]
        significance <- s$table[, 5]
        gof <- numeric()
        gof.names <- character()
        gof.decimal <- logical()
        if (include.aic == TRUE) {
            aic <- AIC(model)
            gof <- c(gof, aic)
            gof.names <- c(gof.names, "AIC")
            gof.decimal <- c(gof.decimal, TRUE)
        }
        if (include.bic == TRUE) {
            bic <- BIC(model)
            gof <- c(gof, bic)
            gof.names <- c(gof.names, "BIC")
            gof.decimal <- c(gof.decimal, TRUE)
        }
        if (include.loglik == TRUE) {
            lik <- logLik(model)[1]
            gof <- c(gof, lik)
            gof.names <- c(gof.names, "Log Likelihood")
            gof.decimal <- c(gof.decimal, TRUE)
        }
        if (include.nobs == TRUE) {
            n <- nrow(model$data)
            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)
    }
MichaelChirico
  • 33,841
  • 14
  • 113
  • 198