Piecewise Structural Equation Modeling

Implements piecewise structural equation modeling from a single list of structural equations, with new methods for non-linear, latent, and composite variables, standardized coefficients, query-based prediction and indirect effects. See < http://jslefche.github.io/piecewiseSEM/> for more.


Getting Help

See our website at http://jslefche.github.io/piecewiseSEM/

Version 2.0.2

Last updated: 24 July 2018

This version is a major update to the piecewiseSEM package that usesa completely revised syntax that better reproduces the base R syntax and output. It is highly recommended that consult vignette("piecewiseSEM") even if you have used the package before as it documents the many changes.

It also incorporates new functionality in the form of coefficient standardization and updated methods for R^2 for mixed models.

Currently supported model classes: lm, glm, gls, pgls, sarlm, lme, glmmPQL, lmerMod, merModLmerTest, glmerMod


# Install development branch from github
install_github("jslefche/[email protected]", build_vignette = TRUE)

# Load library

# Read vignette

# Create fake data

data <- data.frame(
  x = runif(100),
  y1 = runif(100),
  y2 = rpois(100, 1),
  y3 = runif(100)

# Store in SEM list
modelList <- psem(
  lm(y1 ~ x, data),
  glm(y2 ~ x, "poisson", data),
  lm(y3 ~ y1 + y2, data),

# Run summary

# Address conflict using conserve = T
summary(modelList, conserve = T)

# Address conflict using direction = c()
summary(modelList, direction = c("y2 <- y1"))

# Address conflict using correlated errors
modelList2 <- update(modelList, y2 %~~% y1)



Version 2.0.2 Release Notes

  • Fixed bug with partialCorr and negative correlations returning wrong P-value
  • Fixed with coefs and standardization with mixed models

Version 2.0.1 Release Notes

  • Fixed bug with KRp and uneven sample size
  • New warning issued when NAs present in the dataset
  • Added Gamma distribution to rsquared
  • Fixed bug to determine whether graph is cyclic
  • Fixed bug thowing errors with calls to lmer
  • Fixed bug creating errors with objects fit using lmerTest
  • Added pkgdown website

Version 2.0 Release Notes

New syntax

  • All functions have been re-written from the ground up
  • Incorporates new psem function and S3 objects
  • All necessary information can now be obtained with a single function summary

Updated R[2] functions

  • Extends to new distributions and model types using a single function rsquared

New standardization procedures

  • Implements range standardization for all response types
  • Adds multiple forms of standardization for binary responses, see ?coefs


  • Removed sem.plot function
  • Removed sem.lavaan function
  • groups= argument is currently broken but will be fixed in version 2.1 (see doc)

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.


2.1.2 by Jon Lefcheck, a year ago


Report a bug at https://github.com/jslefche/piecewiseSEM/issues

Browse source code at https://github.com/cran/piecewiseSEM

Authors: Jon Lefcheck [aut, cre] , Jarrett Byrnes [aut] , James Grace [aut]

Documentation:   PDF Manual  

Task views: Psychometric Models and Methods

GPL-3 license

Imports car, DiagrammeR, emmeans, igraph, lme4, multcomp, MASS, methods, nlme

Suggests knitr, rmarkdown

Suggested by semEff.

See at CRAN