Merge the levels of
moderators generated by
mod_levels()
into a data frame.
Arguments
- ...
The output from
mod_levels()
, or a list of levels generated bymod_levels_list()
.
Value
A wlevels
-class object,
which is a data frame of the
combinations of levels, with
additional attributes about the
levels.
Details
It merges the levels of
moderators generated by
mod_levels()
into a data frame,
with each row represents a
combination of the levels. The output
is to be used by
cond_indirect_effects()
.
Users usually do not need to use this
function because
cond_indirect_effects()
will merge
the levels internally if necessary.
This function is used when users need
to customize the levels for each
moderator and so cannot use
mod_levels_list()
or the default
levels in cond_indirect_effects()
.
See also
mod_levels()
on generating
the levels of a moderator.
Examples
data(data_med_mod_ab)
dat <- data_med_mod_ab
# Form the levels from a list of lm() outputs
lm_m <- lm(m ~ x*w1 + c1 + c2, dat)
lm_y <- lm(y ~ m*w2 + x + w1 + c1 + c2, dat)
lm_out <- lm2list(lm_m, lm_y)
w1_levels <- mod_levels(lm_out, w = "w1")
w1_levels
#> w1
#> M+1.0SD 6.173157
#> Mean 5.105602
#> M-1.0SD 4.038047
w2_levels <- mod_levels(lm_out, w = "w2")
w2_levels
#> w2
#> M+1.0SD 4.040487
#> Mean 3.047789
#> M-1.0SD 2.055091
merge_mod_levels(w1_levels, w2_levels)
#> w1 w2
#> w1: M+1.0SD; w2: M+1.0SD 6.173157 4.040487
#> w1: M+1.0SD; w2: Mean 6.173157 3.047789
#> w1: M+1.0SD; w2: M-1.0SD 6.173157 2.055091
#> w1: Mean; w2: M+1.0SD 5.105602 4.040487
#> w1: Mean; w2: Mean 5.105602 3.047789
#> w1: Mean; w2: M-1.0SD 5.105602 2.055091
#> w1: M-1.0SD; w2: M+1.0SD 4.038047 4.040487
#> w1: M-1.0SD; w2: Mean 4.038047 3.047789
#> w1: M-1.0SD; w2: M-1.0SD 4.038047 2.055091