Learn R Programming

seminr (version 2.0.2)

dot_graph: Generate a dot graph from various SEMinR models

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

dot_graph(model, title = "", theme = NULL, ...)

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

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

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

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

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

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

# S3 method for 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

Value

The path model as a formatted string in dot language.

Details

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

Examples

Run this code
# NOT RUN {
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)
# }
# NOT RUN {
# generate dot-Notation
res <- dot_graph(mobi_boot, title = "Bootstrapped PLS-Model plot")

# }
# NOT RUN {
DiagrammeR::grViz(res)
# }
# 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)
# }

Run the code above in your browser using DataLab