5.7 E-step

In the E-step, one needs to calculate the posterior probability of observing a response vector \(\mathbf{Y}_i\) for student \(i\) :

\[\begin{equation} P(\mathbf{\alpha}_c| {\mathbf{Y}_i})=\frac{L( {\mathbf{Y}_i}|{\alpha_c})p(\mathbf{\alpha}_c)}{L({\mathbf{Y}_i})} \end{equation}\]

Recall that \(L( {\mathbf{Y}_i}|{\mathbf{\alpha} _c})\) is a \(N\times 2^K\) 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)=\frac{1}{6}\) and \(P(01)=P(11)=\frac{1}{3}\) again and calculate \(P(\mathbf{\alpha}_c| {\mathbf{Y}_i})\):

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:

  • \(\eta_j=0\) for students lacking at least one of the required attributes for item \(j\) and

  • \(\eta_j=1\) for students having all the required attributes for item \(j\).

\[\begin{equation} P(Y_{ij}=1|\eta_j)= \begin{cases} g_j & \quad \text{if } \eta_j=0\\ 1-s_j & \quad \text{if } \eta_j=1 \end{cases} \end{equation}\]

For item \(j\)

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

  • the expected number of students in group \(\eta_j=0\) \[N_j^{(0)}=\sum_iP(\alpha_{c\in \eta_j=0}|\mathbf{Y}_i)\]

  • the expected number of students in group \(\eta_j=1\) \[N_j^{(1)}=\sum_iP(\alpha_{c\in \eta_j=1}|\mathbf{Y}_i)\]

  • the expected number of students in group \(\eta_j=0\) who answer item \(j\) correctly \[R_j^{(0)}=\sum_iy_{ij}P(\alpha_{c\in \eta_j=0}|\mathbf{Y}_i)\]

  • the expected number of students in group \(\eta_j=1\) who answer item \(j\) correctly \[R_j^{(1)}=\sum_iy_{ij}P(\alpha_{c\in \eta_j=1}|\mathbf{Y}_i)\]

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, \(q_5=11\) so \(\alpha_c=00,10,01\) are all in \(\eta_j=0\) group and \(\alpha_c=11\) is in \(\eta_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