| get_edges {tidySEM} | R Documentation |
Extract edges from a SEM model object
Description
Attempts to extract edges from a SEM model object, where edges are defined as regression paths and covariances between variables (nodes).
Usage
get_edges(x, label = "est_sig", ...)
Arguments
x |
A model object of class |
label |
Either a character, indicating which column to use for edge
labels, or an expression. See Details.
Defaults to |
... |
Additional parameters passed to |
Details
The function get_edges identifies all regression paths,
latent variable definitions, and covariances in the model as edges.
The output of table_results for those
paths is used to label the edges.
Custom labels
One way to create custom edge labels is by passing an expression to
label. When an expression is
passed to label, it is evaluated in the context of a data.frame
containing the results
of a call to table_results on the x argument.
Another way to create custom labels is by requesting auxiliary variables
using the columns argument (which is passed to
table_results), and then using these columns to construct a new
label. See examples.
Value
An object of class 'tidy_edges'
Examples
# Standard use
library(lavaan)
res <- sem("dist ~ speed", cars)
get_edges(res)
# Pass an expression to the 'label' argument for custom labels
get_edges(res, label = paste(est_sig, confint))
# Pass the argument 'columns' to table_results through '...' to retain
# auxiliary columns for further processing
edg <- get_edges(res, columns = c("est_sig", "confint"))
edg
edg <- within(edg, {label <- paste(est_sig, confint)})
edg