Closed vincentarelbundock closed 5 hours ago
Let me see where this information gets lost... at least format_parameters()
works as intended:
set.seed(1024)
N <- 5000
X <- rbinom(N, 1, .5)
M <- sample(c("a", "b", "c"), N, replace = TRUE)
b <- runif(8, -1, 1)
Y <- rbinom(N, 1, prob = plogis(
b[1] + b[2] * X +
b[3] * (M == "b") + b[4] * (M == "b") + b[5] * (M == "c") +
b[6] * X * (M == "a") + b[7] * X + (M == "b") +
b[8] * X * (M == "c")
))
dat <- data.frame(Y, X, M)
mod <- glm(Y ~ X * M, data = dat, family = binomial)
parameters::format_parameters(mod)
#> (Intercept) X Mb Mc X:Mb
#> "(Intercept)" "X" "M [b]" "M [c]" "X × M [b]"
#> X:Mc
#> "X × M [c]"
Created on 2024-10-20 with reprex v2.1.1
dat$M <- as.factor(dat$M)
solves the problem. I think I just need to convert to factor inside .format_value_labels()
.
Awesome!
Who said stringsAsFactors = TRUE
was a bad default? 😜
@strengejacke as discussed.
Pretty labels include
NA
with interactions: