View source: R/tidy_forest_model.R
| tidy_forest_model | R Documentation |
Uses broom::tidy() to convert a fitted model into forest-plot data.
tidy_forest_model(
model,
conf.int = TRUE,
conf.level = 0.95,
exponentiate = NULL,
intercept = FALSE,
term_labels = NULL,
sort_terms = c("none", "descending", "ascending")
)
model |
A fitted model object supported by |
conf.int |
Logical; if |
conf.level |
Confidence level for intervals. |
exponentiate |
Logical; passed through to |
intercept |
Logical; if |
term_labels |
Optional named vector used to relabel displayed terms. Names should match model term names and values are the labels to display. |
sort_terms |
How to sort rows: |
A standardized coefficient data frame ready for ggforestplot().
if (requireNamespace("broom", quietly = TRUE)) {
fit <- lm(mpg ~ wt + hp + qsec, data = mtcars)
tidy_forest_model(fit)
set.seed(123)
logit_data <- data.frame(
age = rnorm(250, mean = 62, sd = 8),
bmi = rnorm(250, mean = 28, sd = 4),
treatment = factor(rbinom(250, 1, 0.45), labels = c("Control", "Treatment"))
)
linpred <- -9 + 0.09 * logit_data$age + 0.11 * logit_data$bmi +
0.9 * (logit_data$treatment == "Treatment")
logit_data$event <- rbinom(250, 1, plogis(linpred))
logit_fit <- glm(event ~ age + bmi + treatment, data = logit_data, family = binomial())
tidy_forest_model(logit_fit, exponentiate = TRUE)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.