    library(irt)

An `Itempool` object is a collection of `Item` and `Testlet` objects. It contains information of all items in a test or all items that will be used in an item pool of an adaptive test.

## Creating an `Itempool` Object

### Dichotomous Items (`Rasch`, `1PL`, `2PL`, `3PL`, `4PL`)

There are multiple ways to create an `Itempool` object. If all of the items are from the same psychometric model, then using a `data.frame` object to create an `Itempool` object is the most straightforward way.

    # Create an item pool of 2PL items:
    ip_dtf <- data.frame(
      a = c(1.1821, 0.6645, 0.8994, 1.0731, 1.0252, 1.2325, 0.9278, 1.0967),
      b = c(0.4185, -0.5992, 0.2193, 0.8823, 0.4652, 1.4006, -1.1193, -0.3747))

    ip <- itempool(ip_dtf, model = "2PL")
    ip
    #> An object of class 'Itempool'.
    #> Model of items: 2PL
    #> D = 1
    #>
    #>   item_id     a      b
    #>   <chr>   <dbl>  <dbl>
    #> 1 Item_1  1.18   0.418
    #> 2 Item_2  0.664 -0.599
    #> 3 Item_3  0.899  0.219
    #> 4 Item_4  1.07   0.882
    #> 5 Item_5  1.03   0.465
    #> 6 Item_6  1.23   1.40
    #> 7 Item_7  0.928 -1.12
    #> 8 Item_8  1.10  -0.375

If desired, `item_id`'s and content areas of each item can be specified:

    ip_dtf <- data.frame(
      a = c(1.1821, 0.6645, 0.8994, 1.0731, 1.0252, 1.2325, 0.9278, 1.0967),
      b = c(0.4185, -0.5992, 0.2193, 0.8823, 0.4652, 1.4006, -1.1193, -0.3747),
      item_id = c("i1", "i2", "i3", "i4", "i5", "i6", "i7", "i8"),
      content = c("Geometry", "Geometry", "Algebra", "Algebra", "Algebra",
                  "Geometry", "Algebra", "Algebra")
      )

    ip <- itempool(ip_dtf, model = "2PL")
    ip
    #> An object of class 'Itempool'.
    #> Model of items: 2PL
    #> D = 1
    #>
    #>   item_id     a      b content
    #>   <chr>   <dbl>  <dbl> <chr>
    #> 1 i1      1.18   0.418 Geometry
    #> 2 i2      0.664 -0.599 Geometry
    #> 3 i3      0.899  0.219 Algebra
    #> 4 i4      1.07   0.882 Algebra
    #> 5 i5      1.03   0.465 Algebra
    #> 6 i6      1.23   1.40  Geometry
    #> 7 i7      0.928 -1.12  Algebra
    #> 8 i8      1.10  -0.375 Algebra

By default, the scaling parameter `D` for most of the models are set to 1. This can be overwritten:

    ip <- itempool(ip_dtf, model = "2PL", D = 1.7)
    ip
    #> An object of class 'Itempool'.
    #> Model of items: 2PL
    #> D = 1.7
    #>
    #>   item_id     a      b content
    #>   <chr>   <dbl>  <dbl> <chr>
    #> 1 i1      1.18   0.418 Geometry
    #> 2 i2      0.664 -0.599 Geometry
    #> 3 i3      0.899  0.219 Algebra
    #> 4 i4      1.07   0.882 Algebra
    #> 5 i5      1.03   0.465 Algebra
    #> 6 i6      1.23   1.40  Geometry
    #> 7 i7      0.928 -1.12  Algebra
    #> 8 i8      1.10  -0.375 Algebra

Please review psychometric models for other models and required parameters. For example, for `3PL` model:

    ip_dtf <- data.frame(a = c(0.9303, 1.9423, 0.8417, 1.2622),
                         b = c(1.3515, -0.5039, -1.7263, 1.3125),
                         c = c(0.2301, 0.2224, 0.0967, 0.0112))
    ip <- itempool(ip_dtf, model = "3PL", D = 1.7)
    ip
    #> An object of class 'Itempool'.
    #> Model of items: 3PL
    #> D = 1.7
    #>
    #>   item_id     a      b      c
    #>   <chr>   <dbl>  <dbl>  <dbl>
    #> 1 Item_1  0.930  1.35  0.230
    #> 2 Item_2  1.94  -0.504 0.222
    #> 3 Item_3  0.842 -1.73  0.0967
    #> 4 Item_4  1.26   1.31  0.0112

### Polytomous Items (`GRM`, `GPCM`, `PCM`)

For polytomous items, usually a vector of item thresholds should be specified. So, threshold (or step) parameters can given as the following example:

    ip_dtf <- data.frame(a = c(1.8619, 1.2458, 1.3213, 0.6174, 1.3625),
                         b1 = c(-0.3666, -0.9717, -1.1588, 0.1093, 0.0858),
                         b2 = c(0.3178, 0.2458, -0.4978, 0.6437, 0.5161),
                         b3 = c(1.0384, 1.2382, 1.2787, 1.3609, 1.2145))

    ip <- itempool(ip_dtf, model = "GPCM")
    ip
    #> An object of class 'Itempool'.
    #> Model of items: GPCM
    #> D = 1
    #>
    #>   item_id     a      b1     b2    b3
    #>   <chr>   <dbl>   <dbl>  <dbl> <dbl>
    #> 1 Item_1  1.86  -0.367   0.318  1.04
    #> 2 Item_2  1.25  -0.972   0.246  1.24
    #> 3 Item_3  1.32  -1.16   -0.498  1.28
    #> 4 Item_4  0.617  0.109   0.644  1.36
    #> 5 Item_5  1.36   0.0858  0.516  1.21

The number of threshold parameters can be differ among items. In those cases, simply fill the rest of the values using `NA`:

    ip_dtf <- data.frame(a = c(1.175, 0.981, 1.0625, 0.9545, 0.7763),
                         b1 = c(-0.9633, -0.4098, -0.298, 0.0576, -0.5342),
                         b2 = c(-0.6213, NA, 0.4792, 0.538, 0.0363),
                         b3 = c(0.5938, NA, NA, 0.9815, NA),
                         b4 = c(NA, NA, NA, 1.3351, NA))
    ip <- itempool(ip_dtf, model = "GRM", D = 1.702)
    ip
    #> An object of class 'Itempool'.
    #> Model of items: GRM
    #> D = 1.702
    #>
    #>   item_id     a      b1      b2     b3    b4
    #>   <chr>   <dbl>   <dbl>   <dbl>  <dbl> <dbl>
    #> 1 Item_1  1.18  -0.963  -0.621   0.594 NA
    #> 2 Item_2  0.981 -0.410  NA      NA     NA
    #> 3 Item_3  1.06  -0.298   0.479  NA     NA
    #> 4 Item_4  0.954  0.0576  0.538   0.982  1.34
    #> 5 Item_5  0.776 -0.534   0.0363 NA     NA

An example reparameterized “GPCM” item pool (see psychometric models vignette for details of this model):

    ip_dtf <- data.frame(a = c(1.1152, 0.8231, 0.9527, 0.6423),
                         b = c(0.234, 0.0219,  0.7424, -0.3426),
                         d1 = c(0.0081, 0.8569, -1.5181, -0.8458),
                         d2 = c(0.3392, NA, -0.1978, 0.3756),
                         d3 = c(NA, NA, 0.1677, NA))
    ip <- itempool(ip_dtf, model = "GPCM2", D = 1.702)
    ip
    #> An object of class 'Itempool'.
    #> Model of items: GPCM2
    #> D = 1.702
    #>
    #>   item_id     a       b      d1     d2     d3
    #>   <chr>   <dbl>   <dbl>   <dbl>  <dbl>  <dbl>
    #> 1 Item_1  1.12   0.234   0.0081  0.339 NA
    #> 2 Item_2  0.823  0.0219  0.857  NA     NA
    #> 3 Item_3  0.953  0.742  -1.52   -0.198  0.168
    #> 4 Item_4  0.642 -0.343  -0.846   0.376 NA

### Mixture of Models

If an `Itempool` object should consist of mixture of items, then the item parameter of each item should be specified as the examples above. But, `model` should be specified for each item in the `data.frame`.

For example, the following item pool consists of three `3PL` items and two `GPCM` items:

    ip_dtf <- data.frame(
      model = c("3PL", "3PL", "3PL", "GPCM", "GPCM"),
      a = c(1.6242, 0.9471, 1.4643, 0.6582, 1.0234),
      b = c(0.4563, -0.2994, -0.3027, NA, NA),
      c = c(0.0156, 0.0339, 0.1243, NA, NA),
      b1 = c(NA, NA, NA, -1.1532, -1.2171),
      b2 = c(NA, NA, NA, -0.5384, -0.3992),
      b3 = c(NA, NA, NA, 0.0591, 0.1431),
      b4 = c(NA, NA, NA, NA, 1.52),
      D = c(1.7, 1.7, 1.7, 1, 1))
    ip <- itempool(ip_dtf)
    ip
    #> An object of class 'Itempool'.
    #>
    #>   item_id model     a      b       c    b1     b2      b3    b4     D
    #>   <chr>   <chr> <dbl>  <dbl>   <dbl> <dbl>  <dbl>   <dbl> <dbl> <dbl>
    #> 1 Item_1  3PL   1.62   0.456  0.0156 NA    NA     NA      NA      1.7
    #> 2 Item_2  3PL   0.947 -0.299  0.0339 NA    NA     NA      NA      1.7
    #> 3 Item_3  3PL   1.46  -0.303  0.124  NA    NA     NA      NA      1.7
    #> 4 Item_4  GPCM  0.658 NA     NA      -1.15 -0.538  0.0591 NA      1
    #> 5 Item_5  GPCM  1.02  NA     NA      -1.22 -0.399  0.143   1.52   1

### Other Ways to Create `Itempool` Objects

An `Itempool` object can be created using individual `Item` and `Testlet` objects. For example, in the the following code, individual `Item` objects are combined to create an `Itempool` object.

    ip <- c(item(model = "3PL", a = 2.09, b = 1.17, c = 0.25, item_id = "i1"),
            item(model = "3PL", a = 0.59, b = 0.77, c = 0.13, item_id = "i2"),
            item(model = "3PL", a = 1.67, b = 1.05, c = 0.04, item_id = "i3"),
            item(model = "3PL", a = 0.84, b = -1.8, c = 0.24, item_id = "i4"),
            item(model = "GPCM", a = 1.96, b = c(-0.94, -0.09, 0.25), item_id = "i5"),
            item(model = "GPCM", a = 0.59, b = c(0.07, 1.46), item_id = "i6"),
            item(model = "GPCM", a = 0.73, b = c(-1.2, -0.78, 0.2, 1.8), item_id = "i7"))
    ip
    #> An object of class 'Itempool'.
    #> D = 1
    #>
    #>   item_id model     a     b     c    b1    b2    b3    b4
    #>   <chr>   <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
    #> 1 i1      3PL    2.09  1.17  0.25 NA    NA    NA     NA
    #> 2 i2      3PL    0.59  0.77  0.13 NA    NA    NA     NA
    #> 3 i3      3PL    1.67  1.05  0.04 NA    NA    NA     NA
    #> 4 i4      3PL    0.84 -1.8   0.24 NA    NA    NA     NA
    #> 5 i5      GPCM   1.96 NA    NA    -0.94 -0.09  0.25  NA
    #> 6 i6      GPCM   0.59 NA    NA     0.07  1.46 NA     NA
    #> 7 i7      GPCM   0.73 NA    NA    -1.2  -0.78  0.2    1.8

Using this method, `Testlet` objects can be added to the item pool.

    # Create a testlet object with three items.
    t1 <- testlet(c(item(model = "3PL", a = 2.09, b = 1.17, c = 0.25, item_id = "i1"),
                    item(model = "3PL", a = 0.59, b = 0.77, c = 0.13, item_id = "i2"),
                    item(model = "3PL", a = 1.67, b = 1.05, c = 0.04, item_id = "i3")),
                  testlet_id = "Testlet-932")
    # Create another testlet object with two items.
    t2 <- testlet(c(item(model = "3PL", a = 0.84, b = -1.8, c = 0.24, item_id = "i4"),
                    item(model = "GPCM", a = 1.96, b = c(-0.94, -0.09, 0.25),
                         item_id = "i5")),
                  testlet_id = "Testlet-77")
    # Standalone items to be added:
    i6 <- item(model = "GPCM", a = 0.59, b = c(0.07, 1.46), item_id = "i6")
    i7 <- item(model = "GPCM", a = 0.73, b = c(-1.2, -0.78, 0.2, 1.8), item_id = "i7")

    # Combine all items and testlets:
    ip_testlet <- c(t1, t2, i6, i7)
    ip_testlet
    #> An object of class 'Itempool'.
    #> D = 1
    #>
    #>   item_id testlet_id  model     a     b     c    b1    b2    b3    b4
    #>   <chr>   <chr>       <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
    #> 1 i1      Testlet-932 3PL    2.09  1.17  0.25 NA    NA    NA     NA
    #> 2 i2      Testlet-932 3PL    0.59  0.77  0.13 NA    NA    NA     NA
    #> 3 i3      Testlet-932 3PL    1.67  1.05  0.04 NA    NA    NA     NA
    #> 4 i4      Testlet-77  3PL    0.84 -1.8   0.24 NA    NA    NA     NA
    #> 5 i5      Testlet-77  GPCM   1.96 NA    NA    -0.94 -0.09  0.25  NA
    #> 6 i6      <NA>        GPCM   0.59 NA    NA     0.07  1.46 NA     NA
    #> 7 i7      <NA>        GPCM   0.73 NA    NA    -1.2  -0.78  0.2    1.8

# Operations with `Itempool` Objects

We will show the operations that can be performed on an `Itempool` object using the following three example item pools:

    ip1 <- itempool(data.frame(
      a = c(1.1821, 0.6645, 0.8994, 1.0731, 1.0252, 1.2325, 0.9278, 1.0967),
      b = c(0.4185, -0.5992, 0.2193, 0.8823, 0.4652, 1.4006, -1.1193, -0.3747),
      item_id = c("i1", "i2", "i3", "i4", "i5", "i6", "i7", "i8"),
      content = c("Geometry", "Geometry", "Algebra", "Algebra", "Algebra",
                  "Geometry", "Algebra", "Algebra")
      ))

    ip_mixed <- itempool(data.frame(
      model = c("3PL", "3PL", "3PL", "GPCM", "GPCM"),
      a = c(1.6242, 0.9471, 1.4643, 0.6582, 1.0234),
      b = c(0.4563, -0.2994, -0.3027, NA, NA),
      c = c(0.0156, 0.0339, 0.1243, NA, NA),
      b1 = c(NA, NA, NA, -1.1532, -1.2171),
      b2 = c(NA, NA, NA, -0.5384, -0.3992),
      b3 = c(NA, NA, NA, 0.0591, 0.1431),
      b4 = c(NA, NA, NA, NA, 1.52),
      D = c(1.7, 1.7, 1.7, 1.7, 1.7)))

    ip_testlet <- c(
      testlet(c(item(model = "3PL", a = 2.09, b = 1.17, c = 0.25, item_id = "i1"),
                item(model = "3PL", a = 0.59, b = 0.77, c = 0.13, item_id = "i2"),
                item(model = "3PL", a = 1.67, b = 1.05, c = 0.04, item_id = "i3")),
              testlet_id = "Testlet-932"),
      item(model = "GPCM", a = 0.59, b = c(0.07, 1.46), item_id = "i6"),
      testlet(c(item(model = "3PL", a = 0.84, b = -1.8, c = 0.24, item_id = "i4"),
                item(model = "GPCM", a = 1.96, b = c(-0.94, -0.09, 0.25),
                     item_id = "i5")),
              testlet_id = "Testlet-77"),
      item(model = "GPCM", a = 0.73, b = c(-1.2, -0.78, 0.2, 1.8), item_id = "i7"))

## Combining Item Pools

Two `Itempool` objects can be combined using `c()` function.

    ip <- c(ip1, ip_mixed)
    ip
    #> An object of class 'Itempool'.
    #>
    #>    item_id model     a      b       c    b1     b2      b3    b4     D content
    #>    <chr>   <chr> <dbl>  <dbl>   <dbl> <dbl>  <dbl>   <dbl> <dbl> <dbl> <chr>
    #>  1 i1      2PL   1.18   0.418 NA      NA    NA     NA      NA      1   Geometry
    #>  2 i2      2PL   0.664 -0.599 NA      NA    NA     NA      NA      1   Geometry
    #>  3 i3      2PL   0.899  0.219 NA      NA    NA     NA      NA      1   Algebra
    #>  4 i4      2PL   1.07   0.882 NA      NA    NA     NA      NA      1   Algebra
    #>  5 i5      2PL   1.03   0.465 NA      NA    NA     NA      NA      1   Algebra
    #>  6 i6      2PL   1.23   1.40  NA      NA    NA     NA      NA      1   Geometry
    #>  7 i7      2PL   0.928 -1.12  NA      NA    NA     NA      NA      1   Algebra
    #>  8 i8      2PL   1.10  -0.375 NA      NA    NA     NA      NA      1   Algebra
    #>  9 Item_1  3PL   1.62   0.456  0.0156 NA    NA     NA      NA      1.7 <NA>
    #> 10 Item_2  3PL   0.947 -0.299  0.0339 NA    NA     NA      NA      1.7 <NA>
    #> 11 Item_3  3PL   1.46  -0.303  0.124  NA    NA     NA      NA      1.7 <NA>
    #> 12 Item_4  GPCM  0.658 NA     NA      -1.15 -0.538  0.0591 NA      1.7 <NA>
    #> 13 Item_5  GPCM  1.02  NA     NA      -1.22 -0.399  0.143   1.52   1.7 <NA>

## Subsetting

`Itempool` objects can be subsetted using brackets `[ ]`. This operation will always return an `Itempool` object.

    # Subset only the first element of the item pool
    ip1[1]
    #> An object of class 'Itempool'.
    #> Model of items: 2PL
    #> D = 1
    #> Content = Geometry
    #>
    #>   item_id     a     b
    #>   <chr>   <dbl> <dbl>
    #> 1 i1       1.18 0.418

    # Create an Itempool using the first and third element:
    ip1[c(1, 3)] # Order is important
    #> An object of class 'Itempool'.
    #> Model of items: 2PL
    #> D = 1
    #>
    #>   item_id     a     b content
    #>   <chr>   <dbl> <dbl> <chr>
    #> 1 i1      1.18  0.418 Geometry
    #> 2 i3      0.899 0.219 Algebra
    ip1[c(3, 1)]
    #> An object of class 'Itempool'.
    #> Model of items: 2PL
    #> D = 1
    #>
    #>   item_id     a     b content
    #>   <chr>   <dbl> <dbl> <chr>
    #> 1 i3      0.899 0.219 Algebra
    #> 2 i1      1.18  0.418 Geometry

    # Create an Itempool using all but the second element:
    ip1[-2]
    #> An object of class 'Itempool'.
    #> Model of items: 2PL
    #> D = 1
    #>
    #>   item_id     a      b content
    #>   <chr>   <dbl>  <dbl> <chr>
    #> 1 i1      1.18   0.418 Geometry
    #> 2 i3      0.899  0.219 Algebra
    #> 3 i4      1.07   0.882 Algebra
    #> 4 i5      1.03   0.465 Algebra
    #> 5 i6      1.23   1.40  Geometry
    #> 6 i7      0.928 -1.12  Algebra
    #> 7 i8      1.10  -0.375 Algebra

    # Subsetting using item ID's:
    ip1[c("i2", "i1")]
    #> An object of class 'Itempool'.
    #> Model of items: 2PL
    #> D = 1
    #> Content = Geometry
    #>
    #>   item_id     a      b
    #>   <chr>   <dbl>  <dbl>
    #> 1 i2      0.664 -0.599
    #> 2 i1      1.18   0.418

    # Subsetting using logical operators:
    ip1[ip1$b < 0]
    #> An object of class 'Itempool'.
    #> Model of items: 2PL
    #> D = 1
    #>
    #>   item_id     a      b content
    #>   <chr>   <dbl>  <dbl> <chr>
    #> 1 i2      0.664 -0.599 Geometry
    #> 2 i7      0.928 -1.12  Algebra
    #> 3 i8      1.10  -0.375 Algebra

    # Select items with information values larger than 0.2 at theta = 1:
    ip1[info(ip1, theta = 1) > 0.2]
    #> An object of class 'Itempool'.
    #> Model of items: 2PL
    #> D = 1
    #>
    #>   item_id     a     b content
    #>   <chr>   <dbl> <dbl> <chr>
    #> 1 i1       1.18 0.418 Geometry
    #> 2 i4       1.07 0.882 Algebra
    #> 3 i5       1.03 0.465 Algebra
    #> 4 i6       1.23 1.40  Geometry

## Extracting Items

An `Item` object can be extracted from an `Itempool` using double bracket operator `[[ ]]`. This operation will return an `Item` or `Testlet` object.

    # Extract the second element
    ip1[[2]]
    #> A '2PL' item.
    #> Item ID:      i2
    #> Model:   2PL (Two-Parameter Logistic Model)
    #> Content: Geometry
    #> Model Parameters:
    #>   a = 0.6645
    #>   b = -0.5992
    #>   D = 1
    #>
    #> --------------------------

    # Extract a testlet
    ip_testlet[[3]]
    #> An object of class 'Testlet'.
    #> Testlet ID:      Testlet-77
    #> Model:   BTM
    #>
    #> Item List:
    #> D = 1
    #>
    #>   item_id model     a     b     c    b1    b2    b3
    #>   <chr>   <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
    #> 1 i4      3PL    0.84  -1.8  0.24 NA    NA    NA
    #> 2 i5      GPCM   1.96  NA   NA    -0.94 -0.09  0.25

## Replacing Items of an `Itempool`

Using the double bracket with assignment operator, individual items of an `Itempool` object can be replaced.

    ip_new <- ip1
    # Replace the second item with a new item
    ip_new[[2]] <- item(a = 1, b = c(-1, 0, 1), model = "GRM", item_id = "NewItm4",
                        D = 1.7, content = "Quadratic Functions")
    ip_new
    #> An object of class 'Itempool'.
    #>
    #>   item_id model     a      b    b1    b2    b3     D content
    #>   <chr>   <chr> <dbl>  <dbl> <dbl> <dbl> <dbl> <dbl> <chr>
    #> 1 i1      2PL   1.18   0.418    NA    NA    NA   1   Geometry
    #> 2 NewItm4 GRM   1     NA        -1     0     1   1.7 Quadratic Functions
    #> 3 i3      2PL   0.899  0.219    NA    NA    NA   1   Algebra
    #> 4 i4      2PL   1.07   0.882    NA    NA    NA   1   Algebra
    #> 5 i5      2PL   1.03   0.465    NA    NA    NA   1   Algebra
    #> 6 i6      2PL   1.23   1.40     NA    NA    NA   1   Geometry
    #> 7 i7      2PL   0.928 -1.12     NA    NA    NA   1   Algebra
    #> 8 i8      2PL   1.10  -0.375    NA    NA    NA   1   Algebra

## Accessing Parts of an `Itempool` object

`$` operator can be used to access parts of an `Itempool` object. Here, we will discuss the most common uses of this operator. The full list of available options can be found in the help page:

    ?`$,Itempool-method`

    # Extract the ID's of the items within an item pool
    ip1$item_id
    #> [1] "i1" "i2" "i3" "i4" "i5" "i6" "i7" "i8"

    # Extract the contents of the items within an item pool
    ip1$content
    #>         i1         i2         i3         i4         i5         i6         i7
    #> "Geometry" "Geometry"  "Algebra"  "Algebra"  "Algebra" "Geometry"  "Algebra"
    #>         i8
    #>  "Algebra"

    # Extract the models of the items within an item pool
    ip1$model
    #>    i1    i2    i3    i4    i5    i6    i7    i8
    #> "2PL" "2PL" "2PL" "2PL" "2PL" "2PL" "2PL" "2PL"
    ip_mixed$model
    #> Item_1 Item_2 Item_3 Item_4 Item_5
    #>  "3PL"  "3PL"  "3PL" "GPCM" "GPCM"

    # Maximum possible score of items
    ip1$max_score
    #> [1] 8
    ip_mixed$max_score
    #> [1] 10
    ip_testlet$max_score
    #> [1] 13

    # Maximum scores of each standalone item
    ip1$item_max_score
    #> i1 i2 i3 i4 i5 i6 i7 i8
    #>  1  1  1  1  1  1  1  1
    ip_mixed$item_max_score
    #> Item_1 Item_2 Item_3 Item_4 Item_5
    #>      1      1      1      3      4
    ip_testlet$item_max_score
    #> i1 i2 i3 i6 i4 i5 i7
    #>  1  1  1  2  1  3  4

Item parameters can also be accessed:

    ip1$a
    #>     i1     i2     i3     i4     i5     i6     i7     i8
    #> 1.1821 0.6645 0.8994 1.0731 1.0252 1.2325 0.9278 1.0967
    ip1$b
    #>      i1      i2      i3      i4      i5      i6      i7      i8
    #>  0.4185 -0.5992  0.2193  0.8823  0.4652  1.4006 -1.1193 -0.3747
    ip1$c
    #> NULL
    ip1$D
    #> i1 i2 i3 i4 i5 i6 i7 i8
    #>  1  1  1  1  1  1  1  1

    ip_mixed$a
    #> Item_1 Item_2 Item_3 Item_4 Item_5
    #> 1.6242 0.9471 1.4643 0.6582 1.0234
    ip_mixed$b
    #>  Item_1  Item_2  Item_3  Item_4  Item_5
    #>  0.4563 -0.2994 -0.3027      NA      NA
    ip_mixed$b1
    #>  Item_1  Item_2  Item_3  Item_4  Item_5
    #>      NA      NA      NA -1.1532 -1.2171
    ip_mixed$b4
    #> Item_1 Item_2 Item_3 Item_4 Item_5
    #>     NA     NA     NA     NA   1.52
    ip_mixed$D
    #> Item_1 Item_2 Item_3 Item_4 Item_5
    #>    1.7    1.7    1.7    1.7    1.7

Using the operator `$n`, we can extract a detailed summary of the number of `Item`s and `Testlet`s in the item pool. This is especially useful if the item pool has both standalone and testlet items.

- `$n$elements` gives the total number of testlets and standalone items.
- `$n$testlets` gives the total number of testlets.
- `$n$items` gives the total number of standalone items and items within testlets.

    # Extract the number of items within an item pool
    ip1$n
    #> $elements
    #> [1] 8
    #>
    #> $testlets
    #> [1] 0
    #>
    #> $items
    #> [1] 8
    # In ip_testlet, there are two testlets and two standalone items. Within those
    # two testlets, there are a total of 5 items. At total there are 7 items.
    ip_testlet$n
    #> $elements
    #> [1] 4
    #>
    #> $testlets
    #> [1] 2
    #>
    #> $items
    #> [1] 7

## Updating Parts of an `Itempool` object

Using `$<-` operator, the parts of an item pool can be updated. For example, using the following code, we can change the `item_id`s and `content`s of the items of an item pool.

    ip_new <- ip1
    ip_new$item_id <- paste0("Question-", 1:length(ip_new))
    ip_new$content <- c("M", "M", "R", "M", "E", "R", "E", "M")

New item parameters can be set this way as well:

    ip_new$a <- 1
    ip_new
    #> An object of class 'Itempool'.
    #> Model of items: 2PL
    #> D = 1
    #>
    #>   item_id        a      b content
    #>   <chr>      <dbl>  <dbl> <chr>
    #> 1 Question-1     1  0.418 M
    #> 2 Question-2     1 -0.599 M
    #> 3 Question-3     1  0.219 R
    #> 4 Question-4     1  0.882 M
    #> 5 Question-5     1  0.465 E
    #> 6 Question-6     1  1.40  R
    #> 7 Question-7     1 -1.12  E
    #> 8 Question-8     1 -0.375 M
    ip_new$b <- rnorm(length(ip_new))
    ip_new
    #> An object of class 'Itempool'.
    #> Model of items: 2PL
    #> D = 1
    #>
    #>   item_id        a      b content
    #>   <chr>      <dbl>  <dbl> <chr>
    #> 1 Question-1     1 -0.712 M
    #> 2 Question-2     1  1.35  M
    #> 3 Question-3     1  0.240 R
    #> 4 Question-4     1 -0.217 M
    #> 5 Question-5     1  0.787 E
    #> 6 Question-6     1 -0.131 R
    #> 7 Question-7     1  0.703 E
    #> 8 Question-8     1 -1.10  M