简体   繁体   English

来自zelig package(R)的turit-ing Tobit输出

[英]texreg-ing Tobit output from zelig package (R)

This is a strange question, but here goes: 这是一个奇怪的问题,但这里有:

I am trying to output my model results into a TeX table with texreg . 我试图将我的模型结果输出到带有texreg的TeX表中。

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

However, I'm getting an error from texreg : 但是,我从texreg收到错误:

texreg(reg)

Error in .local(model, ...) : Only the following Zelig models are currently supported: logit, ls, mlogit, ologit, probit, relogit. .local(model, ...)出错:目前仅支持以下Zelig模型:logit,ls,mlogit,ologit,probit,relogit。

My question is basically: is this an error from Zelig or from texreg ? 我的问题基本上是:这是来自Zelig还是来自texreg的错误?

UPDATE 2015-07-20: 更新2015-07-20:

extract.zelig now has a tobit method ( Zelig_4.2-1 ) extract.zelig现在有一个tobit方法( Zelig_4.2-1

So texreg(reg) now works as expected. 因此, texreg(reg)现在按预期工作。 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") ). 确定了问题的根源后,我更新了extract.zelig方法并将其传递给包创建者/维护者Philip Leifield,后者已合并到最新的R-Forge版本中(可通过install.packages("texreg", repos="http://R-Forge.R-project.org") )。 I'm not sure it's in the current CRAN release (2015-04-07)... 我不确定它是否在当前的CRAN版本中(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)
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM