vglm回归对象(VGAM)的Latex或HTML摘要输出表

时间:2022-07-22 14:55:29

I'm trying to get a latex or html output of the regression results of a VGAM model (in the example bellow it's a generalized ordinal logit). But the packages I know for this purpose do not work with a vglm object.

我正在尝试获得VGAM模型的回归结果的乳胶或html输出(在示例中,它是一个广义的序数logit)。但是我为此目的知道的包不适用于vglm对象。

Here you can see a little toy example with the error messages I'm getting:

在这里你可以看到一个小玩具示例,其中包含我收到的错误消息:

library(VGAM)
n <- 1000
x <- rnorm(n)
y <- ordered( rbinom(n, 3, prob=.5) )

ologit <- vglm(y ~ x,
            family =  cumulative(parallel = F , reverse = TRUE), 
            model=T)

library(stargazer)
stargazer(ologit)

Error in objects[[i]]$zelig.call : $ operator not defined for this S4 class

对象[[i]]中的错误$ zelig.call:$ S4没有为此类定义

library(texreg)
htmlreg(ologit)

Error in (function (classes, fdef, mtable) : unable to find an inherited method for function ‘extract’ for signature ‘"vglm"’

(函数(classes,fdef,mtable)中的错误:无法为签名'“vglm”找到函数'extract'的继承方法

library(memisc)
mtable(ologit)

Error in UseMethod("getSummary") : no applicable method for 'getSummary' applied to an object of class "c('vglm', 'vlm', 'vlmsmall')"

UseMethod(“getSummary”)中的错误:没有适用于“getSummary”的方法应用于类“c('vglm','vlm','vlmsmall')的对象”

1 个解决方案

#1


I just had the same problem. My first work around is to run the OLogit Regression with the polr function of the MASS package. The resulting objects are easily visualizable / summarizable by the usual packages (I recommend sjplot 's tab_model function for the table output!)

我刚遇到同样的问题。我的第一个工作是使用MASS包的polr函数运行OLogit回归。生成的对象很容易通过常用的包进行可视化/总结(我建议sjplot的tab_model函数用于表输出!)

2nd Option is to craft your own table, which you then turn into a neat HTML object via stargazer.

第二种选择是制作自己的表格,然后通过观星者将其变成一个整洁的HTML对象。

For this you need to know that s4 objects are not subsettable in the same manner as conventional objects (http://adv-r.had.co.nz/Subsetting.html). The most straight forward solution is to subset the object, i.e. extract the relevant aspects with an @ instead of a $ symbol:

为此,您需要知道s4对象不是与传统对象相同的子集(http://adv-r.had.co.nz/Subsetting.html)。最直接的解决方案是对对象进行子集化,即用@而不是$符号提取相关方面:

sumobject <- summaryvglm(yourvglmobject)
stargazer(sumpbject@coef3, type="html", out = "RegDoc.doc")

A little cumbersome but it did the trick for me. Hope this helps!

有点麻烦,但它为我做了伎俩。希望这可以帮助!

#1


I just had the same problem. My first work around is to run the OLogit Regression with the polr function of the MASS package. The resulting objects are easily visualizable / summarizable by the usual packages (I recommend sjplot 's tab_model function for the table output!)

我刚遇到同样的问题。我的第一个工作是使用MASS包的polr函数运行OLogit回归。生成的对象很容易通过常用的包进行可视化/总结(我建议sjplot的tab_model函数用于表输出!)

2nd Option is to craft your own table, which you then turn into a neat HTML object via stargazer.

第二种选择是制作自己的表格,然后通过观星者将其变成一个整洁的HTML对象。

For this you need to know that s4 objects are not subsettable in the same manner as conventional objects (http://adv-r.had.co.nz/Subsetting.html). The most straight forward solution is to subset the object, i.e. extract the relevant aspects with an @ instead of a $ symbol:

为此,您需要知道s4对象不是与传统对象相同的子集(http://adv-r.had.co.nz/Subsetting.html)。最直接的解决方案是对对象进行子集化,即用@而不是$符号提取相关方面:

sumobject <- summaryvglm(yourvglmobject)
stargazer(sumpbject@coef3, type="html", out = "RegDoc.doc")

A little cumbersome but it did the trick for me. Hope this helps!

有点麻烦,但它为我做了伎俩。希望这可以帮助!