5.7 E-step

In the E-step, one needs to calculate the posterior probability of observing a response vector Yi for student i :

P(αc|Yi)=L(Yi|αc)p(αc)L(Yi)

Recall that L(Yi|αc) is a N×2K matrix called Li.given.alpha.c.

Code
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

Let us assume P(00)=P(10)=16 and P(01)=P(11)=13 again and calculate P(αc|Yi):

Code
P.alphac.given.yi <- matrix(NA, nrow = 10, ncol = 4)
p.alphac <- c(1/6, 1/6, 1/3, 1/3)
for (i in 1:10) {
    p.yi <- sum(Li.given.alpha.c[i, ] * p.alphac)
    P.alphac.given.yi[i, ] <- Li.given.alpha.c[i, ] * p.alphac/p.yi
}

colnames(P.alphac.given.yi) <- c("00", "10", "01", "11")
rownames(P.alphac.given.yi) <- paste("student", 1:10)
P.alphac.given.yi
##                 00      10    01   11
## student 1  0.01757 0.03124 0.062 0.89
## student 2  0.12923 0.22975 0.459 0.18
## student 3  0.00557 0.00027 0.713 0.28
## student 4  0.00839 0.53726 0.030 0.42
## student 5  0.23358 0.41525 0.023 0.33
## student 6  0.16640 0.00822 0.592 0.23
## student 7  0.12923 0.22975 0.459 0.18
## student 8  0.00051 0.00091 0.066 0.93
## student 9  0.00839 0.53726 0.030 0.42
## student 10 0.01757 0.03124 0.062 0.89

Recall that the DINA model groups students into two groups:

  • ηj=0 for students lacking at least one of the required attributes for item j and

  • ηj=1 for students having all the required attributes for item j.

P(Yij=1|ηj)={gjif ηj=01sjif ηj=1

For item j

Based on provisional item parameter estimates, the E-step calculates

  • the expected number of students in group ηj=0 N(0)j=iP(αcηj=0|Yi)

  • the expected number of students in group ηj=1 N(1)j=iP(αcηj=1|Yi)

  • the expected number of students in group ηj=0 who answer item j correctly R(0)j=iyijP(αcηj=0|Yi)

  • the expected number of students in group ηj=1 who answer item j correctly R(1)j=iyijP(αcηj=1|Yi)

Code
P.alphac.given.yi
##                 00      10    01   11
## student 1  0.01757 0.03124 0.062 0.89
## student 2  0.12923 0.22975 0.459 0.18
## student 3  0.00557 0.00027 0.713 0.28
## student 4  0.00839 0.53726 0.030 0.42
## student 5  0.23358 0.41525 0.023 0.33
## student 6  0.16640 0.00822 0.592 0.23
## student 7  0.12923 0.22975 0.459 0.18
## student 8  0.00051 0.00091 0.066 0.93
## student 9  0.00839 0.53726 0.030 0.42
## student 10 0.01757 0.03124 0.062 0.89
Code
y
##       [,1] [,2] [,3] [,4] [,5]
##  [1,]    1    0    1    0    1
##  [2,]    0    1    1    0    0
##  [3,]    0    0    1    1    1
##  [4,]    1    1    0    1    0
##  [5,]    1    0    0    0    1
##  [6,]    0    0    1    0    1
##  [7,]    0    1    1    0    0
##  [8,]    0    1    1    1    1
##  [9,]    1    1    0    1    0
## [10,]    1    0    1    0    1

For item 5, q5=11 so αc=00,10,01 are all in ηj=0 group and αc=11 is in ηj=1 group.

Code
Nj0 <- sum(P.alphac.given.yi[, 1:3])
Nj1 <- sum(P.alphac.given.yi[, 4])
Rj0 <- sum(y[, 5] * rowSums(P.alphac.given.yi[, 1:3]))
Rj1 <- sum(y[, 5] * P.alphac.given.yi[, 4])
## Nj0 = 5.2 
## Nj1 = 4.8 
## Rj0 = 2.4 
## Rj1 = 3.6

Exercise 5.3 Find these quantities for item 1.

Click for Answer
Code
Nj0 <- sum(P.alphac.given.yi[, 1:3])
Nj1 <- sum(P.alphac.given.yi[, 4])
Rj0 <- sum(y[, 1] * rowSums(P.alphac.given.yi[, 1:3]))
Rj1 <- sum(y[, 1] * P.alphac.given.yi[, 4])

cat("Nj0 =", Nj0, "\nNj1 =", Nj1, "\nRj0 =", Rj0, "\nRj1 =", Rj1)
## Nj0 = 5.2 
## Nj1 = 4.8 
## Rj0 = 2 
## Rj1 = 3