Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Latex or HTML summary output table for vglm regression objects (VGAM)

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.

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

library(texreg)
htmlreg(ologit)

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

library(memisc)
mtable(ologit)

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

like image 528
RogerioJB Avatar asked Sep 11 '25 02:09

RogerioJB


1 Answers

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!)

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

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:

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

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

like image 57
Philipp Mendoza Avatar answered Sep 13 '25 15:09

Philipp Mendoza