cat.dt tutorial

knitr::opts_chunk$set(echo = TRUE)

The cat.dt package implements the Merged Tree-CAT method (RodrĂ­guez-Cuadrado et al., 2019, aimed at creating Computerized Adaptive Tests (CATs) in a fast and efficient way. The package stores the CAT in a tree structure where each node contains an item of the test. The examinee starts from a root node and progresses through the tree, depending on the responses provided to the items found.

The cat.dt package includes the following functionalities:

Tree-CAT creation

The package can be installed from CRAN:


It can also be installed from the development version’s github repository

Once the package is installed, the Tree-CAT is built by calling the main function CAT_DT. This function has the following input parameters:

Therefore, it is necessary to have a bank of calibrated items in the form of 'data.frame' or 'matrix'. The cat.dt package includes an item bank that will be used in this tutorial:


The function CAT_DT is called and the tree is stored in the variable TreeCAT:

TreeCAT = CAT_DT(bank = itemBank, model = "GRM", crit = "MEPV", C = 0.3, stop = c(6, 0.6), limit = 200, inters = 0.98, p = 0.9, dens = dnorm, 0, 1)

The function CAT_DT returns an object of class cat.dt. This object contains a list of the input parameters and also the following elements:

Tree-CAT summary

The Tree-CAT summary is a description of the Tree-CAT that contains the following elements:

The summary is obtained in the following way:


Tree-CAT visualization

The Tree-CAT is displayed by calling the plot_tree function. This function takes as input arguments: i) The Tree-CAT created; ii) The number of levels to plot and iii) The index of the root node to start the test. For example, to visualize the first three levels of the tree starting by the root node two:

plot_tree(TreeCAT, levels = 3, tree = 2)

The number within each node represents the item selected for that node and the color of each branch represents the response provided. In the figure above, we can see that the test starts with item 11. If we give answer 1 to that item, we will advance to item 18, and so on.

Evaluation of an individual and a group of examinees

Once the Tree-CAT is created, it can be administered to an individual or a group of participants. To administer the Tree-CAT to an individual, the function predict is used. The arguments of this function are the object Tree-CAT of the class cat.dt and a vector that contains the responses provided by the individual to each item from the item bank. It is important to note that the responses must take integer values from $1$ upwards.

As an example, the response dataset itemRes included in the package will be used. From that dataset, the first individual is evaluated (first row). The output is stored in the variable individual_ev:

individual_ev = predict(TreeCAT, itemRes[1, ])

This function returns a list with the following elements:

The estimation output:


The credible interval output:


The administered items output:


The plot of the evolution of the ability level estimation:


This plot represents the estimation of the ability level after responding to each one of the test items. For example, giving the response $1$ to the item $70$ results in an estimate of $-0.5$. Then, after giving the response $3$ to the item $18$, the estimate increases to $0$ approximately, and so on. Note that the value of the response influences whether the estimate decreases or increases.

This results can also be obtained by introducing

individual_ev = TreeCAT$predict(itemRes[1, ])


individual_ev = CAT_ability_est(TreeCAT, itemRes[1, ])

Note: By repeating this same code, the results of this section may be different. If the tree has a number of root nodes greater than one, the same individual may start the test by a different root node and therefore obtain different results when performing the test again.

The function predict is also used to evaluate a group of examinees. However, in this case, the vector of responses is replaced by a matrix containing in each row the answers of each examinee. This function returns a list, where each element in the list represents one of the examinees in the group. Each element contains a list with the same elements that the function returns when it is applied to an individual. As an example, we proceed to store the result in the variable group_ev:

group_ev = predict(TreeCAT, itemRes)

If, for example, we want to know which items have been administered to examinee number 6:


Try the cat.dt package in your browser

Any scripts or data that you put into this service are public.

cat.dt documentation built on March 31, 2021, 5:07 p.m.