Skip to content

Commit

Permalink
Add tests, allow to plot specific effect (#355)
Browse files Browse the repository at this point in the history
* Add tests, allow to plot specific effect

* docs

* wordlist
  • Loading branch information
strengejacke authored Aug 12, 2024
1 parent 52a0f0d commit b294a18
Show file tree
Hide file tree
Showing 18 changed files with 1,125 additions and 10 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: see
Title: Model Visualisation Toolbox for 'easystats' and 'ggplot2'
Version: 0.8.5.5
Version: 0.8.5.6
Authors@R:
c(person(given = "Daniel",
family = "Lüdecke",
Expand Down
10 changes: 7 additions & 3 deletions R/plot.check_dag.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
#' `"all"`, `"current"` or `"required"`.
#' @param check_colliders Logical indicating whether to highlight colliders.
#' Set to `FALSE` if the algorithm to detect colliders is very slow.
#' @param ... Not used.
#' @param effect Character string indicating which effect for the required model
#' is to be estimated. Can be either `"total"` or `"direct"`.
#' @param ... Currently not used.
#'
#' @return A ggplot2-object.
#'
Expand Down Expand Up @@ -55,14 +57,16 @@ plot.see_check_dag <- function(x,
size_text = 4.5,
colors = NULL,
which = "all",
effect = "total",
check_colliders = TRUE,
...) {
.data <- NULL
insight::check_if_installed(c("ggdag", "ggplot2"))
which <- match.arg(which, choices = c("all", "current", "required"))
effect <- match.arg(effect, choices = c("total", "direct"))

# get plot data
p1 <- p2 <- suppressWarnings(ggdag::dag_adjustment_sets(x))
p1 <- p2 <- suppressWarnings(ggdag::dag_adjustment_sets(x, effect = effect))
adjusted_for <- attributes(x)$adjusted

# if we have multiple sets, we only need one for the current model
Expand Down Expand Up @@ -148,7 +152,7 @@ plot.see_check_dag <- function(x,
# plot2 - required model
plot2 <- ggplot2::ggplot(p2$data, ggplot2::aes(x = .data$x, y = .data$y)) +
common_layers +
ggplot2::ggtitle("Required model")
ggplot2::ggtitle(sprintf("Required model (%s effect)", effect))

# if we have multiple sets, we want to facet the second plot by sets
if (!is.null(p2$data$set) && insight::n_unique(p2$data$set) > 1) {
Expand Down
2 changes: 2 additions & 0 deletions inst/WORDLIST
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
Acyclic
BFs
BayesFactor
Biserial
Expand All @@ -6,6 +7,7 @@ Bluebrown
BossekJakob
CMD
Cai
DAGs
DOI
Dasgupta
Dom
Expand Down
6 changes: 5 additions & 1 deletion man/plot.see_check_dag.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit b294a18

Please sign in to comment.