0

I got this example data frame in order to show what I want.

# Set the random seed for reproducibility
set.seed(123)

# Create a vector with categories for each variable
var1 <- sample(c("A", "B", "C", "D"), 200, replace = TRUE)
var2 <- sample(c("X", "Y", "Z"), 200, replace = TRUE)
var3 <- sample(c("Red", "Green", "Blue"), 200, replace = TRUE)
var4 <- sample(c("High", "Medium", "Low"), 200, replace = TRUE)
var5 <- sample(c("Yes", "No"), 200, replace = TRUE)
var6 <- sample(c("Male", "Female"), 200, replace = TRUE)

# Create the data frame
sim_data <- data.frame(var1, var2, var3, var4, var5, var6)

sim_data <- data.frame(lapply(sim_data, factor))

library(tidyverse)
library(mfx)
library(gtsummary)

model1<-logitmfx(var5 ~ var1 + var2 + var3 + var4 + var6, sim_data, atmean = F)

model1

# Create summary regression table, adding stars and remove CI and p-value
m1<-tbl_regression(model1)%>%
  add_significance_stars(hide_ci = T, hide_p = T)
m1

My html output is this, that is almost what I want:

enter image description here

Is there a way to tell tbl_regression to order the output by the beta column values in ascending or descending order?

Anyway, I know the logitmfxobjects are not supported by tbl_regression, but the output is almost ok. Nevertheless, I would like the SE to be shown below the Beta values, like this

Characteristic  Beta
Var1B          -0.03
             (0.099)
Var1C           0.07
             (0.098)
Var1D          -0.03
             (0.103)
Var2Y          -0.12
              (0.08)
#And so on with all the coefficients.

In adition to this, I would like to know if there is a way to add more stars with largers significance p-values. Right now add_significance_starsonly adds stars at *p<0.05; **p<0.01; ***p<0.001. For example, I would like to show a . or a + when p<0.1

Also, when I plot the tbl_regressionobject the reference labels are kind of broken, when I use plot this is the output:

plot(m1)

enter image description here

Is there a way to properly show the reference levels in both plot and table?

Thanks in advance.

esteban
  • 102
  • 8

0 Answers0