Package: deepirtools
DeepIRToolsDeep Learning-Based Estimation and Inference for Item Response Theory ModelsDeepIRTools is a small Pytorch-based Python package that uses scalable deep learning methods to fit a number of different confirmatory and exploratory latent factor models, with a particular focus on item response theory (IRT) models. Graphics processing unit (GPU) support is available for most computations.DescriptionLatent factor models reduce the dimensionality of data by converting a large number of discrete or continuous observed variables (calleditems) into a smaller number of continuous unobserved variables (calledlatent factors), potentially making the data easier to understand. Latent factor models for discrete items are calleditem response theory(IRT) models.Traditional maximum likelihood (ML) estimation methods for IRT models are computationally intensive when the sample size, the number of items, and the number of latent factors are all large. This issue can be avoided by approximating the ML estimator using animportance-weighted amortized variational estimator(I-WAVE) from the field of deep learning (for details, seeUrban and Bauer, 2021). As an estimation byproduct, I-WAVE allows researchers to compute approximate factor scores and log-likelihoods for any observation — even new observations that were not used for model fitting.DeepIRTools' main functionality is the stand-aloneIWAVEclass contained in theiwavemodule. This class includesfit(),scores(), andlog_likelihood()methods for fitting a latent factor model and for computing approximate factor scores and log-likelihoods for the fitted model.The following (multidimensional) latent factor models are currently available......for binary and ordinal items:Graded response modelGeneralized partial credit modelNominal response model...for continuous items:Normal (linear) factor modelLognormal factor model...for count data:Poisson factor modelNegative binomial factor modelDeepIRTools supports mixing item types, handling missing completely at random data, and predicting the mean of the latent factors with covariates (i.e., latent regression modeling); all models are estimable in both confirmatory and exploratory contexts. In the confirmatory context, constraints on the factor loadings, intercepts, and factor covariance matrix are implemented by providing appropriate arguments tofit(). In the exploratory context, thescreeplot()function in thefiguresmodule may help identify the number of latent factors underlying the data.RequirementsPython 3.7 or highertorchpyro-pplnumpyInstallationTo install the latest version:pip install deepirtoolsDocumentationOfficial documentation is availablehere.ExamplesTutorialSeebig_5_tutorial.ipynbfor a tutorial on using DeepIRTools to fit several kinds of latent factor models using large-scale data.DemonstrationSeemnist_demo.ipynbfor a demonstration of how DeepIRTools may be used to fit a flexible and identifiable model for generating realistic handwritten digits.Quick ExampleIn[1]:importdeepirtools...:fromdeepirtoolsimportIWAVE...:importtorchIn[2]:deepirtools.manual_seed(123)In[3]:data=deepirtools.load_grm()["data"]In[4]:n_items=data.shape[1]In[5]:model=IWAVE(...:model_type="grm",...:latent_size=4,...:n_cats=[3]*n_items,...:Q=torch.block_diag(*[torch.ones([3,1])]*4),...:correlated_factors=[0,1,2,3],...:)InitializingmodelparametersInitializationendedin0.0secondsIn[6]:model.fit(data,iw_samples=10)FittingstartedEpoch=100Iter.=25201Cur.loss=10.68Intervalsnochange=100Fittingendedin109.23secondsIn[7]:model.loadings# Loadings matrix.Out[7]:tensor([[0.8295,0.0000,0.0000,0.0000],[0.5793,0.0000,0.0000,0.0000],[0.7116,0.0000,0.0000,0.0000],[0.0000,0.7005,0.0000,0.0000],[0.0000,1.1687,0.0000,0.0000],[0.0000,1.2890,0.0000,0.0000],[0.0000,0.0000,0.9268,0.0000],[0.0000,0.0000,1.2653,0.0000],[0.0000,0.0000,1.5622,0.0000],[0.0000,0.0000,0.0000,1.0346],[0.0000,0.0000,0.0000,1.3641],[0.0000,0.0000,0.0000,1.1348]])In[8]:model.intercepts# Category intercepts.Out[8]:tensor([[2.4245,-0.1637],[1.8219,-1.0013],[2.0811,-1.1320],[0.0948,-1.7253],[2.6597,-2.3412],[0.2610,-1.4938],[2.8196,-1.3281],[0.4833,-2.8053],[1.6395,-2.2220],[1.3482,-1.8870],[2.1606,-2.8600],[2.5318,-0.1333]])In[9]:model.cov# Factor covariance matrix.Out[9]:tensor([[1.0000,-0.0737,0.2130,0.2993],[-0.0737,1.0000,-0.1206,-0.3031],[0.2130,-0.1206,1.0000,0.1190],[0.2993,-0.3031,0.1190,1.0000]])In[10]:model.log_likelihood(data)# Approximate log-likelihood.Computingapprox.LLApprox.LLcomputedin33.27secondsOut[6]:-85961.69088745117In[11]:model.scores(data)# Approximate factor scores.Out[11]:tensor([[-0.6211,0.1301,-0.7207,-0.7485],[0.2189,-0.2649,0.0109,-0.2363],[0.0544,0.9308,0.7940,-0.8851],...,[-0.2964,-0.9597,-0.8885,-0.0057],[-1.6015,0.9812,0.0486,0.1773],[2.0448,0.0583,1.2005,-0.9317]])CitationTo cite DeepIRTools in publications, use:Urban, C. J., & He, S. (2022). DeepIRTools: Deep learning-based estimation and inference for item response theory models. Python package.https://github.com/cjurban/deepirtoolsTo cite the method, use:Urban, C. J., & Bauer, D. J. (2021). A deep learning algorithm for high-dimensional exploratory  item factor analysis. Psychometrika, 86(1), 1-29.https://link.springer.com/article/10.1007/s11336-021-09748-3and/or:Urban, C. J. (2021).Machine learning-based estimation and goodness-of-fit for large-scale confirmatory item factor analysis(Publication No. 28772217) [Master's thesis, University of North Carolina at Chapel Hill]. ProQuest Dissertations Publishing.https://www.proquest.com/docview/2618877227/21C6C467D6194C1DPQ/BibTeX entries for LaTeX users are:@Manual{DeepIRTools,title={{D}eep{IRT}ools: {D}eep learning-based estimation and inference for item response theory models},author={Urban, Christopher J. and He, Shara},year={2022},note={Python package},url={https://github.com/cjurban/deepirtools},}@article{UrbanBauer2021,author={Urban, Christopher J. and Bauer, Daniel J.},year={2021},title={{A} deep learning algorithm for high-dimensional exploratory item factor analysis},journal={Psychometrika},volume={86},number={1},pages={1--29}}@phdthesis{Urban2021,author={Urban, Christopher J.},title={{M}achine learning-based estimation and goodness-of-fit for large-scale confirmatory item factor analysis},publisher={ProQuest Dissertations Publishing},school={University of North Carolina at Chapel Hill},year={2021},type={Master's thesis},}