Skip to main content

CodeFactor PyPI version License: MIT PyPI - Downloads

GIRTH MCMC

Item Response Theory using Markov Chain Monte Carlo / Variational Inference

Dependencies

We recommend using Anaconda. Individual packages can be installed through pip otherwise.

  • Python ≥ 3.8
  • Numpy
  • Scipy
  • Girth
  • PyMC3

Installation

Via pip

pip install girth_mcmc --upgrade

From Source

pip install . -t $PYTHONPATH --upgrade

Supports

Unidimensional

  • Rasch Model
  • 1PL Model
  • 2PL Model
  • 3PL Model
  • Graded Response Model
  • Partial Credit Model

Multi-dimensional

  • 2PL Model
  • Graded Response Model
  • Partial Credit Model

Usage

Subject to change but for now:

import numpy as np
from girth.synthetic import create_synthetic_irt_dichotomous
from girth_mcmc import GirthMCMC
                        
discrimination = 0.89 * np.sqrt(-2 * np.log(np.random.rand(10)))
difficulty = np.random.randn(10)
theta = np.random.randn(100)

syn_data = create_synthetic_irt_dichotomous(difficulty, discrimination, 
                                            theta)

girth_model = GirthMCMC(model='2PL', 
                        options={'n_processors': 4})
results = girth_model(syn_data)
print(results)

for the graded response model, pass in the number of categories

import numpy as np
from girth.synthetic import create_synthetic_irt_polytomous
from girth_mcmc import GirthMCMC

n_categories = 3

difficulty = np.random.randn(10, n_categories-1)
difficulty = np.sort(difficulty, 1)        
discrimination = 0.96 * np.sqrt(-2 * np.log(np.random.rand(10)))
theta = np.random.randn(150)

syn_data = create_synthetic_irt_polytomous(difficulty, discrimination, 
                                            theta, model='grm')

girth_model = GirthMCMC(model='GRM', model_args=(n_categories,),
                        options={'n_processors': 4})
results = girth_model(syn_data)
print(results)

Is some data missing? Tag it with a convenience function and run it like normal

import numpy as np
from girth.synthetic import create_synthetic_irt_dichotomous
from girth_mcmc import GirthMCMC
from girth_mcmc.utils import tag_missing_data_mcmc
                        
discrimination = 0.89 * np.sqrt(-2 * np.log(np.random.rand(10)))
difficulty = np.random.randn(10)
theta = np.random.randn(100)

syn_data = create_synthetic_irt_dichotomous(difficulty, discrimination, 
                                            theta)
mask = np.random.rand(*syn_data.shape) < .1
syn_data[mask] = -9999
syn_data_missing = tag_missing_data_mcmc(syn_data, [0, 1])

girth_model = GirthMCMC(model='2PL', 
                        options={'n_processors': 4})
results = girth_model(syn_data_missing)
print(results)

Don't like waiting? me either. Run Variational Inference for faster but less accurate estimation.

import numpy as np
from girth.synthetic import create_synthetic_irt_polytomous
from girth_mcmc import GirthMCMC

n_categories = 3

difficulty = np.random.randn(10, n_categories-1)
difficulty = np.sort(difficulty, 1)        
discrimination = 1.76 * np.sqrt(-2 * np.log(np.random.rand(10)))
theta = np.random.randn(150)

syn_data = create_synthetic_irt_polytomous(difficulty, discrimination, 
                                            theta, model='grm')

girth_model = GirthMCMC(model='GRM', model_args=(n_categories,),
                        options={'variational_inference': True,
                                 'variational_samples': 10000,
                                 'n_samples': 10000})
results_variational = girth_model(syn_data, progressbar=False)
print(results_variational)

Unittests

pytest with coverage.py module

pytest --cov=girth_mcmc --cov-report term

Contact

Ryan Sanchez
ryan.sanchez@gofactr.com

Other Estimation Packages

If you are looking for Marginal Maximum Likelihood estimation routines, check out GIRTH, a graphical interface is also at GoFactr

License

MIT License

Copyright (c) 2021 Ryan C. Sanchez

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Metadata

Release files for girth-mcmc 0.6.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for girth-mcmc 0.6.0
File Size Uploaded Provenance Actions
girth_mcmc-0.6.0.tar.gz 15.2 kB Without provenance Details for girth_mcmc-0.6.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for girth-mcmc 0.6.0
File Interpreter ABI Platform Actions
girth_mcmc-0.6.0-py3-none-any.whl Python 3 none any Details for girth_mcmc-0.6.0-py3-none-any.whl

Total release size: 36.2 kB

Release files / girth_mcmc-0.6.0.tar.gz

Download URL girth_mcmc-0.6.0.tar.gz
Size 15.2 kB
Tags Source
SHA-256 checksum
How to use checksums
fa9df9b47627e33ec3c962e3176dc13178f86a28072d048ce0371eef925a6457
BLAKE2b-256 checksum
How to use checksums
4b3304b00ea9dedbefc24124555f8483102eebd5adaed49fbedfa483a319b97b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.8

Release files / girth_mcmc-0.6.0-py3-none-any.whl

Download URL girth_mcmc-0.6.0-py3-none-any.whl
Size 21.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fe9a70435ef75bd7f71c43ab280e7a1417c666d135a3f94201c78eca121fe951
BLAKE2b-256 checksum
How to use checksums
053bca2fb8af758402795ec55aeeb78a36f939d4c870349a101d1e12fb50ba58
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.8

Security for girth-mcmc 0.6.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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page