diff --git a/DESCRIPTION b/DESCRIPTION index cc972ad..e617c01 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Package: robmedExtra Type: Package Title: Extra Functionality for (Robust) Mediation Analysis -Version: 0.1.2 -Date: 2024-11-02 +Version: 0.1.1 +Date: 2024-11-03 Depends: robmed (>= 0.10.0) Imports: diff --git a/NEWS b/NEWS new file mode 100644 index 0000000..3c51426 --- /dev/null +++ b/NEWS @@ -0,0 +1,7 @@ +Changes in robmed version 0.1.1 + + + Added note in GUI that the resolution of the preview doesn't reflect the selected resolution for the png file. + + + Default in tables is now to include p values of the indirect effects. + + + Updated examples in help files. diff --git a/R/export_docx.R b/R/export_docx.R index 9ffb5d0..fe194c4 100644 --- a/R/export_docx.R +++ b/R/export_docx.R @@ -47,19 +47,18 @@ #' @examples #' data("BSG2014") #' -#' # seed to be used for the random number generator -#' seed <- 20211117 -#' #' # perform mediation analysis via robust bootstrap test ROBMED -#' set.seed(seed) -#' robust_boot <- test_mediation(BSG2014, -#' x = "ValueDiversity", -#' y = "TeamCommitment", -#' m = "TaskConflict", -#' robust = TRUE) +#' set.seed(20241101) +#' boot <- test_mediation(BSG2014, +#' x = "SharedLeadership", +#' y = "TeamPerformance", +#' m = c("ProceduralJustice", +#' "InteractionalJustice"), +#' covariates = c("AgeDiversity", +#' "GenderDiversity")) #' #' # construct flextable of results -#' ft <- to_flextable(robust_boot) +#' ft <- to_flextable(boot) #' #' # export to Microsoft Word #' file_name <- tempfile(fileext = ".docx") diff --git a/R/export_pptx.R b/R/export_pptx.R index 8c90666..7b093ab 100644 --- a/R/export_pptx.R +++ b/R/export_pptx.R @@ -41,19 +41,18 @@ #' @examples #' data("BSG2014") #' -#' # seed to be used for the random number generator -#' seed <- 20211117 -#' #' # perform mediation analysis via robust bootstrap test ROBMED -#' set.seed(seed) -#' robust_boot <- test_mediation(BSG2014, -#' x = "ValueDiversity", -#' y = "TeamCommitment", -#' m = "TaskConflict", -#' robust = TRUE) +#' set.seed(20241101) +#' boot <- test_mediation(BSG2014, +#' x = "SharedLeadership", +#' y = "TeamPerformance", +#' m = c("ProceduralJustice", +#' "InteractionalJustice"), +#' covariates = c("AgeDiversity", +#' "GenderDiversity")) #' #' # construct flextable of results -#' ft <- to_flextable(robust_boot) +#' ft <- to_flextable(boot) #' #' # export to Microsoft Powerpoint #' file_name <- tempfile(fileext = ".pptx") diff --git a/R/to_flextable.R b/R/to_flextable.R index 40d7ce3..c1a1f47 100644 --- a/R/to_flextable.R +++ b/R/to_flextable.R @@ -68,7 +68,7 @@ #' data("BSG2014") #' #' # seed to be used for the random number generator -#' seed <- 20211117 +#' seed <- 20150601 #' #' # perform mediation analysis via robust bootstrap test ROBMED #' set.seed(seed) @@ -78,6 +78,10 @@ #' m = "TaskConflict", #' robust = TRUE) #' +#' # note that depending on the seed of the random number +#' # generator, the p value of the indirect effect may fall +#' # below or above the arbitrary 5% threshold +#' #' # construct flextable of results #' to_flextable(robust_boot) #' @@ -133,13 +137,13 @@ to_flextable.test_mediation <- function(object, type = c("boot", "data"), ...) { #' @name to_flextable #' #' @param p_value a logical indicating whether to include p-values for the -#' indirect effects if mediation analysis was done via a bootstrap procedure -#' (defaults to \code{FALSE}). If \code{TRUE}, the p-values are obtained via +#' indirect effects if mediation analysis was done via a bootstrap procedure. +#' If \code{TRUE} (the default), the p-values are obtained via #' \code{\link[robmed]{p_value}()}. #' #' @export -to_flextable.summary_test_mediation <- function(object, p_value = FALSE, ...) { +to_flextable.summary_test_mediation <- function(object, p_value = TRUE, ...) { # call workhorse function to format tables for effects tables <- get_mediation_tables(object, p_value = p_value, ...) # put data frames of effects together @@ -163,7 +167,7 @@ to_flextable.summary_test_mediation <- function(object, p_value = FALSE, ...) { #' #' @export -to_flextable.list <- function(object, type = c("boot", "data"), p_value = FALSE, +to_flextable.list <- function(object, type = c("boot", "data"), p_value = TRUE, orientation = c("landscape", "portrait"), ...) { # check arguments @@ -293,22 +297,21 @@ to_flextable.list <- function(object, type = c("boot", "data"), p_value = FALSE, #' @examples #' data("BSG2014") #' -#' # seed to be used for the random number generator -#' seed <- 20211117 -#' #' # perform mediation analysis via robust bootstrap test ROBMED -#' set.seed(seed) -#' robust_boot <- test_mediation(BSG2014, -#' x = "ValueDiversity", -#' y = "TeamCommitment", -#' m = "TaskConflict", -#' robust = TRUE) +#' set.seed(20150601) +#' boot <- test_mediation(BSG2014, +#' x = "ValueDiversity", +#' y = "TeamCommitment", +#' m = "TaskConflict") #' #' # construct flextable of results -#' ft <- to_flextable(robust_boot) +#' ft <- to_flextable(boot) #' # add additional row to the footer -#' footer_line <- paste("Additional explanations on the conducted", -#' "analysis.") +#' footer_line <- flextable::as_paragraph( +#' "Depending on the seed of the random number generator, the ", +#' flextable::as_i("p"), " value of the indirect effect may ", +#' "fall below or above the arbitrary 5% threshold." +#' ) #' ft <- flextable::add_footer_lines(ft, values = footer_line) #' ft <- theme_mediation(ft) #' ft diff --git a/R/to_latex.R b/R/to_latex.R index 8096da5..768d462 100644 --- a/R/to_latex.R +++ b/R/to_latex.R @@ -87,7 +87,7 @@ #' data("BSG2014") #' #' # seed to be used for the random number generator -#' seed <- 20211117 +#' seed <- 20150601 #' #' # perform mediation analysis via robust bootstrap test ROBMED #' set.seed(seed) @@ -97,6 +97,10 @@ #' m = "TaskConflict", #' robust = TRUE) #' +#' # note that depending on the seed of the random number +#' # generator, the p value of the indirect effect may fall +#' # below or above the arbitrary 5% threshold +#' #' # construct LaTeX table of results #' to_latex(robust_boot) #' @@ -152,8 +156,8 @@ to_latex.test_mediation <- function(object, type = c("boot", "data"), ...) { #' @name to_latex #' #' @param p_value a logical indicating whether to include p-values for the -#' indirect effects if mediation analysis was done via a bootstrap procedure -#' (defaults to \code{FALSE}). If \code{TRUE}, the p-values are obtained via +#' indirect effects if mediation analysis was done via a bootstrap procedure. +#' If \code{TRUE} (the default), the p-values are obtained via #' \code{\link[robmed]{p_value}()}. #' @param align a character vector of length two. The first element is used #' as the alignment specification in the \code{\\begin\{tabular\}\{\}} @@ -167,7 +171,7 @@ to_latex.test_mediation <- function(object, type = c("boot", "data"), ...) { #' #' @export -to_latex.summary_test_mediation <- function(object, p_value = FALSE, +to_latex.summary_test_mediation <- function(object, p_value = TRUE, align = c("lrrrr", "c"), ...) { # TODO: add checks for argument 'align' @@ -194,7 +198,7 @@ to_latex.summary_test_mediation <- function(object, p_value = FALSE, #' #' @export -to_latex.list <- function(object, type = c("boot", "data"), p_value = FALSE, +to_latex.list <- function(object, type = c("boot", "data"), p_value = TRUE, orientation = c("landscape", "portrait"), align = NULL, ...) { # check argument for orientation diff --git a/README.md b/README.md index 3cb4ae9..44a996c 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ To cite packages `robmed` and `robmedExtra` in publications, please use: Alfons, A., Ates, N.Y., & Groenen, P.J.F. (2022b). Robust Mediation Analysis: The `R` Package `robmed`. *Journal of Statistical Software*, **103**(13), 1--45. doi: [10.18637/jss.v103.i13](https://doi.org/10.18637/jss.v103.i13). -Alfons A., Archimbaud A., & Drenth V. (2023). *`robmedExtra`: Extra Functionality for (Robust) Mediation Analysis*. `R` package, . +Alfons A., & Archimbaud A. (2024). *`robmedExtra`: Extra Functionality for (Robust) Mediation Analysis*. `R` package, . ## About ROBMED diff --git a/man/export_docx.Rd b/man/export_docx.Rd index b06e3a5..4fb9536 100644 --- a/man/export_docx.Rd +++ b/man/export_docx.Rd @@ -49,19 +49,18 @@ orientation. \examples{ data("BSG2014") -# seed to be used for the random number generator -seed <- 20211117 - # perform mediation analysis via robust bootstrap test ROBMED -set.seed(seed) -robust_boot <- test_mediation(BSG2014, - x = "ValueDiversity", - y = "TeamCommitment", - m = "TaskConflict", - robust = TRUE) +set.seed(20241101) +boot <- test_mediation(BSG2014, + x = "SharedLeadership", + y = "TeamPerformance", + m = c("ProceduralJustice", + "InteractionalJustice"), + covariates = c("AgeDiversity", + "GenderDiversity")) # construct flextable of results -ft <- to_flextable(robust_boot) +ft <- to_flextable(boot) # export to Microsoft Word file_name <- tempfile(fileext = ".docx") diff --git a/man/export_pptx.Rd b/man/export_pptx.Rd index 65f81c8..20267d5 100644 --- a/man/export_pptx.Rd +++ b/man/export_pptx.Rd @@ -42,19 +42,18 @@ mediation analysis. It is essentially a wrapper for \examples{ data("BSG2014") -# seed to be used for the random number generator -seed <- 20211117 - # perform mediation analysis via robust bootstrap test ROBMED -set.seed(seed) -robust_boot <- test_mediation(BSG2014, - x = "ValueDiversity", - y = "TeamCommitment", - m = "TaskConflict", - robust = TRUE) +set.seed(20241101) +boot <- test_mediation(BSG2014, + x = "SharedLeadership", + y = "TeamPerformance", + m = c("ProceduralJustice", + "InteractionalJustice"), + covariates = c("AgeDiversity", + "GenderDiversity")) # construct flextable of results -ft <- to_flextable(robust_boot) +ft <- to_flextable(boot) # export to Microsoft Powerpoint file_name <- tempfile(fileext = ".pptx") diff --git a/man/theme_mediation.Rd b/man/theme_mediation.Rd index 0b3770e..89692ba 100644 --- a/man/theme_mediation.Rd +++ b/man/theme_mediation.Rd @@ -36,22 +36,21 @@ the table have been added (e.g., additional header or footer rows). \examples{ data("BSG2014") -# seed to be used for the random number generator -seed <- 20211117 - # perform mediation analysis via robust bootstrap test ROBMED -set.seed(seed) -robust_boot <- test_mediation(BSG2014, - x = "ValueDiversity", - y = "TeamCommitment", - m = "TaskConflict", - robust = TRUE) +set.seed(20150601) +boot <- test_mediation(BSG2014, + x = "ValueDiversity", + y = "TeamCommitment", + m = "TaskConflict") # construct flextable of results -ft <- to_flextable(robust_boot) +ft <- to_flextable(boot) # add additional row to the footer -footer_line <- paste("Additional explanations on the conducted", - "analysis.") +footer_line <- flextable::as_paragraph( + "Depending on the seed of the random number generator, the ", + flextable::as_i("p"), " value of the indirect effect may ", + "fall below or above the arbitrary 5\% threshold." +) ft <- flextable::add_footer_lines(ft, values = footer_line) ft <- theme_mediation(ft) ft diff --git a/man/to_flextable.Rd b/man/to_flextable.Rd index 33ed015..b3550d6 100644 --- a/man/to_flextable.Rd +++ b/man/to_flextable.Rd @@ -11,12 +11,12 @@ to_flextable(object, ...) \method{to_flextable}{test_mediation}(object, type = c("boot", "data"), ...) -\method{to_flextable}{summary_test_mediation}(object, p_value = FALSE, ...) +\method{to_flextable}{summary_test_mediation}(object, p_value = TRUE, ...) \method{to_flextable}{list}( object, type = c("boot", "data"), - p_value = FALSE, + p_value = TRUE, orientation = c("landscape", "portrait"), ... ) @@ -56,8 +56,8 @@ percentile-based confidence interval due to the asymmetry of its distribution.} \item{p_value}{a logical indicating whether to include p-values for the -indirect effects if mediation analysis was done via a bootstrap procedure -(defaults to \code{FALSE}). If \code{TRUE}, the p-values are obtained via +indirect effects if mediation analysis was done via a bootstrap procedure. +If \code{TRUE} (the default), the p-values are obtained via \code{\link[robmed]{p_value}()}.} \item{orientation}{a character string specifying how to arrange the results @@ -91,7 +91,7 @@ number formatting between functions \code{to_flextable()} and data("BSG2014") # seed to be used for the random number generator -seed <- 20211117 +seed <- 20150601 # perform mediation analysis via robust bootstrap test ROBMED set.seed(seed) @@ -101,6 +101,10 @@ robust_boot <- test_mediation(BSG2014, m = "TaskConflict", robust = TRUE) +# note that depending on the seed of the random number +# generator, the p value of the indirect effect may fall +# below or above the arbitrary 5\% threshold + # construct flextable of results to_flextable(robust_boot) diff --git a/man/to_latex.Rd b/man/to_latex.Rd index 7ace819..6d17df5 100644 --- a/man/to_latex.Rd +++ b/man/to_latex.Rd @@ -11,12 +11,12 @@ to_latex(object, ...) \method{to_latex}{test_mediation}(object, type = c("boot", "data"), ...) -\method{to_latex}{summary_test_mediation}(object, p_value = FALSE, align = c("lrrrr", "c"), ...) +\method{to_latex}{summary_test_mediation}(object, p_value = TRUE, align = c("lrrrr", "c"), ...) \method{to_latex}{list}( object, type = c("boot", "data"), - p_value = FALSE, + p_value = TRUE, orientation = c("landscape", "portrait"), align = NULL, ... @@ -57,8 +57,8 @@ percentile-based confidence interval due to the asymmetry of its distribution.} \item{p_value}{a logical indicating whether to include p-values for the -indirect effects if mediation analysis was done via a bootstrap procedure -(defaults to \code{FALSE}). If \code{TRUE}, the p-values are obtained via +indirect effects if mediation analysis was done via a bootstrap procedure. +If \code{TRUE} (the default), the p-values are obtained via \code{\link[robmed]{p_value}()}.} \item{align}{a character vector of length two. The first element is used @@ -125,7 +125,7 @@ any additional arguments, and it returns the supplied object invisibly. data("BSG2014") # seed to be used for the random number generator -seed <- 20211117 +seed <- 20150601 # perform mediation analysis via robust bootstrap test ROBMED set.seed(seed) @@ -135,6 +135,10 @@ robust_boot <- test_mediation(BSG2014, m = "TaskConflict", robust = TRUE) +# note that depending on the seed of the random number +# generator, the p value of the indirect effect may fall +# below or above the arbitrary 5\% threshold + # construct LaTeX table of results to_latex(robust_boot)