Convert an 'cond_indirect_effects' Object to a 'flextable' Object
Source:R/as_flextable.cond_indirect_effects.R
as_flextable.cond_indirect_effects.Rd
The 'as_flextable' method for the output of 'manymome::many_indirect_effects()'.
Usage
# S3 method for cond_indirect_effects
as_flextable(
x,
pvalue = FALSE,
se = TRUE,
var_labels = NULL,
digits = 2,
pval_digits = 3,
use_arrow = TRUE,
indirect_raw = TRUE,
indirect_raw_ci = indirect_raw,
indirect_raw_se = indirect_raw,
footnote = TRUE,
show_wvalues = TRUE,
show_indicators = FALSE,
show_path = TRUE,
pcut = 0.001,
...
)
Arguments
- x
The object to be converted. Should be of the class
cond_indirect_effects
from the packagemanymome
.- pvalue
If bootstrap confidence intervals are stored, whether asymmetric p-values are reported. Default is
FALSE
. Seemanymome::print.cond_indirect_effects()
for the computational details.- se
Whether standard errors are reported if confidence intervals are stored. Default is
TRUE
. Seemanymome::print.cond_indirect_effects()
for the computation details.- var_labels
A named vectors. Used to replace variable names by other names when generating the table. For example,
c(x = "I.V", y = "D.V.")
replacesx
by"I.V"
andy
by"D.V."
in the output.- digits
The number of digits to be displayed for most numerical columns, such as effect estimates, standard errors, and confidence intervals. Default is 2.
- pval_digits
The number of digits to be displayed for the p-value column, if present. Default is 3.
- use_arrow
If
TRUE
, the default, use the arrow symbol in the paths.- indirect_raw
If
TRUE
, the default, report unstandardized effects even if standardization was done.- indirect_raw_ci
If
TRUE
, report the confidence intervals of unstandardized effects even if standardization was done and confidence intervals were stored. Default to be equal toindirect_raw
. NOTE: Not used for now. AlwaysFALSE
.- indirect_raw_se
If
TRUE
, report the standard errors of unstandardized effects even if standardization was done and confidence intervals were stored. Default to be equal toindirect_raw
. NOTE: Not used for now. AlwaysFALSE
.- footnote
If
TRUE
, the default, add footnote(s) regarding the results to the bottom of the table.- show_wvalues
Whether the values of moderators will be shown. If
FALSE
, no values will be shown, even for categorical moderators. Default isTRUE
.- show_indicators
Whether the values of indicators (dummy variables) will be shown for categorical moderators. Default is
FALSE
.- show_path
Whether the paths being moderated will be displayed. Default is
TRUE
.- pcut
Any p-value less than
pcut
will be displayed as<[pcut]
,"[pcut]"
replaced by the value ofpcut
. Default is .001.- ...
Additional arguments. Ignored.
Details
It converts an cond_indirect_effects
object,
which is usually created by
manymome::cond_indirect_effects()
,
to a flextable
object. The output
can be further modified by functions
from the flextable
package.
Examples
library(manymome)
library(flextable)
# List of indirect effects
dat <- data_med_mod_a
lm_m <- lm(m ~ x*w + c1 + c2, dat)
lm_y <- lm(y ~ m + x + c1 + c2, dat)
fit_lm <- lm2list(lm_m, lm_y)
# Should set R to 5000 or 10000 in real research
boot_out_lm <- do_boot(fit_lm,
R = 100,
seed = 54532,
parallel = FALSE,
progress = FALSE)
out_xmy_on_w <- cond_indirect_effects(wlevels = "w",
x = "x",
y = "y",
m = "m",
fit = fit_lm,
boot_ci = TRUE,
boot_out = boot_out_lm)
std_xmy_on_w <- cond_indirect_effects(wlevels = "w",
x = "x",
y = "y",
m = "m",
fit = fit_lm,
boot_ci = TRUE,
boot_out = boot_out_lm,
standardized_x = TRUE,
standardized_y = TRUE)
ft1 <- as_flextable(out_xmy_on_w,
var_labels = c(w = "Moderator"))
ft1
Path: x → m → y
[Moderator]
(Moderator)
Effect
95% CI
SE
M+1.0SD
3.16
3.06
[2.17
, 4.04]
0.46
Mean
2.18
2.14
[1.41
, 2.93]
0.36
M-1.0SD
1.19
1.21
[-0.29
, 2.56]
0.59
Note: [w] is the meaning of a level of moderator 'w'; (w) is the value of a level of moderator 'w': CI = confidence interval.
ft2 <- as_flextable(std_xmy_on_w,
var_labels = c(w = "Moderator"),
se = FALSE,
digits = 3)
ft2
Path: x → m → y
[Moderator]
(Moderator)
Effect
Std. Effect
95% CI
M+1.0SD
3.164
3.060
0.318
[0.220
, 0.437]
Mean
2.179
2.136
0.222
[0.134
, 0.309]
M-1.0SD
1.194
1.212
0.126
[-0.031
, 0.260]
Note: [w] is the meaning of a level of moderator 'w'; (w) is the value of a level of moderator 'w': CI = confidence interval; Std. Effect is completely standardized effect.