3

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')"

RogerioJB
  • 355
  • 1
  • 8
  • 2
    if you want the coefficients and st.errors you can use the `xtable` package: `xtable(coef(summary(ologit)))` . You can also extract other output you want and bind them to the table. – user20650 May 04 '15 at 18:37

1 Answers1

3

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!