StepMix
For StepMixR, please refer to this repository.
A Python package following the scikit-learn API for generalized mixture modeling. The package supports categorical data (Latent Class Analysis) and continuous data (Gaussian Mixtures/Latent Profile Analysis). StepMix can be used for both clustering and supervised learning.
Additional features include:
- Support for missing values through Full Information Maximum Likelihood (FIML);
- Multiple stepwise Expectation-Maximization (EM) estimation methods based on pseudolikelihood theory;
- Covariates and distal outcomes;
- Parametric and non-parametric bootstrapping.
Reference
If you find StepMix useful, please leave a ⭐ and consider citing our Journal of Statistical Software paper:
@Article{,
title = {{StepMix}: A {Python} Package for Pseudo-Likelihood
Estimation of Generalized Mixture Models with External
Variables},
author = {Sacha Morin and Robin Legault and F{\'e}lix Lalibert{\'e}
and Zsuzsa Bakk and Charles-{\'E}douard Gigu{\`e}re and Roxane
{de la Sablonni{\`e}re} and {\'E}ric Lacourse},
journal = {Journal of Statistical Software},
year = {2025},
volume = {113},
number = {8},
pages = {1--39},
doi = {10.18637/jss.v113.i08},
}
Install
You can install StepMix with pip, preferably in a virtual environment:
pip install stepmix
Quickstart
A StepMix mixture using categorical variables on a preloaded data matrix. StepMix accepts either numpy.arrayor
pandas.DataFrame. Categories should be integer-encoded and 0-indexed.
from stepmix.stepmix import StepMix
# Categorical StepMix Model with 3 latent classes
model = StepMix(n_components=3, measurement="categorical")
model.fit(data)
# Allow missing values
model_nan = StepMix(n_components=3, measurement="categorical_nan")
model_nan.fit(data_nan)
For binary data you can also use measurement="binary" or measurement="binary_nan". For continuous data, you can fit a Gaussian Mixture with diagonal covariances using measurement="continuous" or measurement="continuous_nan".
Set verbose=1 for a detailed output.
Please refer to the StepMix tutorials to learn how to combine continuous and categorical data in the same model.
Tutorials
Detailed tutorials are available in notebooks:
- Generalized Mixture Models with StepMix:
an in-depth look at how mixture models can be defined with StepMix. The tutorial uses the Iris Dataset as an example
and covers:
- Gaussian Mixtures (Latent Profile Analysis);
- Binary Mixtures (LCA);
- Categorical Mixtures (LCA);
- Mixed Categorical and Continuous Mixtures;
- Missing Values through Full-Information Maximum Likelihood.
- Stepwise Estimation with StepMix:
a tutorial demonstrating how to define measurement and structural models. The tutorial discusses:
- LCA models with distal outcomes;
- LCA models with covariates;
- 1-step, 2-step and 3-step estimation;
- Corrections (BCH or ML) and other options for 3-step estimation;
- Putting it All Together: A Complete Model with Missing Values
- Model Selection:
- Selecting the number of components in a mixture model (
n_components) with cross-validation; - Selecting the number of components with the Parametric Bootstrapped Likelihood Ratio Test (BLRT);
- Fit indices: AIC, BIC and other metrics.
- Selecting the number of components in a mixture model (
- Parameters, Bootstrapping and CI:
a tutorial discussing how to:
- Access StepMix parameters;
- Bootstrap StepMix estimators;
- Quickly plot confidence intervals.
- Supervised and Semi-Supervised Learning with StepMix:
- Binary Classification;
- Multiclass Classification;
- Semi-Supervised Learning;
- Cross-Validation.
- Deriving p-values in StepMix: a tutorial demonstrating how to transform SM parameters into conventional regression coefficients and how to derive p-values.
The tutorial covers models with:
- Continuous covariate;
- Binary covariate;
- Categorical covariate;
- Multiple covariates (different distributions);
- Binary distal outcome;
Metadata
Release files for stepmix 3.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| stepmix-3.0.0.tar.gz | 61.7 kB | Without provenance | Details for stepmix-3.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| stepmix-3.0.0-py3-none-any.whl | Python 3 | none | any | Details for stepmix-3.0.0-py3-none-any.whl |
Total release size: 106.2 kB
Release files / stepmix-3.0.0.tar.gz
| Download URL | stepmix-3.0.0.tar.gz |
|---|---|
| Size | 61.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
11f878e97d7b00403b75da6539963f5cb67aff5a8eb903c2ae61319367da3398
|
|
BLAKE2b-256 checksum How to use checksums |
69035b5dc796be94d0ec2cb8d420a2ff0f4f0fcd748d1bc408265b20ddd66fd9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-requests/2.33.1
|
Release files / stepmix-3.0.0-py3-none-any.whl
| Download URL | stepmix-3.0.0-py3-none-any.whl |
|---|---|
| Size | 44.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5b44579d3238d70ef516c354a2cd71a4d4d0362f3931d833f87c82b1e9eb969c
|
|
BLAKE2b-256 checksum How to use checksums |
325e1cadb823d7a96cd393a52011f3d749d1ba88ffa64224ad07cc804b6582c9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-requests/2.33.1
|
Security for stepmix 3.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.