Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

plotting estimates for binomial glm using sjplot in r

I am trying to use sjplot to create html tables for output for a glm (actually a mixed effects model, but I will keep it simple), and I can’t figure out how to print estimates and se for predictors. Here is an example:

n <- 50
cov <- 10
x <- c(rep(0,n/2), rep(1, n/2))
p <- 0.4 + 0.2*x
y <- rbinom(n, cov, p)

ggplot(data.frame(x=factor(x),y=as.numeric(y)), 
       aes(x=x, y=y/cov)) +
  geom_point(position=position_jitter(height=0.02, width=0.07)) +
  xlab("x") + 
  ylab("y/cov") 


model0 <- glm(cbind(y, cov-y) ~ x, family="binomial")
summary(model0)

tab_model(model0,show.est = TRUE)

As you can see in the results, tab_model() doesn’t print the estimates, only the odd ratio and CI for the odd ratio. Is it possible to do this in sjplot, or should I look elsewhere. I am basically just wanting to put the table into an rmarkdown, but find it to be a little more tricky than I expected.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You need to include the argument transform = NULL to prevent tab_model from automatically exponentiating the estimates into odds ratios:

tab_model(model0, transform = NULL, show.est = TRUE, show.se = TRUE)

enter image description here

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading