StepMix
For StepMixR, please refer to this repository.
A Python package following the scikit-learn API for model-based clustering and generalized mixture modeling (latent class/profile analysis) of continuous and categorical data. StepMix handles missing values through Full Information Maximum Likelihood (FIML) and provides multiple stepwise Expectation-Maximization (EM) estimation methods based on pseudolikelihood theory. Additional features include support for covariates and distal outcomes, various simulation utilities, and non-parametric bootstrapping, which allows inference in semi-supervised and unsupervised settings.
Reference
If you find StepMix useful, please consider citing our arXiv preprint:
@article{morin2023stepmix,
title={StepMix: A Python Package for Pseudo-Likelihood Estimation of Generalized Mixture Models with External Variables},
author={Morin, Sacha and Legault, Robin and Bakk, Zsuzsa and Gigu{\`e}re, Charles-{\'E}douard and de la Sablonni{\`e}re, Roxane and Lacourse, {\'E}ric},
journal={arXiv preprint arXiv:2304.03853},
year={2023}
}
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 latent class models can be defined with StepMix. The tutorial uses the Iris Dataset as an example
and covers:
- Continuous LCA models (latent profile analysis/gaussian mixture model);
- Binary LCA models;
- Categorical LCA models;
- Mixed variables mixture models (continuous and categorical data);
- 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.
- Model Selection:
a short tutorial discussing:
- Selecting the number of components in a mixture model (
n_components); - Comparing models with fit indices: AIC and BIC.
- 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.
Metadata
Release files for stepmix 1.2.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| stepmix-1.2.5.tar.gz | 49.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| stepmix-1.2.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 88.8 kB
Release files / stepmix-1.2.5.tar.gz
| Download URL | stepmix-1.2.5.tar.gz |
|---|---|
| Size | 49.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bbcc7b7955456423bd18f56a7b99a108800fdee499bd2764c192327a7f83a7ee
|
|
BLAKE2b-256 checksum How to use checksums |
9e483d41fc7487435c37a3779d49881ae1013078eff8f5711012d7a3056f346e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-requests/2.28.1
|
Release files / stepmix-1.2.5-py3-none-any.whl
| Download URL | stepmix-1.2.5-py3-none-any.whl |
|---|---|
| Size | 39.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d9b6b075c34c26547764424fd4a467145073a507bc30a08f6237f86c80a0ff2b
|
|
BLAKE2b-256 checksum How to use checksums |
1fe9b8c3a48f7f6fb39d3d1f8d6dddf464b681dc30623751e2036bd7405f5788
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-requests/2.28.1
|