Closed mathewrm closed 1 year ago
It could be a good idea. Let me explore it and try to prepare PR
Could you have a look at #33?
library(ggstats)
mod <- lm(Sepal.Length ~ Sepal.Width + Species, data = iris)
ggcoef_table(mod)
ggcoef_table(mod, table_stat = c("estimate", "ci"))
ggcoef_table(mod, table_witdhs = c(1, 1), table_text_size = 5)
ggcoef_table(mod, stripped_rows = FALSE)
d_titanic <- as.data.frame(Titanic)
d_titanic$Survived <- factor(d_titanic$Survived, c("No", "Yes"))
mod_titanic <- glm(
Survived ~ Sex * Age + Class,
weights = Freq,
data = d_titanic,
family = binomial
)
ggcoef_table(mod_titanic, exponentiate = TRUE)
# display only a subset of terms
ggcoef_table(mod_titanic, exponentiate = TRUE, include = c("Age", "Class"))
Created on 2023-08-01 with reprex v2.0.2
I've tried the code and it works as expected. Kudos!
The output plot of ggcoef_* functions are good. I would also love to see an option that allows users to specify whether or not to include a table which shows coefficient estimates (e.g. OR) and confidence intervals corresponding to each term in the model.
Here is an example of what I mean (although the code could use a significant improvement for more flexible customizability):
attach trial data from gtsummary package
data(trial, package="gtsummary")
fit a logistic regression model
glm_model <- glm( response ~ rms::rcs(age, 3) + trt*grade + marker + stage, data = trial, family = binomial )
define a function to attach a coefficients table to ggcoef_model output
use custom function on fitted model
ggcoef_table(model = glm_model)