plot.see_check_dag: Plot method for check DAGs

View source: R/plot.check_dag.R

plot.see_check_dagR Documentation

Plot method for check DAGs

Description

The plot() method for the performance::check_dag() function.

Usage

## S3 method for class 'see_check_dag'
plot(
  x,
  size_point = 20,
  size_text = 4.5,
  colors = NULL,
  which = "all",
  effect = "total",
  check_colliders = TRUE,
  ...
)

Arguments

x

A check_dag object.

size_point

Numeric value specifying size of point geoms.

size_text

Numeric value specifying size of text elements.

colors

Character vector of length five, indicating the colors (in hex-format) for different types of variables, which are assigned in following order: outcome, exposure, adjusted, unadjusted, and collider.

which

Character string indicating which plot to show. Can be either "all", "current" or "required".

effect

Character string indicating which effect for the required model is to be estimated. Can be either "total" or "direct".

check_colliders

Logical indicating whether to highlight colliders. Set to FALSE if the algorithm to detect colliders is very slow.

...

Currently not used.

Value

A ggplot2-object.

Examples


library(performance)
# incorrect adjustment
dag <- check_dag(
  y ~ x + b + c,
  x ~ b,
  outcome = "y",
  exposure = "x"
)
dag
plot(dag)

# plot only model with required adjustments
plot(dag, which = "required")

# collider-bias?
dag <- check_dag(
  y ~ x + c + d,
  x ~ c + d,
  b ~ x,
  b ~ y,
  outcome = "y",
  exposure = "x",
  adjusted = "c"
)
plot(dag)

# longer labels, automatic detection of outcome and exposure
dag <- check_dag(
  QoL ~ age + education + gender,
  age ~ education
)
plot(dag)


see documentation built on Sept. 11, 2024, 5:51 p.m.