Skip to contents

Builds a symbolized_drm_sem from a fitted drm_sem() / drm_psem() object by walking the topological-order node list and calling symbolizer::symbolize() on each node's underlying drmTMB fit. The result is a list of per-node symbolized_models plus the SEM's graph metadata (edges, topological order, modelled distributional components per node), so the rendering generics (symbolizer::as_latex(), symbolizer::equations(), symbolizer::assumption_table()) can collate the SEM's equations as one document.

Usage

# S3 method for class 'drm_sem'
symbolize(fit, symbols = NULL, units = NULL, context = NULL, ...)

Arguments

fit

A drm_sem object.

symbols, units, context

Passed through to each per-node symbolizer::symbolize() call. See ?symbolizer::symbolize for the shape (named character vectors keyed by variable name).

...

Passed through to each per-node symbolizer::symbolize() call (for example, ci_method = "profile" for drmTMB nodes).

Value

A symbolized_drm_sem object (a list with elements parts, edges, order, dpars, metadata).

Details

This is the model-specification layer: per-node distributional equations (location, scale, shape, zero-inflation, hurdle, residual correlation), families, links, and assumptions. The SEM layer — DAG plotting, d-separation, Fisher's C, the simulation-based effect calculus — stays with the existing drmSEM machinery; symbolizer does not attempt to render the (simulation-based) distribution-mediated effect.

Requires the symbolizer package (a Suggests).

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, sigma ~ temp),
                       family = stats::gaussian()),
  abundance = drm_node(drmTMB::bf(abundance ~ size + temp, zi ~ habitat),
                       family = drmTMB::nbinom2()),
  data = dat
)
sym <- symbolizer::symbolize(sem)
symbolizer::as_latex(sym)         # publication-ready equations
symbolizer::equations(sym)        # raw equation table
symbolizer::assumption_table(sym) # families, links, deferred components
} # }