Metadata-Version: 2.4
Name: psymetrics
Version: 0.1.0
Summary: Reliability, factor analysis and SEM for psychologists with an R-like API
Project-URL: Homepage, https://github.com/anovamethods/psy
Project-URL: Lab, https://labmm.org/
Project-URL: ORCID, https://orcid.org/0000-0001-5303-5782
Author-email: Luis Anunciacao <luisfca@gmail.com>
License-Expression: MIT
Keywords: cronbach alpha,factor analysis,psychometrics,reliability,sem
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Scientific/Engineering
Requires-Python: >=3.10
Requires-Dist: factor-analyzer>=0.5
Requires-Dist: numpy>=1.24
Requires-Dist: pandas>=2.0
Requires-Dist: scikit-learn<1.6
Requires-Dist: scipy>=1.10
Provides-Extra: sem
Requires-Dist: semopy>=2.3; extra == 'sem'
Description-Content-Type: text/markdown

# psymetrics

Reliability, factor analysis and SEM for psychologists, with an R-like
functional API. Part of the **ANOVA Methods** family (psystats, psymetrics,
psyreport).

Free and open (MIT). Results print R-style summaries and render to APA-7 through
`psyreport.report()`.

## Install

```bash
pip install psymetrics
```

## What's inside

Reliability — `alpha` (Cronbach's alpha with the Feldt confidence interval,
corrected item-total correlations, alpha-if-dropped, reverse keying), like
`psych::alpha`.

Factorability — `kmo` (Kaiser-Meyer-Olkin, overall and per item) and `bartlett`
(test of sphericity).

Exploratory factor analysis — `efa` with selectable estimator (`minres`, `ml`,
`principal`) and rotation (`varimax`, `promax`, `oblimin`, `quartimax`, ...);
returns loadings, communalities, eigenvalues, variance explained, and the factor
correlation matrix for oblique rotations.

Confirmatory factor analysis and SEM — `cfa` using **lavaan-style syntax**;
returns standardized loadings and the usual fit indices (χ², df, p, CFI, TLI,
RMSEA).

## Example

```python
import pandas as pd
from psymetrics import alpha, kmo, efa, cfa

df = pd.read_csv("scale.csv")
items = df[[f"q{i}" for i in range(1, 11)]]

print(alpha(items))                 # like psych::alpha
print(kmo(items))                   # sampling adequacy
print(efa(items, 3, method="minres", rotation="promax"))

model = """
visual  =~ x1 + x2 + x3
textual =~ x4 + x5 + x6
speed   =~ x7 + x8 + x9
"""
print(cfa(model, df))               # lavaan-style CFA
```

EFA is validated against `factor_analyzer` and CFA fit indices against `semopy`.

> Note: `factor_analyzer` (0.5.x) requires `scikit-learn < 1.6`; this pin is
> declared as a dependency so `efa` works out of the box.
