Skip to main content

MCMC Item Response Theory Estimation.

Project description

CodeFactor License: MIT

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.7.6
  • Numpy
  • Scipy
  • PyMC3

Supports

Unidimensional

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

Usage

Subject to change but for now:

import numpy as np
from girth_mcmc import (create_synthetic_irt_dichotomous, 
                        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_mcmc import (create_synthetic_irt_polytomous, 
                        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)

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

import numpy as np
from girth_mcmc import (create_synthetic_irt_polytomous, 
                        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

The unittests are just smoke tests for now:

Without coverage.py module

nosetests testing/

With coverage.py module

nosetests --with-coverage --cover-package=girth_mcmc testing/

Other Estimation Packages

If you are looking for Marginal Maximum Likelihood estimation routines, check out GIRTH.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

girth_mcmc-0.1.0-py3.7.egg (30.7 kB view details)

Uploaded Source

File details

Details for the file girth_mcmc-0.1.0-py3.7.egg.

File metadata

  • Download URL: girth_mcmc-0.1.0-py3.7.egg
  • Upload date:
  • Size: 30.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.9

File hashes

Hashes for girth_mcmc-0.1.0-py3.7.egg
Algorithm Hash digest
SHA256 a6c157aad2b07bf685c4df5b3da983824f0ccd6ae0db5df1fa200dd34b043cdf
MD5 d642b6c76c962d04340e39ab81777da7
BLAKE2b-256 327810bd6577fb8fca84798c22636eb22ab8daf660c95f3b1c52e9fec18470da

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page