Metadata-Version: 2.5
Name: pyfcirt
Version: 0.1.0b1
Summary: Bayesian forced-choice IRT modeling with PyMC and ArviZ
Project-URL: Repository, https://github.com/qipengchen/pyfcirt
Project-URL: Issues, https://github.com/qipengchen/pyfcirt/issues
Author: qipengchen
License-Expression: MIT AND Apache-2.0
License-File: LICENSE
License-File: LICENSES/JAX-Apache-2.0.txt
License-File: NOTICE
License-File: pyfcirt/_example_data/studies/carelessness_big_five/LICENSE-CC-BY-4.0.txt
Requires-Python: >=3.12
Requires-Dist: arviz-stats<2,>=1
Requires-Dist: arviz<2,>=1
Requires-Dist: blackjax[progress]<1.6,>=1.5
Requires-Dist: jax>=0.12.1
Requires-Dist: numpy>=2
Requires-Dist: optax<0.3,>=0.2.8
Requires-Dist: pandas>=2.2
Requires-Dist: pymc<7,>=6.4.0
Requires-Dist: pytensor<4,>=3.3.7
Requires-Dist: scipy>=1.13
Requires-Dist: xarray>=2025.1
Provides-Extra: covariates
Requires-Dist: formulae<0.10,>=0.9; extra == 'covariates'
Provides-Extra: cuda12
Requires-Dist: jax[cuda12]; extra == 'cuda12'
Provides-Extra: cuda13
Requires-Dist: jax[cuda13]; extra == 'cuda13'
Provides-Extra: docs
Requires-Dist: ipykernel; extra == 'docs'
Requires-Dist: myst-nb; extra == 'docs'
Requires-Dist: numpydoc; extra == 'docs'
Requires-Dist: pydata-sphinx-theme<1,>=0.16; extra == 'docs'
Requires-Dist: sphinx; extra == 'docs'
Requires-Dist: sphinx-design<1,>=0.8; extra == 'docs'
Requires-Dist: watermark<3,>=2.5; extra == 'docs'
Provides-Extra: io
Requires-Dist: h5netcdf; extra == 'io'
Requires-Dist: h5py; extra == 'io'
Provides-Extra: lint
Requires-Dist: ruff; extra == 'lint'
Provides-Extra: numpyro
Requires-Dist: numpyro; extra == 'numpyro'
Provides-Extra: plots
Requires-Dist: arviz-plots[matplotlib]<2,>=1; extra == 'plots'
Requires-Dist: seaborn<0.14,>=0.13; extra == 'plots'
Provides-Extra: posterior
Requires-Dist: scikit-learn<2,>=1.9; extra == 'posterior'
Provides-Extra: release
Requires-Dist: build; extra == 'release'
Requires-Dist: twine; extra == 'release'
Provides-Extra: test
Requires-Dist: coverage<8,>=7.6; extra == 'test'
Requires-Dist: pytest-cov<8,>=6; extra == 'test'
Requires-Dist: pytest-xdist<4,>=3.6; extra == 'test'
Requires-Dist: pytest>=8; extra == 'test'
Description-Content-Type: text/markdown

# PyFCIRT

Bayesian forced-choice modeling in Python.

[![Checks](https://github.com/qipengchen/pyfcirt/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/qipengchen/pyfcirt/actions/workflows/ci.yml)
[![Coverage](https://codecov.io/gh/qipengchen/pyfcirt/branch/main/graph/badge.svg)](https://codecov.io/gh/qipengchen/pyfcirt)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
[![License](https://img.shields.io/badge/License-MIT%20%26%20Apache--2.0-blue)](NOTICE)

<!-- quick-start-start -->

## Overview

PyFCIRT is a high-level Bayesian forced-choice modeling interface written in
Python. Built on the [PyMC](https://github.com/pymc-devs/pymc) probabilistic
programming framework, it is designed to make forced-choice models easy to
specify, fit, and evaluate. GPU-accelerated sampling is available through JAX.

## Supported models

**Forced-choice: dominance models**

- Thurstonian item response theory model (`TIRT`).
- Thurstonian IRT model with a joint-ranking likelihood (`TIRTRank`).
- Two-parameter logistic model for rankings (`TwoPLRank`).
- Multidimensional generalized partial preference model (`MGPPM`).

**Forced-choice: ideal-point models**

- Generalized Thurstonian unfolding model (`GTUM`).
- Generalized graded unfolding model for rankings (`GGUMRank`).

**Likert and dichotomous models**

- One- to four-parameter logistic IRT models (`DichotomousIRT`).
- Generalized partial credit model (`GPCM`).
- Generalized graded unfolding model (`GGUM`).

Different measurement models can be combined within a test, including
forced-choice, Likert, and dichotomous models.

## Installation

Use Python 3.12 or later for pip or conda. These commands install the beta release.

### pip

```console
python -m pip install --pre pyfcirt
```

For NVIDIA GPU sampling on Linux or WSL 2:

```console
python -m pip install --pre "pyfcirt[cuda13]"
```

### conda

```console
conda install -c qipengchen/label/beta -c conda-forge pyfcirt
```

### Docker

CPU:

```console
docker run --rm -it ghcr.io/qipengchen/pyfcirt:0.1.0b1-cpu
```

NVIDIA GPU (CUDA 13):

```console
docker run --rm -it --gpus all ghcr.io/qipengchen/pyfcirt:0.1.0b1-cuda13
```

See [GPU setup](https://qipengchen.github.io/pyfcirt/examples/gpu.html) for compatibility and verification.

## Your first analysis

Fit TIRT to a simulated teaching dataset with 100 respondents and 24 triplets.
The design table assigns each statement to a block and trait; the response table
contains one person's judgment of a named statement pair per row.

```python
import pyfcirt as fc

example = fc.load_example("tirt_study", model="TIRT")
design_df = example.data.design
response_df = example.data.responses.frame

# design_df.head(3):
# block_id position statement_id trait keying
#       B1        1           S1    T1      1
#       B1        2           S2    T2      1
#       B1        3           S3    T3      1

# response_df.head(3):
# person_id block_id statement_1 statement_2 response
#        P1       B1          S1          S2        0
#        P1       B1          S1          S3        1
#        P1       B1          S2          S3        1
```

Register the design and responses, then fit TIRT.

```python
model = fc.Model()
model.add_fc(
    design_df,
    response_df,
    format="comparison_long",
    model="TIRT",
)
model.prepare()
model.fit(random_seed=42)
model.coef(blocks=["B1"], kind="stats", round_to="auto")
```

`model="TIRT"` selects the measurement model. Each response records a pair
judgment. Response `1` prefers the first statement;
`0` prefers the second. In the design, `position` gives presentation order and
`keying` gives the loading direction on the named trait.

`model.coef()` reports posterior means, standard deviations and uncertainty
intervals for the statements and pairs in B1.

Follow the [examples](https://qipengchen.github.io/pyfcirt/examples.html) for
prior prediction, diagnostics and model checks, and use the
[API reference](https://qipengchen.github.io/pyfcirt/api.html) for individual calls.
Use [Prepare your data](https://qipengchen.github.io/pyfcirt/reference/generated/pyfcirt.ResponseTable.html) to define
your own design and read CSV or spreadsheet responses.

<!-- quick-start-end -->

## Documentation

- [Quick start](https://qipengchen.github.io/pyfcirt/guide/getting_started.html)
- [Installation and GPU support](https://qipengchen.github.io/pyfcirt/guide/getting_started.html#installation)
- [API reference](https://qipengchen.github.io/pyfcirt/api.html)
- [Examples](https://qipengchen.github.io/pyfcirt/examples.html)

## Contributing

Questions, bug reports, and feature suggestions are welcome through
[GitHub Issues](https://github.com/qipengchen/pyfcirt/issues).

For bug reports, include a small reproducible example and the package versions
used. Contributions can be submitted through pull requests.

## License

PyFCIRT is primarily licensed under the [MIT License](LICENSE).
See [NOTICE](NOTICE) for the JAX attribution retained from earlier revisions.
