dot_graph | R Documentation |
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.
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,
...
)
model |
Model created with |
title |
An optional title for the plot |
theme |
Theme created with |
... |
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 |
Current limitations: - Only plots PLS Models - no higher order constructs
The path model as a formatted string in dot language.
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.