if (FALSE) { # require("gt", quietly = TRUE) && require("glmmTMB", quietly = TRUE)
# \donttest{
library(parameters)
model <- glmmTMB::glmmTMB(
count ~ spp + mined + (1 | site),
ziformula = ~mined,
family = poisson(),
data = Salamanders
)
mp <- model_parameters(model)
print(mp, pretty_names = FALSE)
print(mp, split_components = FALSE)
print(mp, select = c("Parameter", "Coefficient", "SE"))
print(mp, select = "minimal")
# group parameters ------
data(iris)
model <- lm(
Sepal.Width ~ Sepal.Length + Species + Petal.Length,
data = iris
)
# don't select "Intercept" parameter
mp <- model_parameters(model, parameters = "^(?!\\(Intercept)")
groups <- list(
"Focal Predictors" = c("Speciesversicolor", "Speciesvirginica"),
"Controls" = c("Sepal.Length", "Petal.Length")
)
print(mp, groups = groups)
# or use row indices
print(mp, groups = list(
"Focal Predictors" = c(1, 4),
"Controls" = c(2, 3)
))
# only show coefficients, CI and p,
# put non-matched parameters to the end
data(mtcars)
mtcars$cyl <- as.factor(mtcars$cyl)
mtcars$gear <- as.factor(mtcars$gear)
model <- lm(mpg ~ hp + gear * vs + cyl + drat, data = mtcars)
# don't select "Intercept" parameter
mp <- model_parameters(model, parameters = "^(?!\\(Intercept)")
print(mp, groups = list(
"Engine" = c("cyl6", "cyl8", "vs", "hp"),
"Interactions" = c("gear4:vs", "gear5:vs")
))
# }
# custom column layouts ------
data(iris)
lm1 <- lm(Sepal.Length ~ Species, data = iris)
lm2 <- lm(Sepal.Length ~ Species + Petal.Length, data = iris)
# custom style
result <- compare_parameters(lm1, lm2, select = "{estimate}{stars} ({se})")
print(result)
# \donttest{
# custom style, in HTML
result <- compare_parameters(lm1, lm2, select = "{estimate}({se})|{p}")
print_html(result)
# }
}
Run the code above in your browser using DataLab