Package: girth-mcmc
GIRTH MCMCItem Response Theory using Markov Chain Monte Carlo / Variational InferenceDependenciesWe recommend usingAnaconda. Individual
packages can be installed through pip otherwise.Python ≥ 3.8NumpyScipyGirthPyMC3InstallationVia pippipinstallgirth_mcmc--upgradeFrom Sourcepipinstall.-t$PYTHONPATH--upgradeSupportsUnidimensionalRasch Model1PL Model2PL Model3PL ModelGraded Response ModelPartial Credit ModelMulti-dimensional2PL ModelGraded Response ModelPartial Credit ModelUsageSubject to change but for now:importnumpyasnpfromgirth.syntheticimportcreate_synthetic_irt_dichotomousfromgirth_mcmcimportGirthMCMCdiscrimination=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 categoriesimportnumpyasnpfromgirth.syntheticimportcreate_synthetic_irt_polytomousfromgirth_mcmcimportGirthMCMCn_categories=3difficulty=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 normalimportnumpyasnpfromgirth.syntheticimportcreate_synthetic_irt_dichotomousfromgirth_mcmcimportGirthMCMCfromgirth_mcmc.utilsimporttag_missing_data_mcmcdiscrimination=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)<.1syn_data[mask]=-9999syn_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.importnumpyasnpfromgirth.syntheticimportcreate_synthetic_irt_polytomousfromgirth_mcmcimportGirthMCMCn_categories=3difficulty=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)Unittestspytestwith coverage.py modulepytest--cov=girth_mcmc--cov-reporttermContactRyan Sanchezryan.sanchez@gofactr.comOther Estimation PackagesIf you are looking for Marginal Maximum Likelihood estimation routines,
check outGIRTH, a graphical interface
is also atGoFactrLicenseMIT LicenseCopyright (c) 2021 Ryan C. SanchezPermission 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.