Skip to contents

[Stable]

Provides an interface to visualize the model results with visreg package, to show how a predictor variable x affects an outcome y.

Usage

br_show_fitted_line(breg, idx = 1, ...)

Arguments

breg

A regression object with results (must pass assert_breg_obj_with_results()).

idx

Length-1 vector. Index or name (focal variable) of the model. This is different from idx in br_show_forest_ggstats, only one model is supported to visualized here, so only length-1 vector is supported as idx.

...

Arguments passing to visreg::visreg() excepts fit and data. See visreg::visreg() for available arguments.

Value

A plot

Note

Starting with visreg 3.0, all plots use ggplot2 (the gg argument has been removed) and several arguments have been renamed to use snake_case: line.par -> line, fill.par -> fill, points.par -> points, band.par -> band. See vignette("migrating-to-3-0", package = "visreg") for full details.

Examples

if (rlang::is_installed("visreg")) {
  m <- br_pipeline(mtcars,
    y = "mpg",
    x = colnames(mtcars)[2:4],
    x2 = "vs",
    method = "gaussian"
  )

  if (interactive()) {
    br_show_fitted_line(m)
  }
  br_show_fitted_line(m, xvar = "cyl")
}
#> subset model list with idx: 1
#> model call: stats::glm(formula = mpg ~ cyl + vs, family = stats::gaussian, data
#> = data)