Mia Colomar Riutort
Mia Colomar Riutort

Reputation: 1

Can tab_model collapse all models in one column?

I am using the tab_model function from the sjPlot package in R to do a table with 18 univariate models, all with the same response variable, but with one different variable each, as an example, this could be the first two models:

GEE1  <- geeglm(hospitalization ~ xxx,                   
    id = record_id, data = dades, family = binomial, corstr = "ar1")
GEE2  <- geeglm(hospitalization ~ xxx,                 
    id = record_id, data = dades, family = binomial, corstr = "ar1")

When using tab_model, I am getting one column (or set of columns) for each model, I would like to have them all in the same set of columns . Meaning just one column for all the estimates, all the p-values etc. But now I have one set (estimates, 95% and p-value) of columns per each model. making the table, obviously too wide. I want to have just all the models listed with the results.

I have tried to do a function and use kable, but it is very manual and I would love to find an alternative

A dummie example could be:

data = mtcars
m1 = lm(mpg~ disp, data = data)
m2 = lm(mpg~ cyl, data = data)
library(sjPlot)
tab_model(m1,m2,show.intercept = FALSE)

If I run this I get a table somewhat similar to:

mpg mpg
Predictors Estimates $C I$ $p$ Estimates $C I$ $p$
disp -0.04 $-0.05--0.03$ $<0.001$
cy1 -2.88 $-3.53--2.22$ $<0.001$

I would need to collapse all in one column as I am fitting this for 18 variables (I need that to do a model selection with Hosmer-Lemeshow algoritm due to the structure of my data).

It has to be something like:

mpg
Predictors Estimates $C I$ $p$
disp -0.04 $-0.05--0.03$ $<0.001$
cy1 -2.88 $-3.53--2.22$ $<0.001$

And then I wil export it to latex, tat culd be another question but if you know the answer drop it here too :)

Upvotes: 0

Views: 37

Answers (0)

Related Questions