Skip to contents

drm_sem() is the declarative interface. You describe each endogenous node with drm_node(); drm_sem() fits each node with drmTMB::drmTMB() and then builds the same object drm_psem() returns. Causal paths are component-labelled: a predictor may target mu, sigma, nu, zi, hu, sd(group), or rho12 of a node.

Usage

drm_sem(..., data, covariances = NULL, composites = NULL, feedback = NULL)

Arguments

...

Named drm_node() specifications, one per endogenous node.

data

A data frame supplied to every node fit.

covariances

Optional covary() declaration(s) (one object or a list) recording residual (rho12) or higher-level (corpair) covariance edges between responses; see covariances().

composites

Optional drm_composite() declaration(s). Each construct column is materialized from its indicators before fitting, so node formulas can reference it as an ordinary observed column; the loadings are reported by loadings().

feedback

Optional drm_cycle() declaration(s) naming a feedback (cyclic) motif, allowing those nodes to form a cycle (every undeclared cycle stays an error). Node-wise ML of a declared cycle is inconsistent under simultaneity (a warning is emitted); equilibrium effects use the fixed-point propagator. See docs/design/10-cyclic-feedback.md.

Value

A drm_sem object.

References

Shipley B (2009). “Confirmatory Path Analysis in a Generalized Multilevel Context.” Ecology, 90(2), 363–368. doi:10.1890/08-1034.1 .

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 .

Brooks ME, Kristensen K, van Benthem KJ, Magnusson A, Berg CW, Nielsen A, Skaug HJ, Maechler M, Bolker BM (2017). “glmmTMB Balances Speed and Flexibility Among Packages for Zero-Inflated Generalized Linear Mixed Models.” The R Journal, 9(2), 378–400. doi:10.32614/RJ-2017-066 .

Rigby RA, Stasinopoulos DM (2005). “Generalized Additive Models for Location, Scale and Shape.” Journal of the Royal Statistical Society Series C: Applied Statistics, 54(3), 507–554. doi:10.1111/j.1467-9876.2005.00510.x .

Examples

if (FALSE) { # \dontrun{
sem <- drm_sem(
  size = drm_node(
    drmTMB::bf(size ~ temp + habitat + (1 | species), sigma ~ temp),
    family = stats::gaussian()
  ),
  abundance = drm_node(
    drmTMB::bf(abundance ~ size + temp + (1 | site), sigma ~ temp, zi ~ habitat),
    family = drmTMB::nbinom2()
  ),
  data = dat
)
paths(sem)
dsep(sem)
indirect_effects(sem, from = "temp", to = "abundance")
} # }