5.3 Likelihood of an individual response vector (Cont’d)

Suppose these items are DINA-type items and assume that guessing and slip parameters are .1 and .2 respectively for all of them.

Recall that for the DINA model, the conditional success probability of student i to item j is P(Yij=1|αc)={gjif αTcqj<qTjqj1sjotherwise

Calculate the conditional success probability P(Yj=1|αc), which can be saved in a matrix with each item (in rows) and each attribute profile (i.e., 00,10,01 and 11 in columns):

Code
g <- 0.1
s <- 0.2
J <- 5
K <- 2
N <- 10
p.y.given.alpha <- matrix(NA, nrow = J, ncol = 2^K)
attributeprofiles <- GDINA::attributepattern(2)
for (j in 1:J) {
    for (a in 1:2^K) {
        if (sum(attributeprofiles[a, ] * Q[j, ]) < sum(Q[j, ] * Q[j, ])) {
            p.y.given.alpha[j, a] <- g
        } else {
            p.y.given.alpha[j, a] <- 1 - s
        }
    }
}
00 10 01 11
item 1 0.1 0.8 0.1 0.8
item 2 0.1 0.8 0.1 0.8
item 3 0.1 0.1 0.8 0.8
item 4 0.1 0.1 0.8 0.8
item 5 0.1 0.1 0.1 0.8

Let αi be the attribute profile of student i. Under the assumption of local independence, the likelihood of observing a response vector Yi for student i is

L(Yi|αi)=Jj=1P(Yij=1|αi)Yij[1P(Yij=1|αi)]1Yij

Exercise 5.1 Verify that for the first student, L(Y1|αi=10)=.00144.

What is L(Y3|αi=01)?

Click for Answer

L(Yi|αc) can be presented in a matrix of N×2K:

Code
Li.given.alpha.c <- matrix(NA, nrow = 10, ncol = 4)
for (i in 1:10) {
    # for each student for each latent class
    for (cc in 1:4) {
        Li.given.alpha.c[i, cc] <- prod((p.y.given.alpha[, cc]^y[i, ]) *
            (1 - p.y.given.alpha[, cc])^(1 - y[i, ]))
    }
}
colnames(Li.given.alpha.c) <- c("00", "10", "01", "11")
rownames(Li.given.alpha.c) <- paste("student", 1:10)
Li.given.alpha.c
##                 00      10      01     11
## student 1  0.00081 0.00144 0.00144 0.0205
## student 2  0.00729 0.01296 0.01296 0.0051
## student 3  0.00081 0.00004 0.05184 0.0205
## student 4  0.00081 0.05184 0.00144 0.0205
## student 5  0.00729 0.01296 0.00036 0.0051
## student 6  0.00729 0.00036 0.01296 0.0051
## student 7  0.00729 0.01296 0.01296 0.0051
## student 8  0.00009 0.00016 0.00576 0.0819
## student 9  0.00081 0.05184 0.00144 0.0205
## student 10 0.00081 0.00144 0.00144 0.0205