modmed_marginal_graph: Create a marginal effect plot for the selected moderated...

Description Usage Arguments Value See Also Examples

View source: R/modmed_marginal_graph.R

Description

Create a marginal effect plot for the selected moderated relationship or path.

Usage

1
2
modmed_marginal_graph(marginal_effect = NULL, x = NA, m = NA, y = NA,
  z = NA, mod_level = c("Low value", "High value"))

Arguments

marginal_effect

Tibble. Table containing the bootstraped coefficients and intervals of the paths.

x

Character string. Name of the independent variable.

m

Character string. Name of the mediating variable (if NA, the direct relationship is reported; if "all", the total effect is reported; if specified, the mediation is reported).

y

Character string. Name of the dependent variable.

z

Character string. Name of the moderating variable.

mod_level

Character vector. Specify the labels for the low and high values of the moderator (used only if the moderator dichotomous).

Value

A ggplot graph of the marginal effect of an independent variable on a dependent variable for all values of the moderating variable.

See Also

modmed()

modmed_marginal_effect()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
library(modelest)
data("edwards2007")
dataset <- edwards2007
draws = 10
x <- "fbkc"
m <- "satc"
y <- "comc"
z <- "cenc"
mm <- modmed(dataset = dataset,
             draws = draws,
             x = x,
             m = m,
             y = y,
             z = z,
             ctrl_s1 = NA,
             ctrl_s2 = NA,
             inst_x = NA,
             inst_m = NA,
             model = "DFS",
             method = "OLS")
# Prepare 2 hypothetical values of the moderator
mod_values <- dataset[[z]]
# Compute the simple paths for the selected values of the moderator
marginal_effect <- modmed_marginal_effect(
  coefficients = mm$coefficients,
    x = x,
    m = m,
    y = y,
    mod_values = mod_values
 )
# Create the marginal effect plot
modmed_marginal_graph(marginal_effect = marginal_effect,
                      x = x,
                      m = m,
                      y = y,
                      z = z)

NicolasJBM/model documentation built on Feb. 15, 2018, 11:12 p.m.