% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/tidy_forest_model.R
\name{tidy_forest_model}
\alias{tidy_forest_model}
\title{Tidy a model object for forest plotting}
\usage{
tidy_forest_model(
  model,
  conf.int = TRUE,
  conf.level = 0.95,
  exponentiate = FALSE,
  intercept = FALSE,
  sort_terms = c("none", "descending", "ascending")
)
}
\arguments{
\item{model}{A fitted model object supported by \code{\link[broom:reexports]{broom::tidy()}}.}

\item{conf.int}{Logical; if \code{TRUE}, request confidence intervals from
\code{\link[broom:reexports]{broom::tidy()}}.}

\item{conf.level}{Confidence level for intervals.}

\item{exponentiate}{Logical; passed through to \code{\link[broom:reexports]{broom::tidy()}}.}

\item{intercept}{Logical; if \code{FALSE}, drop the intercept term.}

\item{sort_terms}{How to sort rows: \code{"none"}, \code{"descending"}, or
\code{"ascending"}.}
}
\value{
A standardized coefficient data frame ready for \code{\link[=ggforestplot]{ggforestplot()}}.
}
\description{
Uses \code{\link[broom:reexports]{broom::tidy()}} to convert a fitted model into forest-plot data.
}
\examples{
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)
}
}
