Learn R Programming

CausalQueries (version 1.1.0)

plot_model: Plots a DAG in ggplot style using a causal model input

Description

If confounds are indicated (provided in attr(model$P, 'confounds')), then these are represented as bidirectional arcs. Builds on functionality from ggdag and dagitty.

Usage

plot_model(
  model = NULL,
  x_coord = NULL,
  y_coord = NULL,
  title = "",
  textcol = "white",
  textsize = 3.88,
  shape = 16,
  nodecol = "black",
  nodesize = 16
)

Value

A DAG plot in ggplot style.

Arguments

model

A causal_model object generated from make_model

x_coord

A vector of x coordinates for DAG nodes. If left empty, coordinates are randomly generated

y_coord

A vector of y coordinates for DAG nodes. If left empty, coordinates are randomly generated

title

String specifying title of graph

textcol

String specifying color of text labels

textsize

Numeric, size of text labels

shape

Indicates shape of node. Defaults to circular node.

nodecol

String indicating color of node that is accepted by ggplot's default palette

nodesize

Size of node.

Examples

Run this code

if (FALSE) {
model <- make_model('X -> K -> Y; X <-> Y')

model |>
  CausalQueries:::plot_model()
model |>
  CausalQueries:::plot_model(
    x_coord = 1:3,
    y_coord = 1:3,
    title = "Mixed text and math: $\\alpha^2 + \\Gamma$")
}

Run the code above in your browser using DataLab