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
|
... |
additional arguments to be passed down, eventually to
|
type |
a character string specifying which estimates and significance
tests to report if mediation analysis was done via a bootstrap procedure.
If |
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 |
align |
a character vector of length two. The first element is used
as the alignment specification in the |
orientation |
a character string specifying how to arrange the results
from different objects (list elements) in the LaTeX table. If
|
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 |
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()
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)