MichaelChirico - 1 year ago 51

R Question

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`

`texreg`

Answer Source

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)
}
```