From 945e7d7953e63521fafe7241dcbb4d72740255cd Mon Sep 17 00:00:00 2001 From: Shu Fai Cheung Date: Sat, 28 Sep 2024 12:32:51 +0800 Subject: [PATCH 1/3] Alert users that cols and rows are limited to one variable --- R/plotmod.R | 6 ++++++ tests/testthat/test_plot_cond_indirect_effects_2ws.R | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/R/plotmod.R b/R/plotmod.R index c1e2bed6..0632ba59 100644 --- a/R/plotmod.R +++ b/R/plotmod.R @@ -612,11 +612,17 @@ plot.cond_indirect_effects <- function( if (!all(facet_grid_cols %in% w_names)) { stop("'facet_grid_cols' must be among the moderators.") } + if (length(facet_grid_cols) != 1) { + stop("Having more than one column in facet_grid is not yet supported.") + } } if (!is.null(facet_grid_rows)) { if (!all(facet_grid_rows %in% w_names)) { stop("'facet_grid_rows' must be among the moderators.") } + if (length(facet_grid_rows) != 1) { + stop("Having more than one row in facet_grid is not yet supported.") + } } w_names_in <- setdiff(w_names, union(facet_grid_cols, facet_grid_rows)) if (length(w_names_in) == 0) { diff --git a/tests/testthat/test_plot_cond_indirect_effects_2ws.R b/tests/testthat/test_plot_cond_indirect_effects_2ws.R index cfa05766..400b92f6 100644 --- a/tests/testthat/test_plot_cond_indirect_effects_2ws.R +++ b/tests/testthat/test_plot_cond_indirect_effects_2ws.R @@ -51,3 +51,8 @@ test_that("Three moderators", { expect_no_error(plot(out_1, graph_type = "tumble", facet_grid_rows = "gp", facet_grid_cols = "w4")) expect_no_error(plot(out_1, graph_type = "tumble", facet_grid_rows = "w4", facet_grid_cols = "city")) }) + +test_that("Three moderators", { + expect_error(plot(out_1, facet_grid_cols = c("gp", "w4"))) + expect_error(plot(out_1, facet_grid_rows = c("gp", "w4"))) +}) From a50f34b10a1513564c26cd68c38bc77abdf93fb6 Mon Sep 17 00:00:00 2001 From: Shu Fai Cheung Date: Sat, 28 Sep 2024 12:33:03 +0800 Subject: [PATCH 2/3] Update README on limitation --- NEWS.md | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/NEWS.md b/NEWS.md index 6c6fbf04..1043510a 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# manymome 0.2.3.5 +# manymome 0.2.3.7 ## New Features @@ -7,7 +7,7 @@ using `facet_grid()` to plot the conditional effects when there are two or more moderators in a path. - (0.2.3.3, 0.2.3.5) + (0.2.3.3, 0.2.3.5, 0.2.3.6) ## Improvement @@ -28,6 +28,13 @@ such as when computing effects in a moderation-only model. (0.2.3.4) +## Documentation + +- Corrected `README` to remark that + dichotomous `x`-variables are supported + by most functions if coded as a + numeric dummy variable. (0.2.3.7) + ## Bug Fixes - Fixed an issue related to From 89d8e88b76da4ef9a282c2cd415b3ea08179cf2f Mon Sep 17 00:00:00 2001 From: Shu Fai Cheung Date: Sat, 28 Sep 2024 12:33:28 +0800 Subject: [PATCH 3/3] Update to 0.2.3.7 --- DESCRIPTION | 2 +- README.md | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index aa385e24..96e45422 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: manymome Title: Mediation, Moderation and Moderated-Mediation After Model Fitting -Version: 0.2.3.5 +Version: 0.2.3.7 Authors@R: c(person(given = "Shu Fai", family = "Cheung", diff --git a/README.md b/README.md index 196998f7..4cd5089a 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ [![R-CMD-check](https://github.com/sfcheung/manymome/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/sfcheung/manymome/actions/workflows/R-CMD-check.yaml) -(Version 0.2.3.5, updated on 2024-09-28, [release history](https://sfcheung.github.io/manymome/news/index.html)) +(Version 0.2.3.7, updated on 2024-09-28, [release history](https://sfcheung.github.io/manymome/news/index.html)) # manymome @@ -129,7 +129,15 @@ by multiple regression. The package was introduced in: Despite the aforementioned advantages, the current version of `manymome` has the following limitations: -- Does not (officially) support categorical predictors. +- Does not (officially) support + categorical `x`-variables with more + than two categories. Note that most + functions will work with dichotomous + `x`-variables, and the effect of `x` + is simply the difference in predicted + `y` between the two levels if coded as + 0 and 1 (or any coding with a + difference of 1, e.g., 1 and 2). - Does not support multilevel models (although `lavaan` does).