dot_graph: Generate a dot graph from various SEMinR models

Description Usage Arguments Details Value Examples

View source: R/plot_dot.R

Description

With the help of the DiagrammeR package this dot graph can then be plotted in various in RMarkdown, shiny, and other contexts. Depending on the type of model, different parameters can be used.

For a full description of parameters for lavaan models see semPaths method in the semPlot package.

Usage

 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
dot_graph(model, title = "", theme = NULL, ...)

## S3 method for class 'cfa_model'
dot_graph(
  model,
  title = "",
  theme = NULL,
  what = "std",
  whatLabels = "std",
  ...
)

## S3 method for class 'cbsem_model'
dot_graph(
  model,
  title = "",
  theme = NULL,
  what = "std",
  whatLabels = "std",
  ...
)

## S3 method for class 'measurement_model'
dot_graph(model, title = "", theme = NULL, ...)

## S3 method for class 'structural_model'
dot_graph(model, title = "", theme = NULL, ...)

## S3 method for class 'specified_model'
dot_graph(
  model,
  title = "",
  theme = NULL,
  measurement_only = FALSE,
  structure_only = FALSE,
  ...
)

## S3 method for class 'boot_seminr_model'
dot_graph(
  model,
  title = "",
  theme = NULL,
  measurement_only = FALSE,
  structure_only = FALSE,
  ...
)

## S3 method for class 'pls_model'
dot_graph(
  model,
  title = "",
  theme = NULL,
  measurement_only = FALSE,
  structure_only = FALSE,
  ...
)

Arguments

model

Model created with seminr.

title

An optional title for the plot

theme

Theme created with seminr_theme_create.

...

Unused

what

The metric to use for edges ("path", "est", "std", "eq", "col")

whatLabels

The metric to use for edge labels

measurement_only

Plot only measurement part

structure_only

Plot only structure part

Details

Current limitations: - Only plots PLS Models - no higher order constructs

Value

The path model as a formatted string in dot language.

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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
mobi <- mobi

#seminr syntax for creating measurement model
mobi_mm <- constructs(
             reflective("Image",        multi_items("IMAG", 1:5)),
             reflective("Expectation",  multi_items("CUEX", 1:3)),
             reflective("Quality",      multi_items("PERQ", 1:7)),
             reflective("Value",        multi_items("PERV", 1:2)),
             reflective("Satisfaction", multi_items("CUSA", 1:3)),
             reflective("Complaints",   single_item("CUSCO")),
             reflective("Loyalty",      multi_items("CUSL", 1:3))
           )
#seminr syntax for creating structural model
mobi_sm <- relationships(
  paths(from = "Image",        to = c("Expectation", "Satisfaction", "Loyalty")),
  paths(from = "Expectation",  to = c("Quality", "Value", "Satisfaction")),
  paths(from = "Quality",      to = c("Value", "Satisfaction")),
  paths(from = "Value",        to = c("Satisfaction")),
  paths(from = "Satisfaction", to = c("Complaints", "Loyalty")),
  paths(from = "Complaints",   to = "Loyalty")
)

mobi_pls <- estimate_pls(data = mobi,
                         measurement_model = mobi_mm,
                         structural_model = mobi_sm)

# adapt nboot for better results
mobi_boot <- bootstrap_model(mobi_pls, nboot = 20, cores = 1)
# generate dot-Notation
res <- dot_graph(mobi_pls, title = "PLS-Model plot")

## Not run: 
DiagrammeR::grViz(res)
## End(Not run)

# generate dot-Notation
res <- dot_graph(mobi_boot, title = "Bootstrapped PLS-Model plot")

## Not run: 
DiagrammeR::grViz(res)
## End(Not run)

# - - - - - - - - - - - - - - - -
# Example for plotting a measurement model
mobi_mm <- constructs(
             reflective("Image",        multi_items("IMAG", 1:5)),
             reflective("Expectation",  multi_items("CUEX", 1:3)),
             reflective("Quality",      multi_items("PERQ", 1:7)),
             reflective("Value",        multi_items("PERV", 1:2)),
             reflective("Satisfaction", multi_items("CUSA", 1:3)),
             reflective("Complaints",   single_item("CUSCO")),
             reflective("Loyalty",      multi_items("CUSL", 1:3))
           )
dot_graph(mobi_mm, title = "Preview measurement model")
# - - - - - - - - - - - - - - - -
# Example for plotting a structural model
mobi_sm <- relationships(
  paths(from = "Image",        to = c("Expectation", "Satisfaction", "Loyalty")),
  paths(from = "Expectation",  to = c("Quality", "Value", "Satisfaction")),
  paths(from = "Quality",      to = c("Value", "Satisfaction")),
  paths(from = "Value",        to = c("Satisfaction")),
  paths(from = "Satisfaction", to = c("Complaints", "Loyalty")),
  paths(from = "Complaints",   to = "Loyalty")
)
res <- dot_graph(mobi_sm, title = "Preview structural model")

## Not run: 
DiagrammeR::grViz(res)

## End(Not run)

seminr documentation built on Sept. 5, 2021, 5:36 p.m.