IRT without the normality assumption

library(IRTest)
library(ggplot2)




1. Dichotomous items

The function DataGeneration can be used for the pre-analysis step. This function returns artificial data and some useful objects for analysis (i.e., theta, data_D, item_D, and initialitem_d).

In the parameter estimation process, the initialitem can be used for an input of the function IRTest_Dich (i.e., initialitem = initialitem). The data is an artificial item response data that could be unnecessary if user-imported item response data is used. The theta and item are not used for the estimation process. They can be considered as the true parameters only if the artificial data (data) is used for analysis.

Alldata <- DataGeneration(seed = 123456789,
                          model_D = rep(1:2, each=5),
                          N=1000,
                          nitem_D = 10,
                          nitem_P = 0,
                          d = 1.664,
                          sd_ratio = 2,
                          prob = 0.3)

data <- Alldata$data_D
item <- Alldata$item_D
initialitem <- Alldata$initialitem_D
theta <- Alldata$theta

If the artificial data (data) is used, the true latent distribution looks like,




######                            ######
###### Empirical histogram method ######
######                            ######
Mod1 <- IRTest_Dich(initialitem = initialitem,
                    data = data,
                    model = rep(1:2, each=5),
                    latent_dist = "EHM",
                    max_iter = 200,
                    threshold = .0001)
#> Method = EHM, EM cycle = 1, Max-Change = 1.14005883919173 Method = EHM,
#> EM cycle = 2, Max-Change = 0.217457817143965 Method = EHM, EM cycle = 3,
#> Max-Change = 0.0955915489894688 Method = EHM, EM cycle = 4, Max-Change =
#> 0.0358405002790235 Method = EHM, EM cycle = 5, Max-Change = 0.0285635437289516
#> Method = EHM, EM cycle = 6, Max-Change = 0.0234969794594866 Method = EHM,
#> EM cycle = 7, Max-Change = 0.0204662534522857 Method = EHM, EM cycle = 8,
#> Max-Change = 0.0200949726775232 Method = EHM, EM cycle = 9, Max-Change =
#> 0.0187660519670731 Method = EHM, EM cycle = 10, Max-Change = 0.0171632047022134
#> Method = EHM, EM cycle = 11, Max-Change = 0.0155465421620229 Method =
#> EHM, EM cycle = 12, Max-Change = 0.0140115656791813 Method = EHM, EM cycle
#> = 13, Max-Change = 0.0125917102791262 Method = EHM, EM cycle = 14, Max-
#> Change = 0.0112964979160926 Method = EHM, EM cycle = 15, Max-Change =
#> 0.0101252498562294 Method = EHM, EM cycle = 16, Max-Change = 0.00907383763163416
#> Method = EHM, EM cycle = 17, Max-Change = 0.00814805756028436 Method
#> = EHM, EM cycle = 18, Max-Change = 0.00729173223939394 Method = EHM,
#> EM cycle = 19, Max-Change = 0.00650537019558506 Method = EHM, EM cycle
#> = 20, Max-Change = 0.00582186456986333 Method = EHM, EM cycle = 21,
#> Max-Change = 0.00520529798160485 Method = EHM, EM cycle = 22, Max-
#> Change = 0.00465221827122653 Method = EHM, EM cycle = 23, Max-
#> Change = 0.00428163649214941 Method = EHM, EM cycle = 24, Max-
#> Change = 0.00396921083330071 Method = EHM, EM cycle = 25, Max-
#> Change = 0.00369014609293039 Method = EHM, EM cycle = 26, Max-Change =
#> 0.00343510750168363 Method = EHM, EM cycle = 27, Max-Change = 0.0031866758618202
#> Method = EHM, EM cycle = 28, Max-Change = 0.00294813635862035 Method = EHM,
#> EM cycle = 29, Max-Change = 0.00272013468554411 Method = EHM, EM cycle = 30,
#> Max-Change = 0.00250244068826966 Method = EHM, EM cycle = 31, Max-Change =
#> 0.0022952845795583 Method = EHM, EM cycle = 32, Max-Change = 0.00209918371445328
#> Method = EHM, EM cycle = 33, Max-Change = 0.00191438240497099 Method =
#> EHM, EM cycle = 34, Max-Change = 0.00174117071445057 Method = EHM, EM cycle
#> = 35, Max-Change = 0.00157926600288905 Method = EHM, EM cycle = 36, Max-
#> Change = 0.0014286235027865 Method = EHM, EM cycle = 37, Max-Change =
#> 0.0012888670846416 Method = EHM, EM cycle = 38, Max-Change = 0.00115952149486986
#> Method = EHM, EM cycle = 39, Max-Change = 0.00104004700004978 Method =
#> EHM, EM cycle = 40, Max-Change = 0.000929864888749687 Method = EHM, EM
#> cycle = 41, Max-Change = 0.000828378250406381 Method = EHM, EM cycle
#> = 42, Max-Change = 0.0007349884811374 Method = EHM, EM cycle = 43,
#> Max-Change = 0.000649107948626604 Method = EHM, EM cycle = 44, Max-
#> Change = 0.000570169281675525 Method = EHM, EM cycle = 45, Max-
#> Change = 0.000497631789268205 Method = EHM, EM cycle = 46, Max-
#> Change = 0.000430985519817906 Method = EHM, EM cycle = 47, Max-
#> Change = 0.000369753445251142 Method = EHM, EM cycle = 48, Max-
#> Change = 0.000313492208199317 Method = EHM, EM cycle = 49, Max-
#> Change = 0.000261791809010425 Method = EHM, EM cycle = 50, Max-
#> Change = 0.000214274546957327 Method = EHM, EM cycle = 51, Max-
#> Change = 0.000170593467114788 Method = EHM, EM cycle = 52, Max-
#> Change = 0.000174691136431537 Method = EHM, EM cycle = 53, Max-
#> Change = 0.000195540665820726 Method = EHM, EM cycle = 54, Max-
#> Change = 0.000214685008886217 Method = EHM, EM cycle = 55, Max-
#> Change = 0.000232260043464994 Method = EHM, EM cycle = 56, Max-
#> Change = 0.000248390954942224 Method = EHM, EM cycle = 57, Max-
#> Change = 0.000263192783256816 Method = EHM, EM cycle = 58, Max-
#> Change = 0.000276771094381623 Method = EHM, EM cycle = 59, Max-
#> Change = 0.000289234013148842 Method = EHM, EM cycle = 60, Max-
#> Change = 0.000300665601096206 Method = EHM, EM cycle = 61, Max-
#> Change = 0.00031113960147966 Method = EHM, EM cycle = 62, Max-
#> Change = 0.000320731480348169 Method = EHM, EM cycle = 63, Max-
#> Change = 0.000329509983641785 Method = EHM, EM cycle = 64, Max-
#> Change = 0.00033755713614525 Method = EHM, EM cycle = 65, Max-
#> Change = 0.000344925271684282 Method = EHM, EM cycle = 66, Max-
#> Change = 0.000351679223568713 Method = EHM, EM cycle = 67, Max-
#> Change = 0.000357862709691847 Method = EHM, EM cycle = 68, Max-
#> Change = 0.000363509628073633 Method = EHM, EM cycle = 69, Max-
#> Change = 0.000368826395613198 Method = EHM, EM cycle = 70, Max-
#> Change = 0.000373873967621119 Method = EHM, EM cycle = 71, Max-
#> Change = 0.000377410735556971 Method = EHM, EM cycle = 72, Max-
#> Change = 0.000380102211888556 Method = EHM, EM cycle = 73, Max-
#> Change = 0.000382977035546794 Method = EHM, EM cycle = 74, Max-
#> Change = 0.000386040236137752 Method = EHM, EM cycle = 75, Max-
#> Change = 0.000389190657248406 Method = EHM, EM cycle = 76, Max-
#> Change = 0.000392347010952143 Method = EHM, EM cycle = 77, Max-
#> Change = 0.000395362132769694 Method = EHM, EM cycle = 78, Max-
#> Change = 0.000398182278364079 Method = EHM, EM cycle = 79, Max-
#> Change = 0.0004007950322511 Method = EHM, EM cycle = 80, Max-
#> Change = 0.000403134745168288 Method = EHM, EM cycle = 81, Max-
#> Change = 0.000405186573893879 Method = EHM, EM cycle = 82, Max-
#> Change = 0.000406949735376028 Method = EHM, EM cycle = 83, Max-
#> Change = 0.000408430748954469 Method = EHM, EM cycle = 84, Max-
#> Change = 0.000409640435402814 Method = EHM, EM cycle = 85, Max-
#> Change = 0.000410592025367418 Method = EHM, EM cycle = 86, Max-
#> Change = 0.000411299882153493 Method = EHM, EM cycle = 87, Max-
#> Change = 0.000411778638635507 Method = EHM, EM cycle = 88, Max-
#> Change = 0.000412042629044596 Method = EHM, EM cycle = 89, Max-
#> Change = 0.000412105533141638 Method = EHM, EM cycle = 90, Max-
#> Change = 0.000411980171540982 Method = EHM, EM cycle = 91, Max-
#> Change = 0.000411678407548077 Method = EHM, EM cycle = 92, Max-
#> Change = 0.000411211121027932 Method = EHM, EM cycle = 93, Max-
#> Change = 0.00041058822961304 Method = EHM, EM cycle = 94, Max-
#> Change = 0.000409818738383638 Method = EHM, EM cycle = 95, Max-
#> Change = 0.000408910805933971 Method = EHM, EM cycle = 96, Max-
#> Change = 0.000407871817664329 Method = EHM, EM cycle = 97, Max-
#> Change = 0.000406708459747662 Method = EHM, EM cycle = 98, Max-
#> Change = 0.000405426791504127 Method = EHM, EM cycle = 99, Max-
#> Change = 0.000404032312362634 Method = EHM, EM cycle = 100, Max-
#> Change = 0.000402530023868142 Method = EHM, EM cycle = 101, Max-
#> Change = 0.000400924485530307 Method = EHM, EM cycle = 102, Max-
#> Change = 0.000399219864630762 Method = EHM, EM cycle = 103, Max-
#> Change = 0.000397419980819436 Method = EHM, EM cycle = 104, Max-
#> Change = 0.000395528345563445 Method = EHM, EM cycle = 105, Max-
#> Change = 0.000393548197154647 Method = EHM, EM cycle = 106, Max-
#> Change = 0.000391482531846954 Method = EHM, EM cycle = 107, Max-
#> Change = 0.000389334131664754 Method = EHM, EM cycle = 108, Max-
#> Change = 0.000387105588810943 Method = EHM, EM cycle = 109, Max-
#> Change = 0.000384799328466467 Method = EHM, EM cycle = 110, Max-
#> Change = 0.000382417627995846 Method = EHM, EM cycle = 111, Max-
#> Change = 0.000379962635605136 Method = EHM, EM cycle = 112, Max-
#> Change = 0.000377436386110208 Method = EHM, EM cycle = 113, Max-
#> Change = 0.00037484081609751 Method = EHM, EM cycle = 114, Max-
#> Change = 0.000372177776908789 Method = EHM, EM cycle = 115, Max-
#> Change = 0.00036944904722036 Method = EHM, EM cycle = 116, Max-
#> Change = 0.000366656343793181 Method = EHM, EM cycle = 117, Max-
#> Change = 0.000363801331611846 Method = EHM, EM cycle = 118, Max-
#> Change = 0.000360885632970209 Method = EHM, EM cycle = 119, Max-
#> Change = 0.000357910835684816 Method = EHM, EM cycle = 120, Max-
#> Change = 0.000354878500550715 Method = EHM, EM cycle = 121, Max-
#> Change = 0.000351790167909982 Method = EHM, EM cycle = 122, Max-
#> Change = 0.000348647363706878 Method = EHM, EM cycle = 123, Max-
#> Change = 0.000345451604756963 Method = EHM, EM cycle = 124, Max-
#> Change = 0.000342204403414925 Method = EHM, EM cycle = 125, Max-
#> Change = 0.000338907271779654 Method = EHM, EM cycle = 126, Max-
#> Change = 0.000335561725173239 Method = EHM, EM cycle = 127, Max-
#> Change = 0.000332169285224282 Method = EHM, EM cycle = 128, Max-
#> Change = 0.000328731482641231 Method = EHM, EM cycle = 129, Max-
#> Change = 0.000325249859197463 Method = EHM, EM cycle = 130, Max-
#> Change = 0.000321725969552933 Method = EHM, EM cycle = 131, Max-
#> Change = 0.000318161382750315 Method = EHM, EM cycle = 132, Max-
#> Change = 0.00031455768306321 Method = EHM, EM cycle = 133, Max-
#> Change = 0.000310916470889655 Method = EHM, EM cycle = 134, Max-
#> Change = 0.000307239363068756 Method = EHM, EM cycle = 135, Max-
#> Change = 0.000303527993006814 Method = EHM, EM cycle = 136, Max-
#> Change = 0.000299784010616033 Method = EHM, EM cycle = 137, Max-
#> Change = 0.000296009081856674 Method = EHM, EM cycle = 138, Max-
#> Change = 0.000292204888280967 Method = EHM, EM cycle = 139, Max-
#> Change = 0.000288373126149377 Method = EHM, EM cycle = 140, Max-
#> Change = 0.000284515505634353 Method = EHM, EM cycle = 141, Max-
#> Change = 0.000280633749488945 Method = EHM, EM cycle = 142, Max-
#> Change = 0.000276729592060043 Method = EHM, EM cycle = 143, Max-
#> Change = 0.000272804777722957 Method = EHM, EM cycle = 144, Max-
#> Change = 0.000268861059470993 Method = EHM, EM cycle = 145, Max-
#> Change = 0.000264900197351814 Method = EHM, EM cycle = 146, Max-
#> Change = 0.000260923956798109 Method = EHM, EM cycle = 147, Max-
#> Change = 0.000256934106765527 Method = EHM, EM cycle = 148, Max-
#> Change = 0.000252932418201901 Method = EHM, EM cycle = 149, Max-
#> Change = 0.00024892066196136 Method = EHM, EM cycle = 150, Max-
#> Change = 0.000244900607063947 Method = EHM, EM cycle = 151, Max-
#> Change = 0.000240874018829995 Method = EHM, EM cycle = 152, Max-
#> Change = 0.000236842656800018 Method = EHM, EM cycle = 153, Max-
#> Change = 0.000232808273065377 Method = EHM, EM cycle = 154, Max-
#> Change = 0.000228772610135763 Method = EHM, EM cycle = 155, Max-
#> Change = 0.000224737399294295 Method = EHM, EM cycle = 156, Max-
#> Change = 0.000220704358461443 Method = EHM, EM cycle = 157, Max-
#> Change = 0.000216675190546578 Method = EHM, EM cycle = 158, Max-
#> Change = 0.000212651581524614 Method = EHM, EM cycle = 159, Max-
#> Change = 0.000208635198786222 Method = EHM, EM cycle = 160, Max-
#> Change = 0.000204627689326387 Method = EHM, EM cycle = 161, Max-
#> Change = 0.000200630678143021 Method = EHM, EM cycle = 162, Max-
#> Change = 0.000196645766555648 Method = EHM, EM cycle = 163, Max-
#> Change = 0.000192674530758996 Method = EHM, EM cycle = 164, Max-
#> Change = 0.000188718520241604 Method = EHM, EM cycle = 165, Max-
#> Change = 0.000184779256453549 Method = EHM, EM cycle = 166, Max-
#> Change = 0.000180858231450198 Method = EHM, EM cycle = 167, Max-
#> Change = 0.000176956906632331 Method = EHM, EM cycle = 168, Max-
#> Change = 0.000173076711448505 Method = EHM, EM cycle = 169, Max-
#> Change = 0.000169219042536639 Method = EHM, EM cycle = 170, Max-
#> Change = 0.000165385262416162 Method = EHM, EM cycle = 171, Max-
#> Change = 0.000161576698749499 Method = EHM, EM cycle = 172, Max-
#> Change = 0.000157794643264708 Method = EHM, EM cycle = 173, Max-
#> Change = 0.000154040351332707 Method = EHM, EM cycle = 174, Max-
#> Change = 0.000150315040734483 Method = EHM, EM cycle = 175, Max-
#> Change = 0.000146619891554511 Method = EHM, EM cycle = 176, Max-
#> Change = 0.000142956045292575 Method = EHM, EM cycle = 177, Max-
#> Change = 0.00013932460458399 Method = EHM, EM cycle = 178, Max-
#> Change = 0.00013572663273953 Method = EHM, EM cycle = 179, Max-
#> Change = 0.000132163153495402 Method = EHM, EM cycle = 180, Max-
#> Change = 0.000128635150673517 Method = EHM, EM cycle = 181, Max-
#> Change = 0.000125143568109998 Method = EHM, EM cycle = 182, Max-
#> Change = 0.000121689309664053 Method = EHM, EM cycle = 183, Max-
#> Change = 0.000118273238993272 Method = EHM, EM cycle = 184, Max-
#> Change = 0.00011489617978766 Method = EHM, EM cycle = 185, Max-
#> Change = 0.000111558915793175 Method = EHM, EM cycle = 186, Max-
#> Change = 0.0001082621910653 Method = EHM, EM cycle = 187, Max-
#> Change = 0.000105006710142685 Method = EHM, EM cycle = 188, Max-
#> Change = 0.000101793138431727 Method = EHM, EM cycle = 189, Max-Change =
#> 9.86221025724987e-05

######                                  ######
###### Kernel density estimation method ######
######                                  ######
# Mod1 <- IRTest_Dich(initialitem = initialitem,
#                     data = data,
#                     model = rep(1:2, each=5),
#                     latent_dist = "KDE",
#                     bandwidth = "SJ-ste",
#                     max_iter = 200,
#                     threshold = .001)

######                      ######
###### Normality assumption ######
######                      ######
#  Mod1 <- IRTest_Dich(initialitem = initialitem,
#                      data = data,
#                      model = rep(1:2, each=5),
#                      latent_dist = "Normal",
#                      max_iter = 200,
#                      threshold = .0001)

######                                             ######
###### Two-component Gaussian mixture distribution ######
######                                             ######
#  Mod1 <- IRTest_Dich(initialitem = initialitem,
#                      data = data,
#                      model = rep(1:2, each=5),
#                      latent_dist = "Mixture",
#                      max_iter = 200,
#                      threshold = .0001)

######                                                       ######
###### Davidian curve (for an arbitrarily chosen case of h=4)######
######                                                       ######
#  Mod1 <- IRTest_Dich(initialitem = initialitem,
#                      data = data,
#                      model = rep(1:2, each=5),
#                      latent_dist = "DC",
#                      max_iter = 200,
#                      threshold = .0001,
#                      h=4)




### The estimated item parameters
Mod1$par_est
#>              a           b c
#>  [1,] 1.000000 -0.81791378 0
#>  [2,] 1.000000  0.93346265 0
#>  [3,] 1.000000  0.45638984 0
#>  [4,] 1.000000 -0.06571304 0
#>  [5,] 1.000000 -0.85014932 0
#>  [6,] 1.214051 -0.37829522 0
#>  [7,] 2.201096 -1.10134627 0
#>  [8,] 2.343780 -0.44424687 0
#>  [9,] 2.095085 -0.21417143 0
#> [10,] 1.071522  0.08171582 0

### The asymptotic standard errors of item parameters
Mod1$se
#>                a          b  c
#>  [1,]         NA 0.07316482 NA
#>  [2,]         NA 0.07437462 NA
#>  [3,]         NA 0.07091295 NA
#>  [4,]         NA 0.06991033 NA
#>  [5,]         NA 0.07343322 NA
#>  [6,] 0.08725007 0.06247266 NA
#>  [7,] 0.15999786 0.04858514 NA
#>  [8,] 0.13483504 0.04037375 NA
#>  [9,] 0.12184146 0.04188987 NA
#> [10,] 0.08285023 0.06617414 NA

### The estimated ability parameters
head(Mod1$theta)
#> [1] -0.7537932 -0.5428673 -1.2226573 -1.0056440 -1.1277099 -1.3182821

### The estimated latent distribution
plot_LD(Mod1, xlim = c(-6,6))




2. Polytomous items

As in the case of dichotomous items, the function DataGeneration can be used for the pre-analysis step. This function returns artificial data and some useful objects for analysis (i.e., theta, data_P, item_P, and initialitem_P).

In the parameter estimation process, the initialitem can be used for an input of the function IRTest_Poly (i.e., initialitem = initialitem). The data is an artificial item response data that could be unnecessary if user-imported item response data is used. The theta and item are not used for the estimation process. They can be considered as the true parameters only if the artificial data (data) is used for analysis.

Alldata <- DataGeneration(seed = 123456789,
                          model_P = "GPCM",
                          categ = rep(c(3,7), each = 5),
                          N=1000,
                          nitem_D = 0,
                          nitem_P = 10,
                          d = 1.414,
                          sd_ratio = 2,
                          prob = 0.5)

data <- Alldata$data_P
item <- Alldata$item_P
initialitem <- Alldata$initialitem_P
theta <- Alldata$theta

If the artificial data (data) is used, the true latent distribution looks like,




######                                  ######
###### Kernel density estimation method ######
######                                  ######
Mod1 <- IRTest_Poly(initialitem = initialitem,
                    data = data,
                    model = "GPCM",
                    latent_dist = "KDE",
                    bandwidth = "SJ-ste",
                    max_iter = 200,
                    threshold = .001)
#> Method = KDE, EM cycle = 1, Max-Change = 1.06861179488865 Method = KDE, EM
#> cycle = 2, Max-Change = 0.572576285885708 Method = KDE, EM cycle = 3, Max-Change
#> = 1.1956289848566 Method = KDE, EM cycle = 4, Max-Change = 1.33304744136422
#> Method = KDE, EM cycle = 5, Max-Change = 0.652894453937292 Method = KDE,
#> EM cycle = 6, Max-Change = 0.399749918296198 Method = KDE, EM cycle = 7,
#> Max-Change = 0.226152345091642 Method = KDE, EM cycle = 8, Max-Change =
#> 0.120544125380424 Method = KDE, EM cycle = 9, Max-Change = 0.0607672232908261
#> Method = KDE, EM cycle = 10, Max-Change = 0.0260925050459035 Method = KDE,
#> EM cycle = 11, Max-Change = 0.0198914998910418 Method = KDE, EM cycle = 12,
#> Max-Change = 0.0158930673063724 Method = KDE, EM cycle = 13, Max-Change =
#> 0.0130926924936661 Method = KDE, EM cycle = 14, Max-Change = 0.0108270260815266
#> Method = KDE, EM cycle = 15, Max-Change = 0.00963938334502812 Method =
#> KDE, EM cycle = 16, Max-Change = 0.00931969037839542 Method = KDE, EM cycle
#> = 17, Max-Change = 0.00954657222262956 Method = KDE, EM cycle = 18, Max-
#> Change = 0.00977403467488447 Method = KDE, EM cycle = 19, Max-Change =
#> 0.0092152434487085 Method = KDE, EM cycle = 20, Max-Change = 0.00846831844475071
#> Method = KDE, EM cycle = 21, Max-Change = 0.00715153573911209 Method
#> = KDE, EM cycle = 22, Max-Change = 0.00631484417174333 Method = KDE,
#> EM cycle = 23, Max-Change = 0.00548551243527617 Method = KDE, EM cycle
#> = 24, Max-Change = 0.00483454547226048 Method = KDE, EM cycle = 25,
#> Max-Change = 0.00416850067370778 Method = KDE, EM cycle = 26, Max-
#> Change = 0.00356760538470802 Method = KDE, EM cycle = 27, Max-
#> Change = 0.00303001332387343 Method = KDE, EM cycle = 28, Max-
#> Change = 0.00255758952716789 Method = KDE, EM cycle = 29, Max-
#> Change = 0.00214994775526112 Method = KDE, EM cycle = 30, Max-
#> Change = 0.00180343918837256 Method = KDE, EM cycle = 31, Max-
#> Change = 0.00143548204651678 Method = KDE, EM cycle = 32, Max-
#> Change = 0.00129110152521683 Method = KDE, EM cycle = 33, Max-
#> Change = 0.00235994271063023 Method = KDE, EM cycle = 34, Max-
#> Change = 0.00223687640370152 Method = KDE, EM cycle = 35, Max-
#> Change = 0.00150460130580399 Method = KDE, EM cycle = 36, Max-
#> Change = 0.00145400439244447 Method = KDE, EM cycle = 37, Max-
#> Change = 0.00128605458284081 Method = KDE, EM cycle = 38, Max-
#> Change = 0.00110342365498983 Method = KDE, EM cycle = 39, Max-Change =
#> 0.000936361577671185

######                      ######
###### Normality assumption ######
######                      ######
#  Mod1 <- IRTest_Poly(initialitem = initialitem,
#                      data = data,
#                      model = "GPCM",
#                      latent_dist = "Normal",
#                      max_iter = 200,
#                      threshold = .001)

######                            ######
###### Empirical histogram method ######
######                            ######
#  Mod1 <- IRTest_Poly(initialitem = initialitem,
#                      data = data,
#                      model = "GPCM",
#                      latent_dist = "EHM",
#                      max_iter = 200,
#                      threshold = .001)

######                                             ######
###### Two-component Gaussian mixture distribution ######
######                                             ######
#  Mod1 <- IRTest_Poly(initialitem = initialitem,
#                      data = data,
#                      model = "GPCM",
#                      latent_dist = "Mixture",
#                      max_iter = 200,
#                      threshold = .001)

######                                                        ######
###### Davidian curve (for an arbitrarily chosen case of h=4) ######
######                                                        ######
#  Mod1 <- IRTest_Poly(initialitem = initialitem,
#                      data = data,
#                      model = "GPCM",
#                      latent_dist = "DC",
#                      max_iter = 200,
#                      threshold = .001,
#                      h=4)




### The estimated item parameters
Mod1$par_est
#>               a          b_1         b_2        b_3         b_4        b_5
#>  [1,] 1.9320419  0.396698909  0.46603651         NA          NA         NA
#>  [2,] 1.6880632 -0.303763927  0.05188864         NA          NA         NA
#>  [3,] 2.0504530 -0.376056390 -0.24941074         NA          NA         NA
#>  [4,] 1.0605873 -0.159282350  0.16815184         NA          NA         NA
#>  [5,] 0.7835049  0.003729855  0.22658723         NA          NA         NA
#>  [6,] 1.8907281  0.253908544  0.29706486  0.5563451  0.56108999  0.7435219
#>  [7,] 1.5439636 -1.603051232 -1.12357477 -1.0013097 -1.06426560 -0.7066684
#>  [8,] 0.9479375 -0.332417438 -0.17196848  0.3086190  0.06595696 -0.2510836
#>  [9,] 1.4230350 -0.784687384 -0.69487372 -0.6851528 -0.46813907 -0.5758896
#> [10,] 2.5827215  0.546921194  0.94939512  0.7099745  1.04467562  1.0309654
#>              b_6
#>  [1,]         NA
#>  [2,]         NA
#>  [3,]         NA
#>  [4,]         NA
#>  [5,]         NA
#>  [6,]  0.8505778
#>  [7,] -0.6593098
#>  [8,]  0.1465100
#>  [9,] -0.4351178
#> [10,]  1.2435975

### The asymptotic standard errors of item parameters
Mod1$se
#>                a        b_1        b_2       b_3        b_4        b_5
#>  [1,] 0.11560425 0.06407208 0.06475432        NA         NA         NA
#>  [2,] 0.09873818 0.05692682 0.05873271        NA         NA         NA
#>  [3,] 0.12254146 0.05222493 0.05290338        NA         NA         NA
#>  [4,] 0.06700339 0.08275252 0.08438107        NA         NA         NA
#>  [5,] 0.05524448 0.10839246 0.10990234        NA         NA         NA
#>  [6,] 0.11338544 0.06983861 0.08428678 0.1076463 0.11530990 0.10459915
#>  [7,] 0.09071435 0.14185389 0.12458750 0.1208955 0.10620807 0.08435877
#>  [8,] 0.05380619 0.11427616 0.13330931 0.1692535 0.18844552 0.17129060
#>  [9,] 0.08124190 0.10135122 0.11385157 0.1183858 0.11737822 0.10510023
#> [10,] 0.16806178 0.05840518 0.08680555 0.1003863 0.09807777 0.09198491
#>              b_6
#>  [1,]         NA
#>  [2,]         NA
#>  [3,]         NA
#>  [4,]         NA
#>  [5,]         NA
#>  [6,] 0.08789139
#>  [7,] 0.07567987
#>  [8,] 0.13258224
#>  [9,] 0.08666445
#> [10,] 0.07509506

### The estimated ability parameters
head(Mod1$theta)
#> [1] -0.5375323 -0.5787214 -0.2605974 -1.0428218 -0.9306040 -1.2750381

### The estimated latent distribution
plot_LD(Mod1, xlim = c(-6,6))




3. Mixed-format test

As in the case of dichotomous and polytomous items, the function DataGeneration can be used for the pre-analysis step. This function returns artificial data and some useful objects for analysis (i.e., theta, data_D, item_D, initialitem_D, data_P, item_P, and initialitem_P).

In the parameter estimation process, the initialitem can be used for an input of the function IRTest_Mix (i.e., initialitem = initialitem). The data is an artificial item response data that could be unnecessary if user-imported item response data is used. The theta and item are not used for the estimation process. They can be considered as the true parameters only if the artificial data (data) is used for analysis.

Alldata <- DataGeneration(seed = 123456789,
                          model_D = rep(2,5),
                          model_P = "GPCM",
                          categ = rep(3,5),
                          N=1000,
                          nitem_D = 5,
                          nitem_P = 5,
                          d = 1.664,
                          sd_ratio = 1,
                          prob = 0.5)

DataD <- Alldata$data_D
DataP <- Alldata$data_P
itemD <- Alldata$item_D
itemP <- Alldata$item_P
initialitemD <- Alldata$initialitem_D
initialitemP <- Alldata$initialitem_P
theta <- Alldata$theta

If the artificial data (data) is used, the true latent distribution looks like,




######                                  ######
###### Kernel density estimation method ######
######                                  ######
Mod1 <- IRTest_Mix(initialitem_D = initialitemD,
                   initialitem_P = initialitemP,
                   data_D = DataD,
                   data_P = DataP,
                   model_D = rep(2,5),
                   model_P = "GPCM",
                   latent_dist = "KDE",
                   bandwidth = "SJ-ste",
                   max_iter = 200,
                   threshold = .001)
#> Method = KDE, EM cycle = 1, Max-Change = 1.27664510969542 Method = KDE,
#> EM cycle = 2, Max-Change = 0.283162925229327 Method = KDE, EM cycle = 3,
#> Max-Change = 0.11468686740523 Method = KDE, EM cycle = 4, Max-Change =
#> 0.0428847062639028 Method = KDE, EM cycle = 5, Max-Change = 0.0202299168294221
#> Method = KDE, EM cycle = 6, Max-Change = 0.0158767224469275 Method = KDE,
#> EM cycle = 7, Max-Change = 0.0134661933298211 Method = KDE, EM cycle = 8,
#> Max-Change = 0.0121555027373784 Method = KDE, EM cycle = 9, Max-Change =
#> 0.0106195686463368 Method = KDE, EM cycle = 10, Max-Change = 0.00898701305472549
#> Method = KDE, EM cycle = 11, Max-Change = 0.00788076379489278 Method
#> = KDE, EM cycle = 12, Max-Change = 0.00711577652295109 Method = KDE,
#> EM cycle = 13, Max-Change = 0.00565935518666261 Method = KDE, EM cycle
#> = 14, Max-Change = 0.00525599397267795 Method = KDE, EM cycle = 15,
#> Max-Change = 0.00477736944784368 Method = KDE, EM cycle = 16, Max-
#> Change = 0.00561566260576329 Method = KDE, EM cycle = 17, Max-
#> Change = 0.00453338476661269 Method = KDE, EM cycle = 18, Max-
#> Change = 0.00365807940276097 Method = KDE, EM cycle = 19, Max-
#> Change = 0.00537557750561257 Method = KDE, EM cycle = 20, Max-
#> Change = 0.00274684001503989 Method = KDE, EM cycle = 21, Max-
#> Change = 0.00178229497981702 Method = KDE, EM cycle = 22, Max-
#> Change = 0.00149983028944267 Method = KDE, EM cycle = 23, Max-
#> Change = 0.00128409555727266 Method = KDE, EM cycle = 24, Max-
#> Change = 0.00110103212071344 Method = KDE, EM cycle = 25, Max-
#> Change = 0.00102975032884611 Method = KDE, EM cycle = 26, Max-
#> Change = 0.00106703937639074 Method = KDE, EM cycle = 27, Max-
#> Change = 0.00129952864838123 Method = KDE, EM cycle = 28, Max-
#> Change = 0.00144199601112338 Method = KDE, EM cycle = 29, Max-
#> Change = 0.00358150758132147 Method = KDE, EM cycle = 30, Max-
#> Change = 0.00181468350188441 Method = KDE, EM cycle = 31, Max-Change =
#> 0.000826399164590264

######                      ######
###### Normality assumption ######
######                      ######
#  Mod1 <- IRTest_Mix(initialitem_D = initialitemD,
#                     initialitem_P = initialitemP,
#                     data_D = DataD,
#                     data_P = DataP,
#                     model_D = rep(2,5),
#                     model_P = "GPCM",
#                     latent_dist = "Normal",
#                     max_iter = 200,
#                     threshold = .001)

######                            ######
###### Empirical histogram method ######
######                            ######
#  Mod1 <- IRTest_Mix(initialitem_D = initialitemD,
#                     initialitem_P = initialitemP,
#                     data_D = DataD,
#                     data_P = DataP,
#                     model_D = rep(2,5),
#                     model_P = "GPCM",
#                     latent_dist = "EHM",
#                     max_iter = 200,
#                     threshold = .001)

######                                             ######
###### Two-component Gaussian mixture distribution ######
######                                             ######
#  Mod1 <- IRTest_Mix(initialitem_D = initialitemD,
#                     initialitem_P = initialitemP,
#                     data_D = DataD,
#                     data_P = DataP,
#                     model_D = rep(2,5),
#                     model_P = "GPCM",
#                     latent_dist = "Mixture",
#                     max_iter = 200,
#                     threshold = .001)

######                                                        ######
###### Davidian curve (for an arbitrarily chosen case of h=4) ######
######                                                        ######
#  Mod1 <- IRTest_Mix(initialitem_D = initialitemD,
#                     initialitem_P = initialitemP,
#                     data_D = DataD,
#                     data_P = DataP,
#                     model_D = rep(2,5),
#                     model_P = "GPCM",
#                     latent_dist = "DC",
#                     max_iter = 200,
#                     threshold = .001,
#                     h = 4)




### The estimated item parameters
Mod1$par_est
#> $Dichotomous
#>             a          b c
#> [1,] 2.200954  0.9115074 0
#> [2,] 1.984903 -1.0332999 0
#> [3,] 1.110728  0.4980855 0
#> [4,] 1.258792  0.5392781 0
#> [5,] 2.287480  1.4436252 0
#> 
#> $Polytomous
#>             a        b_1         b_2 b_3 b_4 b_5 b_6
#> [1,] 1.966701  0.3937469  0.42467910  NA  NA  NA  NA
#> [2,] 2.007852 -0.3261131  0.06844343  NA  NA  NA  NA
#> [3,] 2.056885 -0.3897486 -0.22236003  NA  NA  NA  NA
#> [4,] 1.030497 -0.1731280  0.19751324  NA  NA  NA  NA
#> [5,] 0.785141  0.2433940  0.08376259  NA  NA  NA  NA

### The asymptotic standard errors of item parameters
Mod1$se
#> $Dichotomous
#>               a          b  c
#> [1,] 0.15475720 0.04668629 NA
#> [2,] 0.14171212 0.05355501 NA
#> [3,] 0.08520384 0.06947386 NA
#> [4,] 0.09141200 0.06332382 NA
#> [5,] 0.19665345 0.06471224 NA
#> 
#> $Polytomous
#>               a        b_1        b_2 b_3 b_4 b_5 b_6
#> [1,] 0.11688799 0.05981212 0.05958615  NA  NA  NA  NA
#> [2,] 0.11456065 0.05304505 0.05249768  NA  NA  NA  NA
#> [3,] 0.11996224 0.05626596 0.05611498  NA  NA  NA  NA
#> [4,] 0.06432937 0.08543217 0.08539457  NA  NA  NA  NA
#> [5,] 0.05401889 0.11481480 0.11424988  NA  NA  NA  NA

### The estimated ability parameters
head(Mod1$theta)
#> [1] -0.5775496 -0.7558405  0.6185433 -0.8691925 -1.3624809 -1.5623822

### The estimated latent distribution
plot_LD(Mod1, xlim = c(-6,6))



—-