Learn R Programming

see (version 0.10.0)

plot.see_check_dag: Plot method for check DAGs

Description

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

Usage

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

Value

A ggplot2-object.

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.

Examples

Run this code
if (FALSE) { # require("ggdag", quietly = TRUE)
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)
}

Run the code above in your browser using DataLab