get.priority.Rd
This function will provide the priorities of attributes for all items.
get.priority(Y = NULL, Q = NULL, CDM.obj = NULL, model = "GDINA")
A required \(N\) × \(I\) matrix or data.frame
consisting of the responses of N
individuals
to \(N\) × \(I\) items. Missing values need to be coded as NA
.
A required binary \(I\) × \(K\) matrix containing the attributes not required or required
master the items. The i
th row of the matrix is a binary indicator vector indicating which
attributes are not required (coded by 0) and which attributes are required (coded by 1) to master
item \(i\).
An object of class CDM.obj
. When it is not NULL, it enables rapid validation
of the Q-matrix without the need for parameter estimation. @seealso CDM
.
Type of model to fit; can be "GDINA"
, "LCDM"
, "DINA"
, "DINO"
, "ACDM"
, "LLM"
, or "rRUM"
. Default = "GDINA"
.
@seealso CDM
.
A matrix containing all attribute priorities.
The calculation of priorities is straightforward (Qin & Guo, 2025): the priority of an attribute is the regression coefficient obtained from a LASSO multinomial logistic regression, with the attribute as the independent variable and the response data from the examinees as the dependent variable. The formula (Tu et al., 2022) is as follows:
$$ \log[\frac{P(X_{pi} = 1 | \boldsymbol{\Lambda}_{p})}{P(X_{pi} = 0 | \boldsymbol{\Lambda}_{p})}] = logit[P(X_{pi} = 1 | \boldsymbol{\Lambda}_{p})] = \beta_{i0} + \beta_{i1} \Lambda_{p1} + \ldots + \beta_{ik} \Lambda_{pk} + \ldots + \beta_{iK} \Lambda_{pK} $$
Where \(X_{pi}\) represents the response of examinee \(p\) on item \(i\),
\(\boldsymbol{\Lambda}_{p}\) denotes the marginal mastery probabilities of examinee \(p\)
(which can be obtained from the return value alpha.P
of the CDM
function),
\(\beta_{i0}\) is the intercept term, and \(\beta_{ik}\) represents the regression coefficient.
The LASSO loss function can be expressed as:
$$l_{lasso}(\boldsymbol{X}_i | \boldsymbol{\Lambda}) = l(\boldsymbol{X}_i | \boldsymbol{\Lambda}) - \lambda |\boldsymbol{\beta}_i|$$
Where \(l_{lasso}(\boldsymbol{X}_i | \boldsymbol{\Lambda})\) is the penalized likelihood, \(l(\boldsymbol{X}_i | \boldsymbol{\Lambda})\) is the original likelihood, and \(\lambda\) is the tuning parameter for penalization (a larger value imposes a stronger penalty on \(\boldsymbol{\beta}_i = [\beta_{i1}, \ldots, \beta_{ik}, \ldots, \beta_{iK}]\)). The priority for attribute \(i\) is defined as: \(\boldsymbol{priority}_i = \boldsymbol{\beta}_i = [\beta_{i1}, \ldots, \beta_{ik}, \ldots, \beta_{iK}]\)
Qin, H., & Guo, L. (2025). Priority attribute algorithm for Q-matrix validation: A didactic. Behavior Research Methods, 57(1), 31. DOI: 10.3758/s13428-024-02547-5.
Tu, D., Chiu, J., Ma, W., Wang, D., Cai, Y., & Ouyang, X. (2022). A multiple logistic regression-based (MLR-B) Q-matrix validation method for cognitive diagnosis models: A confirmatory approach. Behavior Research Methods. DOI: 10.3758/s13428-022-01880-x.
set.seed(123)
library(Qval)
## generate Q-matrix and data
K <- 5
I <- 20
IQ <- list(
P0 = runif(I, 0.1, 0.3),
P1 = runif(I, 0.7, 0.9)
)
# \donttest{
Q <- sim.Q(K, I)
data <- sim.data(Q = Q, N = 500, IQ = IQ, model = "GDINA", distribute = "horder")
#> distribute = horder
#> model = GDINA
#> number of attributes: 5
#> number of items: 20
#> num of examinees: 500
#> average of P0 = 0.21
#> average of P1 = 0.815
#> theta_mean = 0.03 , theta_sd = 0.969
#> a = 1.5 1.5 1.5 1.5 1.5
#> b = 1.5 -1.5 0 -0.75 0.75
MQ <- sim.MQ(Q, 0.1)
#> rate of mis-specifications = 0.1
#> rate of over-specifications = 0.07
#> rate of under-specifications = 0.03
CDM.obj <- CDM(data$dat, MQ)
#>
Iter = 1 Max. abs. change = 0.34790 Deviance = 13326.50
Iter = 2 Max. abs. change = 0.12730 Deviance = 11964.63
Iter = 3 Max. abs. change = 0.07033 Deviance = 11851.95
Iter = 4 Max. abs. change = 0.04349 Deviance = 11822.60
Iter = 5 Max. abs. change = 0.03059 Deviance = 11810.76
Iter = 6 Max. abs. change = 0.02304 Deviance = 11804.28
Iter = 7 Max. abs. change = 0.01716 Deviance = 11800.29
Iter = 8 Max. abs. change = 0.01489 Deviance = 11797.47
Iter = 9 Max. abs. change = 0.01406 Deviance = 11795.34
Iter = 10 Max. abs. change = 0.01324 Deviance = 11793.70
Iter = 11 Max. abs. change = 0.01243 Deviance = 11792.43
Iter = 12 Max. abs. change = 0.01167 Deviance = 11791.41
Iter = 13 Max. abs. change = 0.01089 Deviance = 11790.60
Iter = 14 Max. abs. change = 0.01060 Deviance = 11789.95
Iter = 15 Max. abs. change = 0.01040 Deviance = 11789.42
Iter = 16 Max. abs. change = 0.01027 Deviance = 11789.00
Iter = 17 Max. abs. change = 0.01015 Deviance = 11788.67
Iter = 18 Max. abs. change = 0.01011 Deviance = 11788.40
Iter = 19 Max. abs. change = 0.01003 Deviance = 11788.18
Iter = 20 Max. abs. change = 0.01005 Deviance = 11788.00
Iter = 21 Max. abs. change = 0.00813 Deviance = 11787.84
Iter = 22 Max. abs. change = 0.00536 Deviance = 11787.71
Iter = 23 Max. abs. change = 0.00503 Deviance = 11787.60
Iter = 24 Max. abs. change = 0.00511 Deviance = 11787.52
Iter = 25 Max. abs. change = 0.00635 Deviance = 11787.45
Iter = 26 Max. abs. change = 0.00764 Deviance = 11787.39
Iter = 27 Max. abs. change = 0.00878 Deviance = 11787.34
Iter = 28 Max. abs. change = 0.01001 Deviance = 11787.29
Iter = 29 Max. abs. change = 0.01123 Deviance = 11787.25
Iter = 30 Max. abs. change = 0.01243 Deviance = 11787.22
Iter = 31 Max. abs. change = 0.01351 Deviance = 11787.19
Iter = 32 Max. abs. change = 0.01459 Deviance = 11787.16
Iter = 33 Max. abs. change = 0.00282 Deviance = 11787.14
Iter = 34 Max. abs. change = 0.01730 Deviance = 11787.12
Iter = 35 Max. abs. change = 0.00280 Deviance = 11787.10
Iter = 36 Max. abs. change = 0.01950 Deviance = 11787.08
Iter = 37 Max. abs. change = 0.01957 Deviance = 11787.06
Iter = 38 Max. abs. change = 0.01948 Deviance = 11787.05
Iter = 39 Max. abs. change = 0.01912 Deviance = 11787.03
Iter = 40 Max. abs. change = 0.01591 Deviance = 11787.02
Iter = 41 Max. abs. change = 0.00317 Deviance = 11787.00
Iter = 42 Max. abs. change = 0.00102 Deviance = 11786.99
Iter = 43 Max. abs. change = 0.00097 Deviance = 11786.98
Iter = 44 Max. abs. change = 0.00093 Deviance = 11786.97
Iter = 45 Max. abs. change = 0.00090 Deviance = 11786.96
Iter = 46 Max. abs. change = 0.00144 Deviance = 11786.96
Iter = 47 Max. abs. change = 0.00082 Deviance = 11786.95
Iter = 48 Max. abs. change = 0.00079 Deviance = 11786.95
Iter = 49 Max. abs. change = 0.00076 Deviance = 11786.94
Iter = 50 Max. abs. change = 0.00110 Deviance = 11786.94
Iter = 51 Max. abs. change = 0.00069 Deviance = 11786.93
Iter = 52 Max. abs. change = 0.00068 Deviance = 11786.93
Iter = 53 Max. abs. change = 0.00065 Deviance = 11786.93
Iter = 54 Max. abs. change = 0.00062 Deviance = 11786.92
Iter = 55 Max. abs. change = 0.00060 Deviance = 11786.92
Iter = 56 Max. abs. change = 0.00058 Deviance = 11786.92
Iter = 57 Max. abs. change = 0.00100 Deviance = 11786.91
Iter = 58 Max. abs. change = 0.00054 Deviance = 11786.91
Iter = 59 Max. abs. change = 0.00052 Deviance = 11786.91
Iter = 60 Max. abs. change = 0.00050 Deviance = 11786.91
Iter = 61 Max. abs. change = 0.00073 Deviance = 11786.91
Iter = 62 Max. abs. change = 0.00046 Deviance = 11786.91
Iter = 63 Max. abs. change = 0.00045 Deviance = 11786.90
Iter = 64 Max. abs. change = 0.00044 Deviance = 11786.90
Iter = 65 Max. abs. change = 0.00042 Deviance = 11786.90
Iter = 66 Max. abs. change = 0.00042 Deviance = 11786.90
Iter = 67 Max. abs. change = 0.00039 Deviance = 11786.90
Iter = 68 Max. abs. change = 0.00039 Deviance = 11786.90
Iter = 69 Max. abs. change = 0.00037 Deviance = 11786.90
Iter = 70 Max. abs. change = 0.00065 Deviance = 11786.90
Iter = 71 Max. abs. change = 0.00054 Deviance = 11786.90
Iter = 72 Max. abs. change = 0.00034 Deviance = 11786.90
Iter = 73 Max. abs. change = 0.00033 Deviance = 11786.90
Iter = 74 Max. abs. change = 0.00032 Deviance = 11786.90
Iter = 75 Max. abs. change = 0.00031 Deviance = 11786.89
Iter = 76 Max. abs. change = 0.00030 Deviance = 11786.89
Iter = 77 Max. abs. change = 0.00052 Deviance = 11786.89
Iter = 78 Max. abs. change = 0.00028 Deviance = 11786.89
Iter = 79 Max. abs. change = 0.00027 Deviance = 11786.89
Iter = 80 Max. abs. change = 0.00026 Deviance = 11786.89
Iter = 81 Max. abs. change = 0.00027 Deviance = 11786.89
Iter = 82 Max. abs. change = 0.00053 Deviance = 11786.89
Iter = 83 Max. abs. change = 0.00041 Deviance = 11786.89
Iter = 84 Max. abs. change = 0.00024 Deviance = 11786.89
Iter = 85 Max. abs. change = 0.00024 Deviance = 11786.89
Iter = 86 Max. abs. change = 0.00025 Deviance = 11786.89
Iter = 87 Max. abs. change = 0.00020 Deviance = 11786.89
Iter = 88 Max. abs. change = 0.00011 Deviance = 11786.89
Iter = 89 Max. abs. change = 0.00010 Deviance = 11786.89
Iter = 90 Max. abs. change = 0.00012 Deviance = 11786.89
Iter = 91 Max. abs. change = 0.00018 Deviance = 11786.89
Iter = 92 Max. abs. change = 0.00005 Deviance = 11786.89
priority <- get.priority(data$dat, Q, CDM.obj)
head(priority)
#> A1 A2 A3 A4 A5
#> item 1 0.0000000 6.3203665 0.000000 0.000000 0.0000000
#> item 2 -0.7297358 -0.5433502 -1.401537 -1.448311 8.2786176
#> item 3 -0.2603273 0.0000000 4.789927 0.000000 -0.6815893
#> item 4 0.0000000 2.9298894 0.000000 0.000000 0.4173271
#> item 5 0.0000000 0.0000000 0.000000 1.234767 2.4409801
#> item 6 0.0000000 0.3906798 4.229747 0.000000 0.0000000
# }