This function estimates attribute profiles using nonparametric approaches for both the "AND gate" (conjunctive) and the "OR gate" (disjunctive) cognitive diagnostic models. These algorithms select the attribute profile with the smallest loss function value (plain, weighted, or penalized Hamming distance, see below for details) as the estimate. If more than one attribute profiles have the smallest loss function value, one of them is randomly chosen.
1 2 
Y 
A matrix of binary responses. Rows represent persons and columns represent items. 1=correct, 0=incorrect. 
Q 
The Qmatrix of the test. Rows represent items and columns represent attributes. 1=attribute required by the item, 0=attribute not required by the item. 
gate 

method 
The method of nonparametric estimation. 
wg 
Additional argument for the "penalized" method. 
ws 
Additional input for the "penalized" method. 
alpha.est 
Estimated attribute profiles. Rows represent persons and columns represent attributes. 1=examinee masters the attribute, 0=examinee does not master the attribute. 
est.ideal 
Estimated ideal response to all items by all examinees. Rows represent persons and columns represent items. 1=correct, 0=incorrect. 
est.class 
The class number (row index in 
n.tie 
Number of ties in the Hamming distance among the candidate attribute profiles for each person. When we encounter ties, one of the tied attribute profiles is randomly chosen. 
pattern 
All possible attribute profiles in the search space. 
loss.matrix 
The matrix of the values for the loss function (the plain, weighted, or penalized Hamming distance). Rows represent candidate attribute profiles in the same order with the pattern matrix; columns represent different examinees. 
Chiu, C. (2011). Flexible approaches to cognitive diagnosis: nonparametric methods and small sample techniques. Invited session of cognitive diagnosis and item response theory at 2011 Joint Statistical Meeting.
Chiu, C. Y., & Douglas, J. A. (2013). A nonparametric approach to cognitive diagnosis by proximity to ideal response patterns. Journal of Classification 30(2), 225250.
AlphaMLE
, JMLE
, print.AlphaNP
, plot.AlphaNP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39  # Generate item and examinee profiles
natt < 3
nitem < 4
nperson < 5
Q < rbind(c(1, 0, 0), c(0, 1, 0), c(0, 0, 1), c(1, 1, 1))
alpha < rbind(c(0, 0, 0), c(1, 0, 0), c(0, 1, 0), c(0, 0, 1), c(1, 1, 1))
# Generate DINA modelbased response data
slip < c(0.1, 0.15, 0.2, 0.25)
guess < c(0.1, 0.15, 0.2, 0.25)
my.par < list(slip=slip, guess=guess)
data < matrix(NA, nperson, nitem)
eta < matrix(NA, nperson, nitem)
for (i in 1:nperson) {
for (j in 1:nitem) {
eta[i, j] < prod(alpha[i,] ^ Q[j, ])
P < (1  slip[j]) ^ eta[i, j] * guess[j] ^ (1  eta[i, j])
u < runif(1)
data[i, j] < as.numeric(u < P)
}
}
# Using the function to estimate examinee attribute profile
alpha.est.NP.H < AlphaNP(data, Q, gate="AND", method="Hamming")
alpha.est.NP.W < AlphaNP(data, Q, gate="AND", method="Weighted")
alpha.est.NP.P < AlphaNP(data, Q, gate="AND", method="Penalized", wg=2, ws=1)
nperson < 1 # Choose an examinee to investigate
print(alpha.est.NP.H) # Print the estimated examinee attribute profiles
plot(alpha.est.NP.H, nperson) # Plot the sorted loss function of different
#attribute profiles for this examinee
ItemFit(alpha.est.NP.H, model="DINA", par=list(slip=slip, guess=guess))
ItemFit(alpha.est.NP.W, model="DINA", par=list(slip=slip, guess=guess))
ItemFit(alpha.est.NP.P, model="DINA", par=list(slip=slip, guess=guess))

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.
All documentation is copyright its authors; we didn't write any of that.