to_latex {robmedExtra}R Documentation

'LaTeX' table of results from (robust) mediation analysis

Description

Generate LaTeX code for a tabular summary of results from (robust) mediation analysis in the form of a tabular environment. This tabular environment can easily be integrated into a dynamic LaTeX document with tools such as package knitr, which eliminates the risk of mistakes in reporting that stem from copying-and-pasting results. Note that to_latex() itself does not actually produce any LaTeX code, it is the print() method of the resulting object that prints the code for the tabular environment.

Usage

to_latex(object, ...)

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

## S3 method for class 'summary_test_mediation'
to_latex(object, p_value = FALSE, align = c("lrrrr", "c"), ...)

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

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 LaTeX table, 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.

align

a character vector of length two. The first element is used as the alignment specification in the \begin{tabular}{} statement, while the second element is used for the alignment specification in \multicolumn{}{}{} statements in case of bootstrapped confidence intervals of the indirect effect. For the former, note that if object is a list of objects and orientation is "landscape", two empty columns are inserted in the LaTeX table. It is not recommended to set this argument unless you know what you are doing.

orientation

a character string specifying how to arrange the results from different objects (list elements) in the LaTeX table. 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 (or LaTeX table environments such as sidewaystable). 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_latex_tables" with the following components:

labels

a character string giving the labels to be used in the LaTeX table (only returned if a list of objects is supplied).

total

a data frame containing a tabular summary of the total effects, or a list of such data frames.

direct

a data frame containing a tabular summary of the direct effects, or a list of such data frames.

indirect

a data frame containing a tabular summary of the indirect effects, or a list of such data frames.

x, m, y, covariates

character vectors specifying the respective variables used.

n

a character string containing the (formatted) sample size.

R

a character string containing the (formatted) number of bootstrap samples (only returned if applicable).

orientation

a character string specifying how to arrange the results from different objects in the LaTeX table (only returned if a list of objects is supplied).

align

a character vector of length two. The first element gives the alignment specification to be used in the \begin{tabular}{} statement, while the second element gives the alignment specification to be used in \multicolumn{}{}{} statements for any bootstrapped confidence intervals of the indirect effect.

Note

The print() method for class "mediation_latex_tables" prints the LaTeX code for the tabular environment. It ignores any additional arguments, and it returns the supplied object invisibly.

Author(s)

Andreas Alfons

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()

to_flextable()

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 LaTeX table of results
to_latex(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 LaTeX table of results from both procedures
boot_list <- list(ols_boot, robust_boot)
to_latex(boot_list)

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


[Package robmedExtra version 0.1.0 Index]