to_flextable {robmedExtra}R Documentation

Tabular summary of results from (robust) mediation analysis

Description

Convert results from (robust) mediation analysis to a tabular summary in the form of a flextable. This flextable can easily be exported to Microsoft Word or Microsoft Powerpoint, or integrated into a dynamic Markdown document. This eliminates the risk of mistakes in reporting that stem from copying-and-pasting results.

Usage

to_flextable(object, ...)

## S3 method for class 'test_mediation'
to_flextable(object, type = c("boot", "data"), ...)

## S3 method for class 'summary_test_mediation'
to_flextable(object, p_value = FALSE, ...)

## S3 method for class 'list'
to_flextable(
  object,
  type = c("boot", "data"),
  p_value = FALSE,
  orientation = c("landscape", "portrait"),
  ...
)

Arguments

object

an object inheriting from class "test_mediation" or "summary_test_mediation" containing results from (robust) mediation analysis, or a list of such objects (typically obtained via different procedures for mediation analysis). In case of a named list, the supplied names are used as labels in the resulting flextable, otherwise default labels are constructed based on how the mediation model was fitted and which type of test was used (e.g., "ROBMED" or "OLS Bootstrap").

...

additional arguments to be passed down, eventually to formatC() for formatting numbers. In particular, argument digits can be used to customize the number of digits after the decimal point (defaults to 3). Also note that argument big.mark is ignored for the numbers in the table; it is only used for formatting the sample size and (if applicable) the number of bootstrap samples in the table note.

type

a character string specifying which estimates and significance tests to report if mediation analysis was done via a bootstrap procedure. If "boot" (the default), the means of the bootstrap replicates are reported as point estimates for all effects, and significance tests for the total and direct effects use the normal approximation of the bootstrap distribution (i.e., the tests assume a normal distribution of the corresponding effect with the standard deviation computed from the bootstrap replicates). If "data", the point estimates on the original data are reported for all effects, and the significance tests for the total and direct effects are based on statistical theory (e.g., t-tests if the coefficients are estimated via regression). Note that for bootstrap procedures, significance of the indirect effect is always reported via a percentile-based confidence interval due to the asymmetry of its distribution.

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 FALSE). If TRUE, the p-values are obtained via p_value() and may take some time to compute.

orientation

a character string specifying how to arrange the results from different objects (list elements) in the flextable. If "landscape" (the default), results from two objects are arranged next to each other with the results from remaining objects underneath (in groups of two), which is intended for documents in landscape mode. If "portrait", results from different objects are arranged underneath one another, which is intended for documents in portrait mode.

Value

An object of class "mediation_flextable", which inherits from class "flextable".

Note

Numbers are not formatted via flextable defaults (see set_flextable_defaults()), but instead via formatC(). This is done to ensure consistency in number formatting between functions to_flextable() and to_latex().

Author(s)

Andreas Alfons, based on code by Vincent Drenth

References

Alfons, A., Ates, N.Y. and Groenen, P.J.F. (2022a) A Robust Bootstrap Test for Mediation Analysis. Organizational Research Methods, 25(3), 591–617. doi:10.1177/1094428121999096.

Alfons, A., Ates, N.Y. and 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.

See Also

test_mediation(), summary()

export_docx(), export_pptx()

to_latex()

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)

# construct flextable of results
to_flextable(robust_boot)

# perform mediation analysis via the OLS bootstrap
set.seed(seed)
ols_boot <- test_mediation(BSG2014,
                           x = "ValueDiversity",
                           y = "TeamCommitment",
                           m = "TaskConflict",
                           robust = FALSE)

# construct flextable of results from both procedures
boot_list <- list(ols_boot, robust_boot)
to_flextable(boot_list)

# customize labels for procedures and number of digits
boot_list_named <- list("Non-robust" = ols_boot,
                        "Robust" = robust_boot)
to_flextable(boot_list_named, digits = 4)


[Package robmedExtra version 0.1.0 Index]