Skip to contents

Nodes are variables; directed arrows are coloured and styled by the distributional component they target (mu solid black, sigma dashed green, zi dotted orange, random-effect scale grey dotted, a directed x -> rho12 path long-dash). Covariance edges declared with covary() / drm_pair() are drawn as double-headed arcs — solid grey for a residual correlation (rho12), dashed grey for a higher-level random-effect correlation (corpair) — so the three edge classes (directed path, residual covariance, higher-level covariance) are visually distinct (docs/design/07-bivariate-covariance-edges.md). Composite measurement edges — each drm_composite() construct's indicators pointing into the construct — are drawn as steel-blue arrows, with the indicators shown as distinctly-filled nodes, so a formative measurement model reads apart from the structural paths. Uses igraph for layout.

Usage

# S3 method for class 'drm_sem'
plot(x, show = c("all", "paths"), ...)

Arguments

x

A drm_sem object.

show

"all" (default) draws directed paths and covariance arcs and composite measurement edges; "paths" draws the directed structural edges only.

...

Passed to the underlying igraph plot. A layout = matrix is honoured (if it carries rownames it is reordered to the internal vertex order), so a fixed, crossing-free layout can be supplied.

Value

x, invisibly.

Details

The legend lists only the components, covariance classes, and measurement edges actually present in the plotted graph (its swatches come from the same style function as the edges, so they cannot drift from what is drawn). Node fills distinguish endogenous responses, exogenous predictors, and composite indicators. Parallel paths between one pair (for example a mu and a sigma arrow) are fanned onto separate arcs.

References

Wright S (1934). “The Method of Path Coefficients.” The Annals of Mathematical Statistics, 5(3), 161–215. doi:10.1214/aoms/1177732676 .

Shipley B (2016). Cause and Correlation in Biology: A User's Guide to Path Analysis, Structural Equations and Causal Inference with R, 2nd edition. Cambridge University Press, Cambridge.

Lefcheck JS (2016). “piecewiseSEM: Piecewise Structural Equation Modelling in R for Ecology, Evolution, and Systematics.” Methods in Ecology and Evolution, 7(5), 573–579. doi:10.1111/2041-210X.12512 .

Examples

if (FALSE) { # \dontrun{
sem <- drm_sem(
  size = drm_node(drmTMB::bf(size ~ temp + habitat, sigma ~ temp),
                  family = stats::gaussian()),
  abundance = drm_node(drmTMB::bf(abundance ~ size + temp, zi ~ habitat),
                       family = drmTMB::nbinom2()),
  data = dat)
plot(sem)              # directed paths + any covariance arcs
plot(sem, show = "paths")
} # }