Metadata-Version: 2.4
Name: mesem
Version: 1.0.0
Summary: Maximum Entropy Structural Equation Modeling (Affogato Core)
Author: Teuku Meldi Kesuma, M. Ridha Siregar, Muhammad R Siregar, Muhammad Iqbal Fajri
License-Expression: MIT
Project-URL: Homepage, https://github.com/tmkesuma/mesem
Project-URL: Bug Tracker, https://github.com/tmkesuma/mesem/issues
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: OS Independent
Classifier: Intended Audience :: Science/Research
Classifier: Topic :: Scientific/Engineering :: Mathematics
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy>=1.21.0
Requires-Dist: pandas>=1.3.0
Requires-Dist: scipy>=1.7.0
Requires-Dist: numba>=0.55.0
Requires-Dist: joblib>=1.1.0
Dynamic: license-file

# MESEM: Maximum Entropy Structural Equation Modeling
**Version 1.0.0 (Affogato Core)**

Welcome to MESEM—a next-generation Structural Equation Modeling (SEM) engine for Python.

Designed for precision and flexibility, MESEM 1.0.0 (Affogato Core) natively handles the complex realities of psychometric and behavioral data that legacy software struggles with.
It does the heavy mathematical lifting so you can focus on the science.

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Python 3.7+](https://img.shields.io/badge/python-3.7+-blue.svg)](https://www.python.org/downloads/)

---

## The Philosophy

* **The Maximum Entropy Principle**: MESEM is grounded in Information Theory. Instead of forcing rigid, often false distributional assumptions (like multivariate normality) onto your data, the Affogato Core builds the least biased distribution consistent with your observed constraints.
* **Parsimony by Default**: By maximizing entropy, the engine strictly commits only to the information your data actually provides. It avoids "illusory precision" and refuses to add mathematical structure where the data does not support it.
* **Information-Theoretic Robustness**: This theoretical foundation translates directly to empirical stability, providing highly reliable parameter estimates across both continuous and discrete (ordinal) manifolds.

---

## Key Features

* **Speed of JIT-Compiled Math**: Heavy bivariate normal integration for ordinal objective functions is routed through a Numba LLVM JIT-compiler, executing complex mathematical topologies at C-level speeds.
* **Flawless Mixed-Data Routing**: No more data wrangling. Continuous scores and ordinal survey data can be fed into the same model and MESEM automatically routes them to Pearson, Polyserial, or Polychoric matrices cell-by-cell. 
* **Advanced Construct Validity**: Natively supports formative Multicollinearity (VIF) checks and the gold-standard Satorra-Bentler Scaled $\Delta\chi^2$ Difference Test to rigorously establish discriminant validity.
* **Native Latent Moderation**: Testing moderation? Just write `Y ~ X + W + X:W`. That's it. The engine dynamically intercepts the syntax, builds the product indicators, standardizes them, and estimates the latent interaction on the fly.
* **Categorical Power (DWLSMV)**: Treat ordinal Likert scales as they actually are. MESEM features a true Diagonally Weighted Least Squares estimator backed by robust Huber-White (Sandwich) standard errors.
* **Parallel Bias-Corrected Bootstrapping**: Need to test a complex mediation pathway? Trigger the multi-core `BootstrapManager` to generate empirical, Bias-Corrected (BC) confidence intervals in a fraction of the time.
* **Surgical Multi-Group Syntax**: Test for measurement invariance using `R`-style vectors like `Y ~ c(0.5, NA)*X` to rigidly fix a parameter in one group while freeing it in another.

---


## Installation

### From PyPI (coming soon)
```
pip install mesem
```

### From GitHub (development version)
```
git clone https://github.com/siregarmr/mesem.git
cd mesem
pip install -e .
```

---

## Quick Start

### Test Dataset

Don't have a dataset ready? MESEM ships with a suite of built-in textbook datasets. Let's go from zero to a heterogeneous latent moderation model in three lines of code:

```
from mesem.datasets import load_heterogeneous_moderation
from mesem.fit import fit

# 1. Load the textbook dataset (Continuous + Ordinal data)
data, syntax = load_heterogeneous_moderation()

# 2. Fit the model! (ULSMV + Robust Standard Errors)
results = fit(data, syntax, estimator='ulsmv', se='robust')

# 3. View the professional statistical report
results.summary()
```

### The Interactive Textbook

The repository includes an `examples/` directory containing interactive Jupyter notebooks. Clone the repo and learn how to do following in MESEM:

1. Standard Continuous CFAs
2. Bootstrapping & Mediation
3. Ordinal Data (DWLSMV)
4. Multi-Group Invariance Constraints
5. Formative (MIMIC) Models
6. Mixed-Data Latent Moderation
7. Construct Validity (VIF & Satorra-Bentler Tests)

---

## License

MESEM is open-source and distributed under the MIT License – see the LICENSE file for details.
