Reputation: 49
Although I think it is not best practise to do so, I want to have a linear model and a linear mixed effect model in one table next to each other. I use sjPlot::tab_model. The problem occurs with r2. In the lm it computes the r2 and the adjusted r2. But in the lmer it computes the marginal and conditional r2. Tab_model prints for the row r2 the name of the metrics used in the first assigned model. I think best would be to make a new row and give the r2 for each model with the correct name seperately, but as well changing the name of what tab_model writes for r2 would solve the issue somehow.
Here is a reproducable example, and as it is just for layouting reasons it does not have to make sense at all:
library("sjPlot")
library("lme4")
lm1 <- lm(mpg ~ cyl, mtcars)
lmer2 <- lmer(mpg ~ hp + (1|gear), mtcars)
tab_model(lm1, lmer2,
show.aic = T,
show.fstat = T,
show.r2 = T)
Upvotes: 0
Views: 1225
Reputation: 24838
It's a total hack, but you can just assign the sjTable output and then use base::gsub
to manually change the word adjusted:
tab <- tab_model(lm1, lmer2,
show.aic = T,
show.fstat = T,
show.r2 = T)
tab$page.complete <- gsub("adjusted","adjusted or conditional",
tab$page.complete)
tab
Upvotes: 3