Package: girth
GIRTH:ItemResponseTheoryGirth is a python package for estimating item response theory (IRT) parameters.  In addition, synthetic IRT data generation is supported. Below is a list of available functions, for more information visit the GIRTHhomepage.Interested in Bayesian Models? Check outgirth_mcmc. It provides markov chain and variational inference estimation methods.Need general statistical support? Download my other projectRyStatswhich implements commonly used statistical functions. These functions are also implemented in an interactive webappGoFactr.comwithout the need to download or install software.Item Response TheoryUnidimensional ModelsDichotomous ModelsRasch ModelJoint Maximum LikelihoodConditional LikelihoodMarginal Maximum LikelihoodOne Parameter Logistic ModelsJoint Maximum LikelihoodMarginal Maximum LikelihoodTwo Parameter Logistic ModelsJoint Maximum LikelihoodMarginal Maximum LikelihoodMixed Expected A Prior / Marginal Maximum LikelihoodThree Parameter Logistic ModelsMarginal Maximum Likelihood (No Optimization and Minimal Support)Polytomous ModelsGraded Response ModelJoint Maximum LikelihoodMarginal Maximum LikelihoodMixed Expected A Prior / Marginal Maximum LikelihoodPartial Credit ModelJoint Maximum LikelihoodMarginal Maximum LikelihoodGraded Unfolding ModelMarginal Maximum LikelihoodAblity EstimationDichotomousMaximum Likelihood EstimationMaximum a Posteriori EstimationExpected a Posteriori EstimationPolytomousExpected a Posteriori EstimationMultidimensional ModelsTwo Parameter Logistic ModelsMarginal Maximum LikelihoodGraded Response ModelMarginal Maximum LikelihoodAblity EstimationDichotomousMaximum a Posteriori EstimationExpected a Posteriori EstimationPolytomousMaximum a Posteriori EstimationExpected a Posteriori EstimationSupported Synthetic Data GenerationUnidimensionalRasch / 1PL Models Dichotomous Models2 PL Dichotomous Models3 PL Dichotomous ModelsGraded Response Model PolytomousPartial Credit Model PolytomousGraded Unfolding Model PolytomousMultidimensionalTwo Parameters Logisitic Models DichotomousGraded Response Models PolytomousUsageStandard EstimationTo run girth with unidimensional models.importnumpyasnpfromgirth.syntheticimportcreate_synthetic_irt_dichotomousfromgirthimporttwopl_mml# Create Synthetic Datadifficulty=np.linspace(-2.5,2.5,10)discrimination=np.random.rand(10)+0.5theta=np.random.randn(500)syn_data=create_synthetic_irt_dichotomous(difficulty,discrimination,theta)# Solve for parametersestimates=twopl_mml(syn_data)# Unpack estimatesdiscrimination_estimates=estimates['Discrimination']difficulty_estimates=estimates['Difficulty']Missing DataMissing data is supported with thetag_missing_datafunction.fromgirthimporttag_missing_data,twopl_mml# import data (you supply this function)my_data=import_data(filename)# Assume its dichotomous data with True -> 1 and False -> 0tagged_data=tag_missing_data(my_data,[0,1])# Run Estimationresults=twopl_mml(tagged_data)Multidimensional EstimationGIRTH supports multidimensional estimation but these estimation methods suffer
from the curse of dimensionality, using more than 3 factors takes a considerable amount
of timeimportnumpyasnpfromgirth.syntheticimportcreate_synthetic_irt_dichotomousfromgirthimportmultidimensional_twopl_mml# Create Synthetic Datadiscrimination=np.random.uniform(-2,2,(20,2))thetas=np.random.randn(2,1000)difficulty=np.linspace(-1.5,1,20)syn_data=create_synthetic_irt_dichotomous(difficulty,discrimination,thetas)# Solve for parametersestimates=multidimensional_twopl_mml(syn_data,2,{'quadrature_n':21})# Unpack estimatesdiscrimination_estimates=estimates['Discrimination']difficulty_estimates=estimates['Difficulty']Standard ErrorsGIRTH does not use typical hessian based optimization routines and, therefore,currentlyhas limited support for standard errors. Confidence Intervals based on bootstrapping are
supported but take longer to run. Missing Data is supported in the bootstrap function as well.The bootstrap does not support the 3PL IRT Model or the GGUM.fromgirthimporttwopl_mml,standard_errors_bootstrap# import data (you supply this function)my_data=import_data(filename)results=standard_errors_bootstrap(my_data,twopl_mml,n_processors=4,bootstrap_iterations=1000)print(results['95th CI']['Discrimination'])Factor AnalysisFactor analysis is another common method for latent variable exploration and estimation. These tools are helpful for understanding dimensionality or finding initial estimates of item parameters.Factor Analysis Extraction MethodsPrincipal Component AnalysisPrincipal Axis FactorMinimum Rank Factor AnalysisMaximum Likelihood Factor AnalysisExampleimportgirth.factoranalysisasgfa# Assume you have converted data into correlation matrixn_factors=3results=gfa.maximum_likelihood_factor_analysis(corrleation,n_factors)print(results)Polychoric Correlation EstimationWhen collected data is ordinal, Pearson's correlation will provide biased estimates of the correlation. Polychoric correlations estimate the correlation given that the data is ordinal and normally distributed.importgirth.syntheticasgsynimportgirth.factoranalysisasgfaimportgirth.commonasgcmdiscrimination=np.random.uniform(-2,2,(20,2))thetas=np.random.randn(2,1000)difficulty=np.linspace(-1.5,1,20)syn_data=gsyn.create_synthetic_irt_dichotomous(difficulty,discrimination,thetas)polychoric_corr=gcm.polychoric_correlation(syn_data,start_val=0,stop_val=1)results_fa=gfa.maximum_likelihood_factor_analysis(polychoric_corr,2)SupportInstallationVia pippipinstallgirth--upgradeFrom Sourcepipinstall.-t$PYTHONPATH--upgradeDependenciesWe recommend the anaconda environment which can be installedherePython ≥ 3.8NumpyScipyUnittestspytestwith coverage.py modulepytest--cov=girth--cov-reporttermContactPlease contact me with any questions or feature requests. Thank you!Ryan Sanchezryan.sanchez@gofactr.comLicenseMIT 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.