Structural Equation Modeling Optimization in Python.
Slowing down. Last release over 2 years ago, little activity since. Fine for existing code; think twice for a new project.
pip install semopysemopy
Visit our website for a detailed introduction
semopy is a Python package that includes numerous Structural Equation Modelling (SEM) techniques.
Features
- Write down a model description in a user-friendly syntax
- Estimate model's parameters using a variety of objective functions
- Estimate models with population structure via random effects
- Restricted Maximum Likelihood
- Integration with gaussian processes/mixture models to tackle huge variety of phenomena
- Calculate numerous statistics and fit indices
- Estimate model's parameters in presence of ordinal variables
- A vast number of settings to fit a researcher's needs
- Fast and accurate
- Automatically create fancy HTML reports
Installation
semopy is available at PyPi and can be installed by typing the following line into terminal:
pip install semopy
Syntax
To specify SEM models, The semopy uses the syntax, which is natural to describe regression models in R. The syntax supports three operator symbols characterising relationships between variables:
- ~ to specify structural part,
- =~ to specify measurement part,
- ~~ to specify common variance between variables.
For example, let a linear equation in the structural part of SEM model take the form:
y = β1 x1 + β2 x2 + ε
Then, in semopy syntax it becomes:
y ~ x1 + x2
Parameters β1, β2 are to be estimated by semopy. In some cases a user might want to fix some of parameters to particular value. For instance, let's assume that we want β1 to stay equal to 2.0 and we are only interested in estimating β2:
y ~ 2*x1 + x2
Likewise, if a latent variable η is explained by manifest variables y1, y2, y3, then in semopy syntax it can be written down this way:
eta =~ y1 + y2 + y3
Quickstart
The pipeline for working with SEM models in semopy consists of three steps:
- Specifying a model
- Loading a dataset.
- Estimating parameters of the model.
Main object required for scpecifying and estimating an SEM model is .