我应该做什么,如果xtable不知道特殊命令.例如,假设一个tobit模型的估计,如下所示:
require(AER)
require(xtable)
attach(cars)
tob<-tobit(dist~speed)
summary(tob)
xtable(summary(tob))
detach(cars)
与线性模型的输出相比,摘要的输出非常相似......为了使xtable理解,我想做什么,我想在Latex表中得到系数?Samme与像其它功能summary(zeroinfl(<model>))从PAKAGE pscl?你们建议做什么?
这是您可以使用的另一个功能。它是为 lm 定义的 xtable 的修改版本。即我刚刚针对 tobit 情况修改了函数 xtable.summary.lm 。它还将与其他 xtable 功能保持一致
xtable.summary.tobit <-
function (x, caption = NULL, label = NULL, align = NULL, digits = NULL,
display = NULL, ...)
{
x <- data.frame(unclass(x$coef), check.names = FALSE)
class(x) <- c("xtable", "data.frame")
caption(x) <- caption
label(x) <- label
align(x) <- switch(1 + is.null(align), align, c("r", "r",
"r", "r", "r"))
digits(x) <- switch(1 + is.null(digits), digits, c(0, 4,
4, 2, 4))
display(x) <- switch(1 + is.null(display), display, c("s",
"f", "f", "f", "f"))
return(x)
}
## Now this should give you the desired result
xtable(summary(tob))
Run Code Online (Sandbox Code Playgroud)
希望它有助于获得想要的结果